From: rnv Date: Tue, 12 Mar 2019 10:22:52 +0000 (+0300) Subject: [CEA 13302] Policy for c++ files ? using namespaces in c++ header files. boost_ptr... X-Git-Tag: V9_3_0b1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=043c1006f421f0351650034b279b688919b7b4d6;p=modules%2Fgui.git [CEA 13302] Policy for c++ files ? using namespaces in c++ header files. boost_ptr / shared_ptr --- diff --git a/src/TreeData/DataModel.cxx b/src/TreeData/DataModel.cxx index 872c31581..1b0c746e7 100644 --- a/src/TreeData/DataModel.cxx +++ b/src/TreeData/DataModel.cxx @@ -33,7 +33,7 @@ bool DataModel::addDataObject(DataObject * dataObject) { _mapDataObjects[dataObject->getNameId()] = dataObject; return true; } -bool DataModel::removeDataObject(string nameId) { +bool DataModel::removeDataObject(std::string nameId) { _mapDataObjects.erase(nameId); return true; } @@ -42,16 +42,16 @@ bool DataModel::removeDataObject(DataObject * dataObject) { return removeDataObject(dataObject->getNameId()); } -DataObject * DataModel::getDataObject(string id) { +DataObject * DataModel::getDataObject(std::string id) { return _mapDataObjects[id]; } -map::iterator DataModel::begin() { +std::map::iterator DataModel::begin() { return _mapDataObjects.begin(); } -map::iterator DataModel::end() { +std::map::iterator DataModel::end() { return _mapDataObjects.end(); } diff --git a/src/TreeData/DataModel.hxx b/src/TreeData/DataModel.hxx index 677d1f978..911370a2e 100644 --- a/src/TreeData/DataModel.hxx +++ b/src/TreeData/DataModel.hxx @@ -47,16 +47,16 @@ public: /*! 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::iterator begin(); - map::iterator end(); + std::map::iterator begin(); + std::map::iterator end(); private: - map _mapDataObjects; + std::map _mapDataObjects; }; diff --git a/src/TreeData/DataObject.cxx b/src/TreeData/DataObject.cxx index c7b10da8b..4867da256 100644 --- a/src/TreeData/DataObject.cxx +++ b/src/TreeData/DataObject.cxx @@ -24,8 +24,8 @@ // 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); @@ -39,33 +39,33 @@ DataObject::~DataObject() { _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(); diff --git a/src/TreeData/DataObject.hxx b/src/TreeData/DataObject.hxx index 57f4356c9..fd4b440ea 100644 --- a/src/TreeData/DataObject.hxx +++ b/src/TreeData/DataObject.hxx @@ -26,7 +26,6 @@ #include #include -using namespace std; class TREEDATA_EXPORT DataObject { @@ -34,35 +33,35 @@ public: 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 _properties; + std::map _properties; static int _lastId; - static const string _BASENAME; + static const std::string _BASENAME; }; #endif // DATAOBJECT_H diff --git a/src/TreeData/Test/MyDataModel.cxx b/src/TreeData/Test/MyDataModel.cxx index 224358e06..0fce394f6 100644 --- a/src/TreeData/Test/MyDataModel.cxx +++ b/src/TreeData/Test/MyDataModel.cxx @@ -25,9 +25,9 @@ // ================================================================= // -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"); @@ -38,15 +38,15 @@ MyDataObject::MyDataObject() : DataObject() { /*! 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); diff --git a/src/TreeData/Test/MyDataModel.hxx b/src/TreeData/Test/MyDataModel.hxx index 44ee7c79a..7a35dd75a 100644 --- a/src/TreeData/Test/MyDataModel.hxx +++ b/src/TreeData/Test/MyDataModel.hxx @@ -31,10 +31,10 @@ 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; }; diff --git a/src/TreeData/Test/tester.cxx b/src/TreeData/Test/tester.cxx index ca6b6ea64..ff54e6a5e 100644 --- a/src/TreeData/Test/tester.cxx +++ b/src/TreeData/Test/tester.cxx @@ -48,7 +48,7 @@ void TEST_DataModel() { MyDataModel * dataModel = new MyDataModel(); int refIter = 53; - string refNameId; + std::string refNameId; DataObject * dataObject; for (int i=0; i<100; i++) {