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

#include <CMIRIAMResource.h>

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

Public Member Functions

void addMIRIAMResource (CMIRIAMResource *pMIRIAMResource)
 
bool autoUpdateMIRIAMResources (CProcessReport *pProcessReport)
 
 CMIRIAMResources (const std::string &name="MIRIAM Resources", const CCopasiContainer *pParent=NULL)
 
 CMIRIAMResources (const CMIRIAMResources &src, const CCopasiContainer *pParent=NULL)
 
 CMIRIAMResources (const CCopasiParameterGroup &group, const CCopasiContainer *pParent=NULL)
 
virtual bool elevateChildren ()
 
const unsigned C_INT32getMIRIAMLastUpdateDate () const
 
const CMIRIAMResourcegetMIRIAMResource (const size_t index) const
 
size_t getMIRIAMResourceIndex (const std::string &URI) const
 
const CMIRIAMResourcesgetMIRIAMResources () const
 
const unsigned C_INT32getMIRIAMUpdateFrequency () const
 
size_t getResourceIndexFromDisplayName (const std::string &displayName) const
 
const CCopasiParameterGroupgetResourceList () const
 
void initializeParameter ()
 
void setMIRIAMUpdateFrequencyInDays (const size_t &days)
 
bool updateMIRIAMResources (CProcessReport *pProcessReport)
 
bool updateMIRIAMResourcesFromFile (CProcessReport *pProcessReport, const std::string &filename)
 
virtual ~CMIRIAMResources ()
 
- Public Member Functions inherited from CCopasiParameterGroup
bool addGroup (const std::string &name)
 
bool addParameter (const CCopasiParameter &parameter)
 
bool addParameter (const std::string &name, const CCopasiParameter::Type type)
 
template<class CType >
bool addParameter (const std::string &name, const CCopasiParameter::Type type, const CType &value)
 
void addParameter (CCopasiParameter *pParameter)
 
CCopasiParameterGroupassertGroup (const std::string &name)
 
template<class CType >
CCopasiParameterassertParameter (const std::string &name, const CCopasiParameter::Type type, const CType &defaultValue)
 
index_iterator beginIndex () const
 
name_iterator beginName () const
 
 CCopasiParameterGroup (const CCopasiParameterGroup &src, const CCopasiContainer *pParent=NULL)
 
 CCopasiParameterGroup (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &objectType="ParameterGroup")
 
void clear ()
 
index_iterator endIndex () const
 
name_iterator endName () const
 
CCopasiParameterGroupgetGroup (const std::string &name)
 
const CCopasiParameterGroupgetGroup (const std::string &name) const
 
CCopasiParameterGroupgetGroup (const size_t &index)
 
const CCopasiParameterGroupgetGroup (const size_t &index) const
 
size_t getIndex (const std::string &name) const
 
std::string getKey (const std::string &name) const
 
std::string getKey (const size_t &index) const
 
virtual const std::string & getName (const size_t &index) const
 
virtual const CObjectInterfacegetObject (const CCopasiObjectName &cn) const
 
CCopasiParametergetParameter (const std::string &name)
 
const CCopasiParametergetParameter (const std::string &name) const
 
CCopasiParametergetParameter (const size_t &index)
 
const CCopasiParametergetParameter (const size_t &index) const
 
CCopasiParameter::Type getType (const std::string &name) const
 
CCopasiParameter::Type getType (const size_t &index) const
 
std::string getUniqueParameterName (const CCopasiParameter *pParameter) const
 
const CCopasiParameter::ValuegetValue (const std::string &name) const
 
const CCopasiParameter::ValuegetValue (const size_t &index) const
 
CCopasiParameter::ValuegetValue (const std::string &name)
 
CCopasiParameter::ValuegetValue (const size_t &index)
 
CCopasiParameterGroupoperator= (const CCopasiParameterGroup &rhs)
 
virtual void print (std::ostream *ostream) const
 
bool removeParameter (const std::string &name)
 
bool removeParameter (const size_t &index)
 
template<class CType >
bool setValue (const std::string &name, const CType &value)
 
template<class CType >
bool setValue (const size_t &index, const CType &value)
 
size_t size () const
 
bool swap (const size_t &iFrom, const size_t &iTo)
 
bool swap (index_iterator &from, index_iterator &to)
 
virtual ~CCopasiParameterGroup ()
 
- Public Member Functions inherited from CCopasiParameter
 CCopasiParameter (const CCopasiParameter &src, const CCopasiContainer *pParent=NULL)
 
 CCopasiParameter (const std::string &name, const Type &type, const void *pValue=NULL, const CCopasiContainer *pParent=NULL, const std::string &objectType="Parameter")
 
