COPASI API  4.40.278
CDataArray Class Reference

#include <CDataArray.h>

Inheritance diagram for CDataArray:
[legend]

Public Types

typedef C_FLOAT64 data_type
 
typedef CArray::index_type index_type
 
enum class  Mode {
  Objects , Vector , VectorOnTheFly , Strings ,
  Numbers , __SIZE
}
 
typedef std::vector< std::string > name_index_type
 
- Public Types inherited from CDataContainer
typedef CDataObjectMap objectMap
 
- Public Types inherited from CDataObject
typedef std::set< const CDataObject * > DataObjectSet
 
enum  Flag {
  Container , Vector , Matrix , NameVector ,
  Reference , ValueBool , ValueInt , ValueInt64 ,
  ValueDbl , NonUniqueName , StaticString , ValueString ,
  Separator , DisplayName , ModelEntity , Array ,
  DataModel , Root , Gui , __SIZE
}
 
- Public Types inherited from CObjectInterface
typedef std::vector< const CDataContainer * > ContainerList
 
typedef std::set< const CObjectInterface * > ObjectSet
 

Public Member Functions

const CDataObjectaddElementReference (C_INT32 u) const
 
const CDataObjectaddElementReference (C_INT32 u, C_INT32 v) const
 
const CDataObjectaddElementReference (const index_type &index) const
 
const CDataObjectaddElementReference (const name_index_type &nameIndex) const
 
CArrayInterfacearray ()
 
const CArrayInterfacearray () const
 
 CDataArray (const std::string &name, const CDataContainer *pParent, CArrayInterface *array, const bool &adopt)
 
index_type cnToIndex (const name_index_type &cnIndex) const
 
size_t dimensionality () const
 
name_index_type displayNamesToCN (const std::vector< std::string > &DisplayNames) const
 
const std::vector< CRegisteredCommonName > & getAnnotationsCN (size_t d) const
 
const std::vector< std::string > & getAnnotationsString (size_t d, bool display=true) const
 
CArrayInterfacegetArray () const
 
Mode getDefaultMode () const
 
const std::string & getDescription () const
 
const std::string & getDimensionDescription (size_t d) const
 
Mode getMode (size_t d) const
 
virtual const CObjectInterfacegetObject (const CCommonName &cn) const
 
virtual std::string getObjectDisplayName () const
 
bool isEmpty ()
 
data_typeoperator[] (const name_index_type &nameIndex)
 
const data_typeoperator[] (const name_index_type &nameIndex) const
 
virtual void print (std::ostream *ostream) const
 
void printRecursively (std::ostream &ostream, size_t level, CArrayInterface::index_type &index, const std::vector< std::vector< std::string > > &display) const
 
void reDimensionalize (size_t d)
 
void resize ()
 
void resizeOneDimension (size_t d)
 
void setAnnotation (size_t d, size_t i, const CDataObject *pObject)
 
void setAnnotationString (size_t d, size_t i, const std::string s)
 
void setArray (CArrayInterface *a)
 
template<class CType >
void setCopasiVector (size_t d, const CDataVector< CType > &v)
 
void setDescription (const std::string &s)
 
void setDimensionDescription (size_t d, const std::string &s)
 
void setMode (Mode m)
 
void setMode (size_t d, Mode m)
 
CArrayInterface::index_type size () const
 
virtual ~CDataArray ()
 
- Public Member Functions inherited from CDataContainer
virtual bool add (CDataObject *pObject, const bool &adopt=true)
 
virtual bool appendDeletedDependentData (CUndoData &undoData) const
 
virtual bool applyData (const CData &data, CUndoData::CChangeSet &changes) override
 
 CDataContainer (const CDataContainer &src, const CDataContainer *pParent)
 
 CDataContainer (const std::string &name, const CDataContainer *pParent=NO_PARENT, const std::string &type="CN", const CFlags< Flag > &flag=CFlags< Flag >::None)
 
