Back to index

salome-kernel  6.5.0
SALOMEDS_AttributeStudyProperties.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  File   : SALOMEDS_AttributeStudyProperties.cxx
00024 //  Author : Sergey RUIN
00025 //  Module : SALOME
00026 //
00027 #include "SALOMEDS_AttributeStudyProperties.hxx"
00028 #include "SALOMEDS.hxx"
00029 
00030 SALOMEDS_AttributeStudyProperties::SALOMEDS_AttributeStudyProperties
00031                                    (SALOMEDSImpl_AttributeStudyProperties* theAttr)
00032 :SALOMEDS_GenericAttribute(theAttr)
00033 {}
00034 
00035 SALOMEDS_AttributeStudyProperties::SALOMEDS_AttributeStudyProperties
00036                                    (SALOMEDS::AttributeStudyProperties_ptr theAttr)
00037 :SALOMEDS_GenericAttribute(theAttr)
00038 {}
00039 
00040 SALOMEDS_AttributeStudyProperties::~SALOMEDS_AttributeStudyProperties()
00041 {
00042 }
00043 
00044 void SALOMEDS_AttributeStudyProperties::SetUserName(const std::string& theName)
00045 {
00046   if (_isLocal) {
00047     CheckLocked();
00048     SALOMEDS::Locker lock;
00049     SALOMEDSImpl_AttributeStudyProperties* anImpl =
00050       dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl);
00051     anImpl->ChangeCreatorName(theName);
00052   } else
00053     ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->SetUserName(theName.c_str());
00054 }
00055 
00056 std::string SALOMEDS_AttributeStudyProperties::GetUserName()
00057 {
00058   std::string aName;
00059   if (_isLocal) {
00060     SALOMEDS::Locker lock;
00061     aName = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->GetCreatorName();
00062   }
00063 #ifndef WIN32
00064   else aName = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetUserName();
00065 #else
00066   else aName = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetUserNameA();
00067 #endif
00068   return aName;
00069 }
00070 
00071 void SALOMEDS_AttributeStudyProperties::SetCreationDate
00072               (int theMinute, int theHour, int theDay, int theMonth, int theYear)
00073 {
00074   if (_isLocal) {
00075     CheckLocked();
00076     SALOMEDS::Locker lock;
00077     SALOMEDSImpl_AttributeStudyProperties* anImpl =
00078       dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl);
00079     int aTmp;
00080     if (anImpl->GetCreationDate(aTmp, aTmp, aTmp, aTmp, aTmp)) return;
00081     std::string S;
00082     anImpl->SetModification(S, theMinute, theHour, theDay, theMonth, theYear);
00083   } else {
00084     ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->SetCreationDate(theMinute,
00085                                                                               theHour,
00086                                                                               theDay,
00087                                                                               theMonth,
00088                                                                               theYear);
00089   }
00090 }
00091 
00092 bool SALOMEDS_AttributeStudyProperties::GetCreationDate(int& theMinute,
00093                                                         int& theHour,
00094                                                         int& theDay,
00095                                                         int& theMonth,
00096                                                         int& theYear)
00097 {
00098   bool ret;
00099   if (_isLocal) {
00100     SALOMEDS::Locker lock;
00101     ret = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>
00102       (_local_impl)->GetCreationDate(theMinute, theHour, theDay, theMonth, theYear);
00103   } else {
00104     CORBA::Long aMinute, anHour, aDay, aMonth, anYear;
00105     ret = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetCreationDate(aMinute,
00106                                                                                     anHour,
00107                                                                                     aDay,
00108                                                                                     aMonth,
00109                                                                                     anYear);
00110     theMinute = (int)aMinute;
00111     theHour = (int)anHour;
00112     theDay = (int)aDay;
00113     theMonth = (int)aMonth;
00114     theYear = (int)anYear;
00115   }
00116   return ret;
00117 }
00118 
00119 void SALOMEDS_AttributeStudyProperties::SetCreationMode(const std::string& theMode)
00120 {
00121   if (_isLocal) {
00122     CheckLocked();
00123     SALOMEDS::Locker lock;
00124     if (theMode == "from scratch")
00125       dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->SetCreationMode(1);
00126     else if (theMode == "copy from")
00127       dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->SetCreationMode(2);
00128     else //Not defined
00129       dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->SetCreationMode(0);
00130   }
00131   else ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->SetCreationMode(theMode.c_str());
00132 }
00133 
00134 std::string SALOMEDS_AttributeStudyProperties::GetCreationMode()
00135 {
00136   std::string aMode;
00137   if (_isLocal) {
00138     SALOMEDS::Locker lock;
00139     int mode  = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->GetCreationMode();
00140     if (mode == 1) aMode = "from scratch";
00141     if (mode == 2) aMode = "copy from";
00142   }
00143   else
00144     aMode = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetCreationMode();
00145   return aMode;
00146 }
00147 
00148 void SALOMEDS_AttributeStudyProperties::SetModified(int theModified)
00149 {
00150   if (_isLocal) {
00151     SALOMEDS::Locker lock;
00152     dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->SetModified(theModified);
00153   }
00154   else
00155     ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->SetModified(theModified);
00156 }
00157 
00158 bool SALOMEDS_AttributeStudyProperties::IsModified()
00159 {
00160   bool ret;
00161   if (_isLocal) {
00162     SALOMEDS::Locker lock;
00163     ret = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->IsModified();
00164   }
00165   else
00166     ret = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->IsModified();
00167   return ret;
00168 }
00169 
00170 int SALOMEDS_AttributeStudyProperties::GetModified()
00171 {
00172   int isModified;
00173   if (_isLocal) {
00174     SALOMEDS::Locker lock;
00175     isModified = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->GetModified();
00176   }
00177   else
00178     isModified = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetModified();
00179   return isModified;
00180 }
00181 
00182 void SALOMEDS_AttributeStudyProperties::SetLocked(bool theLocked)
00183 {
00184   if (_isLocal) {
00185     SALOMEDS::Locker lock;
00186     dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->SetLocked(theLocked);
00187   }
00188   else
00189     ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->SetLocked(theLocked);
00190 }
00191 
00192 bool SALOMEDS_AttributeStudyProperties::IsLocked()
00193 {
00194   bool ret;
00195   if (_isLocal) {
00196     SALOMEDS::Locker lock;
00197     ret = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->IsLocked();
00198   }
00199   else
00200     ret = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->IsLocked();
00201   return ret;
00202 }
00203 
00204 void SALOMEDS_AttributeStudyProperties::SetModification(const std::string& theName,
00205                                                         int theMinute,
00206                                                         int theHour,
00207                                                         int theDay,
00208                                                         int theMonth,
00209                                                         int theYear)
00210 {
00211   if (_isLocal) {
00212     CheckLocked();
00213     SALOMEDS::Locker lock;
00214     SALOMEDSImpl_AttributeStudyProperties* anImpl = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl);
00215     anImpl->SetModification(theName, theMinute, theHour, theDay, theMonth, theYear);
00216   } else
00217     ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->SetModification(theName.c_str(),
00218                                                                               theMinute,
00219                                                                               theHour,
00220                                                                               theDay,
00221                                                                               theMonth,
00222                                                                               theYear);
00223 }
00224 
00225 void SALOMEDS_AttributeStudyProperties::GetModificationsList(std::vector<std::string>& theNames,
00226                                                              std::vector<int>& theMinutes,
00227                                                              std::vector<int>& theHours,
00228                                                              std::vector<int>& theDays,
00229                                                              std::vector<int>& theMonths,
00230                                                              std::vector<int>& theYears,
00231                                                              bool theWithCreator)
00232 {
00233   int i, aLength;
00234 
00235   if (_isLocal) {
00236     SALOMEDS::Locker lock;
00237     std::vector<std::string> aNames;
00238     std::vector<int> aMinutes, aHours, aDays, aMonths, aYears;
00239     SALOMEDSImpl_AttributeStudyProperties* anImpl = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl);
00240     anImpl->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
00241     aLength = aNames.size();
00242     i = ((theWithCreator) ? 1 : 2);
00243     for (; i <= aLength; i++) {
00244       theNames.push_back(aNames[i-1]);
00245       theMinutes.push_back(aMinutes[i-1]);
00246       theHours.push_back(aHours[i-1]);
00247       theDays.push_back(aDays[i-1]);
00248       theMonths.push_back(aMonths[i-1]);
00249       theYears.push_back(aYears[i-1]);
00250     }
00251   } else {
00252     SALOMEDS::StringSeq_var aNames;
00253     SALOMEDS::LongSeq_var aMinutes, aHours, aDays, aMonths, aYears;
00254     ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetModificationsList(aNames.out(),
00255                                                                                    aMinutes.out(),
00256                                                                                    aHours.out(),
00257                                                                                    aDays.out(),
00258                                                                                    aMonths.out(),
00259                                                                                    aYears.out(),
00260                                                                                    theWithCreator);
00261     aLength = aNames->length();
00262     for (i = 0; i<aLength; i++) {
00263       theNames.push_back(aNames[i].in());
00264       theMinutes.push_back(aMinutes[i]);
00265       theHours.push_back(aHours[i]);
00266       theDays.push_back(aDays[i]);
00267       theMonths.push_back(aMonths[i]);
00268       theYears.push_back(aYears[i]);
00269     }
00270   }
00271 }
00272 
00273 
00274 void SALOMEDS_AttributeStudyProperties::SetComment(const std::string& theComment)
00275 {
00276   if (_isLocal) {
00277     CheckLocked();
00278     SALOMEDS::Locker lock;
00279     SALOMEDSImpl_AttributeStudyProperties* anImpl =
00280       dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl);
00281     anImpl->SetComment(theComment);
00282   } else
00283     ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->SetComment(theComment.c_str());
00284 }
00285 
00286 std::string SALOMEDS_AttributeStudyProperties::GetComment()
00287 {
00288   std::string aComment;
00289   if (_isLocal) {
00290     SALOMEDS::Locker lock;
00291     aComment = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->GetComment();
00292   }
00293   else 
00294     aComment = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetComment();
00295   return aComment;
00296 }
00297 
00298 
00299 void SALOMEDS_AttributeStudyProperties::SetUnits(const std::string& theUnits)
00300 {
00301   if (_isLocal) {
00302     CheckLocked();
00303     SALOMEDS::Locker lock;
00304     SALOMEDSImpl_AttributeStudyProperties* anImpl =
00305       dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl);
00306     anImpl->SetUnits(theUnits);
00307   } else
00308     ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->SetUnits(theUnits.c_str());
00309 }
00310 
00311 std::string SALOMEDS_AttributeStudyProperties::GetUnits()
00312 {
00313   std::string anUnits;
00314   if (_isLocal) {
00315     SALOMEDS::Locker lock;
00316     anUnits = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->GetUnits();
00317   }
00318   else 
00319     anUnits = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetUnits();
00320   return anUnits;
00321 }