virtual CCopasiObjectName getCN () const
 
virtual const std::string & getKey () const
 
virtual std::string getObjectDisplayName (bool regular=true, bool richtext=false) const
 
const CCopasiParameter::TypegetType () const
 
const ValuegetValue () const
 
ValuegetValue ()
 
virtual voidgetValuePointer () const
 
CCopasiObjectgetValueReference () const
 
bool isValidValue (const C_FLOAT64 &value) const
 
bool isValidValue (const C_INT32 &value) const
 
bool isValidValue (const unsigned C_INT32 &value) const
 
bool isValidValue (const bool &value) const
 
bool isValidValue (const std::string &value) const
 
bool isValidValue (const CCopasiObjectName &value) const
 
bool isValidValue (const std::vector< CCopasiParameter * > &value) const
 
CCopasiParameteroperator= (const CCopasiParameter &rhs)
 
template<class CType >
bool setValue (const CType &value)
 
bool setValue (const std::vector< CCopasiParameter * > &value)
 
virtual ~CCopasiParameter ()
 
- 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 const DataObjectSetgetDirectDependencies (const DataObjectSet &context=DataObjectSet()) 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
 
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

void createDisplayNameMap ()
 
void createURIMap ()
 
unsigned C_INT32 getActDateInSeconds ()
 
void setMIRIAMLastUpdateDate ()
 

Private Attributes

std::map< std::string, size_t > mDisplayName2Resource
 
unsigned C_INT32mpLastUpdateDate
 
CCopasiParameterGroupmpMIRIAMResources
 
unsigned C_INT32mpUpdateFrequency
 
std::map< std::string, size_t > mURI2Resource
 

Additional Inherited Members

- Public Types inherited from CCopasiParameterGroup
typedef parameterGroup::iterator index_iterator
 
typedef
CCopasiContainer::objectMap::iterator 
name_iterator
 
typedef std::vector
< CCopasiParameter * > 
parameterGroup
 
- Public Types inherited from CCopasiParameter
enum  Type {
  DOUBLE = 0, UDOUBLE, INT, UINT,
  BOOL, GROUP, STRING, CN,
  KEY, FILE, EXPRESSION, INVALID
}
 
- 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
 
- 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 CCopasiParameter
static const std::string TypeName []
 
static const char * XMLType []
 
- 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 CCopasiParameterGroup
 CCopasiParameterGroup ()
 
- 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 CCopasiParameter
std::string mKey
 
CCopasiObjectmpValueReference
 
size_t mSize
 
Value mValue
 
- Protected Attributes inherited from CCopasiContainer
objectMap mObjects
 
- Static Protected Attributes inherited from CCopasiObject
static CRenameHandlersmpRenameHandler = NULL
 

Detailed Description

Definition at line 173 of file CMIRIAMResource.h.

Constructor & Destructor Documentation

CMIRIAMResources::CMIRIAMResources ( const std::string &  name = "MIRIAM Resources",
const CCopasiContainer pParent = NULL 
)

Default constructor

Parameters
conststd::string & name (default: MIRIAM Resources)
constCCopasiContainer * pParent (default: NULL)

Definition at line 29 of file CMIRIAMResource.cpp.

References initializeParameter().

30  :
31  CCopasiParameterGroup(name, pParent),
32  mpLastUpdateDate(NULL),
33  mpUpdateFrequency(NULL),
34  mpMIRIAMResources(NULL)
CCopasiParameterGroup * mpMIRIAMResources
unsigned C_INT32 * mpUpdateFrequency
unsigned C_INT32 * mpLastUpdateDate
CMIRIAMResources::CMIRIAMResources ( const CMIRIAMResources src,
const CCopasiContainer pParent = NULL 
)

Copy constructor

Parameters
constCMIRIAMResources & src
constCCopasiContainer * pParent (default: NULL)

Definition at line 37 of file CMIRIAMResource.cpp.

References initializeParameter().

38  :
39  CCopasiParameterGroup(src, pParent),
40  mpLastUpdateDate(NULL),
41  mpUpdateFrequency(NULL),
42  mpMIRIAMResources(NULL)
CCopasiParameterGroup * mpMIRIAMResources
unsigned C_INT32 * mpUpdateFrequency
unsigned C_INT32 * mpLastUpdateDate
CMIRIAMResources::CMIRIAMResources ( const CCopasiParameterGroup group,
const CCopasiContainer pParent = NULL 
)

Specific constructor

Parameters
constCCopasiParameterGroup & group
constCCopasiContainer * pParent (default: NULL)

Definition at line 45 of file CMIRIAMResource.cpp.

References initializeParameter().

