containerInformation.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. #include <string>
  3. #include <baseContainer.h>
  4. namespace pika
  5. {
  6. struct ContainerInformation
  7. {
  8. ContainerInformation() {};
  9. ContainerInformation(
  10. size_t containerStructBaseSize,
  11. const char *containerName,
  12. const ContainerStaticInfo& containerStaticInfo):
  13. containerStructBaseSize(containerStructBaseSize), containerName(containerName),
  14. containerStaticInfo(containerStaticInfo)
  15. {
  16. useDefaultAllocator = containerStaticInfo.useDefaultAllocator;
  17. };
  18. bool operator==(const ContainerInformation &other)
  19. {
  20. if (this == &other) { return true; }
  21. return
  22. this->containerStructBaseSize == other.containerStructBaseSize &&
  23. this->containerName == other.containerName &&
  24. this->containerStaticInfo == other.containerStaticInfo &&
  25. this->useDefaultAllocator == other.useDefaultAllocator;
  26. }
  27. bool operator!=(const ContainerInformation &other)
  28. {
  29. return !(*this == other);
  30. }
  31. size_t containerStructBaseSize = 0; //static memory
  32. std::string containerName = "";
  33. ContainerStaticInfo containerStaticInfo = {};
  34. bool useDefaultAllocator = 0; //move into container static info when implementing
  35. size_t calculateMemoryRequirements()
  36. {
  37. if (useDefaultAllocator) { return 0; }
  38. size_t size = 0;
  39. size += containerStructBaseSize;
  40. pika::align64(size);
  41. size += containerStaticInfo.defaultHeapMemorySize;
  42. for (auto i : containerStaticInfo.bonusAllocators)
  43. {
  44. pika::align64(size);
  45. size += i;
  46. }
  47. return size;
  48. }
  49. };
  50. }