StateVariableArray Class
(CDPSim::StateVariableArray)The StateVariableArray wraps an array of StateVariables. More...
| Header: | #include <DynamicSimComponent/StateVariableArray.h> |
Public Functions
| StateVariableArray() | |
| StateVariableArray(const StateVariableArray &other) = delete | |
| ~StateVariableArray() | |
| void | Create(const char *name, DynamicSimComponent *parent, int size) |
| void | SetSize(int newSize) |
| int | Size() const |
| StateVariableArray & | operator=(const StateVariableArray &other) = delete |
| StateVariable & | operator[](int i) |
Detailed Description
The StateVariableArray wraps an array of StateVariables.
Usage
Create a member in the header file of a DynamicSimComponent inherited class.
Resizing
To resize the array, first call SetSize(), then call the owner component's Reset(). This can not be safely done while the simulator is running.
Features
- Dynamically creates an array of StateVariable objects.
- Size is specified as a parameter to Create(), or later by calling SetSize()
- The array is registered as a child object of the DynamicSimComponent owner.
- StateVariables created are registered as childs of the DynamicSimComponent
Member Function Documentation
StateVariableArray::StateVariableArray()
Default constructs an instance of StateVariableArray.
[delete] StateVariableArray::StateVariableArray(const StateVariableArray &other)
Copy constructor.
StateVariableArray::~StateVariableArray()
Destroys the instance of StateVariableArray.
void StateVariableArray::Create(const char *name, DynamicSimComponent *parent, int size)
Creates the instance, binds it to name and registers to parent.
void StateVariableArray::SetSize(int newSize)
Sets new size.
Must typically be called early in the parent's Reset() function since the new resize will not happen until a Reallocate() is called later (which is done by DynamicSimComponent::Reset()/SetupStateVariables())
int StateVariableArray::Size() const
Get number of StateVariables in this array.
[delete] StateVariableArray &StateVariableArray::operator=(const StateVariableArray &other)
Copy-assignment operator.
StateVariable &StateVariableArray::operator[](int i)
Allows notation like: A[4] = 3.0; and A[4].ddt = 2.0;
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.