46  :
47  CCopasiParameterGroup(group, pParent),
48  mpLastUpdateDate(NULL),
49  mpUpdateFrequency(NULL),
50  mpMIRIAMResources(NULL)
CCopasiParameterGroup * mpMIRIAMResources
unsigned C_INT32 * mpUpdateFrequency
unsigned C_INT32 * mpLastUpdateDate
CMIRIAMResources::~CMIRIAMResources ( )
virtual

Destructor

Definition at line 466 of file CMIRIAMResource.cpp.

467 {}

Member Function Documentation

void CMIRIAMResources::addMIRIAMResource ( CMIRIAMResource pMIRIAMResource)

Add a MIRIAM Resource to the list of MIRIAM Resources

Parameters
CMIRIAMResource* pMIRIAMResource

Definition at line 67 of file CMIRIAMResource.cpp.

References CCopasiParameterGroup::addParameter(), and mpMIRIAMResources.

68 {
69  mpMIRIAMResources->addParameter(mimriamResource);
70 }
CCopasiParameterGroup * mpMIRIAMResources
bool addParameter(const CCopasiParameter &parameter)
bool CMIRIAMResources::autoUpdateMIRIAMResources ( CProcessReport pProcessReport)

Automatically update the resources when the last update is older than the current date minus the update interval.

Parameters
CProcessReport* pProcessReport
Returns
bool success

Definition at line 323 of file CMIRIAMResource.cpp.

References getActDateInSeconds(), mpLastUpdateDate, mpUpdateFrequency, and updateMIRIAMResources().

324 {
326  {return updateMIRIAMResources(pProcessReport);}
327 
328  return false;
329 }
unsigned C_INT32 * mpUpdateFrequency
unsigned C_INT32 getActDateInSeconds()
unsigned C_INT32 * mpLastUpdateDate
bool updateMIRIAMResources(CProcessReport *pProcessReport)
void CMIRIAMResources::createDisplayNameMap ( )
private

Initialize the display name to resource index map

Definition at line 344 of file CMIRIAMResource.cpp.

References CCopasiParameterGroup::beginIndex(), CCopasiParameterGroup::endIndex(), CMIRIAMResource::getMIRIAMDisplayName(), getMIRIAMResource(), mDisplayName2Resource, and mpMIRIAMResources.

Referenced by initializeParameter(), updateMIRIAMResources(), and updateMIRIAMResourcesFromFile().

345 {
346  mDisplayName2Resource.clear();
347 
348  size_t Index = 0;
349 
352 
353  for (; it != end; ++it)
354  {
356  Index++;
357  }
358 }
const CMIRIAMResource & getMIRIAMResource(const size_t index) const
CCopasiParameterGroup * mpMIRIAMResources
index_iterator endIndex() const
const std::string & getMIRIAMDisplayName() const
index_iterator beginIndex() const
parameterGroup::iterator index_iterator
std::map< std::string, size_t > mDisplayName2Resource
void CMIRIAMResources::createURIMap ( )
private

Initialize the URI to resource index map

Definition at line 360 of file CMIRIAMResource.cpp.

References CCopasiParameterGroup::beginIndex(), CCopasiParameterGroup::endIndex(), CMIRIAMResource::getIdentifiersOrgURL(), CMIRIAMResource::getMIRIAMDeprecated(), CMIRIAMResource::getMIRIAMURI(), mpMIRIAMResources, and mURI2Resource.

Referenced by initializeParameter(), updateMIRIAMResources(), and updateMIRIAMResourcesFromFile().

361 {
362  mURI2Resource.clear();
363 
364  size_t Index = 0;
365  CMIRIAMResource * pResource = NULL;
366 
369 
370  for (; it != end; ++it)
371  {
372  pResource = static_cast< CMIRIAMResource * >(*it);
373  mURI2Resource[pResource->getMIRIAMURI() + ":"] = Index;
374  mURI2Resource[pResource->getIdentifiersOrgURL() + "/"] = Index;
375 
376  const CCopasiParameterGroup * pDeprecated = &pResource->getMIRIAMDeprecated();
377  CCopasiParameterGroup::index_iterator itDeprecated = pDeprecated->beginIndex();
378  CCopasiParameterGroup::index_iterator endDeprecated = pDeprecated->endIndex();
379 
380  for (; itDeprecated != endDeprecated; ++itDeprecated)
381  {
382  std::string Deprecated = *(*itDeprecated)->getValue().pSTRING;
383 
384  //Deprecated URL style URIs do not use the ':' separator.
385  if (Deprecated[Deprecated.length() - 1] != '/')
386  {
387  Deprecated += ":";
388  }
389 
390  mURI2Resource[Deprecated] = Index;
391  }
392 
393  Index++;
394  }
395 }
const std::string & getMIRIAMURI() const
std::string getIdentifiersOrgURL() const
CCopasiParameterGroup * mpMIRIAMResources
index_iterator endIndex() const
index_iterator beginIndex() const
const CCopasiParameterGroup & getMIRIAMDeprecated() const
parameterGroup::iterator index_iterator
std::map< std::string, size_t > mURI2Resource
bool CMIRIAMResources::elevateChildren ( )
virtual

