COPASI API  4.16.103
Public Types | Public Member Functions | Private Member Functions | List of all members
CCopasiVectorN< CType > Class Template Reference

#include <CCopasiDataModel.h>

Inheritance diagram for CCopasiVectorN< CType >:
Inheritance graph
[legend]
Collaboration diagram for CCopasiVectorN< CType >:
Collaboration graph
[legend]

Public Types

typedef std::vector< CType * >
::const_iterator 
const_iterator
 
typedef std::vector< CType * >
::iterator 
iterator
 
typedef std::vector< CType * >
::value_type 
value_type
 
- Public Types inherited from CCopasiVector< CType >
typedef std::vector< CType * >
::const_iterator 
const_iterator
 
typedef std::vector< CType * >
::iterator 
iterator
 
typedef std::vector< CType * >
::value_type 
value_type
 
- 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

virtual bool add (const CType &src)
 
virtual bool add (CType *src, const bool &adopt=false)
 
 CCopasiVectorN (const std::string &name="NoName", const CCopasiContainer *pParent=NULL)
 
 CCopasiVectorN (const CCopasiVectorN< CType > &src, const CCopasiContainer *pParent=NULL)
 
virtual size_t getIndex (const std::string &name) const
 
virtual const CObjectInterfacegetObject (const CCopasiObjectName &name) const
 
CCopasiVectorN< CType > & operator= (const std::vector< CType * > &rhs)
 
value_typeoperator[] (const size_t &index)
 
const value_typeoperator[] (const size_t &index) const
 
value_typeoperator[] (const std::string &name)
 
const value_typeoperator[] (const std::string &name) const
 
virtual void remove (const std::string &name)
 
virtual ~CCopasiVectorN ()
 
- Public Member Functions inherited from CCopasiVector< CType >
virtual bool add (CType *src, bool adopt=false)
 
iterator begin ()
 
const_iterator begin () const
 
 CCopasiVector (const std::string &name="NoName", const CCopasiContainer *pParent=NULL, const unsigned C_INT32 &flag=CCopasiObject::Vector)
 
 CCopasiVector (const CCopasiVector< CType > &src, const CCopasiContainer *pParent=NULL)
 
virtual void cleanup ()
 
virtual void clear ()
 
void deepCopy (const CCopasiVector< CType > &source)
 
iterator end ()
 
const_iterator end () const
 
virtual size_t getIndex (const CCopasiObject *pObject) const
 
CCopasiVector< CType > & operator= (const CCopasiVector< CType > &rhs)
 
CCopasiVector< CType > & operator= (const std::vector< CType * > &rhs)
 
const value_typeoperator[] (const size_t &index) const
 
value_typeoperator[] (const size_t &index)
 
virtual void remove (const size_t &index)
 
virtual bool remove (CCopasiObject *pObject)
 
virtual void resize (const size_t &newSize)
 
virtual size_t size () const
 
virtual void swap (const size_t &indexFrom, const size_t &indexTo)
 
virtual ~CCopasiVector ()
 
- 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 ~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
 
virtual std::string getObjectDisplayName (bool regular=true, bool richtext=false) 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
 
virtual void print (std::ostream *ostream) 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

virtual bool isInsertAllowed (const CType *src)
 

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

template<class CType>
class CCopasiVectorN< CType >

Definition at line 47 of file CCopasiDataModel.h.

Member Typedef Documentation

template<class CType>
typedef std::vector< CType * >::const_iterator CCopasiVectorN< CType >::const_iterator

Definition at line 573 of file CCopasiVector.h.

template<class CType>
typedef std::vector< CType * >::iterator CCopasiVectorN< CType >::iterator

Definition at line 572 of file CCopasiVector.h.

template<class CType>
typedef std::vector< CType * >::value_type CCopasiVectorN< CType >::value_type

Definition at line 571 of file CCopasiVector.h.

Constructor & Destructor Documentation

template<class CType>
CCopasiVectorN< CType >::CCopasiVectorN ( const std::string &  name = "NoName",
const CCopasiContainer pParent = NULL 
)
inline

Default constructor

Parameters
conststd::string & name (Default: "NoName")
constCCopasiContainer * pParent (Default: NULL)

