1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SALOMEDS_AttributeStudyProperties.cxx
24 // Author : Sergey RUIN
27 #include "SALOMEDS_AttributeStudyProperties.hxx"
28 #include "SALOMEDS.hxx"
30 SALOMEDS_AttributeStudyProperties::SALOMEDS_AttributeStudyProperties
31 (SALOMEDSImpl_AttributeStudyProperties* theAttr)
32 :SALOMEDS_GenericAttribute(theAttr)
35 SALOMEDS_AttributeStudyProperties::SALOMEDS_AttributeStudyProperties
36 (SALOMEDS::AttributeStudyProperties_ptr theAttr)
37 :SALOMEDS_GenericAttribute(theAttr)
40 SALOMEDS_AttributeStudyProperties::~SALOMEDS_AttributeStudyProperties()
44 void SALOMEDS_AttributeStudyProperties::SetUserName(const std::string& theName)
48 SALOMEDS::Locker lock;
49 SALOMEDSImpl_AttributeStudyProperties* anImpl =
50 dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl);
51 anImpl->ChangeCreatorName(theName);
53 ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->SetUserName(theName.c_str());
56 std::string SALOMEDS_AttributeStudyProperties::GetUserName()
60 SALOMEDS::Locker lock;
61 aName = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->GetCreatorName();
64 else aName = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetUserName();
67 else aName = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetUserNameW();
69 else aName = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetUserNameA();
75 void SALOMEDS_AttributeStudyProperties::SetCreationDate
76 (int theMinute, int theHour, int theDay, int theMonth, int theYear)
80 SALOMEDS::Locker lock;
81 SALOMEDSImpl_AttributeStudyProperties* anImpl =
82 dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl);
84 if (anImpl->GetCreationDate(aTmp, aTmp, aTmp, aTmp, aTmp)) return;
86 anImpl->SetModification(S, theMinute, theHour, theDay, theMonth, theYear);
88 ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->SetCreationDate(theMinute,
96 bool SALOMEDS_AttributeStudyProperties::GetCreationDate(int& theMinute,
104 SALOMEDS::Locker lock;
105 ret = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>
106 (_local_impl)->GetCreationDate(theMinute, theHour, theDay, theMonth, theYear);
108 CORBA::Long aMinute, anHour, aDay, aMonth, anYear;
109 ret = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetCreationDate(aMinute,
114 theMinute = (int)aMinute;
115 theHour = (int)anHour;
117 theMonth = (int)aMonth;
118 theYear = (int)anYear;
123 void SALOMEDS_AttributeStudyProperties::SetCreationMode(const std::string& theMode)
127 SALOMEDS::Locker lock;
128 if (theMode == "from scratch")
129 dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->SetCreationMode(1);
130 else if (theMode == "copy from")
131 dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->SetCreationMode(2);
133 dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->SetCreationMode(0);
135 else ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->SetCreationMode(theMode.c_str());
138 std::string SALOMEDS_AttributeStudyProperties::GetCreationMode()
142 SALOMEDS::Locker lock;
143 int mode = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->GetCreationMode();
144 if (mode == 1) aMode = "from scratch";
145 if (mode == 2) aMode = "copy from";
148 aMode = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetCreationMode();
152 void SALOMEDS_AttributeStudyProperties::SetModified(int theModified)
155 SALOMEDS::Locker lock;
156 dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->SetModified(theModified);
159 ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->SetModified(theModified);
162 bool SALOMEDS_AttributeStudyProperties::IsModified()
166 SALOMEDS::Locker lock;
167 ret = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->IsModified();
170 ret = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->IsModified();
174 int SALOMEDS_AttributeStudyProperties::GetModified()
178 SALOMEDS::Locker lock;
179 isModified = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->GetModified();
182 isModified = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetModified();
186 void SALOMEDS_AttributeStudyProperties::SetLocked(bool theLocked)
189 SALOMEDS::Locker lock;
190 dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->SetLocked(theLocked);
193 ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->SetLocked(theLocked);
196 bool SALOMEDS_AttributeStudyProperties::IsLocked()
200 SALOMEDS::Locker lock;
201 ret = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->IsLocked();
204 ret = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->IsLocked();
208 void SALOMEDS_AttributeStudyProperties::SetModification(const std::string& theName,
217 SALOMEDS::Locker lock;
218 SALOMEDSImpl_AttributeStudyProperties* anImpl = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl);
219 anImpl->SetModification(theName, theMinute, theHour, theDay, theMonth, theYear);
221 ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->SetModification(theName.c_str(),
229 void SALOMEDS_AttributeStudyProperties::GetModificationsList(std::vector<std::string>& theNames,
230 std::vector<int>& theMinutes,
231 std::vector<int>& theHours,
232 std::vector<int>& theDays,
233 std::vector<int>& theMonths,
234 std::vector<int>& theYears,
240 SALOMEDS::Locker lock;
241 std::vector<std::string> aNames;
242 std::vector<int> aMinutes, aHours, aDays, aMonths, aYears;
243 SALOMEDSImpl_AttributeStudyProperties* anImpl = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl);
244 anImpl->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
245 aLength = (int)aNames.size(); //!< TODO: conversion from size_t to int
246 i = ((theWithCreator) ? 1 : 2);
247 for (; i <= aLength; i++) {
248 theNames.push_back(aNames[i-1]);
249 theMinutes.push_back(aMinutes[i-1]);
250 theHours.push_back(aHours[i-1]);
251 theDays.push_back(aDays[i-1]);
252 theMonths.push_back(aMonths[i-1]);
253 theYears.push_back(aYears[i-1]);
256 SALOMEDS::StringSeq_var aNames;
257 SALOMEDS::LongSeq_var aMinutes, aHours, aDays, aMonths, aYears;
258 ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetModificationsList(aNames.out(),
265 aLength = aNames->length();
266 for (i = 0; i<aLength; i++) {
267 theNames.push_back(aNames[i].in());
268 theMinutes.push_back(aMinutes[i]);
269 theHours.push_back(aHours[i]);
270 theDays.push_back(aDays[i]);
271 theMonths.push_back(aMonths[i]);
272 theYears.push_back(aYears[i]);
278 void SALOMEDS_AttributeStudyProperties::SetComment(const std::string& theComment)
282 SALOMEDS::Locker lock;
283 SALOMEDSImpl_AttributeStudyProperties* anImpl =
284 dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl);
285 anImpl->SetComment(theComment);
287 ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->SetComment(theComment.c_str());
290 std::string SALOMEDS_AttributeStudyProperties::GetComment()
292 std::string aComment;
294 SALOMEDS::Locker lock;
295 aComment = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->GetComment();
298 aComment = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetComment();
303 void SALOMEDS_AttributeStudyProperties::SetUnits(const std::string& theUnits)
307 SALOMEDS::Locker lock;
308 SALOMEDSImpl_AttributeStudyProperties* anImpl =
309 dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl);
310 anImpl->SetUnits(theUnits);
312 ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->SetUnits(theUnits.c_str());
315 std::string SALOMEDS_AttributeStudyProperties::GetUnits()
319 SALOMEDS::Locker lock;
320 anUnits = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->GetUnits();
323 anUnits = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetUnits();
327 std::vector<std::string> SALOMEDS_AttributeStudyProperties::GetStoredComponents()
329 std::vector<std::string> aComponents;
331 SALOMEDS::Locker lock;
332 aComponents = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->GetStoredComponents();
335 SALOMEDS::StringSeq_var components = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetStoredComponents();
336 int length = components->length();
337 for (int i = 0; i < length; i++) {
338 aComponents.push_back(components[i].in());
344 std::string SALOMEDS_AttributeStudyProperties::GetComponentVersion( const std::string& theComponent )
346 std::string aVersion;
348 SALOMEDS::Locker lock;
349 aVersion = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->GetComponentVersion(theComponent);
352 aVersion = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetComponentVersion(theComponent.c_str());
356 std::vector<std::string> SALOMEDS_AttributeStudyProperties::GetComponentVersions( const std::string& theComponent )
358 std::vector<std::string> aVersions;
360 SALOMEDS::Locker lock;
361 aVersions = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->GetComponentVersions(theComponent);
364 SALOMEDS::StringSeq_var versions = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetComponentVersions(theComponent.c_str());
365 int length = versions->length();
366 for (int i = 0; i < length; i++) {
367 aVersions.push_back(versions[i].in());