This methods must be called to elevate subgroups to derived objects. The default implementation does nothing.

Returns
bool success

Reimplemented from CCopasiParameterGroup.

Definition at line 331 of file CMIRIAMResource.cpp.

References CCopasiParameterGroup::beginIndex(), CCopasiParameterGroup::endIndex(), and mpMIRIAMResources.

Referenced by initializeParameter(), updateMIRIAMResources(), and updateMIRIAMResourcesFromFile().

332 {
333  bool success = true;
334 
337 
338  for (; it != end; ++it)
339  *it = elevate<CMIRIAMResource, CCopasiParameterGroup>(*it);
340 
341  return success;
342 }
CCopasiParameterGroup * mpMIRIAMResources
index_iterator endIndex() const
index_iterator beginIndex() const
parameterGroup::iterator index_iterator
unsigned C_INT32 CMIRIAMResources::getActDateInSeconds ( )
private

Retrieve the current date ins seconds

Definition at line 320 of file CMIRIAMResource.cpp.

References C_INT32.

Referenced by autoUpdateMIRIAMResources(), initializeParameter(), and setMIRIAMLastUpdateDate().

321 {return (unsigned C_INT32) time(NULL);}
#define C_INT32
Definition: copasi.h:90
const unsigned C_INT32 & CMIRIAMResources::getMIRIAMLastUpdateDate ( ) const

Retrieve the day the resources where last updated

Returns
const unsigned C_INT32 & lastUpdateDay

Definition at line 78 of file CMIRIAMResource.cpp.

References mpLastUpdateDate.

79 {return * mpLastUpdateDate;}
unsigned C_INT32 * mpLastUpdateDate
const CMIRIAMResource & CMIRIAMResources::getMIRIAMResource ( const size_t  index) const

Retrieve the indexed resource

Parameters
constsize_t index
Returns
const CMIRIAMResource & resource

Definition at line 397 of file CMIRIAMResource.cpp.

References CCopasiParameterGroup::getGroup(), CCopasiRootContainer::getUnknownMiriamResource(), mpMIRIAMResources, and CCopasiParameterGroup::size().

Referenced by createDisplayNameMap(), CMIRIAMResourceObject::extractId(), CMIRIAMResourceObject::getDisplayName(), CMIRIAMResourceObject::getIdentifiersOrgURL(), CMIRIAMResourceObject::getURI(), and CQMiriamWidget::updateResourcesList().

398 {
399  if (index >= mpMIRIAMResources->size())
401 
402  return * static_cast< CMIRIAMResource * >(mpMIRIAMResources->getGroup(index));
403 }
CCopasiParameterGroup * mpMIRIAMResources
static const CMIRIAMResource & getUnknownMiriamResource()
CCopasiParameterGroup * getGroup(const std::string &name)
size_t CMIRIAMResources::getMIRIAMResourceIndex ( const std::string &  URI) const

Retrieve the index of the resource with the given URI

Parameters
conststd::string & URI
Returns
size_t index

Definition at line 405 of file CMIRIAMResource.cpp.

References C_INVALID_INDEX, and mURI2Resource.

Referenced by CMIRIAMResourceObject::getResource(), and CMIRIAMResourceObject::isValid().

406 {
407  size_t index = C_INVALID_INDEX;
408 
409  std::map< std::string , size_t >::const_iterator it = mURI2Resource.lower_bound(URI);
410  std::map< std::string , size_t >::const_iterator end = mURI2Resource.upper_bound(URI);
411 
412  if (it == mURI2Resource.begin())
413  return index;
414 
415  it--;
416 
417  for (; it != end; ++it)
418  {
419  // Check whether the URI base of the candidate matches.
420  if (URI.compare(0, it->first.length(), it->first) == 0)
421  {
422  index = it->second;
423  break;
424  }
425  }
426 
427  return index;
428 }
#define C_INVALID_INDEX
Definition: copasi.h:222
std::map< std::string, size_t > mURI2Resource
const CMIRIAMResources & CMIRIAMResources::getMIRIAMResources ( ) const

Retrieve the list of MIRIAM Resources

Returns
CMIRIAMResources & MIRIAMResources

Definition at line 72 of file CMIRIAMResource.cpp.