Definition at line 582 of file CCopasiVector.h.

template<class CType>
CCopasiVectorN< CType >::CCopasiVectorN ( const CCopasiVectorN< CType > &  src,
const CCopasiContainer pParent = NULL 
)
inline

Copy constructor

Parameters
constCCopasiVectorN < CType > & src
constCCopasiContainer * pParent (Default: NULL)

Definition at line 595 of file CCopasiVector.h.

596  :
597  CCopasiVector < CType > (src, pParent)
598  {}
template<class CType>
virtual CCopasiVectorN< CType >::~CCopasiVectorN ( )
inlinevirtual

Destructor

Definition at line 603 of file CCopasiVector.h.

603 {}

Member Function Documentation

template<class CType>
virtual bool CCopasiVectorN< CType >::add ( const CType &  src)
inlinevirtual

Add a copy of the object to the end of the vector.

Parameters
constCType & src
Returns
bool success.

Reimplemented from CCopasiVector< CType >.

Definition at line 621 of file CCopasiVector.h.

Referenced by CFunctionParameters::add(), CFunctionDB::add(), CModelAdd::addEvents(), CCompartment::addMetabolite(), CCopasiDataModel::addReport(), CCopasiDataModel::addTask(), CQReportDefinition::btnCopyReportClicked(), CQPlotSubwidget::copyPlot(), CModel::createCompartment(), CModel::createEvent(), CModel::createModelValue(), CKinFunction::createParameters(), createParameterSetsForExperiment(), CModel::createReaction(), CModelExpansion::duplicateEvent(), CCopasiXMLParser::ListOfPlotsElement::end(), CCopasiXMLParser::ListOfTasksElement::end(), CCopasiXMLParser::FunctionElement::end(), SBMLImporter::importEvent(), SEDMLImporter::importTasks(), CFunctionDB::load(), CQEventWidget1::saveToEvent(), CQParameterOverviewWidget::slotBtnCopy(), CQParameterOverviewWidget::slotBtnNew(), CQParameterOverviewWidget::slotBtnSaveAs(), CCopasiXMLParser::ModelParameterSetElement::start(), CCopasiXMLParser::ReactionElement::start(), CCopasiXMLParser::CompartmentElement::start(), CCopasiXMLParser::ModelValueElement::start(), CCopasiXMLParser::EventElement::start(), CCopasiXMLParser::AssignmentElement::start(), CCopasiXMLParser::ReportElement::start(), and test000087::test_simulate_reaction_flux_reference_1().

622  {
623  if (!isInsertAllowed(&src))
624  {
626  MCCopasiVector + 2, src.getObjectName().c_str());
627  return false;
628  }
629 
630  CType * Element;
631 
632  try
633  {
634  Element = new CType(src);
635  }
636  catch (...)
637  {
638  Element = NULL;
639  }
640 
641  if (Element == NULL)
642  CCopasiMessage ex(CCopasiMessage::EXCEPTION, MCopasiBase + 1, sizeof(CType));
643 
644  std::vector< CType * >::push_back(Element);
645  return CCopasiContainer::add(Element);
646  }
#define MCopasiBase
virtual bool isInsertAllowed(const CType *src)
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
#define MCCopasiVector
template<class CType>
virtual bool CCopasiVectorN< CType >::add ( CType *  src,
const bool &  adopt = false 
)
inlinevirtual

Add an object to the end of the vector, if adobt is true the vector. becomes the parent of the object.

Parameters
CType* src
constbool & adopt (Default: false)
Returns
bool success

Definition at line 655 of file CCopasiVector.h.

656  {
657  if (!isInsertAllowed(src))
658  {
660  MCCopasiVector + 2, src->getObjectName().c_str());
661  return false;
662  }
663 
664  // This is not very efficient !!!
665  // It results in a lot of resizing of the vector !!!
666  std::vector< CType * >::push_back(src);
667  return CCopasiContainer::add(src, adopt);
668  }
virtual bool isInsertAllowed(const CType *src)
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
#define MCCopasiVector
template<class CType>
virtual size_t CCopasiVectorN< CType >::getIndex ( const std::string &  name) const
inlinevirtual

Retrieve the index of the named object in the vector. If an object with the given name is not found C_INVALID_INDEX is returned.

