Salome HOME
Merge remote branch 'origin/V7_dev'
[modules/yacs.git] / src / SALOMEDSImpl / testDS.cxx
index 1328442a6c13210939cc93a2c16b3ef7ffed2271..64008945736c9f9fea99675d535160adf9cce70a 100644 (file)
@@ -1,24 +1,25 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //File:    testDS.cxx
 //Author:  Sergey RUIN
 //
 
 //#include "SALOMEDSImpl_.hxx"
 
-using namespace std;
-
 int main (int argc, char * argv[])
 {
-  cout << "Test started " << endl;
+  std::cout << "Test started " << std::endl;
 
   SALOMEDSImpl_StudyManager* aSM = new SALOMEDSImpl_StudyManager();
-  cout << "Manager is created " << endl;
+  std::cout << "Manager is created " << std::endl;
   SALOMEDSImpl_Study* aStudy = aSM->NewStudy("SRN");
-  cout << "Study with id = " << aStudy->StudyId() << " is created " << endl; 
+  std::cout << "Study with id = " << aStudy->StudyId() << " is created " << std::endl; 
 
-  cout << "Check the study lock, locking"   << endl;
+  std::cout << "Check the study lock, locking"   << std::endl;
   aStudy->SetStudyLock("SRN");
-  cout << "Is study locked = " << aStudy->IsStudyLocked() << endl;
-  vector<string> ids = aStudy->GetLockerID();
+  std::cout << "Is study locked = " << aStudy->IsStudyLocked() << std::endl;
+  std::vector<std::string> ids = aStudy->GetLockerID();
   for(int i = 0; i<ids.size(); i++)
-    cout << "Get study locker : " << ids[i] << endl;
+    std::cout << "Get study locker : " << ids[i] << std::endl;
   aStudy->UnLockStudy("SRN");
-  cout << "Is study locked = " << aStudy->IsStudyLocked()  << endl;
+  std::cout << "Is study locked = " << aStudy->IsStudyLocked()  << std::endl;
 
   SALOMEDSImpl_StudyBuilder* aBuilder = aStudy->NewBuilder();
-  cout << "StudyBuilder is created " << endl;
+  std::cout << "StudyBuilder is created " << std::endl;
   SALOMEDSImpl_SComponent aSC = aBuilder->NewComponent("TEST");
-  cout << "New component with type " << aSC.ComponentDataType() << " is created " << endl;
+  std::cout << "New component with type " << aSC.ComponentDataType() << " is created " << std::endl;
   SALOMEDSImpl_SObject aSO = aBuilder->NewObject(aSC);
-  cout << "New SObject with  ID = " << aSO.GetID() << " is created"  << endl;
-  cout << "An entry of newly created SO is "  <<  aSO.GetLabel().Entry() << endl;
+  std::cout << "New SObject with  ID = " << aSO.GetID() << " is created"  << std::endl;
+  std::cout << "An entry of newly created SO is "  <<  aSO.GetLabel().Entry() << std::endl;
   SALOMEDSImpl_AttributeIOR* aIORA = SALOMEDSImpl_AttributeIOR::Set(aSO.GetLabel(), "ior1234");
-  cout << "New AttributeIOR is created, it contains " << dynamic_cast<SALOMEDSImpl_AttributeIOR*>(aIORA)->Value() << endl;
-  cout << "Attribute has type: " << aIORA->Type() << " and value: " << aIORA->Save() << endl; 
-  cout << "Just another way to create an attribute: official one :) " << endl;
-  cout << "Is SO null : " << aSO.IsNull()<< endl;
+  std::cout << "New AttributeIOR is created, it contains " << dynamic_cast<SALOMEDSImpl_AttributeIOR*>(aIORA)->Value() << std::endl;
+  std::cout << "Attribute has type: " << aIORA->Type() << " and value: " << aIORA->Save() << std::endl; 
+  std::cout << "Just another way to create an attribute: official one :) " << std::endl;
+  std::cout << "Is SO null : " << aSO.IsNull()<< std::endl;
   DF_Attribute* aTDFAttr =  aBuilder->FindOrCreateAttribute(aSO, "AttributeName");  
   SALOMEDSImpl_AttributeName* aRN = dynamic_cast<SALOMEDSImpl_AttributeName*>(aTDFAttr);
   aRN->SetValue("name_attribute");
-  cout << " The type = " << aRN->Type() << endl;
-  cout << "Attribute has type: " << aRN->Type() << " and value: " << aRN->Save() << endl;   
-  cout << "Check GetObjectPath: " << aStudy->GetObjectPath(aSO) << endl;
+  std::cout << " The type = " << aRN->Type() << std::endl;
+  std::cout << "Attribute has type: " << aRN->Type() << " and value: " << aRN->Save() << std::endl;   
+  std::cout << "Check GetObjectPath: " << aStudy->GetObjectPath(aSO) << std::endl;
   
   SALOMEDSImpl_SObject aSubSO = aBuilder->NewObject(aSO);
   aTDFAttr =  aBuilder->FindOrCreateAttribute(aSubSO, "AttributeIOR");  
@@ -90,141 +89,141 @@ int main (int argc, char * argv[])
   aBuilder->Addreference(aSubSO, aSO);
   SALOMEDSImpl_SObject aRefObject;
   aSubSO.ReferencedObject(aRefObject);
-  cout << "Check reference : ReferencedObject is " << aRefObject.GetID() << endl;
-  cout << "Check : Remove object: " << endl;
+  std::cout << "Check reference : ReferencedObject is " << aRefObject.GetID() << std::endl;
+  std::cout << "Check : Remove object: " << std::endl;
   aBuilder->RemoveObject(aSubSO);
-  cout << "Remove: done" << endl;
+  std::cout << "Remove: done" << std::endl;
 
-  cout << "Try invalid attribute creation" << endl;
+  std::cout << "Try invalid attribute creation" << std::endl;
   aTDFAttr = aBuilder->FindOrCreateAttribute(aSubSO, "invalid type");
-  cout << "Address of created attribute : " << aTDFAttr << endl;
+  std::cout << "Address of created attribute : " << aTDFAttr << std::endl;
 
-  cout << "Check AttributeUserID"   << endl;
+  std::cout << "Check AttributeUserID"   << std::endl;
   
   aTDFAttr = aBuilder->FindOrCreateAttribute(aSubSO, "AttributeUserID");
   if(aTDFAttr) {
-    cout << "Attribute UserID was created succesfully : id = " << dynamic_cast<SALOMEDSImpl_AttributeUserID*>(aTDFAttr)->Value() << endl;
+    std::cout << "Attribute UserID was created succesfully : id = " << dynamic_cast<SALOMEDSImpl_AttributeUserID*>(aTDFAttr)->Value() << std::endl;
   }
-  else cout << "Can't create AttributeUserID"   << endl;
+  else std::cout << "Can't create AttributeUserID"   << std::endl;
   
-  string id = "0e1c36e6-379b-4d90-ab3b-17a14310e648";
+  std::string id = "0e1c36e6-379b-4d90-ab3b-17a14310e648";
   dynamic_cast<SALOMEDSImpl_AttributeUserID*>(aTDFAttr)->SetValue(id);
-  cout << "SetValue id = " << dynamic_cast<SALOMEDSImpl_AttributeUserID*>(aTDFAttr)->Value()  << endl;
+  std::cout << "SetValue id = " << dynamic_cast<SALOMEDSImpl_AttributeUserID*>(aTDFAttr)->Value()  << std::endl;
 
-  string id2 = "0e1c36e6-379b-4d90-ab3b-18a14310e648";
+  std::string id2 = "0e1c36e6-379b-4d90-ab3b-18a14310e648";
   aTDFAttr = aBuilder->FindOrCreateAttribute(aSubSO, "AttributeUserID"+id2);
   if(aTDFAttr) {
-    cout << "Attribute UserID was created succesfully : id = " << dynamic_cast<SALOMEDSImpl_AttributeUserID*>(aTDFAttr)->Value() << endl;
+    std::cout << "Attribute UserID was created succesfully : id = " << dynamic_cast<SALOMEDSImpl_AttributeUserID*>(aTDFAttr)->Value() << std::endl;
   }
-  else cout << "Can't create AttributeUserID"   << endl;
+  else std::cout << "Can't create AttributeUserID"   << std::endl;
 
-  cout << "Check AttributeTreeNode " << endl;
+  std::cout << "Check AttributeTreeNode " << std::endl;
   aTDFAttr =  aBuilder->FindOrCreateAttribute(aSO, "AttributeTreeNode");  
-  cout << dynamic_cast<SALOMEDSImpl_GenericAttribute*>(aTDFAttr)->Type() << endl;
-  cout << "Check AttributeTreeNode : done " << endl;
+  std::cout << dynamic_cast<SALOMEDSImpl_GenericAttribute*>(aTDFAttr)->Type() << std::endl;
+  std::cout << "Check AttributeTreeNode : done " << std::endl;
 
   aTDFAttr =  aBuilder->FindOrCreateAttribute(aSO, "AttributeParameter");  
-  cout << dynamic_cast<SALOMEDSImpl_GenericAttribute*>(aTDFAttr)->Type() << endl;
+  std::cout << dynamic_cast<SALOMEDSImpl_GenericAttribute*>(aTDFAttr)->Type() << std::endl;
 
-  cout << "Check the attributes on SObject" << endl;
-  vector<DF_Attribute*> aSeq = aSO.GetAllAttributes();
+  std::cout << "Check the attributes on SObject" << std::endl;
+  std::vector<DF_Attribute*> aSeq = aSO.GetAllAttributes();
   for(int i = 0; i < aSeq.size(); i++) 
-    cout << "Found: " << dynamic_cast<SALOMEDSImpl_GenericAttribute*>(aSeq[i])->Type() << endl;
+    std::cout << "Found: " << dynamic_cast<SALOMEDSImpl_GenericAttribute*>(aSeq[i])->Type() << std::endl;
 
 
-  cout << "Check UseCase"   << endl;
+  std::cout << "Check UseCase"   << std::endl;
   SALOMEDSImpl_UseCaseBuilder* ucb = aStudy->GetUseCaseBuilder();
   ucb->AddUseCase("use_case1");
   ucb->AddUseCase("use_case2");
   SALOMEDSImpl_UseCaseIterator ucitr = ucb->GetUseCaseIterator(SALOMEDSImpl_SObject());
   ucitr.Init(false);
-  cout << "More? : " << ucitr.More() << endl;
+  std::cout << "More? : " << ucitr.More() << std::endl;
 
-  cout << "Check AttributeParameter "   << endl;
+  std::cout << "Check AttributeParameter "   << std::endl;
 
   SALOMEDSImpl_AttributeParameter* AP = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(aTDFAttr);
 
-  cout << "AttributeParameter with type : " << AP->Type() << endl;
+  std::cout << "AttributeParameter with type : " << AP->Type() << std::endl;
   
   AP->SetInt("1", 123);
-  cout << "IsSet for int: " << AP->IsSet("1", PT_INTEGER) << " value : " << AP->GetInt("1") << endl;
+  std::cout << "IsSet for int: " << AP->IsSet("1", PT_INTEGER) << " value : " << AP->GetInt("1") << std::endl;
   //for(int i = 2; i < 5; i++) AP->SetInt(i, i*i);
 
   AP->SetReal("1", 123.123);
-  cout << "IsSet for real: " << AP->IsSet("1", PT_REAL) << " value : " << AP->GetReal("1") << endl;
+  std::cout << "IsSet for real: " << AP->IsSet("1", PT_REAL) << " value : " << AP->GetReal("1") << std::endl;
   //for(int i = 2; i < 5; i++) AP->SetReal(i, 0.1);
 
   AP->SetString("1", "value is 123.123!");
-  cout << "IsSet for string: " << AP->IsSet("1", PT_STRING) << " value : " << AP->GetString("1") << endl; 
+  std::cout << "IsSet for string: " << AP->IsSet("1", PT_STRING) << " value : " << AP->GetString("1") << std::endl; 
   /*
   for(int i = 2; i < 5; i++) {
-    string s((double)(1.0/i));
-    cout << "Setting for " << i << " value : " << s  << endl;
+    std::string s((double)(1.0/i));
+    std::cout << "Setting for " << i << " value : " << s  << std::endl;
     AP->SetString(i, s); 
   }
   */
 
   AP->SetBool("1", true);
-  cout << "IsSet for bool: " << AP->IsSet("1", PT_BOOLEAN) << " value : " << AP->GetBool("1") << endl;
+  std::cout << "IsSet for bool: " << AP->IsSet("1", PT_BOOLEAN) << " value : " << AP->GetBool("1") << std::endl;
   //for(int i = 2; i < 5; i++) AP->SetBool(i, 0);
   
-  vector<double> v;
+  std::vector<double> v;
   v.push_back(111.111);
   v.push_back(222.22222);
   v.push_back(333.3333333);
   AP->SetRealArray("1", v);
-  cout << "IsSet for array: " << AP->IsSet("1", PT_REALARRAY);
-  vector<double> v2 = AP->GetRealArray("1");
-  cout.precision(10);
-  cout << " values :  "; 
-  for(int i = 0; i<v2.size(); i++) cout << v2[i] << " ";
-  cout << endl;
+  std::cout << "IsSet for array: " << AP->IsSet("1", PT_REALARRAY);
+  std::vector<double> v2 = AP->GetRealArray("1");
+  std::cout.precision(10);
+  std::cout << " values :  "; 
+  for(int i = 0; i<v2.size(); i++) std::cout << v2[i] << " ";
+  std::cout << std::endl;
   
   v[0] = 211.111;
   v[1] = 422.22222;
   v[2] = 633.3333333;
   AP->SetRealArray("2", v);
 
-  vector<int> vi;
+  std::vector<int> vi;
   vi.push_back(1);
   vi.push_back(2);
   AP->SetIntArray("2", vi);
   
-  vector<string> vs;
+  std::vector<std::string> vs;
   vs.push_back("hello, ");
   vs.push_back("world!");
   AP->SetStrArray("3", vs);        
 
-  string as = AP->Save();
-  cout << "AS = " << as << endl;
+  std::string as = AP->Save();
+  std::cout << "AS = " << as << std::endl;
   AP->Load(as);
   
-  cout << "Restored string with id = 1 is: " << AP->GetString("1") << endl;
-  cout << "Restored int with id = 2 is: " << AP->GetInt("1")  << endl;
-  cout << "Restored real with id = 3 is: " << AP->GetReal("1")  << endl;
-  cout << "Restored bool with id = 1 is: " << AP->GetBool("1")  << endl;
+  std::cout << "Restored string with id = 1 is: " << AP->GetString("1") << std::endl;
+  std::cout << "Restored int with id = 2 is: " << AP->GetInt("1")  << std::endl;
+  std::cout << "Restored real with id = 3 is: " << AP->GetReal("1")  << std::endl;
+  std::cout << "Restored bool with id = 1 is: " << AP->GetBool("1")  << std::endl;
   
   v2 = AP->GetRealArray("2");
-  cout << "Restored real array with id = 2 is: ";
-  for(int i = 0; i<v2.size(); i++) cout << v2[i] << " ";
-  cout << endl;
+  std::cout << "Restored real array with id = 2 is: ";
+  for(int i = 0; i<v2.size(); i++) std::cout << v2[i] << " ";
+  std::cout << std::endl;
 
   vi = AP->GetIntArray("2");
-  cout << "Restored int array with id = 2 is: ";
-  for(int i = 0; i<vi.size(); i++) cout << vi[i] << " ";
-  cout << endl;
+  std::cout << "Restored int array with id = 2 is: ";
+  for(int i = 0; i<vi.size(); i++) std::cout << vi[i] << " ";
+  std::cout << std::endl;
   
   vs = AP->GetStrArray("3");
-  cout << "Restored string array with id = 2 is: ";
-  for(int i = 0; i<vs.size(); i++) cout << vs[i] << " ";
-  cout << endl;
+  std::cout << "Restored string array with id = 2 is: ";
+  for(int i = 0; i<vs.size(); i++) std::cout << vs[i] << " ";
+  std::cout << std::endl;
 
-  cout << "Check RemoveID 1 with type PT_INTEGER" << endl;
+  std::cout << "Check RemoveID 1 with type PT_INTEGER" << std::endl;
   AP->RemoveID("1", PT_INTEGER);
-  cout << "IsSet with id = 1, type = PT_INTEGER : " << AP->IsSet("1", PT_INTEGER)  << endl;
-  cout << "Check RemoveID is done" << endl;
+  std::cout << "IsSet with id = 1, type = PT_INTEGER : " << AP->IsSet("1", PT_INTEGER)  << std::endl;
+  std::cout << "Check RemoveID is done" << std::endl;
   
-  cout << "Check AttributeParameter : done"   << endl;
+  std::cout << "Check AttributeParameter : done"   << std::endl;
 
   
   SALOMEDSImpl_SComponent tst = aBuilder->NewComponent("TEST2");
@@ -237,13 +236,13 @@ int main (int argc, char * argv[])
 
   SALOMEDSImpl_ChildIterator ci=aStudy->NewChildIterator(tst);
   for(ci.InitEx(true); ci.More(); ci.Next())
-    cout << "######## " << ci.Value().GetID() << endl;
+    std::cout << "######## " << ci.Value().GetID() << std::endl;
 
   DF_ChildIterator dci(tst.GetLabel(), true);
   for(; dci.More(); dci.Next()) 
-    cout << "###### DF:  " << dci.Value().Entry() << endl;
+    std::cout << "###### DF:  " << dci.Value().Entry() << std::endl;
 
-  cout << "Test finished " << endl;    
+  std::cout << "Test finished " << std::endl;    
   return 0;
 }