73 {return * this;}
const unsigned C_INT32 & CMIRIAMResources::getMIRIAMUpdateFrequency ( ) const

Retrieve the of interval between updates

Returns
const unsigned C_INT32 & updateFrequency

Definition at line 81 of file CMIRIAMResource.cpp.

References mpUpdateFrequency.

82 {return * mpUpdateFrequency;}
unsigned C_INT32 * mpUpdateFrequency
size_t CMIRIAMResources::getResourceIndexFromDisplayName ( const std::string &  displayName) const

Retrieve the index of the resource with the given display name

Parameters
conststd::string & displayName
Returns
size_t index

Definition at line 430 of file CMIRIAMResource.cpp.

References C_INVALID_INDEX, and mDisplayName2Resource.

Referenced by CMIRIAMResourceObject::setDisplayName().

431 {
432  // Check if the display name is a know resource
433  std::map< std::string, size_t>::const_iterator it =
434  mDisplayName2Resource.find(displayName.c_str());
435 
436  // If we did not find the resource we set it to unknown
437  if (it == mDisplayName2Resource.end())
438  {
439  // unknown is indicated by an invalid index.
440  return C_INVALID_INDEX;
441  }
442 
443  return it->second;
444 }
#define C_INVALID_INDEX
Definition: copasi.h:222
std::map< std::string, size_t > mDisplayName2Resource
const CCopasiParameterGroup & CMIRIAMResources::getResourceList ( ) const

Retrieve the list of MIRIAM resource as a CCopasiParameterGroup

Returns
const CCopasiParameterGroup & resourceList

Definition at line 75 of file CMIRIAMResource.cpp.

References mpMIRIAMResources.

Referenced by CConfigurationFile::load(), and CQMiriamWidget::updateResourcesList().

76 {return * mpMIRIAMResources;}
CCopasiParameterGroup * mpMIRIAMResources
void CMIRIAMResources::initializeParameter ( )

Allocates all group parameters and assures that they are properly initialized.

Definition at line 53 of file CMIRIAMResource.cpp.

References CCopasiParameterGroup::assertGroup(), CCopasiParameterGroup::assertParameter(), C_INT32, createDisplayNameMap(), createURIMap(), elevateChildren(), getActDateInSeconds(), CCopasiParameter::getValue(), mpLastUpdateDate, mpMIRIAMResources, mpUpdateFrequency, CCopasiParameter::Value::pUINT, and CCopasiParameter::UINT.

Referenced by CMIRIAMResources(), and CConfigurationFile::load().

54 {
56  (unsigned C_INT32) getActDateInSeconds())->getValue().pUINT;
58  (unsigned C_INT32) 604800)->getValue().pUINT;
59  mpMIRIAMResources = assertGroup("Resources");
60 
62 
64  createURIMap();
65 }
CCopasiParameterGroup * mpMIRIAMResources
#define C_INT32
Definition: copasi.h:90
unsigned C_INT32 * mpUpdateFrequency
const Value & getValue() const
unsigned C_INT32 * pUINT
CCopasiParameterGroup * assertGroup(const std::string &name)
virtual bool elevateChildren()
unsigned C_INT32 getActDateInSeconds()
CCopasiParameter * assertParameter(const std::string &name, const CCopasiParameter::Type type, const CType &defaultValue)
unsigned C_INT32 * mpLastUpdateDate
void CMIRIAMResources::setMIRIAMLastUpdateDate ( )
private

Set the last update date to the current time

Definition at line 314 of file CMIRIAMResource.cpp.

References getActDateInSeconds(), and mpLastUpdateDate.

Referenced by updateMIRIAMResources(), and updateMIRIAMResourcesFromFile().

unsigned C_INT32 getActDateInSeconds()
unsigned C_INT32 * mpLastUpdateDate
void CMIRIAMResources::setMIRIAMUpdateFrequencyInDays ( const size_t &  days)

Set the days between updates

Parameters
constsize_t & days

Definition at line 317 of file CMIRIAMResource.cpp.

References C_INT32, and mpUpdateFrequency.

318 {*mpUpdateFrequency = (unsigned C_INT32)(days * 24 * 60 * 60);}
#define C_INT32
Definition: copasi.h:90
unsigned C_INT32 * mpUpdateFrequency
bool CMIRIAMResources::updateMIRIAMResources ( CProcessReport pProcessReport)

Update the MIRIAM resources

Parameters
CProcessReport* pProcessReport
Returns
bool success

Definition at line 206 of file CMIRIAMResource.cpp.