virtual void createUndoData (CUndoData &undoData, const CUndoData::Type &type, const CData &oldData=CData(), const CCore::Framework &framework=CCore::Framework::ParticleNumbers) const override
 
virtual std::string getChildObjectUnits (const CDataObject *pObject) const
 
void getDescendants (CDataObject::DataObjectSet &descendants, const bool &recursive=false) const
 
virtual size_t getIndex (const CDataObject *pObject) const
 
virtual objectMapgetObjects ()
 
virtual const objectMapgetObjects () const
 
virtual const std::string getUnits () const override
 
virtual const CDataObjectgetValueObject () const override
 
virtual CUndoObjectInterfaceinsert (const CData &data) override
 
void objectRenamed (CDataObject *pObject, const std::string &oldName)
 
virtual bool remove (CDataObject *pObject)
 
virtual CData toData () const override
 
virtual ~CDataContainer ()
 
- Public Member Functions inherited from CDataObject
void addIssue (const CIssue &issue)
 
void addReference (const CDataContainer *pReference)
 
virtual void calculateValue () override
 
 CDataObject (const CDataObject &src, const CDataContainer *pParent=NULL)
 
virtual void destruct () override
 
virtual CCommonName getCN () const override
 
virtual const CDataObjectgetDataObject () const override
 
virtual const std::string & getKey () const
 
CDataContainergetObjectAncestor (const std::string &type) const
 
CDataModelgetObjectDataModel () const
 
const CObjectInterfacegetObjectFromCN (const CCommonName &cn) const
 
const std::string & getObjectName () const
 
CDataContainergetObjectParent () const
 
const std::string & getObjectType () const
 
virtual const CObjectInterface::ObjectSetgetPrerequisites () const override
 
virtual const CValiditygetValidity () const override
 
virtual void * getValuePointer () const override
 
bool hasFlag (const Flag &flag) const
 
virtual bool isPrerequisiteForContext (const CObjectInterface *pObject, const CCore::SimulationContextFlag &context, const CObjectInterface::ObjectSet &changedObjects) const override
 
bool prerequisitsContains (const DataObjectSet &objects) const
 
void removeIssue (const CIssue &issue)
 
void removeReference (const CDataContainer *pReference)
 
bool setObjectName (const std::string &name)
 
virtual bool setObjectParent (const CDataContainer *pParent)
 
void validityChanged (const CValidity &changedValidity) override
 
void validityRemoved (const CValidity &changedValidity)
 
virtual ~CDataObject ()
 
- Public Member Functions inherited from CObjectInterface
 CObjectInterface ()
 
 CObjectInterface (const CObjectInterface &src)
 
virtual ~CObjectInterface ()
 
- Public Member Functions inherited from CUndoObjectInterface
 CUndoObjectInterface ()
 
 CUndoObjectInterface (const CUndoObjectInterface &src)
 
bool generateUuid ()
 
const xg::Guid & getUuid () const
 
bool setUuid (const std::string &uuid)
 
bool setUuid (const xg::Guid &uuid)
 
virtual void updateIndex (const size_t &index, const CUndoObjectInterface *pUndoObject)
 
virtual ~CUndoObjectInterface ()
 

Private Member Functions

 CDataArray ()
 
 CDataArray (const CDataArray &)
 
std::string createDisplayName (const std::string &cn) const
 
CDataArrayoperator= (const CDataArray &)
 
void updateDisplayNames () const
 

Private Attributes

std::vector< std::vector< CRegisteredCommonName > > mAnnotationsCN
 
std::vector< std::vector< std::string > > mAnnotationsString
 
Mode mDefaultMode
 
std::string mDescription
 
bool mDestructArray
 
std::vector< std::string > mDimensionDescriptions
 
std::vector< ModemModes
 
CArrayInterfacempArray
 

Friends

std::ostream & operator<< (std::ostream &os, const CDataArray &o)
 

Additional Inherited Members

- Static Public Member Functions inherited from CDataContainer
static CDataContainerfromData (const CData &data, CUndoObjectInterface *pParent)
 
- Static Public Member Functions inherited from CDataObject
static CDataObjectfromData (const CData &data, CUndoObjectInterface *pParent)
 
static void sanitizeObjectName (std::string &name)
 
- Static Public Member Functions inherited from CObjectInterface
static const CDataObjectDataObject (const CObjectInterface *pInterface)
 
static CObjectInterfaceGetObjectFromCN (const ContainerList &listOfContainer, const CCommonName &objName)
 
- Static Public Member Functions inherited from CUndoObjectInterface
template<class CType >
static CType * fromData (const CData &, CUndoObjectInterface *)
 
- Static Public Attributes inherited from CDataContainer
static const CObjectInterface::ContainerList EmptyList
 
- Protected Member Functions inherited from CDataContainer
template<class CType >
CDataMatrixReference< CType > * addMatrixReference (const std::string &name, CType &reference, const CFlags< Flag > &flag=CFlags< Flag >::None)
 
template<class CType >
CDataObjectReference< CType > * addObjectReference (const std::string &name, CType &reference, const CFlags< Flag > &flag=CFlags< Flag >::None)
 
template<class CType >
CDataVectorReference< CType > * addVectorReference (const std::string &name, CType &reference, const CFlags< Flag > &flag=CFlags< Flag >::None)
 
 CDataContainer (const CDataContainer &src)
 
void initObjects ()
 
- Protected Member Functions inherited from CDataObject
 CDataObject ()
 
 CDataObject (const std::string &name, const CDataContainer *pParent=static_cast< CDataContainer * >((void *) 0), const std::string &type="CN", const CFlags< Flag > &flag=CFlags< Flag >::None)
 
- Protected Attributes inherited from CDataContainer
objectMap mObjects
 
- Protected Attributes inherited from CDataObject
ObjectSet mPrerequisits
 
std::set< CDataContainer * > mReferences
 
- Protected Attributes inherited from CObjectInterface
CValidity mValidity
 

Detailed Description

This class contains the annotations to a n-dimensional array. Annotations can be provided for the array as such, for each of the dimensions, and for each of the indices (rows, columns, ...)

Member Typedef Documentation

◆ data_type

◆ index_type

◆ name_index_type

typedef std::vector< std::string > CDataArray::name_index_type

Member Enumeration Documentation

◆ Mode

enum CDataArray::Mode
strong

The annotation to an array can work in different modes. The mode for each dimension can be changed independently.

OBJECTS: The CNs for the rows, cols, ... of the array are given explicitly

VECTOR: A CDataVector is provided from which the CNs are generated at the time the vector is set

VectorOnTheFly: A CDataVector is provided, but the CNs are generated every time the annotations are retrieved (so that they are always up to date).

STRINGS: The annotations for the rows, cols, ... are given explicitly as strings.

NUMBERS: The rows, cols, ... of the array are only annotation with running numbers (starting with 0)-

Enumerator
Objects 
Vector 
VectorOnTheFly 
Strings 
Numbers 
__SIZE 

Constructor & Destructor Documentation

◆ CDataArray() [1/3]

CDataArray::CDataArray ( )
private

◆ CDataArray() [2/3]

CDataArray::CDataArray ( const CDataArray )
private

◆ CDataArray() [3/3]

CDataArray::CDataArray ( const std::string &  name,
const CDataContainer pParent,
CArrayInterface array,
const bool &  adopt 
)

References mpArray, and resize().

◆ ~CDataArray()

CDataArray::~CDataArray ( )
virtual

References mDestructArray, mpArray, and pdelete.

Member Function Documentation

◆ addElementReference() [1/4]

const CDataObject * CDataArray::addElementReference ( C_INT32  u) const

a convenience function for 1-dimensional arrays.

References addElementReference().

◆ addElementReference() [2/4]

const CDataObject * CDataArray::addElementReference ( C_INT32  u,
C_INT32  v 
) const

a convenience function for 2-dimensional arrays.

References addElementReference().

◆ addElementReference() [3/4]

const CDataObject * CDataArray::addElementReference ( const index_type index) const

an object that will act as a reference to one element of an array will be created and inserted as a child of the array annotation. Basically most of the work will be done by getObject(). If the element already exists, the existing element will be returned.

References mAnnotationsCN, and StringPrint().

Referenced by COutputAssistant::add2DDataArrayToVector(), addElementReference(), CObjectLists::getListOfConstObjects(), and getObject().

◆ addElementReference() [4/4]

const CDataObject * CDataArray::addElementReference ( const name_index_type nameIndex) const

◆ array() [1/2]

CArrayInterface* CDataArray::array ( )
inline

References mpArray.

Referenced by printRecursively().

◆ array() [2/2]

const CArrayInterface* CDataArray::array ( ) const
inline

References mpArray.

◆ cnToIndex()

CDataArray::index_type CDataArray::cnToIndex ( const name_index_type cnIndex) const

◆ createDisplayName()

std::string CDataArray::createDisplayName ( const std::string &  cn) const
private

◆ dimensionality()

◆ displayNamesToCN()

CDataArray::name_index_type CDataArray::displayNamesToCN ( const std::vector< std::string > &  DisplayNames) const

◆ getAnnotationsCN()

const std::vector< CRegisteredCommonName > & CDataArray::getAnnotationsCN ( size_t  d) const

returns the vector of CNs that correspond to the rows, columns, ... of the array. This method must not be called if the mode for the dimension d is STRINGS or NUMBERS

References mAnnotationsCN.

◆ getAnnotationsString()

const std::vector< std::string > & CDataArray::getAnnotationsString ( size_t  d,
bool  display = true 
) const

This returns strings that annotate the rows, columns, ... of the array. If the mode is OBJECTS, VECTOR, or VectorOnTheFly the display argument determines if the object name or the object display name is used. Note that this method returns a reference. The content that the reference points to may be changes by later calls to the getAnnotationsCN() method with the same value for d. Specifically if you use this method to obtain a reference to the list of display names and then call the method again to get the plain object names, the first reference will after that also point to the plain object names.

References createDisplayName(), mAnnotationsCN, mAnnotationsString, mModes, Numbers, and StringPrint().

◆ getArray()

CArrayInterface * CDataArray::getArray ( ) const

References mpArray.

Referenced by CFitProblem::calculate().

◆ getDefaultMode()

Mode CDataArray::getDefaultMode ( ) const
inline

References mDefaultMode.

◆ getDescription()

const std::string & CDataArray::getDescription ( ) const

References mDescription.

◆ getDimensionDescription()

const std::string & CDataArray::getDimensionDescription ( size_t  d) const

References mDimensionDescriptions.

Referenced by printRecursively().

◆ getMode()

Mode CDataArray::getMode ( size_t  d) const
inline

References mModes.

◆ getObject()

const CObjectInterface * CDataArray::getObject ( const CCommonName cn) const
virtual

Resolve a cn. Since this is an array, the CN can start with an index like "[2][3]". Since this is also a container, this is not necessarily the case.

Reimplemented from CDataContainer.

References addElementReference(), C_INT32, displayNamesToCN(), CDataObjectMap::equal_range(), CCommonName::escape(), CCommonName::getElementName(), CDataContainer::getObject(), CDataObject::getObject(), CCommonName::getRemainder(), and CDataContainer::mObjects.

◆ getObjectDisplayName()

std::string CDataArray::getObjectDisplayName ( ) const
virtual

generate a display name for the array annotation.

Reimplemented from CDataObject.

References CDataObject::getObjectDisplayName(), CDataObject::getObjectName(), CDataObject::getObjectParent(), and CDataObject::getObjectType().

◆ isEmpty()

bool CDataArray::isEmpty ( )

Check whether the size of array is greater than 0 for each dimension. Return true, if so. Otherwise, false.

References dimensionality(), and size().

◆ operator=()

CDataArray& CDataArray::operator= ( const CDataArray )
private

◆ operator[]() [1/2]

