NimbleSM
NimbleSM is a solid mechanics simulation code for dynamic systems
Loading...
Searching...
No Matches
ExpressionParsing::MemoryManager Class Reference

#include <nimble_expression_parser.h>

Inheritance diagram for ExpressionParsing::MemoryManager:
ExpressionParsing::DeletableObjectBaseClass

Classes

struct  MemoryBlock
 

Public Member Functions

 MemoryManager ()
 
template<typename T, typename... In>
T * New (In... inputs)
 
 ~MemoryManager ()
 

Public Attributes

MemoryBlockfirst
 

Static Public Attributes

static const unsigned int BlockSize = 62
 

Constructor & Destructor Documentation

◆ MemoryManager()

ExpressionParsing::MemoryManager::MemoryManager ( )
inline
83: first(new MemoryBlock()) {}
MemoryBlock * first
Definition nimble_expression_parser.h:82
Definition nimble_expression_parser.h:75

◆ ~MemoryManager()

ExpressionParsing::MemoryManager::~MemoryManager ( )
inline
101 { // Deletes everything allocated with MemoryManager::New
102 MemoryBlock* current = first;
103 MemoryBlock* next = current->next;
104 DeletableObjectBaseClass** scan = current->Pointers;
105 unsigned int count = current->count;
106 for (unsigned int i = 0; i < count; ++i) { delete *scan++; }
107 delete current;
108 current = next;
109 while (current) {
110 scan = current->Pointers;
111 next = current->next;
112 for (unsigned int i = 0; i < BlockSize; ++i) { delete *scan++; }
113 delete current;
114 current = next;
115 }
116 }
static const unsigned int BlockSize
Definition nimble_expression_parser.h:73
DeletableObjectBaseClass * Pointers[BlockSize]
Definition nimble_expression_parser.h:76
MemoryBlock * next
Definition nimble_expression_parser.h:78

Member Function Documentation

◆ New()

template<typename T, typename... In>
T * ExpressionParsing::MemoryManager::New ( In... inputs)
inline
87 {
88 T* pointer = new T(inputs...);
89 unsigned long insert_location = first->count;
90 if (insert_location < BlockSize) {
91 first->count = insert_location + 1;
92 first->Pointers[insert_location] = pointer;
93 } else {
94 first = new MemoryBlock(first);
95 first->count = 1;
96 first->Pointers[0] = pointer;
97 }
98 return pointer;
99 }

Member Data Documentation

◆ BlockSize

const unsigned int ExpressionParsing::MemoryManager::BlockSize = 62
static

◆ first

MemoryBlock* ExpressionParsing::MemoryManager::first

The documentation for this class was generated from the following file: