COPASI API  4.16.103
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
CArrayAnnotation Class Reference

#include <CAnnotatedMatrix.h>

Inheritance diagram for CArrayAnnotation:
Inheritance graph
[legend]
Collaboration diagram for CArrayAnnotation:
Collaboration graph
[legend]

Public Types

enum  Mode {
  OBJECTS, VECTOR, VECTOR_ON_THE_FLY, STRINGS,
  NUMBERS
}
 
- Public Types inherited from CCopasiContainer
typedef std::multimap
< std::string, CCopasiObject * > 
objectMap
 
- Public Types inherited from CCopasiObject
typedef std::set< const
CCopasiObject * > 
DataObjectSet
 
typedef std::vector< Refresh * > DataUpdateSequence
 
- Public Types inherited from CObjectInterface
typedef std::set< const
CObjectInterface * > 
ObjectSet
 
typedef std::vector
< CObjectInterface * > 
UpdateSequence
 

Public Member Functions

const CObjectInterfaceaddElementReference (CCopasiAbstractArray::index_type index) const
 
const CObjectInterfaceaddElementReference (C_INT32 u, C_INT32 v) const
 
const CObjectInterfaceaddElementReference (C_INT32 u) const
 
void appendElementReferences (std::set< const CCopasiObject * > &objects) const
 
CCopasiAbstractArrayarray ()
 
const CCopasiAbstractArrayarray () const
 
 CArrayAnnotation (const std::string &name, const CCopasiContainer *pParent, CCopasiAbstractArray *array, const bool &adopt)
 
bool createAnnotationsCNFromCopasiVector (size_t d, const CCopasiContainer *v) const
 
void createNumbers (size_t d) const
 
size_t dimensionality () const
 
const std::vector
< CRegisteredObjectName > & 
getAnnotationsCN (size_t d) const
 
const std::vector< std::string > & getAnnotationsString (size_t d, bool display=true) 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 CCopasiObjectName &cn) const
 
virtual std::string getObjectDisplayName (bool regular=true, bool richtext=false) const
 
bool isEmpty ()
 
virtual void print (std::ostream *ostream) const
 
void printRecursively (std::ostream &ostream, size_t level, CCopasiAbstractArray::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 setAnnotationCN (size_t d, size_t i, const std::string cn)
 
void setAnnotationString (size_t d, size_t i, const std::string s)
 
void setArray (CCopasiAbstractArray *a)
 
void setCopasiVector (size_t d, const CCopasiContainer *v)
 
void setDescription (const std::string &s)
 
void setDimensionDescription (size_t d, const std::string &s)
 
void setMode (size_t d, Mode m)
 
void setMode (Mode m)
 
CCopasiAbstractArray::index_type size () const
 
virtual ~CArrayAnnotation ()
 
- Public Member Functions inherited from CCopasiContainer
virtual bool add (CCopasiObject *pObject, const bool &adopt=true)
 
 CCopasiContainer (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=CCopasiObject::Container)
 
 CCopasiContainer (const CCopasiContainer &src, const CCopasiContainer *pParent=NULL)
 
virtual std::string getChildObjectUnits (const CCopasiObject *pObject) const
 
virtual const objectMapgetObjects () const
 
virtual std::string getUnits () const
 
virtual const CCopasiObjectgetValueObject () const
 
virtual bool remove (CCopasiObject *pObject)
 
virtual ~CCopasiContainer ()
 
- 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 CCopasiObjectName getCN () const
 
virtual const DataObjectSetgetDirectDependencies (const DataObjectSet &context=DataObjectSet()) const
 
virtual const std::string & getKey () 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
CObjectInterface::ObjectSet
getPrerequisites () const
 
virtual RefreshgetRefresh () const
 
UpdateMethodgetUpdateMethod () const
 
virtual voidgetValuePointer () 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

 CArrayAnnotation ()
 
 CArrayAnnotation (const CArrayAnnotation &)
 
CArrayAnnotationoperator= (const CArrayAnnotation &)
 

Private Attributes

std::vector< std::vector
< CRegisteredObjectName > > 
mAnnotationsCN
 
std::vector< std::vector
< std::string > > 
mAnnotationsString
 
std::vector< const
CCopasiContainer * > 
mCopasiVectors
 
Mode mDefaultMode
 
std::string mDescription
 
bool mDestructArray
 
std::vector< std::string > mDimensionDescriptions
 
std::vector< ModemModes
 
CCopasiAbstractArraympArray
 

Friends

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

Additional Inherited Members

- 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)
 