CDataArray::data_type & CDataArray::operator[] ( const name_index_type nameIndex)

References cnToIndex(), and mpArray.

◆ operator[]() [2/2]

const CDataArray::data_type & CDataArray::operator[] ( const name_index_type nameIndex) const

References cnToIndex(), and mpArray.

◆ print()

void CDataArray::print ( std::ostream *  ostream) const
virtual

This is the output method for any object. The default implementation provided with CDataObject uses the ostream operator<< of the object to print the object.To override this default behavior one needs to reimplement the virtual print function.

Parameters
std::ostream* ostream

Reimplemented from CDataObject.

◆ printRecursively()

void CDataArray::printRecursively ( std::ostream &  ostream,
size_t  level,
CArrayInterface::index_type index,
const std::vector< std::vector< std::string > > &  display 
) const

◆ reDimensionalize()

void CDataArray::reDimensionalize ( size_t  d)

resize the internal vectors according to the dimensionality of the array

References mAnnotationsCN, mAnnotationsString, mDefaultMode, mDimensionDescriptions, and mModes.

Referenced by resize().

◆ resize()

◆ resizeOneDimension()

void CDataArray::resizeOneDimension ( size_t  d)

◆ setAnnotation()

◆ setAnnotationString()

◆ setArray()

void CDataArray::setArray ( CArrayInterface a)

let the ArrayAnnotation point to a different array. If you use this method without updating the annotations afterwards it is your responsibility to make sure the new array fits the existing annotation (in dimensionality and, if not in VectorOnTheFly mode, in size).

References mpArray.

◆ setCopasiVector()

template<class CType >
void CDataArray::setCopasiVector ( size_t  d,
const CDataVector< CType > &  v 
)
inline

Associates a dimension d of the array with a CDataVector of CDataObjects. If the mode of the dimension d is VECTOR than the CNs of the objects in the vector are generated and stored immediately. If the mode is VectorOnTheFly the CNs are generated when getAnnotationsCN() or getAnnotationsString() is called.

References dimensionality(), CDataObject::getCN(), mAnnotationsCN, mModes, CDataVector< CType >::size(), Vector, and VectorOnTheFly.

Referenced by CCSPMethod::initializeOutput(), CModel::initObjects(), CLNAMethod::resizeAllMatrices(), CMCAMethod::resizeAllMatrices(), CCSPMethod::setAnnotationM(), CILDMMethod::setAnnotationM(), CILDMModifiedMethod::setAnnotationM(), CCSPMethod::start(), and CModel::updateMatrixAnnotations().

◆ setDescription()

◆ setDimensionDescription()

◆ setMode() [1/2]

void CDataArray::setMode ( Mode  m)

set the mode for all dimensions, this also sets the default mode that is used when resizing the ArrayAnnotion to a larger dimensionality

References mDefaultMode, mModes, and setMode().

◆ setMode() [2/2]

◆ size()

◆ updateDisplayNames()

void CDataArray::updateDisplayNames ( ) const
private

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const CDataArray o 
)
friend

Member Data Documentation

◆ mAnnotationsCN

◆ mAnnotationsString

std::vector< std::vector< std::string > > CDataArray::mAnnotationsString
mutableprivate

◆ mDefaultMode

Mode CDataArray::mDefaultMode
private

This contains the default mode that is used if during a resize() the dimensionality is increased.

Referenced by getDefaultMode(), reDimensionalize(), and setMode().

◆ mDescription

std::string CDataArray::mDescription
private

Referenced by getDescription(), and setDescription().

◆ mDestructArray

bool CDataArray::mDestructArray
private

Referenced by ~CDataArray().

◆ mDimensionDescriptions

std::vector< std::string > CDataArray::mDimensionDescriptions
private

◆ mModes

std::vector<Mode> CDataArray::mModes
private

This contains the mode for the different dimensions

Referenced by dimensionality(), getAnnotationsString(), getMode(), reDimensionalize(), setCopasiVector(), and setMode().

◆ mpArray


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