Parameters
conststd::string & name
Returns
size_t index

Definition at line 774 of file CCopasiVector.h.

Referenced by CFunctionParameters::add(), CFunctionDB::addAndAdaptName(), CCopasiDataModel::addDefaultReports(), CCopasiDataModel::addDefaultTasks(), CModelAdd::addEvents(), CQReportDefinition::btnCopyReportClicked(), CFunction::completeFunctionList(), CQPlotSubwidget::copyPlot(), SBMLImporter::createCCompartmentFromCompartment(), SBMLImporter::createCMetabFromSpecies(), SBMLImporter::createCModelValueFromParameter(), CModel::createCompartment(), SBMLImporter::createCReactionFromReaction(), CCrossSectionTask::createEvent(), CModel::createEvent(), CModel::createMetabolite(), CModel::createModelValue(), CChemEqInterface::createNonExistingMetabs(), CKinFunction::createParameters(), createParameterSetsForExperiment(), CModel::createReaction(), CMetabNameInterface::doesExist(), COptProblem::elevateChildren(), CCopasiXMLParser::COPASIElement::end(), CFunctionDB::findFunction(), CCopasiXML::fixBuild55(), CCopasiXML::fixBuild81(), CMetabNameInterface::getMetabolite(), CCopasiVectorN< CReportDefinition >::getObject(), SBMLImporter::importEvent(), CCopasiVectorN< CReportDefinition >::isInsertAllowed(), CCopasiVectorN< CReportDefinition >::operator[](), CCopasiVectorN< CReportDefinition >::remove(), CQEventWidget1::saveToEvent(), CQParameterOverviewWidget::slotBtnCopy(), FunctionWidget1::slotBtnNew(), ReactionsWidget1::slotNewFunction(), CCopasiXMLParser::AssignmentElement::start(), CCopasiXMLParser::ReportElement::start(), and CCopasiXMLParser::FunctionElement::start().

775  {
776  size_t i, imax = CCopasiVector< CType >::size();
778 
779  std::string Name = unQuote(name);
780 
781  for (i = 0; i < imax; i++, Target++)
782  if (*Target &&
783  ((*Target)->getObjectName() == name ||
784  (*Target)->getObjectName() == Name)) return i;
785 
786  return C_INVALID_INDEX;
787  }
std::string unQuote(const std::string &name)
Definition: utility.cpp:120
virtual size_t size() const
iterator begin()
#define C_INVALID_INDEX
Definition: copasi.h:222
std::vector< CType * >::const_iterator const_iterator
template<class CType>
virtual const CObjectInterface* CCopasiVectorN< CType >::getObject ( const CCopasiObjectName name) const
inlinevirtual

Retrieve a pointer to the named object.

Parameters
conststd::string & name
Returns
const CObjectInterface * pObject

Reimplemented from CCopasiVector< CType >.

Definition at line 742 of file CCopasiVector.h.

Referenced by CCopasiXMLParser::getObjectFromName().

743  {
744  size_t Index = getIndex(name.getElementName(0));
745 
746  if (Index == C_INVALID_INDEX) return NULL;
747 
748  CCopasiObject * pObject = *(CCopasiVector< CType >::begin() + Index);
749 
750  if (name.getObjectType() == pObject->getObjectType())
751  return pObject; //exact match of type and name
752 
753  if (name.getObjectName() == "")
754  return pObject; //cn contains no "="; type cannot be checked
755 
756 #ifdef COPASI_DEBUG
757  std::cout << "CCopasiVector::getObject: Vector contains object of right name but wrong type" << std::endl;
758  std::cout << " CN " << name << std::endl;
759  std::cout << " CN.getName(0) " << name.getElementName(0) << std::endl;
760  std::cout << " Index " << Index << std::endl;
761  std::cout << " CN.getObjName " << name.getObjectName() << std::endl;
762  std::cout << " CN.getObjType " << name.getObjectType() << std::endl << std::endl;
763 #endif // COPASI_DEBUG
764 
765  return NULL;
766  }
iterator begin()
const std::string & getObjectType() const
#define C_INVALID_INDEX
Definition: copasi.h:222
std::string getObjectType() const
virtual size_t getIndex(const std::string &name) const
std::string getElementName(const size_t &pos, const bool &unescape=true) const
std::string getObjectName() const
template<class CType>
virtual bool CCopasiVectorN< CType >::isInsertAllowed ( const CType *  src)
inlineprivatevirtual