- Static Public Attributes inherited from CCopasiContainer
static const std::vector
< CCopasiContainer * > 
EmptyList
 
- 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 CCopasiContainer
template<class CType >
CCopasiObjectaddMatrixReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
template<class CType >
CCopasiObjectaddObjectReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
template<class CType >
CCopasiObjectaddVectorReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
void initObjects ()
 
- 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)
 
- Protected Attributes inherited from CCopasiContainer
objectMap mObjects
 
- Static Protected Attributes inherited from CCopasiObject
static CRenameHandlersmpRenameHandler = NULL
 

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, ...)

Definition at line 44 of file CAnnotatedMatrix.h.

Member Enumeration Documentation

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 CCopasiVector is provided from which the CNs are generated at the time the vector is set

VECTOR_ON_THE_FLY: A CCopasiVector 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 
VECTOR_ON_THE_FLY 
STRINGS 
NUMBERS 

Definition at line 66 of file CAnnotatedMatrix.h.

Constructor & Destructor Documentation

CArrayAnnotation::CArrayAnnotation ( const std::string &  name,
const CCopasiContainer pParent,
CCopasiAbstractArray array,
const bool &  adopt 
)

Definition at line 36 of file CAnnotatedMatrix.cpp.

References mpArray, and resize().

40  : CCopasiContainer(name, pParent, "Array" , CCopasiObject::Array),
41  mpArray(array),
42  mDestructArray(adopt),
44 {
45  assert(mpArray);
46 
47  resize();
48 
49  //addObjectReference("Annotated Matrix", *this, CCopasiObject::ValueDbl);
50 }
CCopasiAbstractArray * mpArray
char name[1]
Definition: stdsoap2.h:1342
CArrayAnnotation::~CArrayAnnotation ( )
virtual

Definition at line 52 of file CAnnotatedMatrix.cpp.

References mDestructArray, mpArray, and pdelete.

53 {
54  if (mDestructArray)
56 }
#define pdelete(p)
Definition: copasi.h:215
CCopasiAbstractArray * mpArray
CArrayAnnotation::CArrayAnnotation ( )
private
CArrayAnnotation::CArrayAnnotation ( const CArrayAnnotation )
private

Member Function Documentation