References ArrayOf_USCORExsd_USCOREstring::__ptr, ArrayOf_USCORExsd_USCOREstring::__size, ns2__getDataTypeURIsResponse::_getDataTypeURIsReturn, CMIRIAMResource::addDeprecatedURL(), CProcessReport::addItem(), CCopasiParameterGroup::addParameter(), C_INT32, CCopasiParameterGroup::CCopasiParameterGroup(), createDisplayNameMap(), createURIMap(), elevateChildren(), CCopasiMessage::ERROR, CProcessReport::finishItem(), MiriamWebServicesSoapBindingProxy::getDataTypePattern(), MiriamWebServicesSoapBindingProxy::getDataTypesName(), ns2__getDataTypesNameResponse::getDataTypesNameReturn, MiriamWebServicesSoapBindingProxy::getDataTypeURI(), MiriamWebServicesSoapBindingProxy::getDataTypeURIs(), MCAnnotation, mpMIRIAMResources, pdelete, CProcessReport::progressItem(), CMIRIAMResource::setMIRIAMCitation(), CMIRIAMResource::setMIRIAMDisplayName(), setMIRIAMLastUpdateDate(), CMIRIAMResource::setMIRIAMPattern(), CMIRIAMResource::setMIRIAMURI(), CProcessReport::setName(), MiriamWebServicesSoapBindingProxy::soap_fault_detail(), MiriamWebServicesSoapBindingProxy::soap_fault_string(), and SOAP_OK.

Referenced by autoUpdateMIRIAMResources().

207 {
208  if (pProcessReport)
209  pProcessReport->setName("MIRIAM Resources Update...");
210 
211  bool success = true;
213 
214  CCopasiParameterGroup * pTmpCpyCMIRIAMResources = new CCopasiParameterGroup("Resources");
215 
216  CMIRIAMResource * pMIRIAMResource = NULL;
217  std::string Name, URI, Deprecated, Pattern, IsDeprecated;
218  int itNames = 0, itURIs = 0, sizeNames = 0, sizeURIs = 0;
219  unsigned C_INT32 processStep = 0, processSteps;
220  size_t hUpdateStep;
221  struct ns2__getDataTypesNameResponse DataTypesName;
222 
223  if (pProxy->getDataTypesName(DataTypesName) == SOAP_OK)
224  {
225  sizeNames = DataTypesName.getDataTypesNameReturn->__size;
226  processSteps = sizeNames + 2;
227  hUpdateStep = pProcessReport->addItem("Update Process", processStep, &processSteps);
228 
229  if (pProcessReport && !pProcessReport->progressItem(hUpdateStep))
230  return false;
231 
232  for (itNames = 0; itNames < sizeNames; itNames++)
233  {
234  struct ns2__getDataTypeURIsResponse DataTypeURIs;
235 
236  if (DataTypesName.getDataTypesNameReturn->__ptr[itNames] != "")
237  Name = DataTypesName.getDataTypesNameReturn->__ptr[itNames];
238 
239  pMIRIAMResource = new CMIRIAMResource(Name, NULL);
240 
241  if ((pProxy->getDataTypeURI(Name, URI) == SOAP_OK)
242  && (pProxy->getDataTypeURIs(Name, DataTypeURIs) == SOAP_OK)
243  && (pProxy->getDataTypePattern(Name, Pattern) == SOAP_OK))
244  {
245  sizeURIs = DataTypeURIs._getDataTypeURIsReturn->__size;
246 
247  if (sizeURIs != 0)
248  {
249  for (itURIs = 0; itURIs < sizeURIs; itURIs++)
250  {
251  Deprecated = DataTypeURIs._getDataTypeURIsReturn->__ptr[itURIs];
252 
253  if (Deprecated != URI)
254  pMIRIAMResource->addDeprecatedURL(Deprecated);
255  }
256  }
257 
258  pMIRIAMResource->setMIRIAMDisplayName(Name);
259  pMIRIAMResource->setMIRIAMURI(URI);
260  pMIRIAMResource->setMIRIAMPattern(Pattern);
261  pMIRIAMResource->setMIRIAMCitation(URI == "urn:miriam:arxiv" ||
262  URI == "urn:miriam:doi" ||
263  URI == "urn:miriam:pubmed" ||
264  URI == "urn:miriam:isbn");
265 
266  pTmpCpyCMIRIAMResources->addParameter(pMIRIAMResource);
267  }
268  else
269  success = false;
270 
271  processStep++;
272 
273  if (pProcessReport && !pProcessReport->progressItem(hUpdateStep))
274  return false;
275  }
276 
277  processStep++;
278 
279  if (pProcessReport && !pProcessReport->progressItem(hUpdateStep))
280  return false;
281  }
282  else
283  success = false;
284 
285  if (success)
286  {
287  // TODO add a resource for local objects, i.e., within the current model.
288 
290  *mpMIRIAMResources = *pTmpCpyCMIRIAMResources;
291  elevateChildren();
293  createURIMap();
294  }
295  else
297  MCAnnotation + 3,
298  pProxy->soap_fault_string(),
299  pProxy->soap_fault_detail());
300 
301  pdelete(pTmpCpyCMIRIAMResources);
302 
303  processStep++;
304 
305  if (pProcessReport && !pProcessReport->progressItem(hUpdateStep)) return false;
306 
307  if (pProcessReport) pProcessReport->finishItem(hUpdateStep);
308 
309  pdelete(pProxy);
310 
311  return success;
312 }
#define pdelete(p)
Definition: copasi.h:215
virtual int getDataTypesName(struct ns2__getDataTypesNameResponse &_param_7)
Web service operation 'getDataTypesName' (returns error code or SOAP_OK)
virtual int getDataTypePattern(std::string _nickname, std::string &_getDataTypePatternReturn)
Web service operation 'getDataTypePattern' (returns error code or SOAP_OK)
void setMIRIAMURI(const std::string &URI)
virtual bool setName(const std::string &name)
CCopasiParameterGroup * mpMIRIAMResources
void setMIRIAMCitation(const bool &isCitation)
void addDeprecatedURL(const std::string &URL)
virtual int getDataTypeURIs(std::string _name, struct ns2__getDataTypeURIsResponse &_param_2)
Web service operation 'getDataTypeURIs' (returns error code or SOAP_OK)
virtual const char * soap_fault_string()
Get SOAP Fault string (NULL when absent)
#define C_INT32
Definition: copasi.h:90
virtual bool progressItem(const size_t &handle)
ArrayOf_USCORExsd_USCOREstring * getDataTypesNameReturn
Definition: soapStub.h:521
#define MCAnnotation
size_t addItem(const std::string &name, const std::string &value, const std::string *pEndValue=NULL)
void setMIRIAMPattern(const std::string &pattern)
virtual bool finishItem(const size_t &handle)
virtual bool elevateChildren()
virtual const char * soap_fault_detail()
Get SOAP Fault detail as string (NULL when absent)
#define SOAP_OK
Definition: stdsoap2.h:995
void setMIRIAMDisplayName(const std::string &displayName)
bool addParameter(const CCopasiParameter &parameter)
virtual int getDataTypeURI(std::string _name, std::string &_getDataTypeURIReturn)
Web service operation 'getDataTypeURI' (returns error code or SOAP_OK)
bool CMIRIAMResources::updateMIRIAMResourcesFromFile ( CProcessReport pProcessReport,
const std::string &  filename 
)

