Salome HOME
0df64a68f8b6fa827d37a26ce88131ec0f0c57e5
[modules/gui.git] / src / TreeData / DataObject.cxx
1 // Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // Author: Guillaume Boulant (EDF/R&D)
21
22 #include "DataObject.hxx"
23 #include <Basics_Utils.hxx>
24
25 // Static assignement
26 int DataObject::_lastId=0;
27 const std::string DataObject::_BASENAME = std::string("object_");
28 const std::string DataObject::pathsep = std::string("/");
29
30 DataObject::DataObject() {
31   _nameId = _BASENAME+ToString(_lastId);
32   _lastId++;
33   // The default label is set to the nameId, but it can be modified
34   // using setLabel whereas the nameId can't be modified.
35   _label  = _nameId;
36 }
37
38 DataObject::~DataObject() {
39   _properties.clear();
40 }
41
42 void DataObject::setLabel(std::string label) {
43   _label = label;
44 }
45 std::string DataObject::getLabel() {
46   return _label;
47 }
48
49 std::string DataObject::getPathName() {
50   std::string pathName;
51   pathName = this->getPath() + pathsep + this->getLabel();
52   return pathName;
53 }
54
55
56 std::string DataObject::getNameId() {
57   return _nameId;
58 }
59
60 void DataObject::setProperty(std::string key, std::string value) {
61   _properties[key] = value;
62 }
63 std::string DataObject::getProperty(std::string key) {
64   return _properties[key];
65 }
66
67 std::string DataObject::toString() {
68   std::string serialize="\n";
69   serialize+="nameId = "+getNameId()+"\n";
70   serialize+="label  = "+getLabel()+"\n";
71   serialize+="path   = "+getPath();
72   return serialize;
73 }