const CObjectInterface * CArrayAnnotation::addElementReference ( CCopasiAbstractArray::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.

Definition at line 251 of file CAnnotatedMatrix.cpp.

References getObject().

Referenced by addElementReference(), CCopasiSelectionDialog::chooseCellMatrix(), and CObjectLists::getListOfConstObjects().

252 {
253  //generate the index string
254  std::string tmp;
255  std::ostringstream indexString;
256  size_t ii = 0;
257 
258  for (ii = 0; ii < index.size(); ++ii)
259  {
260  indexString << "[" << index[ii] << "]";
261  }
262 
263  //handle zero-dimensional arrays
264  if (index.size() == 0)
265  indexString << "[.]";
266 
267  return this->getObject(indexString.str());
268 }
virtual const CObjectInterface * getObject(const CCopasiObjectName &cn) const
const CObjectInterface * CArrayAnnotation::addElementReference ( C_INT32  u,
C_INT32  v 
) const

a convenience function for 2-dimensional arrays.

Definition at line 270 of file CAnnotatedMatrix.cpp.

References addElementReference().

271 {
273  index.push_back(u);
274  index.push_back(v);
275  return addElementReference(index);
276 }
std::vector< size_t > index_type
Definition: CCopasiArray.h:34
const CObjectInterface * addElementReference(CCopasiAbstractArray::index_type index) const
const CObjectInterface * CArrayAnnotation::addElementReference ( C_INT32  u) const

a convenience function for 1-dimensional arrays.

Definition at line 278 of file CAnnotatedMatrix.cpp.

References addElementReference().

279 {
281  index.push_back(u);
282  return addElementReference(index);
283 }
std::vector< size_t > index_type
Definition: CCopasiArray.h:34
const CObjectInterface * addElementReference(CCopasiAbstractArray::index_type index) const
void CArrayAnnotation::appendElementReferences ( std::set< const CCopasiObject * > &  objects) const

Appends all element references to the set of objects

Parameters
std::set<const CCopasiObject * > & objects

Definition at line 285 of file CAnnotatedMatrix.cpp.

References CCopasiContainer::mObjects.

Referenced by DataModelGUI::buildChangedObjects(), CModel::buildInitialRefreshSequence(), and CModel::buildInitialSequence().

286 {
287  objectMap::const_iterator it = mObjects.begin();
288  objectMap::const_iterator end = mObjects.end();
289 
290  for (; it != end; ++it)
291  if (dynamic_cast<const CArrayElementReference *>(it->second) != NULL)
292  objects.insert(it->second);
293 
294  return;
295 }
CCopasiAbstractArray* CArrayAnnotation::array ( )
inline
const CCopasiAbstractArray* CArrayAnnotation::array ( ) const
inline

Definition at line 125 of file CAnnotatedMatrix.h.

References mpArray.

126  {return mpArray;}
CCopasiAbstractArray * mpArray
bool CArrayAnnotation::createAnnotationsCNFromCopasiVector ( size_t  d,
const CCopasiContainer v 
) const

generate the list of CNs from the COPASI vector v. v needs to be a CCopasiVector (or derived from it)!

Definition at line 185 of file CAnnotatedMatrix.cpp.

References CCopasiAbstractArray::dimensionality(), CCopasiObject::isNameVector(), CCopasiObject::isVector(), mAnnotationsCN, mpArray, and CCopasiVector< T >::size().

Referenced by getAnnotationsCN(), getAnnotationsString(), and setCopasiVector().

187 {
188  if (!v) return false;
189 
190  if (!(v->isVector() || v->isNameVector())) return false;
191 
192  if (d >= mpArray->dimensionality()) return false;
193 
194  //now we know we have a vector. A CCopasiVector[N/S], hopefully, so that the following cast is valid:
195  const CCopasiVector< CCopasiObject > * pVector =
196  reinterpret_cast<const CCopasiVector< CCopasiObject > * >(v);
197 
198  mAnnotationsCN[d].resize(pVector->size());
199  //if (pVector->size() < mAnnotations[d].size()) return false;
200 
201  size_t i;
202 
203  for (i = 0; i < mAnnotationsCN[d].size(); ++i)
204  {
205  if (!(*pVector)[i])
206  return false;
207  else
208  mAnnotationsCN[d][i] = (*pVector)[i]->getCN();
209  }
210 
211  return true;
212 }
bool isNameVector() const
virtual size_t size() const
CCopasiAbstractArray * mpArray
std::vector< std::vector< CRegisteredObjectName > > mAnnotationsCN
bool isVector() const
virtual size_t dimensionality() const =0
void CArrayAnnotation::createNumbers ( size_t  d) const

Definition at line 215 of file CAnnotatedMatrix.cpp.

Referenced by getAnnotationsString().

216 {
217  //TODO
218 }
size_t CArrayAnnotation::dimensionality ( ) const
const std::vector< CRegisteredObjectName > & CArrayAnnotation::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

Definition at line 117 of file CAnnotatedMatrix.cpp.

References createAnnotationsCNFromCopasiVector(), mAnnotationsCN, mCopasiVectors, mModes, NUMBERS, STRINGS, and VECTOR_ON_THE_FLY.

118 {
119  assert(d < mModes.size());
120  assert(mModes[d] != STRINGS);
121  assert(mModes[d] != NUMBERS);
122 
123  if (mModes[d] == VECTOR_ON_THE_FLY)
125 
126  return mAnnotationsCN[d];
127 }
std::vector< Mode > mModes
std::vector< std::vector< CRegisteredObjectName > > mAnnotationsCN
bool createAnnotationsCNFromCopasiVector(size_t d, const CCopasiContainer *v) const
std::vector< const CCopasiContainer * > mCopasiVectors
const std::vector< std::string > & CArrayAnnotation::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 VECTOR_ON_THE_FLY 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.

Definition at line 129 of file CAnnotatedMatrix.cpp.

References createAnnotationsCNFromCopasiVector(), createNumbers(), CCopasiDataModel::getDataObject(), CCopasiObject::getObjectDataModel(), CCopasiObject::getObjectDisplayName(), CCopasiObject::getObjectName(), mAnnotationsCN, mAnnotationsString, mCopasiVectors, mModes, NUMBERS, OBJECTS, VECTOR, and VECTOR_ON_THE_FLY.

Referenced by CQArrayAnnotationsWidget::fillBarChart(), CQArrayAnnotationsWidget::fillTable1(), CQArrayAnnotationsWidget::fillTableN(), CQArrayAnnotationsWidget::initSelectionTable(), operator<<(), and CQMatrixDialog::setArray().

130 {
131  assert(d < mModes.size());
132 
133  //generate CNs (if necessary)
134  if (mModes[d] == VECTOR_ON_THE_FLY)
136 
137  //generate DisplayNames
138  if ((mModes[d] == VECTOR) || (mModes[d] == VECTOR_ON_THE_FLY) || (mModes[d] == OBJECTS))
139  {
140  size_t i, imax = mAnnotationsCN[d].size();
141  mAnnotationsString[d].resize(imax);
142  const CCopasiDataModel* pDataModel = getObjectDataModel();
143  assert(pDataModel != NULL);
144 
145  for (i = 0; i < imax; ++i)
146  {
147  const CCopasiObject * obj = pDataModel->getDataObject(mAnnotationsCN[d][i]);
148 
149  if (obj)
150  mAnnotationsString[d][i] =
151  display ? obj->getObjectDisplayName() : obj->getObjectName();
152  else
153  mAnnotationsString[d][i] = "???";
154  }
155  }
156 
157  //generate Numbers
158  if (mModes[d] == NUMBERS)
159  createNumbers(d);
160 
161  // if the mode is STRINGS do nothing, mAnnotationsString is supposed to contain
162  // the correct strings
163 
164  return mAnnotationsString[d];
165 }
CCopasiDataModel * getObjectDataModel()
CCopasiObject * getDataObject(const CCopasiObjectName &CN) const
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
void createNumbers(size_t d) const
const std::string & getObjectName() const
std::vector< Mode > mModes
std::vector< std::vector< CRegisteredObjectName > > mAnnotationsCN
std::vector< std::vector< std::string > > mAnnotationsString
bool createAnnotationsCNFromCopasiVector(size_t d, const CCopasiContainer *v) const
std::vector< const CCopasiContainer * > mCopasiVectors
Mode CArrayAnnotation::getDefaultMode ( ) const
inline

Definition at line 143 of file CAnnotatedMatrix.h.

References mDefaultMode.

144  {return mDefaultMode;};
const std::string & CArrayAnnotation::getDescription ( ) const

Definition at line 179 of file CAnnotatedMatrix.cpp.

References mDescription.

Referenced by operator<<().

180 {return mDescription;}
std::string mDescription
const std::string & CArrayAnnotation::getDimensionDescription ( size_t  d) const

Definition at line 167 of file CAnnotatedMatrix.cpp.

References mDimensionDescriptions.

Referenced by CQArrayAnnotationsWidget::initSelectionTable(), printRecursively(), CQMatrixDialog::setArray(), and CQArrayAnnotationsWidget::setArrayAnnotation().

168 {
169  assert(d < mDimensionDescriptions.size());
170  return mDimensionDescriptions[d];
171 }
std::vector< std::string > mDimensionDescriptions
Mode CArrayAnnotation::getMode ( size_t  d) const
inline

Definition at line 140 of file CAnnotatedMatrix.h.

References mModes.

141  {return mModes[d];};
std::vector< Mode > mModes
const CObjectInterface * CArrayAnnotation::getObject ( const CCopasiObjectName 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 CCopasiContainer.

Definition at line 297 of file CAnnotatedMatrix.cpp.

References C_INT32, CCopasiObjectName::getElementName(), CCopasiContainer::getObject(), CCopasiObject::getObject(), CCopasiObjectName::getRemainder(), and CCopasiContainer::mObjects.

Referenced by addElementReference().

298 {
299  if (cn == "")
300  {
301  return this;
302  }
303 
304  if (cn == "Property=DisplayName")
305  {
306  return CCopasiObject::getObject(cn);
307  }
308 
309  //if there are no indices there could still be other children. This can be handled
310  //by the container base class
311  if (cn.getElementName(0, false) == "") //no indices
312  return this->CCopasiContainer::getObject(cn);
313 
314  //so now we know we have indices. So we check if the array element reference
315  //exists, if not we create it. Then getObject() of the element reference is called
316  //with the remainder TODO
317 
318  /*
319  //first get the array indices. At the moment only numerical indices...
320  C_INT32 ii = 0;
321  CCopasiArray::index_type index;
322  while (cn.getElementName(ii, false) != "")
323  {
324  index.push_back(cn.getElementIndex(ii));
325  ++ii;
326  }
327  */
328 
329  //first get the index string
330  std::string tmp;
331  std::string indexString;
332  C_INT32 ii = 0;
333 
334  while ((tmp = cn.getElementName(ii, false)) != "")
335  {
336  indexString += "[" + tmp + "]";
337  ++ii;
338  }
339 
340  const CCopasiObject* pObject = NULL; //this will contain the element reference
341 
342  //if the reference object already exists, its name will be identical to the index
343  std::pair< objectMap::const_iterator, objectMap::const_iterator > range =
344  mObjects.equal_range(indexString);
345 
346  objectMap::const_iterator it = range.first;
347 
348  while (it != range.second && it->second->getObjectType() != "ElementReference") ++it;
349 
350  if (it == range.second) //not found
351  {
352  //create new element reference
353  pObject = new CArrayElementReference(cn, this);
354  }
355  else
356  {
357  pObject = it->second;
358  }
359 
360  if (pObject)
361  return pObject->getObject(cn.getRemainder());
362  else
363  return NULL;
364 
365  /*
366  if (index.size() != dimensionality()) //wrong number of indices for this array
367  return NULL;
368 
369  size_t i;
370  for (i = 0; i < dimensionality(); ++i)
371  if (index[i] >= size()[i]) //out of range
372  return NULL;
373  */
374 
375  //TODO remove element children after resize
376  //TODO check optimization expression widget...
377 }
CCopasiObjectName getRemainder() const
virtual const CObjectInterface * getObject(const CCopasiObjectName &cn) const
#define C_INT32
Definition: copasi.h:90
std::string getElementName(const size_t &pos, const bool &unescape=true) const
virtual const CObjectInterface * getObject(const CCopasiObjectName &cn) const
std::string CArrayAnnotation::getObjectDisplayName ( bool  regular = true,
bool  richtext = false 
) const
virtual

generate a display name for the array annotation.

Reimplemented from CCopasiObject.

Definition at line 486 of file CAnnotatedMatrix.cpp.

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

487 {
488  std::string part;
489 
490  if (getObjectParent() && getObjectParent()->getObjectType() != "Model")
491  part = getObjectParent()->getObjectDisplayName(regular, richtext) + ".";
492 
493  return part + getObjectName() + "[[]]";
494 }
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
const std::string & getObjectName() const
const std::string & getObjectType() const
CCopasiContainer * getObjectParent() const
bool CArrayAnnotation::isEmpty ( )

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

Definition at line 467 of file CAnnotatedMatrix.cpp.

References dimensionality(), and size().

Referenced by CQSimpleSelectionTree::populateTree().

468 {
469  // either the dimension itself ...
470  size_t dim = dimensionality();
471 
472  if (dim == 0) return false;
473 
474  // ... or the size of each dimension should be greater than zero.
475  size_t idx = 0;
476 
477  for (idx = 0; idx < dim; idx++)
478  {
479  if (!size()[idx])
480  return true;
481  }
482 
483  return false;
484 }
CCopasiAbstractArray::index_type size() const
size_t dimensionality() const
CArrayAnnotation& CArrayAnnotation::operator= ( const CArrayAnnotation )
private
void CArrayAnnotation::print ( std::ostream *  ostream) const
virtual

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.

Parameters
std::ostream* ostream

Reimplemented from CCopasiObject.

Definition at line 379 of file CAnnotatedMatrix.cpp.

380 {*ostream << *this;}
void CArrayAnnotation::printRecursively ( std::ostream &  ostream,
size_t  level,
CCopasiAbstractArray::index_type index,
const std::vector< std::vector< std::string > > &  display 
) const

Definition at line 384 of file CAnnotatedMatrix.cpp.

References array(), dimensionality(), getDimensionDescription(), size(), and SPC.

Referenced by operator<<().

387 {
388  size_t indent = 2 * (dimensionality() - 1 - level);
389 
390  if (level == 0) //only vector
391  {
392  ostream << SPC(indent) << "Rows: " << getDimensionDescription(level) << "\n";
393 
394  size_t imax = size()[0];
395 
396  for (index[0] = 0; index[0] < imax; ++index[0])
397  ostream << SPC(indent) << display[0][index[0]] << "\t" << (*array())[index] << "\n";
398  }
399  else if (level == 1) //matrix
400  {
401  ostream << SPC(indent) << "Rows: " << getDimensionDescription(level - 1) << "\n";
402  ostream << SPC(indent) << "Columns: " << getDimensionDescription(level) << "\n";
403 
404  size_t imax = size()[0];
405  size_t jmax = size()[1];
406  ostream << SPC(indent);
407 
408  for (index[1] = 0; index[1] < jmax; ++index[1])
409  ostream << "\t" << display[1][index[1]];
410 
411  ostream << "\n";
412 
413  for (index[0] = 0; index[0] < imax; ++index[0])
414  {
415  ostream << SPC(indent) << display[0][index[0]];
416 
417  for (index[1] = 0; index[1] < jmax; ++index[1])
418  ostream << "\t" << (*array())[index];
419 
420  ostream << "\n";
421  }
422  }
423  else //dimensionality > 2
424  {
425  size_t i, imax = size()[level];
426 
427  for (i = 0; i < imax; ++i)
428  {
429  ostream << SPC(indent) << getDimensionDescription(level) << ": " << display[level][i] << "\n";
430  index[level] = i;
431  printRecursively(ostream, level - 1, index, display);
432  }
433  }
434 }
const std::string & getDimensionDescription(size_t d) const
CCopasiAbstractArray * array()
#define SPC(level)
CCopasiAbstractArray::index_type size() const
size_t dimensionality() const
void printRecursively(std::ostream &ostream, size_t level, CCopasiAbstractArray::index_type &index, const std::vector< std::vector< std::string > > &display) const
void CArrayAnnotation::reDimensionalize ( size_t  d)

resize the internal vectors according to the dimensionality of the array

Definition at line 221 of file CAnnotatedMatrix.cpp.

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

Referenced by resize().

222 {
223  mAnnotationsCN.resize(d);
224  mAnnotationsString.resize(d);
225  mDimensionDescriptions.resize(d);
226  mCopasiVectors.resize(d);
227  mModes.resize(d, mDefaultMode);
228 }
std::vector< std::string > mDimensionDescriptions
std::vector< Mode > mModes
std::vector< std::vector< CRegisteredObjectName > > mAnnotationsCN
std::vector< std::vector< std::string > > mAnnotationsString
std::vector< const CCopasiContainer * > mCopasiVectors
void CArrayAnnotation::resize ( )
void CArrayAnnotation::resizeOneDimension ( size_t  d)

Definition at line 231 of file CAnnotatedMatrix.cpp.

References mAnnotationsCN, mAnnotationsString, mModes, mpArray, CCopasiAbstractArray::size(), and VECTOR.

Referenced by resize(), setAnnotationCN(), setAnnotationString(), and setMode().

232 {
233  if (mModes[d] != VECTOR)
234  {
235  mAnnotationsCN[d].resize(mpArray->size()[d]);
236  mAnnotationsString[d].resize(mpArray->size()[d]);
237  }
238 }
virtual const index_type & size() const =0
CCopasiAbstractArray * mpArray
std::vector< Mode > mModes
std::vector< std::vector< CRegisteredObjectName > > mAnnotationsCN
std::vector< std::vector< std::string > > mAnnotationsString
void CArrayAnnotation::setAnnotationCN ( size_t  d,
size_t  i,
const std::string  cn 
)

Definition at line 95 of file CAnnotatedMatrix.cpp.

References mAnnotationsCN, mModes, OBJECTS, resizeOneDimension(), and size().

Referenced by CSensMethod::initialize(), CSteadyStateTask::initialize(), CSteadyStateTask::updateMatrices(), and CModel::updateMatrixAnnotations().

96 {
97  assert(d < mAnnotationsCN.size());
98  assert(mModes[d] == OBJECTS);
99 
101  assert(i < mAnnotationsCN[d].size());
102 
103  mAnnotationsCN[d][i] = cn;
104 }
void resizeOneDimension(size_t d)
std::vector< Mode > mModes
std::vector< std::vector< CRegisteredObjectName > > mAnnotationsCN
CCopasiAbstractArray::index_type size() const
void CArrayAnnotation::setAnnotationString ( size_t  d,
size_t  i,
const std::string  s 
)

Definition at line 106 of file CAnnotatedMatrix.cpp.

References mAnnotationsString, mModes, resizeOneDimension(), size(), and STRINGS.

Referenced by CFitProblem::initialize(), CILDMModifiedMethod::setAnnotationM(), CILDMMethod::setAnnotationM(), and CCSPMethod::setAnnotationM().

107 {
108  assert(d < mAnnotationsString.size());
109  assert(mModes[d] == STRINGS);
110 
112  assert(i < mAnnotationsString[d].size());
113 
114  mAnnotationsString[d][i] = s;
115 }
void resizeOneDimension(size_t d)
std::vector< Mode > mModes
std::vector< std::vector< std::string > > mAnnotationsString
CCopasiAbstractArray::index_type size() const
void CArrayAnnotation::setArray ( CCopasiAbstractArray 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 VECTOR_ON_THE_FLY mode, in size).

Definition at line 58 of file CAnnotatedMatrix.cpp.

References mpArray.

59 {
60  mpArray = a;
61 }
CCopasiAbstractArray * mpArray
void CArrayAnnotation::setCopasiVector ( size_t  d,
const CCopasiContainer v 
)

Associates a dimension d of the array with a CCopasiVector of CCopasiObjects. 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 VECTOR_ON_THE_FLY the CNs are generated when getAnnotationsCN() or getAnnotationsString() is called.

Definition at line 84 of file CAnnotatedMatrix.cpp.

References createAnnotationsCNFromCopasiVector(), mCopasiVectors, mModes, VECTOR, and VECTOR_ON_THE_FLY.

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

85 {
86  assert(d < mCopasiVectors.size());
87  assert((mModes[d] == VECTOR) || (mModes[d] == VECTOR_ON_THE_FLY));
88 
89  mCopasiVectors[d] = v;
90 
91  if (mModes[d] == VECTOR)
93 }
std::vector< Mode > mModes
bool createAnnotationsCNFromCopasiVector(size_t d, const CCopasiContainer *v) const
std::vector< const CCopasiContainer * > mCopasiVectors
void CArrayAnnotation::setDescription ( const std::string &  s)
void CArrayAnnotation::setDimensionDescription ( size_t  d,
const std::string &  s 
)
void CArrayAnnotation::setMode ( size_t  d,
Mode  m 
)
void CArrayAnnotation::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

Definition at line 69 of file CAnnotatedMatrix.cpp.

References mDefaultMode, mModes, and setMode().

70 {
71  mDefaultMode = m;
72 
73  size_t i;
74 
75  for (i = 0; i < mModes.size(); ++i)
76  setMode(i, m);
77 }
std::vector< Mode > mModes
void setMode(size_t d, Mode m)
CCopasiAbstractArray::index_type CArrayAnnotation::size ( ) const
inline

Friends And Related Function Documentation

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

Definition at line 438 of file CAnnotatedMatrix.cpp.

439 {
440  if (!o.array()) return os;
441 
442  //cache the display names
443  std::vector<std::vector<std::string> > displaynames;
444  size_t i;
445 
446  for (i = 0; i < o.dimensionality(); ++i)
447  displaynames.push_back(o.getAnnotationsString(i));
448 
449  os << o.getObjectName() << std::endl;
450  os << o.getDescription() << std::endl;
451 
452  CCopasiAbstractArray::index_type arraysize = o.array()->size();
453 
454  if (o.dimensionality() == 0)
455  {
456  //only one scalar value
457  os << (*o.array())[arraysize] << std::endl;
458  }
459  else
460  {
461  o.printRecursively(os, o.dimensionality() - 1, arraysize, displaynames);
462  }
463 
464  return os;
465 }
const std::string & getObjectName() const
const std::vector< std::string > & getAnnotationsString(size_t d, bool display=true) const
virtual const index_type & size() const =0
CCopasiAbstractArray * array()
std::vector< size_t > index_type
Definition: CCopasiArray.h:34
const std::string & getDescription() const
size_t dimensionality() const
void printRecursively(std::ostream &ostream, size_t level, CCopasiAbstractArray::index_type &index, const std::vector< std::vector< std::string > > &display) const

Member Data Documentation

std::vector< std::vector<CRegisteredObjectName> > CArrayAnnotation::mAnnotationsCN
mutableprivate
std::vector< std::vector<std::string> > CArrayAnnotation::mAnnotationsString
mutableprivate
std::vector< const CCopasiContainer * > CArrayAnnotation::mCopasiVectors
private
Mode CArrayAnnotation::mDefaultMode
private

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

Definition at line 94 of file CAnnotatedMatrix.h.

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

std::string CArrayAnnotation::mDescription
private

Definition at line 96 of file CAnnotatedMatrix.h.

Referenced by getDescription(), and setDescription().

bool CArrayAnnotation::mDestructArray
private

Definition at line 77 of file CAnnotatedMatrix.h.

Referenced by ~CArrayAnnotation().

std::vector< std::string > CArrayAnnotation::mDimensionDescriptions
private
std::vector<Mode> CArrayAnnotation::mModes
private
CCopasiAbstractArray* CArrayAnnotation::mpArray
private

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