|
OMNeT++ API 6.1
Discrete Event Simulation Library
|
|
16 #ifndef __OMNETPP_CVALUEARRAY_H
17 #define __OMNETPP_CVALUEARRAY_H
22 #include "cvaluecontainer.h"
40 std::vector<cValue> array;
43 void cannotCast(
cObject *obj,
const char *toClass)
const;
99 virtual std::string str()
const override;
105 virtual void forEachChild(
cVisitor* v)
override;
114 virtual int size()
const {
return array.size();}
119 virtual void clear();
136 virtual void add(
const cValue& value);
142 virtual void insert(
int k,
const cValue& value);
147 const virtual cValue& get(
int k)
const;
152 void set(
int k,
const cValue& value);
163 virtual void erase(
int k);
169 virtual cValue remove(
int k);
174 const std::vector<cValue>&
getArray()
const {
return array;}
184 std::vector<bool> asBoolVector()
const;
190 std::vector<intval_t> asIntVector()
const;
196 std::vector<intval_t> asIntVectorInUnit(
const char *targetUnit)
const;
202 std::vector<double> asDoubleVector()
const;
208 std::vector<double> asDoubleVectorInUnit(
const char *targetUnit)
const;
214 std::vector<std::string> asStringVector()
const;
220 template<
typename T> std::vector<T*> asObjectVector()
const;
228 std::vector<T*> result;
229 result.resize(array.size());
230 for (
int i = 0; i < array.size(); i++) {
231 cObject *obj = array[i].objectValue();
232 result[i] =
dynamic_cast<T*
>(obj);
233 if (result[i] ==
nullptr && obj !=
nullptr)
Common base class for cValue-based containers.
Definition: cvaluecontainer.h:32
cObject is a lightweight class which serves as the root of the OMNeT++ class hierarchy....
Definition: cobject.h:92
A variant-like value class used during evaluating NED expressions.
Definition: cvalue.h:47
std::vector< T * > asObjectVector() const
Definition: cvaluearray.h:226
Enables traversing the tree of (cObject-rooted) simulation objects.
Definition: cvisitor.h:56
const std::vector< cValue > & getArray() const
Definition: cvaluearray.h:174
Container class based on std::vector<cValue> objects.
Definition: cvaluearray.h:37
virtual int size() const
Definition: cvaluearray.h:114
virtual int getCapacity() const
Definition: cvaluearray.h:125
cValueArray(const char *name=nullptr, int capacity=0)
Definition: cvaluearray.h:64
cValueArray(const cValueArray &other)
Definition: cvaluearray.h:58
virtual void setCapacity(int capacity)
Definition: cvaluearray.h:131
const SIM_API char * opp_typename(const std::type_info &t)
Returns the name of a C++ type, correcting the quirks of various compilers.
virtual cValueArray * dup() const override
Definition: cvaluearray.h:93
const cValue & operator[](int k) const
Definition: cvaluearray.h:157