OMNeT++ API 6.1
Discrete Event Simulation Library
cValueArray Class Reference

Description

Container class based on std::vector<cValue> objects.

The added value is ownership handling of object values (cObject* pointers) contained in cValue objects. Guidelines: owned objects are those that subclass from cOwnedObject and getOwner() returns this object, and all cObjects that are non-cOwnedObject.

Inheritance diagram for cValueArray:
[legend]

Public Member Functions

Constructors, destructor, assignment.
 cValueArray (const cValueArray &other)
 
 cValueArray (const char *name=nullptr, int capacity=0)
 
virtual ~cValueArray ()
 
cValueArrayoperator= (const cValueArray &other)
 
Redefined cObject member functions
virtual cValueArraydup () const override
 
virtual std::string str () const override
 
virtual void forEachChild (cVisitor *v) override
 
Container functions.
virtual int size () const
 
virtual void clear ()
 
virtual int getCapacity () const
 
virtual void setCapacity (int capacity)
 
virtual void add (const cValue &value)
 
virtual void insert (int k, const cValue &value)
 
const virtual cValueget (int k) const
 
void set (int k, const cValue &value)
 
const cValueoperator[] (int k) const
 
virtual void erase (int k)
 
virtual cValue remove (int k)
 
const std::vector< cValue > & getArray () const
 
Convenience getters.
std::vector< bool > asBoolVector () const
 
std::vector< intval_tasIntVector () const
 
std::vector< intval_tasIntVectorInUnit (const char *targetUnit) const
 
std::vector< double > asDoubleVector () const
 
std::vector< double > asDoubleVectorInUnit (const char *targetUnit) const
 
std::vector< std::string > asStringVector () const
 
template<typename T >
std::vector< T * > asObjectVector () const
 
- Public Member Functions inherited from cValueContainer
 cValueContainer (const char *name=nullptr)
 
- Public Member Functions inherited from cOwnedObject
 cOwnedObject ()
 
 cOwnedObject (const char *name, bool namepooling=true)
 
 cOwnedObject (const cOwnedObject &obj)
 
virtual ~cOwnedObject ()
 
cOwnedObjectoperator= (const cOwnedObject &o)
 
virtual cObjectgetOwner () const override
 
virtual bool isOwnedObject () const override
 
- Public Member Functions inherited from cNamedObject
 cNamedObject ()
 
 cNamedObject (const char *name, bool namepooling=true)
 
 cNamedObject (const cNamedObject &obj)
 
virtual ~cNamedObject ()
 
cNamedObjectoperator= (const cNamedObject &o)
 
virtual void setName (const char *s)
 
virtual const char * getName () const override
 
virtual void setNamePooling (bool b)
 
virtual bool getNamePooling ()
 
- Public Member Functions inherited from cObject
 cObject ()
 
 cObject (const cObject &other)=default
 
virtual ~cObject ()
 
virtual const char * getClassName () const
 
bool isName (const char *s) const
 
virtual const char * getFullName () const
 
virtual std::string getFullPath () const
 
virtual std::string getClassAndFullName () const
 
virtual std::string getClassAndFullPath () const
 
const cObjectgetThisPtr () const
 
virtual std::ostream & printOn (std::ostream &os) const
 
virtual bool isSoftOwner () const
 
cObjectfindObject (const char *name, bool deep=true)
 
virtual cClassDescriptorgetDescriptor () const
 
void copyNotSupported () const
 

Additional Inherited Members

- Static Public Member Functions inherited from cOwnedObject
static long getTotalObjectCount ()
 
static long getLiveObjectCount ()
 
static void resetObjectCounters ()
 
static cSoftOwnergetOwningContext ()
 
- Protected Member Functions inherited from cObject
virtual void take (cOwnedObject *obj)
 
virtual void drop (cOwnedObject *obj)
 
void dropAndDelete (cOwnedObject *obj)
 

Constructor & Destructor Documentation

◆ cValueArray() [1/2]

cValueArray ( const cValueArray other)
inline

Copy constructor. Contained objects will be duplicated so that the new cValueArray will have its own copy of them.

Note that this behavior is different from most other container classes in the simulation library like cQueue, which only duplicate the objects they own, and leave externally owned objects alone.