Check whether an insert of the given src into the vector is allowed to avoid naming conflicts.

Parameters
constCType * src
Returns
bool insertAllowed

Definition at line 796 of file CCopasiVector.h.

Referenced by CCopasiVectorN< CReportDefinition >::add().

797  {return (getIndex(src->getObjectName()) == C_INVALID_INDEX);}
#define C_INVALID_INDEX
Definition: copasi.h:222
virtual size_t getIndex(const std::string &name) const
template<class CType>
CCopasiVectorN< CType >& CCopasiVectorN< CType >::operator= ( const std::vector< CType * > &  rhs)
inline

Assignment operator.

Parameters
conststd::vector< CType * > & rhs
Returns
CCopasiVectorN< CType > & lhs

Definition at line 610 of file CCopasiVector.h.

611  {
613  return *this;
614  }
CCopasiVector< CType > & operator=(const CCopasiVector< CType > &rhs)
template<class CType>
value_type& CCopasiVectorN< CType >::operator[] ( const size_t &  index)
inline

Retrieve the indexed object.

Parameters
constsize_t & index
Returns
value_type & object

Definition at line 694 of file CCopasiVector.h.

695  {return CCopasiVector< CType >::operator[](index);}
const value_type & operator[](const size_t &index) const
template<class CType>
const value_type& CCopasiVectorN< CType >::operator[] ( const size_t &  index) const
inline

Retrieve the indexed object.

Parameters
constsize_t & index
Returns
const value_type & object

Definition at line 702 of file CCopasiVector.h.

703  {return CCopasiVector< CType >::operator[](index);}
const value_type & operator[](const size_t &index) const
template<class CType>
value_type& CCopasiVectorN< CType >::operator[] ( const std::string &  name)
inline

Retrieve the named object.

Parameters
conststd::string & name
Returns
value_type & object

Definition at line 710 of file CCopasiVector.h.

711  {
712  size_t Index = getIndex(name);
713 
714  if (Index == C_INVALID_INDEX)
716  MCCopasiVector + 1, name.c_str());
717 
718  return *(CCopasiVector< CType >::begin() + Index);
719  }
iterator begin()
#define C_INVALID_INDEX
Definition: copasi.h:222
virtual size_t getIndex(const std::string &name) const
#define MCCopasiVector
template<class CType>
const value_type& CCopasiVectorN< CType >::operator[] ( const std::string &  name) const
inline

Retrieve the named object.

Parameters
conststd::string & name
Returns
const value_type & object

Definition at line 726 of file CCopasiVector.h.

727  {
728  size_t Index = getIndex(name);
729 
730  if (Index == C_INVALID_INDEX)
732  MCCopasiVector + 1, name.c_str());
733 
734  return *(CCopasiVector< CType >::begin() + Index);
735  }
iterator begin()
#define C_INVALID_INDEX
Definition: copasi.h:222
virtual size_t getIndex(const std::string &name) const
#define MCCopasiVector
template<class CType>
virtual void CCopasiVectorN< CType >::remove ( const std::string &  name)
inlinevirtual

Remove the object with the given name from the vector.

Parameters
conststd::string & name

Definition at line 674 of file CCopasiVector.h.

Referenced by CCopasiXMLParser::COPASIElement::end(), CFunctionParameters::remove(), SBMLImporter::removeUnusedFunctions(), CModelExpansion::replaceInMetab(), CQSpeciesDetail::save(), CQEventWidget1::saveToEvent(), CQParameterOverviewWidget::slotBtnDelete(), and test000087::test_simulate_reaction_flux_reference_1().

675  {
676  size_t Index = getIndex(name);
677 
678  if (Index == C_INVALID_INDEX)
679  {
681  MCCopasiVector + 1, name.c_str());
682  return;
683  }
684 
686  return;
687  }
#define C_INVALID_INDEX
Definition: copasi.h:222
virtual size_t getIndex(const std::string &name) const
virtual void remove(const size_t &index)
#define MCCopasiVector

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