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

#include <CCopasiDataModel.h>

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

Public Member Functions

 CDataModelRenameHandler ()
 
virtual void handle (const std::string &oldCN, const std::string &newCN) const
 
void setEnabled (const bool &enabled)
 
virtual ~CDataModelRenameHandler ()
 
- Public Member Functions inherited from CRenameHandler
virtual ~CRenameHandler ()
 

Private Attributes

bool mEnabled
 

Detailed Description

Definition at line 54 of file CCopasiDataModel.h.

Constructor & Destructor Documentation

CDataModelRenameHandler::CDataModelRenameHandler ( )

Definition at line 74 of file CCopasiDataModel.cpp.

74  :
76  mEnabled(true)
77 {}
virtual CDataModelRenameHandler::~CDataModelRenameHandler ( )
inlinevirtual

Definition at line 59 of file CCopasiDataModel.h.

59 {};

Member Function Documentation

void CDataModelRenameHandler::handle ( const std::string &  oldCN,
const std::string &  newCN 
) const
virtual

Implements CRenameHandler.

Definition at line 79 of file CCopasiDataModel.cpp.

References CRegisteredObjectName::getSet(), and mEnabled.

80 {
81  if (mEnabled)
82  {
83  std::set<CRegisteredObjectName*>::const_iterator it = CRegisteredObjectName::getSet().begin();
84  std::set<CRegisteredObjectName*>::const_iterator itEnd = CRegisteredObjectName::getSet().end();
85 
86  size_t oldSize = oldCN.size();
87  size_t currentSize;
88 
89  for (; it != itEnd; ++it)
90  {
91  currentSize = (*it)->size();
92 
93  // We need to make sure that we not change partial names
94  if ((currentSize == oldSize ||
95  (currentSize > oldSize && (**it)[oldSize] == ',')) &&
96  oldCN.compare(0, oldSize, **it, 0, oldSize) == 0)
97  {
98  (**it).replace(0, oldSize, newCN);
99  }
100  }
101  }
102 
103  return;
104 }
static const std::set< CRegisteredObjectName * > & getSet()
void CDataModelRenameHandler::setEnabled ( const bool &  enabled)
virtual

Enable and disable the rename handler

Parameters
constbool & enabled

Implements CRenameHandler.

Definition at line 106 of file CCopasiDataModel.cpp.

References mEnabled.

Referenced by CCopasiDataModel::importSBML(), CCopasiDataModel::importSBMLFromString(), and CCopasiDataModel::loadModel().

107 {
108  mEnabled = enabled;
109 }

Member Data Documentation

bool CDataModelRenameHandler::mEnabled
private

Flag whether the rename handler is enable or not

Definition at line 73 of file CCopasiDataModel.h.

Referenced by handle(), and setEnabled().


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