◆ cValueArray() [2/2]

cValueArray ( const char *  name = nullptr,
int  capacity = 0 
)
inlineexplicit

Constructor. The initial capacity of the container and the delta (by which the capacity will grow if it gets full) can be specified.

◆ ~cValueArray()

virtual ~cValueArray ( )
virtual

Destructor. The contained objects that were owned by the container will be deleted.

Member Function Documentation

◆ operator=()

cValueArray& operator= ( const cValueArray other)

Assignment operator. The name member is not copied; see cNamedObject::operator=() for details. Contained objects that are owned by cValueArray will be duplicated so that the new cValueArray will have its own copy of them.

◆ dup()

virtual cValueArray* dup ( ) const
inlineoverridevirtual

Creates and returns an exact copy of this object. Contained objects will be duplicated so that the new cValueArray will have its own copy of them.

Note that this behavior is different from most other container classes in the simulation library like cQueue, which only duplicate the objects they own, and leave externally owned objects alone.

Reimplemented from cObject.

◆ str()

virtual std::string str ( ) const
overridevirtual

Produces a one-line description of the object's contents. See cObject for more details.

Reimplemented from cObject.

◆ forEachChild()

virtual void forEachChild ( cVisitor v)
overridevirtual

Calls v->visit(this) for each contained object. See cObject for more details.

Reimplemented from cObject.

◆ size()

virtual int size ( ) const
inlinevirtual

Returns the number of elements.

◆ clear()

virtual void clear ( )
virtual

Makes the container empty.

◆ getCapacity()

virtual int getCapacity ( ) const
inlinevirtual

Returns number of elements the array can hold without having to reallocate the underlying storage.

◆ setCapacity()

virtual void setCapacity ( int  capacity)
inlinevirtual

Reserves place for the given number of elements without changing the contents of the array.

◆ add()

virtual void add ( const cValue value)
virtual

Adds the value at the end of the array.

◆ insert()

virtual void insert ( int  k,
const cValue value 
)
virtual

Inserts the value at the given position. Subsequent elements will be shifted up.

◆ get()

const virtual cValue& get ( int  k) const
virtual

Returns the kth element in the array.

◆ set()

void set ( int  k,
const cValue value 
)

Replaces the kth element in the array.

◆ operator[]()

const cValue& operator[] ( int  k) const
inline

Equivalent to get(int) const.

◆ erase()

virtual void erase ( int  k)
virtual

Erases the value given with its index. Subsequent elements will be shifted down.

◆ remove()

virtual cValue remove ( int  k)
virtual

Removes the kth element from the array, and replaces its slot with the undefined value.

◆ getArray()

const std::vector<cValue>& getArray ( ) const
inline

Provides readonly access to the underlying std::vector.

◆ asBoolVector()

std::vector<bool> asBoolVector ( ) const

Converts each element to bool, and returns the result. If an element cannot be converted (see cValue API), an exception is thrown.

◆ asIntVector()

std::vector<intval_t> asIntVector ( ) const

Converts each element to integer, and returns the result. If an element cannot be converted (see cValue API), an exception is thrown.

◆ asIntVectorInUnit()

std::vector<intval_t> asIntVectorInUnit ( const char *  targetUnit) const

Converts each element to integer, and returns the result. If an element cannot be converted (see cValue API), an exception is thrown.

◆ asDoubleVector()

std::vector<double> asDoubleVector ( ) const

Converts each element to double, and returns the result. If an element cannot be converted (see cValue API), an exception is thrown.

◆ asDoubleVectorInUnit()

std::vector<double> asDoubleVectorInUnit ( const char *  targetUnit) const

Converts each element to double, and returns the result. If an element cannot be converted (see cValue API), an exception is thrown.

◆ asStringVector()

std::vector<std::string> asStringVector ( ) const

Converts each element to string, and returns the result. If an element cannot be converted (see cValue API), an exception is thrown.

◆ asObjectVector()

std::vector< T * > asObjectVector

Converts each element to object of the given type, and returns the result. If an element cannot be converted (see cValue API), an exception is thrown.

References omnetpp::opp_typename().


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