COPASI API  4.16.103
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CArrayElementReference Class Reference

#include <CArrayElementReference.h>

Inheritance diagram for CArrayElementReference:
Inheritance graph
Collaboration diagram for CArrayElementReference:
Collaboration graph

Public Member Functions

 CArrayElementReference (const std::string &index, const CCopasiContainer *pParent)
virtual CCopasiObjectName getCN () const
virtual std::string getObjectDisplayName (bool regular=true, bool richtext=false) const
virtual const CCopasiObjectgetValueObject () const
virtual voidgetValuePointer () const
virtual void print (std::ostream *ostream) const
virtual ~CArrayElementReference ()
- Public Member Functions inherited from CCopasiObject
void addDirectDependency (const CCopasiObject *pObject)
 CCopasiObject (const CCopasiObject &src, const CCopasiContainer *pParent=NULL)
void clearDirectDependencies ()
void clearRefresh ()
bool dependsOn (DataObjectSet candidates, const DataObjectSet &context=DataObjectSet()) const
void getAllDependencies (DataObjectSet &dependencies, const DataObjectSet &context) const
virtual const DataObjectSetgetDirectDependencies (const DataObjectSet &context=DataObjectSet()) const
virtual const std::string & getKey () const
virtual const CObjectInterfacegetObject (const CCopasiObjectName &cn) const
CCopasiContainergetObjectAncestor (const std::string &type) const
CCopasiDataModelgetObjectDataModel ()
const CCopasiDataModelgetObjectDataModel () const
const std::string & getObjectName () const
CCopasiContainergetObjectParent () const
const std::string & getObjectType () const
virtual const
getPrerequisites () const
virtual RefreshgetRefresh () const
virtual std::string getUnits () const
UpdateMethodgetUpdateMethod () const
bool hasCircularDependencies (DataObjectSet &candidates, DataObjectSet &verified, const DataObjectSet &context) const
bool hasUpdateMethod () const
bool isArray () const
bool isContainer () const
bool isDataModel () const
bool isMatrix () const
bool isNameVector () const
bool isNonUniqueName () const
virtual bool isPrerequisiteForContext (const CObjectInterface *pObject, const CMath::SimulationContextFlag &context, const CObjectInterface::ObjectSet &changedObjects) const
bool isReference () const
bool isRoot () const
bool isSeparator () const
bool isStaticString () const
bool isValueBool () const
bool isValueDbl () const
bool isValueInt () const
bool isValueInt64 () const
bool isValueString () const
bool isVector () const
virtual bool mustBeDeleted (const DataObjectSet &deletedObjects) const
void removeDirectDependency (const CCopasiObject *pObject)
void setDirectDependencies (const DataObjectSet &directDependencies)
bool setObjectName (const std::string &name)
virtual bool setObjectParent (const CCopasiContainer *pParent)
void setObjectValue (const C_FLOAT64 &value)
void setObjectValue (const C_INT32 &value)
void setObjectValue (const bool &value)
template<class CType >
void setRefresh (CType *pType, void(CType::*method)(void))
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_FLOAT64 &))
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_INT32 &))
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const bool &))
virtual ~CCopasiObject ()
- Public Member Functions inherited from CObjectInterface
 CObjectInterface ()
virtual ~CObjectInterface ()

Private Member Functions

 CArrayElementReference ()
 CArrayElementReference (const CArrayElementReference &src)
void updateMethod (const CCopasiAbstractArray::data_type &value)

Private Attributes

CCopasiObjectName mIndex

Additional Inherited Members

