Back to index

salome-gui  6.5.0
DataObject.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 // Author: Guillaume Boulant (EDF/R&D)
00021 
00022 #include "DataObject.hxx"
00023 #include <Basics_Utils.hxx>
00024 
00025 // Static assignement
00026 int DataObject::_lastId=0;
00027 const string DataObject::_BASENAME = string("object_");
00028 const string DataObject::pathsep = string("/");
00029 
00030 DataObject::DataObject() {
00031   _nameId = _BASENAME+ToString(_lastId);
00032   _lastId++;
00033   // The default label is set to the nameId, but it can be modified
00034   // using setLabel whereas the nameId can't be modified.
00035   _label  = _nameId;
00036 }
00037 
00038 DataObject::~DataObject() {
00039   _properties.clear();
00040 }
00041 
00042 void DataObject::setLabel(string label) {
00043   _label = label;
00044 }
00045 string DataObject::getLabel() {
00046   return _label;
00047 }
00048 
00049 string DataObject::getPathName() {
00050   string pathName;
00051   pathName = this->getPath() + pathsep + this->getLabel();
00052   return pathName;
00053 }
00054 
00055 
00056 string DataObject::getNameId() {
00057   return _nameId;
00058 }
00059 
00060 void DataObject::setProperty(string key, string value) {
00061   _properties[key] = value;
00062 }
00063 string DataObject::getProperty(string key) {
00064   return _properties[key];
00065 }
00066 
00067 string DataObject::toString() {
00068   string serialize="\n";
00069   serialize+="nameId = "+getNameId()+"\n";
00070   serialize+="label  = "+getLabel()+"\n";
00071   serialize+="path   = "+getPath();
00072   return serialize;
00073 }