Back to index

salome-kernel  6.5.0
SALOMEDS_AttributeStudyProperties_i.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_i.cxx
00024 //  Author : Sergey RUIN
00025 //  Module : SALOME
00026 //
00027 #include "SALOMEDS_AttributeStudyProperties_i.hxx"
00028 #include "SALOMEDS.hxx"
00029 
00030 #define CREATION_MODE_NOTDEFINED 0
00031 #define CREATION_MODE_SCRATCH 1
00032 #define CREATION_MODE_COPY 2
00033 
00034 void SALOMEDS_AttributeStudyProperties_i::SetUserName(const char* theName)
00035 {
00036   SALOMEDS::Locker lock;
00037   CheckLocked();
00038   dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->ChangeCreatorName((char*)theName);
00039 }
00040 
00041 char* SALOMEDS_AttributeStudyProperties_i::GetUserName()
00042 {
00043   SALOMEDS::Locker lock;
00044   std::string S = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetCreatorName();
00045   CORBA::String_var c_s = CORBA::string_dup(S.c_str());
00046   return c_s._retn();
00047 }
00048 
00049 void SALOMEDS_AttributeStudyProperties_i::SetCreationDate(CORBA::Long theMinute,
00050                                                           CORBA::Long theHour,
00051                                                           CORBA::Long theDay,
00052                                                           CORBA::Long theMonth,
00053                                                           CORBA::Long theYear)
00054 {
00055   SALOMEDS::Locker lock;
00056   CheckLocked();
00057   SALOMEDSImpl_AttributeStudyProperties* aProp = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl);
00058   int aTmp;
00059   if (aProp->GetCreationDate(aTmp, aTmp, aTmp, aTmp, aTmp)) return;
00060   std::string S;
00061   aProp->SetModification(S, theMinute, theHour, theDay, theMonth, theYear);
00062 }
00063 
00064 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::GetCreationDate(CORBA::Long& theMinute,
00065                                                                     CORBA::Long& theHour,
00066                                                                     CORBA::Long& theDay,
00067                                                                     CORBA::Long& theMonth,
00068                                                                     CORBA::Long& theYear)
00069 {
00070   SALOMEDS::Locker lock;
00071   int aMinute;
00072   int aHour;
00073   int aDay;
00074   int aMonth;
00075   int aYear;
00076   if (dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetCreationDate(aMinute, aHour, aDay, aMonth, aYear)) {
00077     theMinute = aMinute;
00078     theHour = aHour;
00079     theDay = aDay;
00080     theMonth = aMonth;
00081     theYear = aYear;
00082     return true;
00083   }
00084   return false;
00085 }
00086 
00087 void SALOMEDS_AttributeStudyProperties_i::SetCreationMode(const char* theMode)
00088 {
00089   SALOMEDS::Locker lock;
00090   CheckLocked();
00091   SALOMEDSImpl_AttributeStudyProperties* aProp = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl);
00092   if (strcmp(theMode,"from scratch")==0) aProp->SetCreationMode(CREATION_MODE_SCRATCH);
00093   else if (strcmp(theMode,"copy from")==0) aProp->SetCreationMode(CREATION_MODE_COPY);
00094   else aProp->SetCreationMode(CREATION_MODE_NOTDEFINED);
00095 }
00096 
00097 char* SALOMEDS_AttributeStudyProperties_i::GetCreationMode()
00098 {
00099   SALOMEDS::Locker lock;
00100   CORBA::String_var c_s;
00101   switch (dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetCreationMode()) {
00102   case CREATION_MODE_SCRATCH: c_s = "from scratch"; break;
00103   case CREATION_MODE_COPY: c_s = "copy from"; break;
00104   default: c_s = "";
00105   }
00106   return c_s._retn();
00107 }
00108 
00109 void SALOMEDS_AttributeStudyProperties_i::SetModified(CORBA::Long theModified)
00110 {
00111   SALOMEDS::Locker lock;
00112   dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->SetModified(theModified);
00113 }
00114 
00115 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsModified()
00116 {
00117   SALOMEDS::Locker lock;
00118   return dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->IsModified();
00119 }
00120 
00121 CORBA::Long SALOMEDS_AttributeStudyProperties_i::GetModified()
00122 {
00123   SALOMEDS::Locker lock;
00124   return dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetModified();
00125 }
00126 
00127 void SALOMEDS_AttributeStudyProperties_i::SetLocked(CORBA::Boolean theLocked)
00128 {
00129   SALOMEDS::Locker lock;
00130   dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->SetLocked(theLocked);
00131 }
00132 
00133 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsLocked()
00134 {
00135   SALOMEDS::Locker lock;
00136   return dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->IsLocked();
00137 }
00138 
00139 void SALOMEDS_AttributeStudyProperties_i::SetModification(const char* theName,
00140                                                           CORBA::Long theMinute,
00141                                                           CORBA::Long theHour,
00142                                                           CORBA::Long theDay,
00143                                                           CORBA::Long theMonth,
00144                                                           CORBA::Long theYear)
00145 {
00146   SALOMEDS::Locker lock;
00147   CheckLocked();
00148   SALOMEDSImpl_AttributeStudyProperties* aProp = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl);
00149   aProp->SetModification((char*)theName, (int)theMinute, (int)theHour,
00150                          (int)theDay, (int)theMonth, (int)theYear);
00151 }
00152 
00153 void SALOMEDS_AttributeStudyProperties_i::GetModificationsList(SALOMEDS::StringSeq_out theNames,
00154                                                                SALOMEDS::LongSeq_out theMinutes,
00155                                                                SALOMEDS::LongSeq_out theHours,
00156                                                                SALOMEDS::LongSeq_out theDays,
00157                                                                SALOMEDS::LongSeq_out theMonths,
00158                                                                SALOMEDS::LongSeq_out theYears,
00159                                                                CORBA::Boolean theWithCreator)
00160 {
00161   SALOMEDS::Locker lock;
00162   std::vector<std::string> aNames;
00163   std::vector<int> aMinutes, aHours, aDays, aMonths, aYears;
00164   SALOMEDSImpl_AttributeStudyProperties* aProp = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl);
00165   aProp->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
00166   int aLength = aNames.size();
00167   int aRetLength = aLength - ((theWithCreator) ? 0 : 1);
00168   theNames = new SALOMEDS::StringSeq;
00169   theMinutes = new SALOMEDS::LongSeq;
00170   theHours = new SALOMEDS::LongSeq;
00171   theDays = new SALOMEDS::LongSeq;
00172   theMonths = new SALOMEDS::LongSeq;
00173   theYears = new SALOMEDS::LongSeq;
00174   theNames->length(aRetLength);
00175   theMinutes->length(aRetLength);
00176   theHours->length(aRetLength);
00177   theDays->length(aRetLength);
00178   theMonths->length(aRetLength);
00179   theYears->length(aRetLength);
00180   int a = 0, ind = ((theWithCreator) ? 1 : 2);
00181   for (; ind <= aLength; a++, ind++) {
00182     (*theNames)[a] = CORBA::string_dup(aNames[ind-1].c_str());
00183     (*theMinutes)[a] = aMinutes[ind-1];
00184     (*theHours)[a] = aHours[ind-1];
00185     (*theDays)[a] = aDays[ind-1];
00186     (*theMonths)[a] = aMonths[ind-1];
00187     (*theYears)[a] = aYears[ind-1];
00188   }
00189 }
00190 
00191 void SALOMEDS_AttributeStudyProperties_i::SetComment(const char* theComment)
00192 {
00193   SALOMEDS::Locker lock;
00194   CheckLocked();
00195   dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->SetComment(std::string(theComment));
00196 }
00197 
00198 char* SALOMEDS_AttributeStudyProperties_i::GetComment()
00199 {
00200   SALOMEDS::Locker lock;
00201   std::string C = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetComment();
00202   CORBA::String_var c_s = CORBA::string_dup(C.c_str());
00203   return c_s._retn();
00204 }
00205 
00206 void SALOMEDS_AttributeStudyProperties_i::SetUnits(const char* theUnits)
00207 {
00208   SALOMEDS::Locker lock;
00209   CheckLocked();
00210   dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->SetUnits(std::string(theUnits));
00211 }
00212 
00213 char* SALOMEDS_AttributeStudyProperties_i::GetUnits()
00214 {
00215   SALOMEDS::Locker lock;
00216   std::string U = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetUnits();
00217   CORBA::String_var c_s = CORBA::string_dup(U.c_str());
00218   return c_s._retn();
00219 }
00220