- Public Types inherited from CCopasiObject
typedef std::set< const
CCopasiObject * > 
typedef std::vector< Refresh * > DataUpdateSequence
- Public Types inherited from CObjectInterface
typedef std::set< const
CObjectInterface * > 
typedef std::vector
< CObjectInterface * > 
- Static Public Member Functions inherited from CCopasiObject
static std::vector< Refresh * > buildUpdateSequence (const DataObjectSet &objects, const DataObjectSet &uptoDateObjects, const DataObjectSet &context=DataObjectSet())
static void setRenameHandler (CRenameHandler *rh)
- Protected Types inherited from CCopasiObject
enum  Flag {
  Container = 0x1, Vector = 0x2, Matrix = 0x4, NameVector = 0x8,
  Reference = 0x10, ValueBool = 0x20, ValueInt = 0x40, ValueInt64 = 0x80,
  ValueDbl = 0x100, NonUniqueName = 0x200, StaticString = 0x400, ValueString = 0x800,
  Separator = 0x1000, ModelEntity = 0x2000, Array = 0x4000, DataModel = 0x8000,
  Root = 0x10000, Gui = 0x20000
- Protected Member Functions inherited from CCopasiObject
 CCopasiObject ()
 CCopasiObject (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=0)
- Static Protected Attributes inherited from CCopasiObject
static CRenameHandlersmpRenameHandler = NULL

Detailed Description

Class CArrayElementReference

This class is used to make an element of an array accessible as a CCopasiObject. Usually an object from this class will be a child of a CArrayAnnotation and will reference a single element of the array that the CArrayAnnotation points to.

Definition at line 29 of file CArrayElementReference.h.

Constructor & Destructor Documentation

CArrayElementReference::CArrayElementReference ( )

make the default constructor unaccessible

CArrayElementReference::CArrayElementReference ( const CArrayElementReference src)

make the copy constructor unaccessible

CArrayElementReference::CArrayElementReference ( const std::string &  index,
const CCopasiContainer pParent 

create an element reference with a given index. The index is passed as a string, e.g. "[3][2]" The object name will be the index string, the type is "ElementReference" pParent may not be NULL.

Definition at line 18 of file CArrayElementReference.cpp.

19  : CCopasiObject(index, pParent, "ElementReference",
23  // mpReference(NULL),
24  mIndex(index)
25 {
26  assert(pParent != NULL);
27 }
virtual CArrayElementReference::~CArrayElementReference ( )

Definition at line 66 of file CArrayElementReference.h.

66 {}

Member Function Documentation

CCopasiObjectName CArrayElementReference::getCN ( ) const

Retrieve the CN of the object


Reimplemented from CCopasiObject.

Definition at line 89 of file CArrayElementReference.cpp.

References CCopasiObject::getCN(), CCopasiObject::getObjectParent(), and mIndex.

90  {
91  if (getObjectParent())
92  return getObjectParent()->getCN() + mIndex;
93  else
94  return "Array" + mIndex;
95  }
virtual CCopasiObjectName getCN() const
CCopasiContainer * getObjectParent() const
std::string CArrayElementReference::getObjectDisplayName ( bool  regular = true,
bool  richtext = false 
) const

generate a display name.

Reimplemented from CCopasiObject.

Definition at line 69 of file CArrayElementReference.cpp.

References CCopasiObject::getObjectAncestor(), CCopasiObject::getObjectDisplayName(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CCopasiObject::getObjectType(), and mIndex.

70  {
71  if (getObjectParent())
72  {
73  //if the array has as task as ancestor, use the task (skip the problem/method)
74  CCopasiContainer* pT = getObjectAncestor("Task");
76  std::string part;
77  if (pT)
78  part = pT->getObjectDisplayName(regular, richtext) + ".";
80  part = getObjectParent()->getObjectParent()->getObjectDisplayName(regular, richtext) + ".";
82  //now part contains the display name of the task, or the parent of the parent
83  return part + getObjectParent()->getObjectName() + mIndex;
84  }
85  else
86  return "Array" + mIndex;
87  }
CCopasiContainer * getObjectAncestor(const std::string &type) const
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
const std::string & getObjectName() const
const std::string & getObjectType() const
CCopasiContainer * getObjectParent() const
virtual const CCopasiObject* CArrayElementReference::getValueObject ( ) const

Reimplemented from CCopasiObject.

Definition at line 74 of file CArrayElementReference.h.

74 {return this;}
void * CArrayElementReference::getValuePointer ( ) const

returns a pointer to the numerical values of the array element this will be a *C_FLOAT64 for this class.

Reimplemented from CCopasiObject.

Definition at line 35 of file CArrayElementReference.cpp.

References CArrayAnnotation::array(), C_INT32, CArrayAnnotation::dimensionality(), CCopasiObjectName::getElementIndex(), CCopasiObjectName::getElementName(), CCopasiObject::getObjectParent(), mIndex, and CArrayAnnotation::size().

Referenced by print().

36  {
37  CArrayAnnotation * tmpAA = dynamic_cast<CArrayAnnotation*>(getObjectParent());
38  if (!tmpAA) return NULL;
40  //now get the array indices. At the moment only numerical indices...
41  //this could be done in the constructor, actually
42  unsigned C_INT32 ii = 0;
44  std::string tmpIndexString;
45  while ((tmpIndexString = mIndex.getElementName(ii, false)) != "")
46  {
47  if (tmpIndexString == ".")
48  break; //"." indicates 0-dimensional array. This means index should stay empty
49  index.push_back(mIndex.getElementIndex(ii));
50  ++ii;
51  }
53  if (index.size() != tmpAA->dimensionality()) //wrong number of indices for this array
54  return NULL;
56  for (ii = 0; ii < tmpAA->dimensionality(); ++ii)
57  if (index[ii] >= tmpAA->size()[ii]) //out of range
58  return NULL;
60  return &(*tmpAA->array())[index];
62  //TODO
63  //TODO perhaps we should cache the pointer. This would mean we need to invalidate the pointer
64  //if somthing with the array changes
66  //return mpReference;
67  }
size_t getElementIndex(const size_t &pos=0) const
CCopasiAbstractArray * array()
std::vector< size_t > index_type
Definition: CCopasiArray.h:34
#define C_INT32
Definition: copasi.h:90
std::string getElementName(const size_t &pos, const bool &unescape=true) const
CCopasiAbstractArray::index_type size() const
size_t dimensionality() const
CCopasiContainer * getObjectParent() const
void CArrayElementReference::print ( std::ostream *  ostream) const

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

std::ostream* ostream

Reimplemented from CCopasiObject.

Definition at line 97 of file CArrayElementReference.cpp.

References getValuePointer().

98  {
99  //if (mpReference)
100  // (*ostream) << *mpReference;
102  //TODO perhaps we should cache the
104  if (tmp)
105  (*ostream) << *tmp;
106  };
virtual void * getValuePointer() const
void CArrayElementReference::updateMethod ( const CCopasiAbstractArray::data_type value)

this method does nothing at the moment!

Definition at line 29 of file CArrayElementReference.cpp.

30 {
31  // if (mpReference)
32  // *mpReference = value;
33 }

Member Data Documentation

CCopasiObjectName CArrayElementReference::mIndex

this contains the index in string format, e.g. "[2][7]"

Definition at line 38 of file CArrayElementReference.h.

Referenced by getCN(), getObjectDisplayName(), and getValuePointer().

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