Salome HOME
Copyright update: 2016
[modules/gui.git] / src / OBJECT / SALOME_InteractiveObject.cxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 /*!
24   \class SALOME_InteractiveObject SALOME_InteractiveObject.hxx
25   \brief ...
26 */
27
28 #include "SALOME_InteractiveObject.hxx"
29
30 IMPLEMENT_STANDARD_HANDLE (SALOME_InteractiveObject, MMgt_TShared)
31 IMPLEMENT_STANDARD_RTTIEXT(SALOME_InteractiveObject, MMgt_TShared)
32
33 /*!
34   Default constructor
35 */
36 SALOME_InteractiveObject::SALOME_InteractiveObject():
37   myEntry(""),
38   myName(""),
39   myComponentDataType(""),
40   myReference("")
41 {
42 }
43
44 /*!
45   Constructor
46   \param anEntry - entry of object
47   \param aComponentDataType - component data type name
48   \param aName - name of object
49 */
50 SALOME_InteractiveObject::SALOME_InteractiveObject(const char* anEntry, 
51                                                    const char* aComponentDataType,
52                                                    const char* aName):
53   myEntry(anEntry), 
54   myName(aName), 
55   myComponentDataType(aComponentDataType), 
56   myReference("")
57 {}
58
59 /*!
60   Destructor
61 */
62 SALOME_InteractiveObject::~SALOME_InteractiveObject()
63 {
64 }
65
66 /*!
67   Sets entry
68   \param anEntry - new entry of object
69 */
70 void SALOME_InteractiveObject::setEntry(const char* anEntry)
71 {
72   myEntry = anEntry;
73 }
74
75 /*!
76   \return entry
77 */
78 const char* SALOME_InteractiveObject::getEntry()
79 {
80   return myEntry.c_str();
81 }
82
83 /*!
84   Sets component data type
85   \param aComponentDataType - component data type name
86 */
87 void SALOME_InteractiveObject::setComponentDataType(const char* aComponentDataType)
88 {
89   myComponentDataType = aComponentDataType; 
90 }
91
92 /*!
93   \return component data type
94 */
95 const char* SALOME_InteractiveObject::getComponentDataType()
96 {
97   return myComponentDataType.c_str();
98 }
99
100 /*!
101   Sets name
102   \param aName - new name of object
103 */
104 void SALOME_InteractiveObject::setName(const char* aName)
105 {
106   myName = aName;
107 }
108
109 /*!
110   \return name
111 */
112 const char* SALOME_InteractiveObject::getName()
113 {
114   return myName.c_str();
115 }
116
117 /*!
118   \return true if entry isn't empty
119 */
120 Standard_Boolean SALOME_InteractiveObject::hasEntry()
121 {
122   return myEntry != "";
123 }
124
125 /*!
126   \return true if objects have same entries
127   \param anIO - other object
128 */
129 Standard_Boolean SALOME_InteractiveObject::isSame(const Handle(SALOME_InteractiveObject)& anIO )
130 {
131   Standard_Boolean r = Standard_False;
132   if ( anIO->hasEntry() && this->hasEntry() )
133     r = myEntry == anIO->getEntry();
134   return r;
135 }
136
137 /*!
138   \return true if component data types are same
139   \param ComponentDataType - component data type to be checked
140 */
141 Standard_Boolean SALOME_InteractiveObject::isComponentType(const char* ComponentDataType)
142 {
143   return myComponentDataType == ComponentDataType;
144 }
145
146 /*!
147   \return true if object has reference
148 */
149 Standard_Boolean SALOME_InteractiveObject::hasReference()
150 {
151   return myReference != "";
152 }
153
154 /*!
155   \return reference
156 */
157 const char* SALOME_InteractiveObject::getReference()
158 {
159   return myReference.c_str();
160 }
161
162 /*!
163   Sets reference
164   \param aReference - new reference
165 */
166 void SALOME_InteractiveObject::setReference(const char* aReference)
167 {
168   myReference = aReference;
169 }
170
171 /*!
172   Compare two objects
173   \param anIO1 - first object to compare
174   \param anIO1 - second object to compare
175 */
176 Standard_Boolean IsEqual(const Handle(SALOME_InteractiveObject)& anIO1,
177                          const Handle(SALOME_InteractiveObject)& anIO2)
178 {
179   return anIO1->isSame( anIO2 );
180 }