_mapDataObjects[dataObject->getNameId()] = dataObject;
return true;
}
-bool DataModel::removeDataObject(string nameId) {
+bool DataModel::removeDataObject(std::string nameId) {
_mapDataObjects.erase(nameId);
return true;
}
return removeDataObject(dataObject->getNameId());
}
-DataObject * DataModel::getDataObject(string id) {
+DataObject * DataModel::getDataObject(std::string id) {
return _mapDataObjects[id];
}
-map<string, DataObject *>::iterator DataModel::begin() {
+std::map<std::string, DataObject *>::iterator DataModel::begin() {
return _mapDataObjects.begin();
}
-map<string, DataObject *>::iterator DataModel::end() {
+std::map<std::string, DataObject *>::iterator DataModel::end() {
return _mapDataObjects.end();
}
/*! Function to add data object to the model */
bool addDataObject(DataObject * dataObject);
/*! Functions to remove data object from the model */
- bool removeDataObject(string nameId);
+ bool removeDataObject(std::string nameId);
bool removeDataObject(DataObject * dataObject);
/*! Function to retrieve a data object in the model */
- DataObject * getDataObject(string nameId);
+ DataObject * getDataObject(std::string nameId);
- map<string, DataObject *>::iterator begin();
- map<string, DataObject *>::iterator end();
+ std::map<std::string, DataObject *>::iterator begin();
+ std::map<std::string, DataObject *>::iterator end();
private:
- map<string, DataObject *> _mapDataObjects;
+ std::map<std::string, DataObject *> _mapDataObjects;
};
// Static assignement
int DataObject::_lastId=0;
-const string DataObject::_BASENAME = string("object_");
-const string DataObject::pathsep = string("/");
+const std::string DataObject::_BASENAME = std::string("object_");
+const std::string DataObject::pathsep = std::string("/");
DataObject::DataObject() {
_nameId = _BASENAME+ToString(_lastId);
_properties.clear();
}
-void DataObject::setLabel(string label) {
+void DataObject::setLabel(std::string label) {
_label = label;
}
-string DataObject::getLabel() {
+std::string DataObject::getLabel() {
return _label;
}
-string DataObject::getPathName() {
- string pathName;
+std::string DataObject::getPathName() {
+ std::string pathName;
pathName = this->getPath() + pathsep + this->getLabel();
return pathName;
}
-string DataObject::getNameId() {
+std::string DataObject::getNameId() {
return _nameId;
}
-void DataObject::setProperty(string key, string value) {
+void DataObject::setProperty(std::string key, std::string value) {
_properties[key] = value;
}
-string DataObject::getProperty(string key) {
+std::string DataObject::getProperty(std::string key) {
return _properties[key];
}
-string DataObject::toString() {
- string serialize="\n";
+std::string DataObject::toString() {
+ std::string serialize="\n";
serialize+="nameId = "+getNameId()+"\n";
serialize+="label = "+getLabel()+"\n";
serialize+="path = "+getPath();
#include <map>
#include <string>
-using namespace std;
class TREEDATA_EXPORT DataObject {
DataObject();
~DataObject();
- void setLabel(string label);
- string getLabel();
- void setProperty(string key, string value);
- string getProperty(string key);
+ void setLabel(std::string label);
+ std::string getLabel();
+ void setProperty(std::string key, std::string value);
+ std::string getProperty(std::string key);
/*!
* This function specifies the localization of the object in the
* hierarchical organization that can be defined by the DataModel it
* belongs to.
*/
- virtual string getPath() = 0;
- string getPathName();
- string getNameId();
+ virtual std::string getPath() = 0;
+ std::string getPathName();
+ std::string getNameId();
- static const string pathsep;
+ static const std::string pathsep;
/*! This function can be used for debug */
- string toString();
+ std::string toString();
private:
/*! The name this object can be displayed with */
- string _label;
+ std::string _label;
/*! The identifier of this object. An identifier is invariant all the session long */
- string _nameId;
+ std::string _nameId;
/*! The dictionnary of properties that characterize this object */
- map<string, string> _properties;
+ std::map<std::string, std::string> _properties;
static int _lastId;
- static const string _BASENAME;
+ static const std::string _BASENAME;
};
#endif // DATAOBJECT_H
// =================================================================
//
-const string MyDataObject::PROPERTY_KEY_TYPE = "type";
-const string MyDataObject::PROPERTY_KEY_CIRCUIT ="circuit";
-const string MyDataObject::PROPERTY_KEY_REPFONC ="rf";
+const std::string MyDataObject::PROPERTY_KEY_TYPE = "type";
+const std::string MyDataObject::PROPERTY_KEY_CIRCUIT ="circuit";
+const std::string MyDataObject::PROPERTY_KEY_REPFONC ="rf";
MyDataObject::MyDataObject() : DataObject() {
this->setProperty(PROPERTY_KEY_TYPE, "Tuyauterie");
/*! This function specified the localization of the object in the
* hierarchical organization
*/
-string MyDataObject::getPath() {
+std::string MyDataObject::getPath() {
// We choose here a convention for organizing the path for this
// class of object.
/*
- string path = getProperty(PROPERTY_KEY_CIRCUIT) + pathsep
+ std::string path = getProperty(PROPERTY_KEY_CIRCUIT) + pathsep
+ getProperty(PROPERTY_KEY_REPFONC) + pathsep
+ getProperty(PROPERTY_KEY_TYPE);
*/
- string path = getProperty(PROPERTY_KEY_TYPE) + pathsep
+ std::string path = getProperty(PROPERTY_KEY_TYPE) + pathsep
+ getProperty(PROPERTY_KEY_CIRCUIT) + pathsep
+ getProperty(PROPERTY_KEY_REPFONC);
class MyDataObject: public DataObject {
public:
MyDataObject();
- virtual string getPath();
- static const string PROPERTY_KEY_TYPE;
- static const string PROPERTY_KEY_CIRCUIT;
- static const string PROPERTY_KEY_REPFONC;
+ virtual std::string getPath();
+ static const std::string PROPERTY_KEY_TYPE;
+ static const std::string PROPERTY_KEY_CIRCUIT;
+ static const std::string PROPERTY_KEY_REPFONC;
};
MyDataModel * dataModel = new MyDataModel();
int refIter = 53;
- string refNameId;
+ std::string refNameId;
DataObject * dataObject;
for (int i=0; i<100; i++) {