Update the MIRIAM resources using a local filename

Parameters
CProcessReport* pProcessReport
Returns
bool success

Definition at line 84 of file CMIRIAMResource.cpp.

References CMIRIAMResource::addDeprecatedURL(), CProcessReport::addItem(), CCopasiParameterGroup::addParameter(), C_INT32, CCopasiParameterGroup::CCopasiParameterGroup(), createDisplayNameMap(), createURIMap(), elevateChildren(), mpMIRIAMResources, pdelete, CProcessReport::progressItem(), CMIRIAMResource::setMIRIAMCitation(), CMIRIAMResource::setMIRIAMDisplayName(), setMIRIAMLastUpdateDate(), CMIRIAMResource::setMIRIAMPattern(), and CMIRIAMResource::setMIRIAMURI().

Referenced by DataModelGUI::miriamDownloadFinished().

86 {
87  bool success = true;
88 
89  CCopasiParameterGroup * pTmpCpyCMIRIAMResources = new CCopasiParameterGroup("Resources");
90  CMIRIAMResource * pMIRIAMResource = NULL;
91  std::string Name, URI, Deprecated, Pattern, IsDeprecated;
92  int itNames = 0, itURIs = 0, sizeNames = 0, sizeURIs = 0;
93  unsigned C_INT32 processStep = 0, processSteps = 1;
94 
95  size_t hUpdateStep;
96 
97  if (pProcessReport)
98  hUpdateStep = pProcessReport->addItem("Parsing MIRIAM XML", processStep, &processSteps);
99 
100  // parse file into memory
101  XMLInputStream stream(filename.c_str());
102 
103  if (stream.isError()) return false;
104 
105  XMLNode root(stream);
106 
107  ++processStep;
108 
109  if (pProcessReport && !pProcessReport->progressItem(hUpdateStep))
110  return false;
111 
112  sizeNames = root.getNumChildren();
113  processSteps = sizeNames + 2;
114 
115  if (pProcessReport)
116  hUpdateStep = pProcessReport->addItem("Add Items", processStep, &processSteps);
117 
118  if (pProcessReport && !pProcessReport->progressItem(hUpdateStep))
119  return false;
120 
121  // read all datatype elements
122  for (itNames = 0; itNames < sizeNames; itNames++)
123  {
124  XMLNode dataType = root.getChild(itNames);
125 
126  // only parse dataType elements
127  if (dataType.getName() != "datatype") continue;
128 
129  // extract name
130  Name = dataType.getChild("name").getChild(0).getCharacters();
131  pMIRIAMResource = new CMIRIAMResource(Name, NULL);
132 
133  XMLNode uris = dataType.getChild("uris");
134  sizeURIs = uris.getNumChildren();
135 
136  // extract uri & deprecated uris
137  URI.clear();
138 
139  if (sizeURIs != 0)
140  {
141  for (itURIs = 0; itURIs < sizeURIs; itURIs++)
142  {
143  XMLNode uri = uris.getChild(itURIs);
144 
145  if (URI.empty())
146  URI = uri.getChild(0).getCharacters();
147 
148  Deprecated = uri.getAttrValue("deprecated");
149 
150  if (Deprecated == "true")
151  pMIRIAMResource->addDeprecatedURL(uri.getChild(0).getCharacters());
152  }
153  }
154 
155  // set name
156  pMIRIAMResource->setMIRIAMDisplayName(Name);
157 
158  if (URI.empty() || Name.empty())
159  {
160  // ignore invalid item
161  delete pMIRIAMResource;
162  continue;
163  }
164 
165  pMIRIAMResource->setMIRIAMURI(URI);
166  pMIRIAMResource->setMIRIAMPattern(dataType.getAttrValue("pattern"));
167  pMIRIAMResource->setMIRIAMCitation(URI == "urn:miriam:arxiv" ||
168  URI == "urn:miriam:doi" ||
169  URI == "urn:miriam:pubmed" ||
170  URI == "urn:miriam:isbn");
171 
172  pTmpCpyCMIRIAMResources->addParameter(pMIRIAMResource);
173 
174  processStep++;
175 
176  if (pProcessReport && !pProcessReport->progressItem(hUpdateStep))
177  return false;
178  }
179 
180  processStep++;
181 
182  if (pProcessReport && !pProcessReport->progressItem(hUpdateStep))
183  return false;
184 
185  if (success)
186  {
187  // TODO add a resource for local objects, i.e., within the current model.
188 
190  *mpMIRIAMResources = *pTmpCpyCMIRIAMResources;
191  elevateChildren();
193  createURIMap();
194  }
195 
196  pdelete(pTmpCpyCMIRIAMResources);
197 
198  processStep++;
199 
200  if (pProcessReport && !pProcessReport->progressItem(hUpdateStep))
201  return false;
202 
203  return success;
204 }
#define pdelete(p)
Definition: copasi.h:215
void setMIRIAMURI(const std::string &URI)
CCopasiParameterGroup * mpMIRIAMResources
void setMIRIAMCitation(const bool &isCitation)
void addDeprecatedURL(const std::string &URL)
#define C_INT32
Definition: copasi.h:90
virtual bool progressItem(const size_t &handle)
size_t addItem(const std::string &name, const std::string &value, const std::string *pEndValue=NULL)
void setMIRIAMPattern(const std::string &pattern)
virtual bool elevateChildren()
void setMIRIAMDisplayName(const std::string &displayName)
bool addParameter(const CCopasiParameter &parameter)

Member Data Documentation

std::map< std::string, size_t > CMIRIAMResources::mDisplayName2Resource
private

A map from display name to resource index

Definition at line 340 of file CMIRIAMResource.h.

Referenced by createDisplayNameMap(), and getResourceIndexFromDisplayName().

unsigned C_INT32* CMIRIAMResources::mpLastUpdateDate
private

A pointer to the last update date.

Definition at line 325 of file CMIRIAMResource.h.

Referenced by autoUpdateMIRIAMResources(), getMIRIAMLastUpdateDate(), initializeParameter(), and setMIRIAMLastUpdateDate().

CCopasiParameterGroup* CMIRIAMResources::mpMIRIAMResources
private
unsigned C_INT32* CMIRIAMResources::mpUpdateFrequency
private

A pointer to the update interval.

Definition at line 330 of file CMIRIAMResource.h.

Referenced by autoUpdateMIRIAMResources(), getMIRIAMUpdateFrequency(), initializeParameter(), and setMIRIAMUpdateFrequencyInDays().

std::map< std::string, size_t > CMIRIAMResources::mURI2Resource
private

A map from URI to resource index

Definition at line 345 of file CMIRIAMResource.h.

Referenced by createURIMap(), and getMIRIAMResourceIndex().


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