-# SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-#
-# Copyright (C) 2003 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 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
-#
-# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-#
-#
#
# File : Makefile.in
-# Author : Marc Tajchman
+# Author : Sergey RUIN
# Module : SALOME
top_srcdir=@top_srcdir@
EXPORT_HEADERS= \
SALOMEDS_StudyManager_i.hxx \
- SALOMEDS_OCAFApplication.hxx \
- Handle_SALOMEDS_OCAFApplication.hxx
+ SALOMEDS_Driver_i.hxx \
+ SALOMEDS_StudyManager.hxx \
+ SALOMEDS_Study_i.hxx \
+ SALOMEDS_Study.hxx \
+ SALOMEDS_SObject_i.hxx \
+ SALOMEDS_SObject.hxx \
+ SALOMEDS_SComponent_i.hxx \
+ SALOMEDS_SComponent.hxx \
+ SALOMEDS_GenericAttribute_i.hxx \
+ SALOMEDS_GenericAttribute.hxx
# Libraries targets
LIB = libSalomeDS.la
LIB_SRC = \
+ SALOMEDS.cxx \
+ SALOMEDS_Driver_i.cxx \
SALOMEDS_StudyManager_i.cxx \
SALOMEDS_UseCaseBuilder_i.cxx \
SALOMEDS_UseCaseIterator_i.cxx \
SALOMEDS_StudyBuilder_i.cxx \
SALOMEDS_SObject_i.cxx \
SALOMEDS_SComponent_i.cxx \
- SALOMEDS_OCAFApplication.cxx \
SALOMEDS_GenericAttribute_i.cxx \
- SALOMEDS_IORAttribute.cxx \
- SALOMEDS_ExternalFileDef.cxx \
- SALOMEDS_FileType.cxx \
- SALOMEDS_PersRefAttribute.cxx \
SALOMEDS_AttributeComment_i.cxx \
SALOMEDS_AttributeExternalFileDef_i.cxx \
SALOMEDS_AttributeFileType_i.cxx \
SALOMEDS_AttributeTableOfString_i.cxx \
SALOMEDS_AttributeStudyProperties_i.cxx \
SALOMEDS_AttributePythonObject_i.cxx \
- SALOMEDS_SequenceOfRealAttribute.cxx \
- SALOMEDS_SequenceOfIntegerAttribute.cxx \
- SALOMEDS_DrawableAttribute.cxx \
- SALOMEDS_SelectableAttribute.cxx \
- SALOMEDS_ExpandableAttribute.cxx \
- SALOMEDS_OpenedAttribute.cxx \
- SALOMEDS_FlagsAttribute.cxx \
- SALOMEDS_GraphicAttribute.cxx \
- SALOMEDS_TextColorAttribute.cxx \
- SALOMEDS_TextHighlightColorAttribute.cxx \
- SALOMEDS_PixMapAttribute.cxx \
- SALOMEDS_LocalIDAttribute.cxx \
- SALOMEDS_TargetAttribute.cxx \
- SALOMEDS_TableOfIntegerAttribute.cxx \
- SALOMEDS_TableOfRealAttribute.cxx \
- SALOMEDS_TableOfStringAttribute.cxx \
- SALOMEDS_StudyPropertiesAttribute.cxx \
- SALOMEDS_PythonObjectAttribute.cxx \
- SALOMEDS_DataMapOfIntegerString_0.cxx \
- SALOMEDS_DataMapIteratorOfDataMapOfIntegerString_0.cxx \
- SALOMEDS_DataMapNodeOfDataMapOfIntegerString_0.cxx \
- SALOMEDS_DataMapIteratorOfDataMapStringLabel_0.cxx \
- SALOMEDS_DataMapNodeOfDataMapStringLabel_0.cxx \
- SALOMEDS_DataMapStringLabel_0.cxx
+ SALOMEDS_SObject.cxx \
+ SALOMEDS_SComponent.cxx \
+ SALOMEDS_GenericAttribute.cxx \
+ SALOMEDS_ChildIterator.cxx \
+ SALOMEDS_SComponentIterator.cxx \
+ SALOMEDS_UseCaseIterator.cxx \
+ SALOMEDS_UseCaseBuilder.cxx \
+ SALOMEDS_StudyBuilder.cxx \
+ SALOMEDS_Study.cxx \
+ SALOMEDS_StudyManager.cxx \
+ SALOMEDS_AttributeStudyProperties.cxx \
+ SALOMEDS_AttributeComment.cxx \
+ SALOMEDS_AttributeDrawable.cxx \
+ SALOMEDS_AttributeExpandable.cxx \
+ SALOMEDS_AttributeExternalFileDef.cxx \
+ SALOMEDS_AttributeFileType.cxx \
+ SALOMEDS_AttributeFlags.cxx \
+ SALOMEDS_AttributeGraphic.cxx \
+ SALOMEDS_AttributeIOR.cxx \
+ SALOMEDS_AttributeInteger.cxx \
+ SALOMEDS_AttributeLocalID.cxx \
+ SALOMEDS_AttributeName.cxx \
+ SALOMEDS_AttributeOpened.cxx \
+ SALOMEDS_AttributePythonObject.cxx \
+ SALOMEDS_AttributeReal.cxx \
+ SALOMEDS_AttributeSelectable.cxx \
+ SALOMEDS_AttributeSequenceOfInteger.cxx \
+ SALOMEDS_AttributePersistentRef.cxx \
+ SALOMEDS_AttributePixMap.cxx \
+ SALOMEDS_AttributeSequenceOfReal.cxx \
+ SALOMEDS_AttributeTableOfInteger.cxx \
+ SALOMEDS_AttributeTableOfReal.cxx \
+ SALOMEDS_AttributeTableOfString.cxx \
+ SALOMEDS_AttributeTarget.cxx \
+ SALOMEDS_AttributeTextColor.cxx \
+ SALOMEDS_AttributeTextHighlightColor.cxx \
+ SALOMEDS_AttributeTreeNode.cxx \
+ SALOMEDS_AttributeUserID.cxx
+
# Executables targets
BIN = SALOMEDS_Server SALOMEDS_Client
BIN_SRC =
-LIB_SERVER_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl SALOME_ContainerManager.idl
+LIB_SERVER_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl SALOME_GenericObj.idl
BIN_SERVER_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl
BIN_CLIENT_IDL =
-LIB_CLIENT_IDL = SALOME_Component.idl SALOME_GenericObj.idl
-CPPFLAGS+=$(OCC_INCLUDES) $(HDF5_INCLUDES)
-CXXFLAGS+=$(OCC_CXXFLAGS)
-LDFLAGS+= $(HDF5_LIBS) -lTOOLSDS -lSalomeNS -lSalomeHDFPersist -lOpUtil -lSALOMELocalTrace $(CAS_LDPATH) -lTKCAF -lTKBO -lTKStdSchema -lSalomeGenericObj -lSalomeLifeCycleCORBA -lSalomeContainer -lSalomeResourcesManager
+CPPFLAGS+=$(OCC_INCLUDES) $(HDF5_INCLUDES) $(BOOST_CPPFLAGS)
+CXXFLAGS+=$(OCC_CXXFLAGS) $(BOOST_CPPFLAGS)
+LDFLAGS+= $(HDF5_LIBS) -lTOOLSDS -lSalomeNS -lSalomeHDFPersist -lOpUtil -lSALOMELocalTrace -lSalomeDSImpl -lSalomeGenericObj $(CAS_LDPATH) -lTKCAF -lTKBO -lTKStdSchema -lSalomeGenericObj -lSalomeLifeCycleCORBA
# _CS_gbo_090604 Ajout Spécifique Calibre 3, pour l'utilisation de la version 5.12 de la bibliothèque OCC.
# La bibliothèque OCC5.12 a été compilée sur Calibre 3 avec l'extention Xmu (impossible de compiler sans).
# On est donc obligé ici, pour permettre l'édition de lien avec les bibliothèques OCC, de spécifier le
# chemin d'accès aux bibliothèques Xmu
#
+
+# _CS_gbo_090604 Ajout Sp.cifique Calibre 3, pour l'utilisation de la version 5.12 de la biblioth.que OCC.
+# La biblioth.que OCC5.12 a .t. compil.e sur Calibre 3 avec l'extention Xmu (impossible de compiler sans).
+# On est donc oblig. ici, pour permettre l'.dition de lien avec les biblioth.ques OCC, de sp.cifier le
+# chemin d'acc.s aux biblioth.ques Xmu
+#
LDXMUFLAGS= -L/usr/X11R6/lib -lXmu
LDFLAGS+=$(LDXMUFLAGS)
-LDFLAGSFORBIN= $(LDFLAGS) -lRegistry -lSalomeNotification -lSALOMETraceCollector
+LDFLAGSFORBIN= $(LDFLAGS) -lRegistry -lSalomeNotification -lSALOMETraceCollector
@CONCLUDE@
--- /dev/null
+// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
+//
+// Copyright (C) 2003 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 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
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SALOMEDS.cxx
+// Author : Sergey ANIKIN
+// Module : SALOME
+// $Header$
+
+
+#include <SALOMEDS.hxx>
+
+using namespace SALOMEDS;
+
+// PAL8065: san -- Global recursive mutex for SALOMEDS methods
+Utils_Mutex Locker::MutexDS;
+
+// PAL8065: san -- Global SALOMEDS locker
+Locker::Locker()
+: Utils_Locker( &MutexDS )
+{}
+
+Locker::~Locker()
+{}
+
+void SALOMEDS::lock()
+{
+ Locker::MutexDS.lock();
+}
+
+void SALOMEDS::unlock()
+{
+ Locker::MutexDS.unlock();
+}
--- /dev/null
+// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
+//
+// Copyright (C) 2003 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 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
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SALOMEDS.hxx
+// Author : Sergey ANIKIN
+// Module : SALOME
+// $Header$
+
+
+#ifndef SALOMEDS_HeaderFile
+#define SALOMEDS_HeaderFile
+
+#include <Utils_Mutex.hxx>
+
+namespace SALOMEDS
+{
+ // PAL8065: san -- Implementation of convenient locker based on simple recursive
+ // mutex for POSIX platforms.
+ // This class is to protect SALOMEDS CORBA methods which deal with OCC calls from
+ // parallel access by several threads
+ // To protect some method, an instance of Locker class should be created
+ // on the stack at the beginning of guarded code:
+ //
+ // Locker lock;
+ //
+ class Locker : public Utils_Locker
+ {
+ public:
+ Locker();
+ virtual ~Locker();
+
+ private:
+ static Utils_Mutex MutexDS;
+
+ friend void lock();
+ friend void unlock();
+ };
+
+ // Convenient functions to lock/unlock the global SALOMEDS mutex temporarily.
+ // In particular, "unlock-dosomething-lock" scheme should be used, when some non-SALOMEDS
+ // CORBA interface is called (component's engine), to avoid deadlocks in case of
+ // indirect recursion.
+ void lock();
+ void unlock();
+};
+
+#endif
--- /dev/null
+// File : SALOMEDS_AttributeComment.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeComment.hxx"
+
+#include <string>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+SALOMEDS_AttributeComment::SALOMEDS_AttributeComment(const Handle(SALOMEDSImpl_AttributeComment)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeComment::SALOMEDS_AttributeComment(SALOMEDS::AttributeComment_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeComment::~SALOMEDS_AttributeComment()
+{}
+
+std::string SALOMEDS_AttributeComment::Value()
+{
+ std::string aValue;
+ if(_isLocal)
+ aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeComment)::DownCast(_local_impl)->Value()).ToCString();
+ else aValue = SALOMEDS::AttributeComment::_narrow(_corba_impl)->Value();
+ return aValue;
+}
+
+void SALOMEDS_AttributeComment::SetValue(const std::string& value)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeComment)::DownCast(_local_impl)->SetValue((char*)value.c_str());
+ else SALOMEDS::AttributeComment::_narrow(_corba_impl)->SetValue(value.c_str());
+}
--- /dev/null
+// File : SALOMEDS_AttributeComment.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeComment_HeaderFile
+#define SALOMEDS_AttributeComment_HeaderFile
+
+#include "SALOMEDSClient_AttributeComment.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeComment.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributeComment: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeComment
+{
+public:
+ SALOMEDS_AttributeComment(const Handle(SALOMEDSImpl_AttributeComment)& theAttr);
+ SALOMEDS_AttributeComment(SALOMEDS::AttributeComment_ptr theAttr);
+ ~SALOMEDS_AttributeComment();
+
+ virtual std::string Value();
+ virtual void SetValue(const std::string& value);
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeComment_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
-
-#include <TCollection_ExtendedString.hxx>
-#include <TCollection_AsciiString.hxx>
+using namespace std;
#include "SALOMEDS_AttributeComment_i.hxx"
-using namespace std;
+#include <TCollection_ExtendedString.hxx>
+#include "SALOMEDS_SObject_i.hxx"
+#include "SALOMEDS.hxx"
char* SALOMEDS_AttributeComment_i::Value()
{
- TCollection_ExtendedString S = Handle(TDataStd_Comment)::DownCast(_myAttr)->Get();
- CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString());
+ SALOMEDS::Locker lock;
+
+ CORBA::String_var c_s =
+ CORBA::string_dup(TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeComment)::DownCast(_impl)->Value()).ToCString());
return c_s._retn();
}
void SALOMEDS_AttributeComment_i::SetValue(const char* value)
{
- CheckLocked();
- CORBA::String_var Str = CORBA::string_dup(value);
- Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str));
-}
+ SALOMEDS::Locker lock;
-char* SALOMEDS_AttributeComment_i::Store() {
- return Value();
-}
-
-void SALOMEDS_AttributeComment_i::Restore(const char* value) {
- SetValue(value);
+ CheckLocked();
+ TCollection_AsciiString aStr((char*)value);
+ Handle(SALOMEDSImpl_AttributeComment)::DownCast(_impl)->SetValue(TCollection_ExtendedString(aStr));
}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeComment_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#ifndef SALOMEDS_AttributeComment_i_HeaderFile
#define SALOMEDS_AttributeComment_i_HeaderFile
-#include <TDataStd_Comment.hxx>
-
-#include "SALOMEDS_GenericAttribute_i.hxx"
-
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-DEFINE_DERIVED_ATTR(AttributeComment,TDataStd_Comment,true);
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeComment.hxx"
-class SALOMEDS_AttributeComment_i:
- public virtual POA_SALOMEDS::AttributeComment,
- public virtual SALOMEDS_TAttributeComment_i
+class SALOMEDS_AttributeComment_i: public virtual POA_SALOMEDS::AttributeComment,
+ public virtual SALOMEDS_GenericAttribute_i
{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeComment,TDataStd_Comment);
-public:
+public:
+ SALOMEDS_AttributeComment_i(const Handle(SALOMEDSImpl_AttributeComment)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ virtual ~SALOMEDS_AttributeComment_i() {};
+
char* Value();
- void SetValue(const char* theValue);
-
- char* Store();
- void Restore(const char*);
+ void SetValue(const char* value);
};
-
#endif
--- /dev/null
+// File : SALOMEDS_AttributeDrawable.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeDrawable.hxx"
+
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+SALOMEDS_AttributeDrawable::SALOMEDS_AttributeDrawable(const Handle(SALOMEDSImpl_AttributeDrawable)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeDrawable::SALOMEDS_AttributeDrawable(SALOMEDS::AttributeDrawable_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeDrawable::~SALOMEDS_AttributeDrawable()
+{}
+
+bool SALOMEDS_AttributeDrawable::IsDrawable()
+{
+ bool aValue;
+ if(_isLocal) aValue = (bool)Handle(SALOMEDSImpl_AttributeDrawable)::DownCast(_local_impl)->IsDrawable();
+ else aValue = SALOMEDS::AttributeDrawable::_narrow(_corba_impl)->IsDrawable();
+ return aValue;
+}
+
+void SALOMEDS_AttributeDrawable::SetDrawable(bool value)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeDrawable)::DownCast(_local_impl)->SetDrawable((int)value);
+ else SALOMEDS::AttributeDrawable::_narrow(_corba_impl)->SetDrawable(value);
+}
--- /dev/null
+// File : SALOMEDS_AttributeDrawable.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeDrawable_HeaderFile
+#define SALOMEDS_AttributeDrawable_HeaderFile
+
+#include "SALOMEDSClient_AttributeDrawable.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeDrawable.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributeDrawable: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeDrawable
+{
+public:
+ SALOMEDS_AttributeDrawable(const Handle(SALOMEDSImpl_AttributeDrawable)& theAttr);
+ SALOMEDS_AttributeDrawable(SALOMEDS::AttributeDrawable_ptr theAttr);
+ ~SALOMEDS_AttributeDrawable();
+
+ virtual bool IsDrawable();
+ virtual void SetDrawable(bool value);
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeDrawable_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
-#include "SALOMEDS_AttributeDrawable_i.hxx"
using namespace std;
+#include "SALOMEDS_AttributeDrawable_i.hxx"
+#include "SALOMEDS.hxx"
-CORBA::Boolean SALOMEDS_AttributeDrawable_i::IsDrawable() {
- return (Handle(SALOMEDS_DrawableAttribute)::DownCast(_myAttr)->Get() == 1);
+CORBA::Boolean SALOMEDS_AttributeDrawable_i::IsDrawable()
+{
+ SALOMEDS::Locker lock;
+ return (Handle(SALOMEDSImpl_AttributeDrawable)::DownCast(_impl)->IsDrawable() == 1);
}
-void SALOMEDS_AttributeDrawable_i::SetDrawable(CORBA::Boolean value) {
+void SALOMEDS_AttributeDrawable_i::SetDrawable(CORBA::Boolean value)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
- Standard_Integer val = 0;
- if (value != 0) val = 1;
- Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val);
+ Handle(SALOMEDSImpl_AttributeDrawable)::DownCast(_impl)->SetDrawable(value);
}
-char* SALOMEDS_AttributeDrawable_i::Store() {
- return CORBA::string_dup(IsDrawable()?"1":"0");
-}
-
-void SALOMEDS_AttributeDrawable_i::Restore(const char* value) {
- SetDrawable(value[0] == '1');
-}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeDrawable_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header:
#ifndef SALOMEDS_AttributeDrawable_i_HeaderFile
#define SALOMEDS_AttributeDrawable_i_HeaderFile
-#include "SALOMEDS_DrawableAttribute.hxx"
-#include "SALOMEDS_GenericAttribute_i.hxx"
-
// IDL headers
+
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-DEFINE_DERIVED_ATTR(AttributeDrawable,SALOMEDS_DrawableAttribute,false);
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeDrawable.hxx"
-class SALOMEDS_AttributeDrawable_i:
- public virtual POA_SALOMEDS::AttributeDrawable,
- public virtual SALOMEDS_TAttributeDrawable_i
+class SALOMEDS_AttributeDrawable_i: public virtual POA_SALOMEDS::AttributeDrawable,
+ public virtual SALOMEDS_GenericAttribute_i
{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeDrawable,SALOMEDS_DrawableAttribute);
public:
+
+ SALOMEDS_AttributeDrawable_i(const Handle(SALOMEDSImpl_AttributeDrawable)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ virtual ~SALOMEDS_AttributeDrawable_i() {};
CORBA::Boolean IsDrawable();
void SetDrawable(CORBA::Boolean value);
-
- char* Store();
- void Restore(const char*);
-
};
+
#endif
--- /dev/null
+// File : SALOMEDS_AttributeExpandable.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeExpandable.hxx"
+
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+SALOMEDS_AttributeExpandable::SALOMEDS_AttributeExpandable(const Handle(SALOMEDSImpl_AttributeExpandable)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeExpandable::SALOMEDS_AttributeExpandable(SALOMEDS::AttributeExpandable_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeExpandable::~SALOMEDS_AttributeExpandable()
+{}
+
+bool SALOMEDS_AttributeExpandable::IsExpandable()
+{
+ bool aValue;
+ if(_isLocal) aValue = (bool)Handle(SALOMEDSImpl_AttributeExpandable)::DownCast(_local_impl)->IsExpandable();
+ else aValue = SALOMEDS::AttributeExpandable::_narrow(_corba_impl)->IsExpandable();
+ return aValue;
+}
+
+void SALOMEDS_AttributeExpandable::SetExpandable(bool value)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeExpandable)::DownCast(_local_impl)->SetExpandable((int)value);
+ else SALOMEDS::AttributeExpandable::_narrow(_corba_impl)->SetExpandable(value);
+}
--- /dev/null
+// File : SALOMEDS_AttributeExpandable.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeExpandable_HeaderFile
+#define SALOMEDS_AttributeExpandable_HeaderFile
+
+#include "SALOMEDSClient_AttributeExpandable.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeExpandable.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributeExpandable: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeExpandable
+{
+public:
+ SALOMEDS_AttributeExpandable(const Handle(SALOMEDSImpl_AttributeExpandable)& theAttr);
+ SALOMEDS_AttributeExpandable(SALOMEDS::AttributeExpandable_ptr theAttr);
+ ~SALOMEDS_AttributeExpandable();
+
+ virtual bool IsExpandable();
+ virtual void SetExpandable(bool value);
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeExpandable_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
-
-#include "SALOMEDS_AttributeExpandable_i.hxx"
using namespace std;
+#include "SALOMEDS_AttributeExpandable_i.hxx"
+#include "SALOMEDS.hxx"
-CORBA::Boolean SALOMEDS_AttributeExpandable_i::IsExpandable() {
- return (Handle(SALOMEDS_ExpandableAttribute)::DownCast(_myAttr)->Get() == 1);
+CORBA::Boolean SALOMEDS_AttributeExpandable_i::IsExpandable()
+{
+ SALOMEDS::Locker lock;
+ return (Handle(SALOMEDSImpl_AttributeExpandable)::DownCast(_impl)->IsExpandable() == 1);
}
-void SALOMEDS_AttributeExpandable_i::SetExpandable(CORBA::Boolean value) {
- Standard_Integer val = 0;
- if (value != 0) val = 1;
- Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val);
+void SALOMEDS_AttributeExpandable_i::SetExpandable(CORBA::Boolean value)
+{
+ SALOMEDS::Locker lock;
+ CheckLocked();
+ Handle(SALOMEDSImpl_AttributeExpandable)::DownCast(_impl)->SetExpandable(value);
}
-char* SALOMEDS_AttributeExpandable_i::Store() {
- return CORBA::string_dup(IsExpandable()?"1":"0");
-}
-
-void SALOMEDS_AttributeExpandable_i::Restore(const char* value) {
- SetExpandable(value[0] == '1');
-}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeExpandable_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
// $Header:
#define SALOMEDS_AttributeExpandable_i_HeaderFile
// IDL headers
+
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-#include "SALOMEDS_ExpandableAttribute.hxx"
#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeExpandable.hxx"
-DEFINE_DERIVED_ATTR(AttributeExpandable,SALOMEDS_ExpandableAttribute,false);
-
-class SALOMEDS_AttributeExpandable_i:
- public virtual POA_SALOMEDS::AttributeExpandable,
- public virtual SALOMEDS_TAttributeExpandable_i
+class SALOMEDS_AttributeExpandable_i: public virtual POA_SALOMEDS::AttributeExpandable,
+ public virtual SALOMEDS_GenericAttribute_i
{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeExpandable,SALOMEDS_ExpandableAttribute);
public:
+
+ SALOMEDS_AttributeExpandable_i(const Handle(SALOMEDSImpl_AttributeExpandable)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ ~SALOMEDS_AttributeExpandable_i() {};
CORBA::Boolean IsExpandable();
void SetExpandable(CORBA::Boolean value);
-
- char* Store();
- void Restore(const char*);
-
};
--- /dev/null
+// File : SALOMEDS_AttributeExternalFileDef.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeExternalFileDef.hxx"
+
+#include <string>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+SALOMEDS_AttributeExternalFileDef::SALOMEDS_AttributeExternalFileDef(const Handle(SALOMEDSImpl_AttributeExternalFileDef)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeExternalFileDef::SALOMEDS_AttributeExternalFileDef(SALOMEDS::AttributeExternalFileDef_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeExternalFileDef::~SALOMEDS_AttributeExternalFileDef()
+{}
+
+std::string SALOMEDS_AttributeExternalFileDef::Value()
+{
+ std::string aValue;
+ if(_isLocal)
+ aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeExternalFileDef)::DownCast(_local_impl)->Value()).ToCString();
+ else aValue = SALOMEDS::AttributeExternalFileDef::_narrow(_corba_impl)->Value();
+ return aValue;
+}
+
+void SALOMEDS_AttributeExternalFileDef::SetValue(const std::string& value)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeExternalFileDef)::DownCast(_local_impl)->SetValue((char*)value.c_str());
+ else SALOMEDS::AttributeExternalFileDef::_narrow(_corba_impl)->SetValue(value.c_str());
+}
--- /dev/null
+// File : SALOMEDS_AttributeExternalFileDef.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeExternalFileDef_HeaderFile
+#define SALOMEDS_AttributeExternalFileDef_HeaderFile
+
+#include "SALOMEDSClient_AttributeExternalFileDef.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeExternalFileDef.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributeExternalFileDef: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeExternalFileDef
+{
+public:
+ SALOMEDS_AttributeExternalFileDef(const Handle(SALOMEDSImpl_AttributeExternalFileDef)& theAttr);
+ SALOMEDS_AttributeExternalFileDef(SALOMEDS::AttributeExternalFileDef_ptr theAttr);
+ ~SALOMEDS_AttributeExternalFileDef();
+
+ virtual std::string Value();
+ virtual void SetValue(const std::string& value);
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeExternalFileDef_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
+using namespace std;
#include "SALOMEDS_AttributeExternalFileDef_i.hxx"
-
+#include "SALOMEDS.hxx"
#include <TCollection_ExtendedString.hxx>
-#include <TCollection_AsciiString.hxx>
-
-using namespace std;
char* SALOMEDS_AttributeExternalFileDef_i::Value()
-{
- TCollection_ExtendedString S = Handle(SALOMEDS_ExternalFileDef)::DownCast(_myAttr)->Get();
- CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString());
+{
+ SALOMEDS::Locker lock;
+ CORBA::String_var c_s =
+ CORBA::string_dup(TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeExternalFileDef)::DownCast(_impl)->Value()).ToCString());
return c_s._retn();
}
void SALOMEDS_AttributeExternalFileDef_i::SetValue(const char* value)
{
+ SALOMEDS::Locker lock;
CheckLocked();
CORBA::String_var Str = CORBA::string_dup(value);
- // Handle(SALOMEDS_ExternalFileDef)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str));
- Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str));
+ Handle(SALOMEDSImpl_AttributeExternalFileDef)::DownCast(_impl)->SetValue(TCollection_ExtendedString(Str));
}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeExternalFileDef_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#ifndef SALOMEDS_AttributeExternalFileDef_i_HeaderFile
#define SALOMEDS_AttributeExternalFileDef_i_HeaderFile
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
#include "SALOMEDS_GenericAttribute_i.hxx"
-#include "SALOMEDS_ExternalFileDef.hxx"
+#include "SALOMEDSImpl_AttributeExternalFileDef.hxx"
-DEFINE_DERIVED_ATTR(AttributeExternalFileDef,SALOMEDS_ExternalFileDef,false);
-
-class SALOMEDS_AttributeExternalFileDef_i:
- public virtual POA_SALOMEDS::AttributeExternalFileDef,
- public virtual SALOMEDS_TAttributeExternalFileDef_i
+class SALOMEDS_AttributeExternalFileDef_i: public virtual POA_SALOMEDS::AttributeExternalFileDef,
+ public virtual SALOMEDS_GenericAttribute_i
{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeExternalFileDef,SALOMEDS_ExternalFileDef);
public:
+
+ SALOMEDS_AttributeExternalFileDef_i(const Handle(SALOMEDSImpl_AttributeExternalFileDef)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {}
+ ~SALOMEDS_AttributeExternalFileDef_i() {};
+
char* Value();
void SetValue(const char* value);
--- /dev/null
+// File : SALOMEDS_AttributeFileType.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeFileType.hxx"
+
+#include <string>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+SALOMEDS_AttributeFileType::SALOMEDS_AttributeFileType(const Handle(SALOMEDSImpl_AttributeFileType)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeFileType::SALOMEDS_AttributeFileType(SALOMEDS::AttributeFileType_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeFileType::~SALOMEDS_AttributeFileType()
+{}
+
+std::string SALOMEDS_AttributeFileType::Value()
+{
+ std::string aValue;
+ if(_isLocal)
+ aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeFileType)::DownCast(_local_impl)->Value()).ToCString();
+ else aValue = SALOMEDS::AttributeFileType::_narrow(_corba_impl)->Value();
+ return aValue;
+}
+
+void SALOMEDS_AttributeFileType::SetValue(const std::string& value)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeFileType)::DownCast(_local_impl)->SetValue((char*)value.c_str());
+ else SALOMEDS::AttributeFileType::_narrow(_corba_impl)->SetValue(value.c_str());
+}
--- /dev/null
+// File : SALOMEDS_AttributeFileType.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeFileType_HeaderFile
+#define SALOMEDS_AttributeFileType_HeaderFile
+
+#include "SALOMEDSClient_AttributeFileType.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeFileType.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributeFileType: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeFileType
+{
+public:
+ SALOMEDS_AttributeFileType(const Handle(SALOMEDSImpl_AttributeFileType)& theAttr);
+ SALOMEDS_AttributeFileType(SALOMEDS::AttributeFileType_ptr theAttr);
+ ~SALOMEDS_AttributeFileType();
+
+ virtual std::string Value();
+ virtual void SetValue(const std::string& value);
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeFileType_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
+using namespace std;
#include "SALOMEDS_AttributeFileType_i.hxx"
+#include "SALOMEDS.hxx"
#include <TCollection_ExtendedString.hxx>
-#include <TCollection_AsciiString.hxx>
-
-using namespace std;
char* SALOMEDS_AttributeFileType_i::Value()
{
- TCollection_ExtendedString S = Handle(SALOMEDS_FileType)::DownCast(_myAttr)->Get();
- CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString());
+ SALOMEDS::Locker lock;
+ CORBA::String_var c_s =
+ CORBA::string_dup(TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeFileType)::DownCast(_impl)->Value()).ToCString());
return c_s._retn();
}
void SALOMEDS_AttributeFileType_i::SetValue(const char* value)
{
+ SALOMEDS::Locker lock;
CheckLocked();
CORBA::String_var Str = CORBA::string_dup(value);
- // Handle(SALOMEDS_FileType)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str));
- Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str));
+ Handle(SALOMEDSImpl_AttributeFileType)::DownCast(_impl)->SetValue(TCollection_ExtendedString(Str));
}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeFileType_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#ifndef SALOMEDS_AttributeFileType_i_HeaderFile
#define SALOMEDS_AttributeFileType_i_HeaderFile
-#include "SALOMEDS_GenericAttribute_i.hxx"
-#include "SALOMEDS_FileType.hxx"
-
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-DEFINE_DERIVED_ATTR(AttributeFileType,SALOMEDS_FileType,true);
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeFileType.hxx"
-class SALOMEDS_AttributeFileType_i:
- public virtual POA_SALOMEDS::AttributeFileType,
- public virtual SALOMEDS_TAttributeFileType_i
-{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeFileType,SALOMEDS_FileType);
+class SALOMEDS_AttributeFileType_i: public virtual POA_SALOMEDS::AttributeFileType,
+ public virtual SALOMEDS_GenericAttribute_i {
public:
+
+ SALOMEDS_AttributeFileType_i(const Handle(SALOMEDSImpl_AttributeFileType)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+ ~SALOMEDS_AttributeFileType_i() {};
+
char* Value();
void SetValue(const char* value);
--- /dev/null
+// File : SALOMEDS_AttributeFlags.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeFlags.hxx"
+
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+SALOMEDS_AttributeFlags::SALOMEDS_AttributeFlags(const Handle(SALOMEDSImpl_AttributeFlags)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeFlags::SALOMEDS_AttributeFlags(SALOMEDS::AttributeFlags_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeFlags::~SALOMEDS_AttributeFlags()
+{}
+
+int SALOMEDS_AttributeFlags::GetFlags()
+{
+ int aValue;
+ if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeFlags)::DownCast(_local_impl)->Get();
+ else aValue = SALOMEDS::AttributeFlags::_narrow(_corba_impl)->GetFlags();
+ return aValue;
+}
+
+void SALOMEDS_AttributeFlags::SetFlags(int theFlags)
+{
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeFlags)::DownCast(_local_impl)->Set(theFlags);
+ else SALOMEDS::AttributeFlags::_narrow(_corba_impl)->SetFlags(theFlags);
+}
+
+bool SALOMEDS_AttributeFlags::Get(int theFlag)
+{
+ return (GetFlags() & theFlag) ? true : false;
+}
+
+void SALOMEDS_AttributeFlags::Set(int theFlag, bool theValue)
+{
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeFlags) anAttr = Handle(SALOMEDSImpl_AttributeFlags)::DownCast(_local_impl);
+ if ( theValue )
+ anAttr->Set( anAttr->Get() | theFlag );
+ else
+ anAttr->Set( anAttr->Get() & ~theFlag );
+ }
+ else SALOMEDS::AttributeFlags::_narrow(_corba_impl)->Set(theFlag, theValue);
+}
--- /dev/null
+// File : SALOMEDS_AttributeFlags.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeFlags_HeaderFile
+#define SALOMEDS_AttributeFlags_HeaderFile
+
+#include "SALOMEDSClient_AttributeFlags.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeFlags.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributeFlags: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeFlags
+{
+public:
+ SALOMEDS_AttributeFlags(const Handle(SALOMEDSImpl_AttributeFlags)& theAttr);
+ SALOMEDS_AttributeFlags(SALOMEDS::AttributeFlags_ptr theAttr);
+ ~SALOMEDS_AttributeFlags();
+
+ virtual int GetFlags();
+ virtual void SetFlags(int theFlags);
+
+ virtual bool Get(int theFlag);
+ virtual void Set(int theFlag, bool theValue);
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeFlags_i.cxx
-// Author : Sergey LITONIN
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
+using namespace std;
#include "SALOMEDS_AttributeFlags_i.hxx"
+#include "SALOMEDS.hxx"
+
+/*
+ Class : SALOMEDS_AttributeFlags_i
+ Description : This class is intended for storing different object attributes that
+ have only two states (0 and 1).
+
+ Avalable attributes:
+
+ IS_VISIBLE - is equal to 1 if object is visible in 3D view (0 - overwise).
+ This attribute is valid for active view only.
+*/
-using namespace std;
//=======================================================================
// function : SALOMEDS_AttributeFlags_i::GetFlags
//=======================================================================
CORBA::Long SALOMEDS_AttributeFlags_i::GetFlags()
{
- return Handle(SALOMEDS_FlagsAttribute)::DownCast( _myAttr )->Get();
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeFlags)::DownCast(_impl)->Get();
}
//=======================================================================
//=======================================================================
void SALOMEDS_AttributeFlags_i::SetFlags( CORBA::Long theFlags )
{
- Handle(SALOMEDS_FlagsAttribute)::DownCast( _myAttr )->Set( theFlags );
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeFlags)::DownCast(_impl)->Set( theFlags );
}
//=======================================================================
//=======================================================================
CORBA::Boolean SALOMEDS_AttributeFlags_i::Get( CORBA::Long theFlag )
{
- return Handle(SALOMEDS_FlagsAttribute)::DownCast( _myAttr )->Get() & theFlag ? true : false;
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeFlags)::DownCast(_impl)->Get() & theFlag ? true : false;
}
//=======================================================================
//=======================================================================
void SALOMEDS_AttributeFlags_i::Set( CORBA::Long theFlag, CORBA::Boolean theValue )
{
- Handle(SALOMEDS_FlagsAttribute) anAttr =
- Handle(SALOMEDS_FlagsAttribute)::DownCast( _myAttr );
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeFlags) anAttr = Handle(SALOMEDSImpl_AttributeFlags)::DownCast(_impl);
if ( theValue )
anAttr->Set( anAttr->Get() | theFlag );
else
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeFlags_i.hxx
-// Author : Sergey LITONIN
+// Author : Sergey RUIN
// Module : SALOME
// $Header:
#define SALOMEDS_AttributeFlags_i_HeaderFile
// IDL headers
+
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-#include "SALOMEDS_FlagsAttribute.hxx"
#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeFlags.hxx"
/*
Class : SALOMEDS_AttributeFlags_i
This attribute is valid for active view only.
*/
-DEFINE_DERIVED_ATTR(AttributeFlags,SALOMEDS_FlagsAttribute,true);
-
-class SALOMEDS_AttributeFlags_i:
- public virtual POA_SALOMEDS::AttributeFlags,
- public virtual SALOMEDS_TAttributeFlags_i
+class SALOMEDS_AttributeFlags_i: public virtual POA_SALOMEDS::AttributeFlags,
+ public virtual SALOMEDS_GenericAttribute_i
{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeFlags,SALOMEDS_FlagsAttribute);
public:
+
+ SALOMEDS_AttributeFlags_i( const Handle(SALOMEDSImpl_AttributeFlags)& theAttr, CORBA::ORB_ptr orb )
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ virtual ~SALOMEDS_AttributeFlags_i() {};
CORBA::Long GetFlags();
void SetFlags( CORBA::Long theFlags );
--- /dev/null
+// File : SALOMEDS_AttributeGraphic.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeGraphic.hxx"
+
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+SALOMEDS_AttributeGraphic::SALOMEDS_AttributeGraphic(const Handle(SALOMEDSImpl_AttributeGraphic)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeGraphic::SALOMEDS_AttributeGraphic(SALOMEDS::AttributeGraphic_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeGraphic::~SALOMEDS_AttributeGraphic()
+{}
+
+
+bool SALOMEDS_AttributeGraphic:: GetVisibility(int theViewId)
+{
+ bool aValue;
+ if(_isLocal) aValue = (bool)Handle(SALOMEDSImpl_AttributeGraphic)::DownCast(_local_impl)->GetVisibility(theViewId);
+ else aValue = SALOMEDS::AttributeGraphic::_narrow(_corba_impl)->GetVisibility(theViewId);
+ return aValue;
+}
+
+void SALOMEDS_AttributeGraphic::SetVisibility(int theViewId, bool theValue)
+{
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeGraphic)::DownCast(_local_impl)->SetVisibility(theViewId, theValue);
+ else SALOMEDS::AttributeGraphic::_narrow(_corba_impl)->SetVisibility(theViewId, theValue);
+}
--- /dev/null
+// File : SALOMEDS_AttributeGraphic.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeGraphic_HeaderFile
+#define SALOMEDS_AttributeGraphic_HeaderFile
+
+#include "SALOMEDSClient_AttributeGraphic.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeGraphic.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributeGraphic: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeGraphic
+{
+public:
+ SALOMEDS_AttributeGraphic(const Handle(SALOMEDSImpl_AttributeGraphic)& theAttr);
+ SALOMEDS_AttributeGraphic(SALOMEDS::AttributeGraphic_ptr theAttr);
+ ~SALOMEDS_AttributeGraphic();
+
+ virtual void SetVisibility(int theViewId, bool theValue);
+ virtual bool GetVisibility(int theViewId);
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeGraphic_i.cxx
-// Author : Sergey LITONIN
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
+using namespace std;
#include "SALOMEDS_AttributeGraphic_i.hxx"
+#include "SALOMEDS.hxx"
+
+/*
+ Class : SALOMEDS_AttributeGraphic_i
+ Description : This class is intended for storing information about
+ graphic representation of objects in dirrent views
+*/
-using namespace std;
//=======================================================================
// function : SALOMEDS_AttributeGraphic_i::~SetVisibility
void SALOMEDS_AttributeGraphic_i::SetVisibility( CORBA::Long theViewId,
CORBA::Boolean theValue )
{
- Handle(SALOMEDS_GraphicAttribute) anAttr =
- Handle(SALOMEDS_GraphicAttribute)::DownCast( _myAttr );
- if ( !anAttr.IsNull() )
- anAttr->SetVisibility( theViewId, theValue );
+ SALOMEDS::Locker lock;
+ if ( !_impl.IsNull() )
+ Handle(SALOMEDSImpl_AttributeGraphic)::DownCast(_impl)->SetVisibility( theViewId, theValue );
}
//=======================================================================
//=======================================================================
CORBA::Boolean SALOMEDS_AttributeGraphic_i::GetVisibility( CORBA::Long theViewId )
{
- Handle(SALOMEDS_GraphicAttribute) anAttr =
- Handle(SALOMEDS_GraphicAttribute)::DownCast( _myAttr );
- return !anAttr.IsNull() ? anAttr->GetVisibility( theViewId ) : false;
+ SALOMEDS::Locker lock;
+ return !_impl.IsNull() ? Handle(SALOMEDSImpl_AttributeGraphic)::DownCast(_impl)->GetVisibility( theViewId ) : false;
}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeFlags_i.hxx
-// Author : Sergey LITONIN
+// Author : Sergey RUIN
// Module : SALOME
// $Header:
#define SALOMEDS_AttributeGraphic_i_HeaderFile
// IDL headers
+
+
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-#include "SALOMEDS_GraphicAttribute.hxx"
#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeGraphic.hxx"
/*
Class : SALOMEDS_AttributeGraphic_i
graphic representation of objects in dirrent views
*/
-DEFINE_DERIVED_ATTR(AttributeGraphic,SALOMEDS_GraphicAttribute,true);
-
-class SALOMEDS_AttributeGraphic_i:
- public virtual POA_SALOMEDS::AttributeGraphic,
- public virtual SALOMEDS_TAttributeGraphic_i
+class SALOMEDS_AttributeGraphic_i: public virtual POA_SALOMEDS::AttributeGraphic,
+ public virtual SALOMEDS_GenericAttribute_i
{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeGraphic,SALOMEDS_GraphicAttribute);
public:
+
+ SALOMEDS_AttributeGraphic_i( const Handle(SALOMEDSImpl_AttributeGraphic)& theAttr, CORBA::ORB_ptr orb )
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ virtual ~SALOMEDS_AttributeGraphic_i() {};
void SetVisibility( CORBA::Long theViewId,
CORBA::Boolean theValue );
CORBA::Boolean GetVisibility( CORBA::Long theViewId );
+
};
#endif
--- /dev/null
+// File : SALOMEDS_AttributeIOR.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeIOR.hxx"
+
+#include <string>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+SALOMEDS_AttributeIOR::SALOMEDS_AttributeIOR(const Handle(SALOMEDSImpl_AttributeIOR)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeIOR::SALOMEDS_AttributeIOR(SALOMEDS::AttributeIOR_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeIOR::~SALOMEDS_AttributeIOR()
+{}
+
+std::string SALOMEDS_AttributeIOR::Value()
+{
+ std::string aValue;
+ if(_isLocal)
+ aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeIOR)::DownCast(_local_impl)->Value()).ToCString();
+ else aValue = SALOMEDS::AttributeIOR::_narrow(_corba_impl)->Value();
+ return aValue;
+}
+
+void SALOMEDS_AttributeIOR::SetValue(const std::string& value)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeIOR)::DownCast(_local_impl)->SetValue((char*)value.c_str());
+ else SALOMEDS::AttributeIOR::_narrow(_corba_impl)->SetValue(value.c_str());
+}
--- /dev/null
+// File : SALOMEDS_AttributeIOR.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeIOR_HeaderFile
+#define SALOMEDS_AttributeIOR_HeaderFile
+
+#include "SALOMEDSClient_AttributeIOR.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeIOR.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributeIOR: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeIOR
+{
+public:
+ SALOMEDS_AttributeIOR(const Handle(SALOMEDSImpl_AttributeIOR)& theAttr);
+ SALOMEDS_AttributeIOR(SALOMEDS::AttributeIOR_ptr theAttr);
+ ~SALOMEDS_AttributeIOR();
+
+ virtual std::string Value();
+ virtual void SetValue(const std::string& value);
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeIOR_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
+using namespace std;
#include "SALOMEDS_AttributeIOR_i.hxx"
-
+#include "SALOMEDS.hxx"
#include <TCollection_ExtendedString.hxx>
-#include "SALOMEDS_SObject_i.hxx"
-#include "SALOMEDS_Study_i.hxx"
-
-using namespace std;
char* SALOMEDS_AttributeIOR_i::Value()
{
- TCollection_ExtendedString S = Handle(SALOMEDS_IORAttribute)::DownCast(_myAttr)->Get();
- CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString());
+ SALOMEDS::Locker lock;
+ CORBA::String_var c_s =
+ CORBA::string_dup(TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeIOR)::DownCast(_impl)->Value()).ToCString());
return c_s._retn();
}
void SALOMEDS_AttributeIOR_i::SetValue(const char* value)
{
+ SALOMEDS::Locker lock;
CheckLocked();
-
- SALOMEDS_Study_i* aStudy = _mySObject->GetStudyServant();
- aStudy->AddCreatedPostponed(value);
- aStudy->AddPostponed(Value());
-
CORBA::String_var Str = CORBA::string_dup(value);
- Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str));
- aStudy->IORUpdated(Handle(SALOMEDS_IORAttribute)::DownCast(_myAttr));
+ Handle(SALOMEDSImpl_AttributeIOR)::DownCast(_impl)->SetValue(TCollection_ExtendedString(Str));
}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeIOR_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#ifndef SALOMEDS_AttributeIOR_i_HeaderFile
#define SALOMEDS_AttributeIOR_i_HeaderFile
-#include "SALOMEDS_GenericAttribute_i.hxx"
-#include "SALOMEDS_IORAttribute.hxx"
-
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-DEFINE_DERIVED_ATTR(AttributeIOR,SALOMEDS_IORAttribute,true);
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeIOR.hxx"
-class SALOMEDS_AttributeIOR_i:
- public virtual POA_SALOMEDS::AttributeIOR,
- public virtual SALOMEDS_TAttributeIOR_i
-{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeIOR,SALOMEDS_IORAttribute);
+class SALOMEDS_AttributeIOR_i: public virtual POA_SALOMEDS::AttributeIOR,
+ public virtual SALOMEDS_GenericAttribute_i {
public:
+
+ SALOMEDS_AttributeIOR_i(const Handle(SALOMEDSImpl_AttributeIOR)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ ~SALOMEDS_AttributeIOR_i() {};
+
char* Value();
void SetValue(const char* value);
--- /dev/null
+// File : SALOMEDS_AttributeInteger.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeInteger.hxx"
+
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+SALOMEDS_AttributeInteger::SALOMEDS_AttributeInteger(const Handle(SALOMEDSImpl_AttributeInteger)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeInteger::SALOMEDS_AttributeInteger(SALOMEDS::AttributeInteger_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeInteger::~SALOMEDS_AttributeInteger()
+{}
+
+int SALOMEDS_AttributeInteger::Value()
+{
+ int aValue;
+ if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeInteger)::DownCast(_local_impl)->Value();
+ else aValue = SALOMEDS::AttributeInteger::_narrow(_corba_impl)->Value();
+ return aValue;
+}
+
+void SALOMEDS_AttributeInteger::SetValue(int value)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeInteger)::DownCast(_local_impl)->SetValue(value);
+ else SALOMEDS::AttributeInteger::_narrow(_corba_impl)->SetValue(value);
+}
--- /dev/null
+// File : SALOMEDS_AttributeInteger.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeInteger_HeaderFile
+#define SALOMEDS_AttributeInteger_HeaderFile
+
+#include "SALOMEDSClient_AttributeInteger.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeInteger.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributeInteger: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeInteger
+{
+public:
+ SALOMEDS_AttributeInteger(const Handle(SALOMEDSImpl_AttributeInteger)& theAttr);
+ SALOMEDS_AttributeInteger(SALOMEDS::AttributeInteger_ptr theAttr);
+ ~SALOMEDS_AttributeInteger();
+
+ virtual int Value();
+ virtual void SetValue(int value);
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeInteger_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
-
-#include "SALOMEDS_AttributeInteger_i.hxx"
using namespace std;
+#include "SALOMEDS_AttributeInteger_i.hxx"
+#include "SALOMEDS.hxx"
-CORBA::Long SALOMEDS_AttributeInteger_i::Value() {
- return Handle(TDataStd_Integer)::DownCast(_myAttr)->Get();
+CORBA::Long SALOMEDS_AttributeInteger_i::Value()
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeInteger)::DownCast(_impl)->Value();
}
-void SALOMEDS_AttributeInteger_i::SetValue(CORBA::Long value) {
+void SALOMEDS_AttributeInteger_i::SetValue(CORBA::Long value)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
- Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(value);
+ Handle(SALOMEDSImpl_AttributeInteger)::DownCast(_impl)->SetValue(value);
}
-char* SALOMEDS_AttributeInteger_i::Store() {
- char* IntVal = new char[25];
- sprintf(IntVal, "%d", Value());
- return IntVal;
-}
-void SALOMEDS_AttributeInteger_i::Restore(const char* value) {
- char *err = NULL;
- CORBA::Long l = atol(value);
- SetValue(l);
-}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeInteger_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header:
#ifndef SALOMEDS_AttributeInteger_i_HeaderFile
#define SALOMEDS_AttributeInteger_i_HeaderFile
-#include <TDataStd_Integer.hxx>
+// IDL headers
-#include "SALOMEDS_GenericAttribute_i.hxx"
-// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-DEFINE_DERIVED_ATTR(AttributeInteger,TDataStd_Integer,true);
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeInteger.hxx"
-class SALOMEDS_AttributeInteger_i:
- public virtual POA_SALOMEDS::AttributeInteger,
- public virtual SALOMEDS_TAttributeInteger_i
-{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeInteger,TDataStd_Integer);
+class SALOMEDS_AttributeInteger_i: public virtual POA_SALOMEDS::AttributeInteger,
+ public virtual SALOMEDS_GenericAttribute_i {
public:
- CORBA::Long Value();
- void SetValue(CORBA::Long theValue);
+
+ SALOMEDS_AttributeInteger_i(const Handle(SALOMEDSImpl_AttributeInteger)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
- char* Store();
- void Restore(const char*);
+ ~SALOMEDS_AttributeInteger_i() {};
+ CORBA::Long Value();
+ void SetValue(CORBA::Long value);
};
+
#endif
--- /dev/null
+// File : SALOMEDS_AttributeLocalID.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeLocalID.hxx"
+
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+SALOMEDS_AttributeLocalID::SALOMEDS_AttributeLocalID(const Handle(SALOMEDSImpl_AttributeLocalID)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeLocalID::SALOMEDS_AttributeLocalID(SALOMEDS::AttributeLocalID_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeLocalID::~SALOMEDS_AttributeLocalID()
+{}
+
+int SALOMEDS_AttributeLocalID::Value()
+{
+ int aValue;
+ if(_isLocal) aValue = (bool)Handle(SALOMEDSImpl_AttributeLocalID)::DownCast(_local_impl)->Value();
+ else aValue = SALOMEDS::AttributeLocalID::_narrow(_corba_impl)->Value();
+ return aValue;
+}
+
+void SALOMEDS_AttributeLocalID::SetValue(int value)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeLocalID)::DownCast(_local_impl)->SetValue(value);
+ else SALOMEDS::AttributeLocalID::_narrow(_corba_impl)->SetValue(value);
+}
--- /dev/null
+// File : SALOMEDS_AttributeLocalID.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeLocalID_HeaderFile
+#define SALOMEDS_AttributeLocalID_HeaderFile
+
+#include "SALOMEDSClient_AttributeLocalID.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeLocalID.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributeLocalID: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeLocalID
+{
+public:
+ SALOMEDS_AttributeLocalID(const Handle(SALOMEDSImpl_AttributeLocalID)& theAttr);
+ SALOMEDS_AttributeLocalID(SALOMEDS::AttributeLocalID_ptr theAttr);
+ ~SALOMEDS_AttributeLocalID();
+
+ virtual int Value();
+ virtual void SetValue(int value);
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeLocalID_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
-
-#include "SALOMEDS_AttributeLocalID_i.hxx"
using namespace std;
+#include "SALOMEDS_AttributeLocalID_i.hxx"
+#include "SALOMEDS.hxx"
-CORBA::Long SALOMEDS_AttributeLocalID_i::Value() {
- return Handle(SALOMEDS_LocalIDAttribute)::DownCast(_myAttr)->Get();
+CORBA::Long SALOMEDS_AttributeLocalID_i::Value()
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeLocalID)::DownCast(_impl)->Value();
}
-void SALOMEDS_AttributeLocalID_i::SetValue(CORBA::Long value) {
+void SALOMEDS_AttributeLocalID_i::SetValue(CORBA::Long value)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
- Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(value);
+ Handle(SALOMEDSImpl_AttributeLocalID)::DownCast(_impl)->SetValue(value);
}
-char* SALOMEDS_AttributeLocalID_i::Store() {
- char* IntVal = new char[25];
- sprintf(IntVal, "%d", Value());
- return IntVal;
-}
-
-void SALOMEDS_AttributeLocalID_i::Restore(const char* value) {
- char *err = NULL;
- CORBA::Long l = atol(value);
- SetValue(l);
-}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeLocalID_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
// $Header:
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-#include "SALOMEDS_LocalIDAttribute.hxx"
#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeLocalID.hxx"
-DEFINE_DERIVED_ATTR(AttributeLocalID,SALOMEDS_LocalIDAttribute,true);
-
-class SALOMEDS_AttributeLocalID_i:
- public virtual POA_SALOMEDS::AttributeLocalID,
- public virtual SALOMEDS_TAttributeLocalID_i
+class SALOMEDS_AttributeLocalID_i: public virtual POA_SALOMEDS::AttributeLocalID,
+ public virtual SALOMEDS_GenericAttribute_i
{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeLocalID,SALOMEDS_LocalIDAttribute);
public:
+
+ SALOMEDS_AttributeLocalID_i(const Handle(SALOMEDSImpl_AttributeLocalID)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ ~SALOMEDS_AttributeLocalID_i() {};
CORBA::Long Value();
void SetValue(CORBA::Long value);
- char* Store();
- void Restore(const char*);
-
};
+
#endif
--- /dev/null
+// File : SALOMEDS_AttributeName.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeName.hxx"
+
+#include <string>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+SALOMEDS_AttributeName::SALOMEDS_AttributeName(const Handle(SALOMEDSImpl_AttributeName)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeName::SALOMEDS_AttributeName(SALOMEDS::AttributeName_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeName::~SALOMEDS_AttributeName()
+{}
+
+std::string SALOMEDS_AttributeName::Value()
+{
+ std::string aValue;
+ if(_isLocal)
+ aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeName)::DownCast(_local_impl)->Value()).ToCString();
+ else aValue = SALOMEDS::AttributeName::_narrow(_corba_impl)->Value();
+ return aValue;
+}
+
+void SALOMEDS_AttributeName::SetValue(const std::string& value)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeName)::DownCast(_local_impl)->SetValue((char*)value.c_str());
+ else SALOMEDS::AttributeName::_narrow(_corba_impl)->SetValue(value.c_str());
+}
--- /dev/null
+// File : SALOMEDS_AttributeName.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeName_HeaderFile
+#define SALOMEDS_AttributeName_HeaderFile
+
+#include "SALOMEDSClient_AttributeName.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeName.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributeName: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeName
+{
+public:
+ SALOMEDS_AttributeName(const Handle(SALOMEDSImpl_AttributeName)& theAttr);
+ SALOMEDS_AttributeName(SALOMEDS::AttributeName_ptr theAttr);
+ ~SALOMEDS_AttributeName();
+
+ virtual std::string Value();
+ virtual void SetValue(const std::string& value);
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeName_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
+using namespace std;
#include "SALOMEDS_AttributeName_i.hxx"
+#include "SALOMEDS.hxx"
#include <TCollection_ExtendedString.hxx>
-#include <TCollection_AsciiString.hxx>
-
-using namespace std;
-char* SALOMEDS_AttributeName_i::Value() {
- TCollection_ExtendedString S = Handle(TDataStd_Name)::DownCast(_myAttr)->Get();
- CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString());
+char* SALOMEDS_AttributeName_i::Value()
+{
+ SALOMEDS::Locker lock;
+ CORBA::String_var c_s =
+ CORBA::string_dup(TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeName)::DownCast(_impl)->Value()).ToCString());
return c_s._retn();
}
-void SALOMEDS_AttributeName_i::SetValue(const char* theValue) {
+void SALOMEDS_AttributeName_i::SetValue(const char* value)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
- Handle(TDataStd_Name)::DownCast(_myAttr)->Set(TCollection_ExtendedString((char*)theValue));
-}
-
-char* SALOMEDS_AttributeName_i::Store() {
- return Value();
-}
-
-void SALOMEDS_AttributeName_i::Restore(const char* value) {
- SetValue(value);
+ Handle(SALOMEDSImpl_AttributeName)::DownCast(_impl)->SetValue(TCollection_ExtendedString((char*)value));
}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeName_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
// $Header:
#ifndef SALOMEDS_AttributeName_i_HeaderFile
#define SALOMEDS_AttributeName_i_HeaderFile
-#include <TDataStd_Name.hxx>
-
-#include "SALOMEDS_GenericAttribute_i.hxx"
-
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-DEFINE_DERIVED_ATTR(AttributeName,TDataStd_Name,true);
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeName.hxx"
-class SALOMEDS_AttributeName_i:
- public virtual POA_SALOMEDS::AttributeName,
- public virtual SALOMEDS_TAttributeName_i
+class SALOMEDS_AttributeName_i: public virtual POA_SALOMEDS::AttributeName,
+ public virtual SALOMEDS_GenericAttribute_i
{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeName,TDataStd_Name);
public:
+
+ SALOMEDS_AttributeName_i(const Handle(SALOMEDSImpl_AttributeName)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ ~SALOMEDS_AttributeName_i() {};
+
char* Value();
void SetValue(const char* value);
- char* Store();
- void Restore(const char*);
};
--- /dev/null
+// File : SALOMEDS_AttributeOpened.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeOpened.hxx"
+
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+SALOMEDS_AttributeOpened::SALOMEDS_AttributeOpened(const Handle(SALOMEDSImpl_AttributeOpened)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeOpened::SALOMEDS_AttributeOpened(SALOMEDS::AttributeOpened_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeOpened::~SALOMEDS_AttributeOpened()
+{}
+
+bool SALOMEDS_AttributeOpened::IsOpened()
+{
+ bool aValue;
+ if(_isLocal) aValue = (bool)Handle(SALOMEDSImpl_AttributeOpened)::DownCast(_local_impl)->IsOpened();
+ else aValue = SALOMEDS::AttributeOpened::_narrow(_corba_impl)->IsOpened();
+ return aValue;
+}
+
+void SALOMEDS_AttributeOpened::SetOpened(bool value)
+{
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeOpened)::DownCast(_local_impl)->SetOpened((int)value);
+ else SALOMEDS::AttributeOpened::_narrow(_corba_impl)->SetOpened(value);
+}
--- /dev/null
+// File : SALOMEDS_AttributeOpened.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeOpened_HeaderFile
+#define SALOMEDS_AttributeOpened_HeaderFile
+
+#include "SALOMEDSClient_AttributeOpened.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeOpened.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributeOpened: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeOpened
+{
+public:
+ SALOMEDS_AttributeOpened(const Handle(SALOMEDSImpl_AttributeOpened)& theAttr);
+ SALOMEDS_AttributeOpened(SALOMEDS::AttributeOpened_ptr theAttr);
+ ~SALOMEDS_AttributeOpened();
+
+ virtual bool IsOpened();
+ virtual void SetOpened(bool value);
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeOpened_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
-
-#include "SALOMEDS_AttributeOpened_i.hxx"
using namespace std;
+#include "SALOMEDS_AttributeOpened_i.hxx"
+#include "SALOMEDS.hxx"
-CORBA::Boolean SALOMEDS_AttributeOpened_i::IsOpened() {
- return (Handle(SALOMEDS_OpenedAttribute)::DownCast(_myAttr)->Get() == 1);
+CORBA::Boolean SALOMEDS_AttributeOpened_i::IsOpened()
+{
+ SALOMEDS::Locker lock;
+ return (Handle(SALOMEDSImpl_AttributeOpened)::DownCast(_impl)->IsOpened() == 1);
}
-void SALOMEDS_AttributeOpened_i::SetOpened(CORBA::Boolean value) {
+void SALOMEDS_AttributeOpened_i::SetOpened(CORBA::Boolean value)
+{
+ SALOMEDS::Locker lock;
+
Standard_Integer val = 0;
if (value != 0) val = 1;
- Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val);
-}
-
-char* SALOMEDS_AttributeOpened_i::Store() {
- return CORBA::string_dup(IsOpened()?"1":"0");
-}
-
-void SALOMEDS_AttributeOpened_i::Restore(const char* value) {
- SetOpened(value[0] == '1');
+ Handle(SALOMEDSImpl_AttributeOpened)::DownCast(_impl)->SetOpened(val);
}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeOpened_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
// $Header:
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-#include "SALOMEDS_OpenedAttribute.hxx"
#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeOpened.hxx"
-DEFINE_DERIVED_ATTR(AttributeOpened,SALOMEDS_OpenedAttribute,false);
-
-class SALOMEDS_AttributeOpened_i:
- public virtual POA_SALOMEDS::AttributeOpened,
- public virtual SALOMEDS_TAttributeOpened_i
+class SALOMEDS_AttributeOpened_i: public virtual POA_SALOMEDS::AttributeOpened,
+ public virtual SALOMEDS_GenericAttribute_i
{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeOpened,SALOMEDS_OpenedAttribute);
public:
+
+ SALOMEDS_AttributeOpened_i(const Handle(SALOMEDSImpl_AttributeOpened)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+ ~SALOMEDS_AttributeOpened_i() {};
+
CORBA::Boolean IsOpened();
void SetOpened(CORBA::Boolean value);
-
- char* Store();
- void Restore(const char*);
-
};
--- /dev/null
+// File : SALOMEDS_AttributePersistentRef.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributePersistentRef.hxx"
+
+#include <string>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+SALOMEDS_AttributePersistentRef::SALOMEDS_AttributePersistentRef(const Handle(SALOMEDSImpl_AttributePersistentRef)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributePersistentRef::SALOMEDS_AttributePersistentRef(SALOMEDS::AttributePersistentRef_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributePersistentRef::~SALOMEDS_AttributePersistentRef()
+{}
+
+std::string SALOMEDS_AttributePersistentRef::Value()
+{
+ std::string aValue;
+ if(_isLocal)
+ aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributePersistentRef)::DownCast(_local_impl)->Value()).ToCString();
+ else aValue = SALOMEDS::AttributePersistentRef::_narrow(_corba_impl)->Value();
+ return aValue;
+}
+
+void SALOMEDS_AttributePersistentRef::SetValue(const std::string& value)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributePersistentRef)::DownCast(_local_impl)->SetValue((char*)value.c_str());
+ else SALOMEDS::AttributePersistentRef::_narrow(_corba_impl)->SetValue(value.c_str());
+}
--- /dev/null
+// File : SALOMEDS_AttributePersistentRef.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributePersistentRef_HeaderFile
+#define SALOMEDS_AttributePersistentRef_HeaderFile
+
+#include "SALOMEDSClient_AttributePersistentRef.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributePersistentRef.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributePersistentRef: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributePersistentRef
+{
+public:
+ SALOMEDS_AttributePersistentRef(const Handle(SALOMEDSImpl_AttributePersistentRef)& theAttr);
+ SALOMEDS_AttributePersistentRef(SALOMEDS::AttributePersistentRef_ptr theAttr);
+ ~SALOMEDS_AttributePersistentRef();
+
+ virtual std::string Value();
+ virtual void SetValue(const std::string& value);
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributePersistentRef_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
+using namespace std;
#include "SALOMEDS_AttributePersistentRef_i.hxx"
+#include "SALOMEDS.hxx"
#include <TCollection_ExtendedString.hxx>
-#include <TCollection_AsciiString.hxx>
-
-using namespace std;
char* SALOMEDS_AttributePersistentRef_i::Value()
{
- TCollection_ExtendedString S = Handle(SALOMEDS_PersRefAttribute)::DownCast(_myAttr)->Get();
- CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString());
+ SALOMEDS::Locker lock;
+ CORBA::String_var c_s =
+ CORBA::string_dup(TCollection_AsciiString(Handle(SALOMEDSImpl_AttributePersistentRef)::DownCast(_impl)->Value()).ToCString());
return c_s._retn();
}
void SALOMEDS_AttributePersistentRef_i::SetValue(const char* value)
{
+ SALOMEDS::Locker lock;
CheckLocked();
CORBA::String_var Str = CORBA::string_dup(value);
- Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str));
-}
-
-char* SALOMEDS_AttributePersistentRef_i::Store() {
- return Value();
-}
-
-void SALOMEDS_AttributePersistentRef_i::Restore(const char* value) {
- SetValue(value);
+ Handle(SALOMEDSImpl_AttributePersistentRef)::DownCast(_impl)->SetValue(TCollection_ExtendedString(Str));
}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributePersistentRef_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#ifndef SALOMEDS_AttributePersistentRef_i_HeaderFile
#define SALOMEDS_AttributePersistentRef_i_HeaderFile
-#include "SALOMEDS_GenericAttribute_i.hxx"
-#include "SALOMEDS_PersRefAttribute.hxx"
-
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-DEFINE_DERIVED_ATTR(AttributePersistentRef,SALOMEDS_PersRefAttribute,false);
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributePersistentRef.hxx"
-class SALOMEDS_AttributePersistentRef_i:
- public virtual POA_SALOMEDS::AttributePersistentRef,
- public virtual SALOMEDS_TAttributePersistentRef_i
-{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributePersistentRef,SALOMEDS_PersRefAttribute);
+class SALOMEDS_AttributePersistentRef_i: public virtual POA_SALOMEDS::AttributePersistentRef,
+ public virtual SALOMEDS_GenericAttribute_i {
public:
+
+ SALOMEDS_AttributePersistentRef_i(const Handle(SALOMEDSImpl_AttributePersistentRef)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ ~SALOMEDS_AttributePersistentRef_i() {};
+
char* Value();
void SetValue(const char* value);
- char* Store();
- void Restore(const char*);
-
};
+
#endif
--- /dev/null
+// File : SALOMEDS_AttributePixMap.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributePixMap.hxx"
+
+#include <string>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+SALOMEDS_AttributePixMap::SALOMEDS_AttributePixMap(const Handle(SALOMEDSImpl_AttributePixMap)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributePixMap::SALOMEDS_AttributePixMap(SALOMEDS::AttributePixMap_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributePixMap::~SALOMEDS_AttributePixMap()
+{}
+
+bool SALOMEDS_AttributePixMap::HasPixMap()
+{
+ bool ret;
+ if(_isLocal) ret = Handle(SALOMEDSImpl_AttributePixMap)::DownCast(_local_impl)->HasPixMap();
+ else ret = SALOMEDS::AttributePixMap::_narrow(_corba_impl)->HasPixMap();
+}
+
+std::string SALOMEDS_AttributePixMap::GetPixMap()
+{
+ std::string aValue;
+ if(_isLocal)
+ aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributePixMap)::DownCast(_local_impl)->GetPixMap()).ToCString();
+ else aValue = SALOMEDS::AttributePixMap::_narrow(_corba_impl)->GetPixMap();
+ return aValue;
+}
+
+void SALOMEDS_AttributePixMap::SetPixMap(const std::string& value)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributePixMap)::DownCast(_local_impl)->SetPixMap((char*)value.c_str());
+ else SALOMEDS::AttributePixMap::_narrow(_corba_impl)->SetPixMap(value.c_str());
+}
--- /dev/null
+// File : SALOMEDS_AttributePixMap.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributePixMap_HeaderFile
+#define SALOMEDS_AttributePixMap_HeaderFile
+
+#include "SALOMEDSClient_AttributePixMap.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributePixMap.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributePixMap: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributePixMap
+{
+public:
+ SALOMEDS_AttributePixMap(const Handle(SALOMEDSImpl_AttributePixMap)& theAttr);
+ SALOMEDS_AttributePixMap(SALOMEDS::AttributePixMap_ptr theAttr);
+ ~SALOMEDS_AttributePixMap();
+
+ virtual bool HasPixMap();
+ virtual std::string GetPixMap();
+ virtual void SetPixMap(const std::string& value);
+
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributePixMap_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
+using namespace std;
#include "SALOMEDS_AttributePixMap_i.hxx"
+#include "SALOMEDS.hxx"
#include <TCollection_AsciiString.hxx>
-using namespace std;
-
-CORBA::Boolean SALOMEDS_AttributePixMap_i::HasPixMap() {
- TCollection_ExtendedString S = Handle(SALOMEDS_PixMapAttribute)::DownCast(_myAttr)->Get();
- if (strcmp(TCollection_AsciiString(S).ToCString(), "None") == 0) return Standard_False;
- return Standard_True;
+CORBA::Boolean SALOMEDS_AttributePixMap_i::HasPixMap()
+{
+ return Handle(SALOMEDSImpl_AttributePixMap)::DownCast(_impl)->HasPixMap();
}
-char* SALOMEDS_AttributePixMap_i::GetPixMap() {
- CORBA::String_var S = CORBA::string_dup(TCollection_AsciiString(Handle(SALOMEDS_PixMapAttribute)::DownCast(_myAttr)->Get()).ToCString());
- return S._retn();
+char* SALOMEDS_AttributePixMap_i::GetPixMap()
+{
+ SALOMEDS::Locker lock;
+ CORBA::String_var S =
+ CORBA::string_dup(TCollection_AsciiString(Handle(SALOMEDSImpl_AttributePixMap)::DownCast(_impl)->GetPixMap()).ToCString());
+ return S._retn();
}
-void SALOMEDS_AttributePixMap_i::SetPixMap(const char* value) {
+void SALOMEDS_AttributePixMap_i::SetPixMap(const char* value)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
CORBA::String_var Str = CORBA::string_dup(value);
- Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str));
+ Handle(SALOMEDSImpl_AttributePixMap)::DownCast(_impl)->SetPixMap(TCollection_ExtendedString(Str));
}
-char* SALOMEDS_AttributePixMap_i::Store() {
- return GetPixMap();
-}
-
-void SALOMEDS_AttributePixMap_i::Restore(const char* value) {
- SetPixMap(value);
-}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributePixMap_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#ifndef SALOMEDS_AttributePixMap_i_HeaderFile
#define SALOMEDS_AttributePixMap_i_HeaderFile
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-#include "SALOMEDS_PixMapAttribute.hxx"
#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributePixMap.hxx"
-DEFINE_DERIVED_ATTR(AttributePixMap,SALOMEDS_PixMapAttribute,false);
-
-class SALOMEDS_AttributePixMap_i:
- public virtual POA_SALOMEDS::AttributePixMap,
- public virtual SALOMEDS_TAttributePixMap_i
+class SALOMEDS_AttributePixMap_i: public virtual POA_SALOMEDS::AttributePixMap,
+ public virtual SALOMEDS_GenericAttribute_i
{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributePixMap,SALOMEDS_PixMapAttribute);
public:
+
+ SALOMEDS_AttributePixMap_i(const Handle(SALOMEDSImpl_AttributePixMap)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ ~SALOMEDS_AttributePixMap_i() {};
+
CORBA::Boolean HasPixMap();
char* GetPixMap();
void SetPixMap(const char* value);
- char* Store();
- void Restore(const char*);
-
};
--- /dev/null
+// File : SALOMEDS_AttributePythonObject.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributePythonObject.hxx"
+
+#include <string>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+SALOMEDS_AttributePythonObject::SALOMEDS_AttributePythonObject(const Handle(SALOMEDSImpl_AttributePythonObject)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributePythonObject::SALOMEDS_AttributePythonObject(SALOMEDS::AttributePythonObject_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributePythonObject::~SALOMEDS_AttributePythonObject()
+{}
+
+bool SALOMEDS_AttributePythonObject::IsScript()
+{
+ bool ret;
+ if(_isLocal) ret = Handle(SALOMEDSImpl_AttributePythonObject)::DownCast(_local_impl)->IsScript();
+ else ret = SALOMEDS::AttributePythonObject::_narrow(_corba_impl)->IsScript();
+ return ret;
+}
+
+std::string SALOMEDS_AttributePythonObject::GetObject()
+{
+ std::string aValue;
+ if(_isLocal)
+ aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributePythonObject)::DownCast(_local_impl)->GetObject()).ToCString();
+ else aValue = SALOMEDS::AttributePythonObject::_narrow(_corba_impl)->GetObject();
+ return aValue;
+}
+
+void SALOMEDS_AttributePythonObject::SetObject(const std::string& theSequence, bool IsScript)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributePythonObject)::DownCast(_local_impl)->SetObject((char*)theSequence.c_str(), IsScript);
+ else SALOMEDS::AttributePythonObject::_narrow(_corba_impl)->SetObject(theSequence.c_str(), IsScript);
+}
--- /dev/null
+// File : SALOMEDS_AttributePythonObject.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributePythonObject_HeaderFile
+#define SALOMEDS_AttributePythonObject_HeaderFile
+
+#include "SALOMEDSClient_AttributePythonObject.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributePythonObject.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributePythonObject: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributePythonObject
+{
+public:
+ SALOMEDS_AttributePythonObject(const Handle(SALOMEDSImpl_AttributePythonObject)& theAttr);
+ SALOMEDS_AttributePythonObject(SALOMEDS::AttributePythonObject_ptr theAttr);
+ ~SALOMEDS_AttributePythonObject();
+
+ virtual void SetObject(const std::string& theSequence, bool IsScript);
+ virtual std::string GetObject();
+ virtual bool IsScript();
+
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
// File : SALOMEDS_AttributePythonObject_i.cxx
-// Author : Michael Ponikarov
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
+using namespace std;
#include "SALOMEDS_AttributePythonObject_i.hxx"
+#include "SALOMEDS.hxx"
#include <TCollection_ExtendedString.hxx>
#include <TColStd_HArray1OfCharacter.hxx>
-using namespace std;
-
-void SALOMEDS_AttributePythonObject_i::SetObject(const char* theSequence, CORBA::Boolean IsScript) {
+void SALOMEDS_AttributePythonObject_i::SetObject(const char* theSequence, CORBA::Boolean IsScript)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
- Handle(SALOMEDS_PythonObjectAttribute)::DownCast(_myAttr)->SetObject(const_cast<char*>(theSequence), IsScript);
+ char *aSeq = CORBA::string_dup(theSequence);
+ Handle(SALOMEDSImpl_AttributePythonObject)::DownCast(_impl)->SetObject(aSeq, IsScript);
}
-char* SALOMEDS_AttributePythonObject_i::GetObject() {
- char* aSeq = Handle(SALOMEDS_PythonObjectAttribute)::DownCast(_myAttr)->GetObject();
+char* SALOMEDS_AttributePythonObject_i::GetObject()
+{
+ SALOMEDS::Locker lock;
+ char* aSeq = Handle(SALOMEDSImpl_AttributePythonObject)::DownCast(_impl)->GetObject().ToCString();
CORBA::String_var aStr = CORBA::string_dup(aSeq);
return aStr._retn();
}
-CORBA::Boolean SALOMEDS_AttributePythonObject_i::IsScript() {
- return Handle(SALOMEDS_PythonObjectAttribute)::DownCast(_myAttr)->IsScript();
+CORBA::Boolean SALOMEDS_AttributePythonObject_i::IsScript()
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributePythonObject)::DownCast(_impl)->IsScript();
}
-char* SALOMEDS_AttributePythonObject_i::Store() {
- CORBA::String_var aString = GetObject();
- char* aResult = new char[strlen(aString) + 2];
- aResult[0] = IsScript()?'s':'n';
- strcpy(aResult+1, aString);
- return aResult;
-}
-void SALOMEDS_AttributePythonObject_i::Restore(const char* theValue) {
- SetObject(&theValue[1], theValue[0]=='s');
-}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
// File : SALOMEDS_AttributePythonObject_i.hxx
-// Author : Michael Ponikarov
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#ifndef SALOMEDS_AttributePythonObject_i_HeaderFile
#define SALOMEDS_AttributePythonObject_i_HeaderFile
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
#include "SALOMEDS_GenericAttribute_i.hxx"
-#include "SALOMEDS_PythonObjectAttribute.hxx"
+#include "SALOMEDSImpl_AttributePythonObject.hxx"
-DEFINE_DERIVED_ATTR(AttributePythonObject,SALOMEDS_PythonObjectAttribute,true);
-
-class SALOMEDS_AttributePythonObject_i:
- public virtual POA_SALOMEDS::AttributePythonObject,
- public virtual SALOMEDS_TAttributePythonObject_i
-{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributePythonObject,SALOMEDS_PythonObjectAttribute);
+class SALOMEDS_AttributePythonObject_i: public virtual POA_SALOMEDS::AttributePythonObject,
+ public virtual SALOMEDS_GenericAttribute_i {
public:
+
+ SALOMEDS_AttributePythonObject_i(const Handle(SALOMEDSImpl_AttributePythonObject)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ ~SALOMEDS_AttributePythonObject_i() {};
+
virtual void SetObject(const char* theSequence, CORBA::Boolean IsScript);
virtual char* GetObject();
virtual CORBA::Boolean IsScript();
- virtual char* Store();
- virtual void Restore(const char*);
-
};
+
+
+
#endif
--- /dev/null
+// File : SALOMEDS_AttributeReal.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeReal.hxx"
+
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+SALOMEDS_AttributeReal::SALOMEDS_AttributeReal(const Handle(SALOMEDSImpl_AttributeReal)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeReal::SALOMEDS_AttributeReal(SALOMEDS::AttributeReal_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeReal::~SALOMEDS_AttributeReal()
+{}
+
+double SALOMEDS_AttributeReal::Value()
+{
+ double aValue;
+ if(_isLocal) aValue = (bool)Handle(SALOMEDSImpl_AttributeReal)::DownCast(_local_impl)->Value();
+ else aValue = SALOMEDS::AttributeReal::_narrow(_corba_impl)->Value();
+ return aValue;
+}
+
+void SALOMEDS_AttributeReal::SetValue(double value)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeReal)::DownCast(_local_impl)->SetValue(value);
+ else SALOMEDS::AttributeReal::_narrow(_corba_impl)->SetValue(value);
+}
--- /dev/null
+// File : SALOMEDS_AttributeReal.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeReal_HeaderFile
+#define SALOMEDS_AttributeReal_HeaderFile
+
+#include "SALOMEDSClient_AttributeReal.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeReal.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributeReal: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeReal
+{
+public:
+ SALOMEDS_AttributeReal(const Handle(SALOMEDSImpl_AttributeReal)& theAttr);
+ SALOMEDS_AttributeReal(SALOMEDS::AttributeReal_ptr theAttr);
+ ~SALOMEDS_AttributeReal();
+
+ virtual double Value();
+ virtual void SetValue(double value);
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeReal_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#include "SALOMEDS_AttributeReal_i.hxx"
+#include "SALOMEDS_SObject_i.hxx"
+#include "SALOMEDS.hxx"
#include <sstream>
using namespace std;
-static const char* write_double(double value)
+CORBA::Double SALOMEDS_AttributeReal_i::Value()
{
- std::ostringstream os;
- unsigned char* array = (unsigned char*)&value;
- for(int i = 0; i < sizeof(double); i++) {
- unsigned tmp = (unsigned short)array[i];
- os << " " << tmp;
- }
- return os.str().c_str();
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeReal)::DownCast(_impl)->Value();
}
-static double read_double(const char* str)
+void SALOMEDS_AttributeReal_i::SetValue(CORBA::Double value)
{
- std::istringstream is(str);
- double value;
- unsigned char* array = (unsigned char*)(&value);
- for(int i = 0; i < sizeof(double); i++) {
- unsigned tmp;
- is >> tmp;
- array[i] = (unsigned char)tmp;
- }
- return value;
-}
-
-CORBA::Double SALOMEDS_AttributeReal_i::Value() {
- return Handle(TDataStd_Real)::DownCast(_myAttr)->Get();
-}
-
-void SALOMEDS_AttributeReal_i::SetValue(CORBA::Double value) {
+ SALOMEDS::Locker lock;
CheckLocked();
- Handle(TDataStd_Real)::DownCast(_myAttr)->Set(value);
-}
-
-char* SALOMEDS_AttributeReal_i::Store() {
- // char* RealVal = new char[35];
- // sprintf(RealVal, "%.20f", Value());
- //return RealVal;
- return (char*)write_double( (double)Value() );
-}
-
-void SALOMEDS_AttributeReal_i::Restore(const char* value) {
- //char *err = NULL;
- //CORBA::Double r = strtod(value, &err);
- //if (err != value) SetValue(r);
- SetValue( read_double(value) );
+ Handle(SALOMEDSImpl_AttributeReal)::DownCast(_impl)->SetValue(value);
}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeReal_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#ifndef SALOMEDS_AttributeReal_i_HeaderFile
#define SALOMEDS_AttributeReal_i_HeaderFile
-#include <TDataStd_Real.hxx>
-
-#include "SALOMEDS_GenericAttribute_i.hxx"
-
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-DEFINE_DERIVED_ATTR(AttributeReal,TDataStd_Real,true);
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeReal.hxx"
-class SALOMEDS_AttributeReal_i:
- public virtual POA_SALOMEDS::AttributeReal,
- public virtual SALOMEDS_TAttributeReal_i
-{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeReal,TDataStd_Real);
+class SALOMEDS_AttributeReal_i: public virtual POA_SALOMEDS::AttributeReal,
+ public virtual SALOMEDS_GenericAttribute_i {
public:
- CORBA::Double Value();
- void SetValue(CORBA::Double theValue);
+
+ SALOMEDS_AttributeReal_i(const Handle(SALOMEDSImpl_AttributeReal)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
- char* Store();
- void Restore(const char*);
+ ~SALOMEDS_AttributeReal_i() {};
+ CORBA::Double Value();
+ void SetValue(CORBA::Double value);
};
--- /dev/null
+// File : SALOMEDS_AttributeSelectable.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeSelectable.hxx"
+
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+SALOMEDS_AttributeSelectable::SALOMEDS_AttributeSelectable(const Handle(SALOMEDSImpl_AttributeSelectable)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeSelectable::SALOMEDS_AttributeSelectable(SALOMEDS::AttributeSelectable_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeSelectable::~SALOMEDS_AttributeSelectable()
+{}
+
+bool SALOMEDS_AttributeSelectable::IsSelectable()
+{
+ bool aValue;
+ if(_isLocal) aValue = (bool)Handle(SALOMEDSImpl_AttributeSelectable)::DownCast(_local_impl)->IsSelectable();
+ else aValue = SALOMEDS::AttributeSelectable::_narrow(_corba_impl)->IsSelectable();
+ return aValue;
+}
+
+void SALOMEDS_AttributeSelectable::SetSelectable(bool value)
+{
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeSelectable)::DownCast(_local_impl)->SetSelectable((int)value);
+ else SALOMEDS::AttributeSelectable::_narrow(_corba_impl)->SetSelectable(value);
+}
--- /dev/null
+// File : SALOMEDS_AttributeSelectable.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeSelectable_HeaderFile
+#define SALOMEDS_AttributeSelectable_HeaderFile
+
+#include "SALOMEDSClient_AttributeSelectable.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeSelectable.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributeSelectable: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeSelectable
+{
+public:
+ SALOMEDS_AttributeSelectable(const Handle(SALOMEDSImpl_AttributeSelectable)& theAttr);
+ SALOMEDS_AttributeSelectable(SALOMEDS::AttributeSelectable_ptr theAttr);
+ ~SALOMEDS_AttributeSelectable();
+
+ virtual bool IsSelectable();
+ virtual void SetSelectable(bool value);
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeSelectable_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
-
-#include "SALOMEDS_AttributeSelectable_i.hxx"
using namespace std;
+#include "SALOMEDS_AttributeSelectable_i.hxx"
+#include "SALOMEDS.hxx"
-CORBA::Boolean SALOMEDS_AttributeSelectable_i::IsSelectable() {
- return (Handle(SALOMEDS_SelectableAttribute)::DownCast(_myAttr)->Get() == 1);
+CORBA::Boolean SALOMEDS_AttributeSelectable_i::IsSelectable()
+{
+ SALOMEDS::Locker lock;
+ return (Handle(SALOMEDSImpl_AttributeSelectable)::DownCast(_impl)->IsSelectable() == 1);
}
-void SALOMEDS_AttributeSelectable_i::SetSelectable(CORBA::Boolean value) {
+void SALOMEDS_AttributeSelectable_i::SetSelectable(CORBA::Boolean value)
+{
+ SALOMEDS::Locker lock;
Standard_Integer val = 0;
if (value != 0) val = 1;
- Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val);
+ Handle(SALOMEDSImpl_AttributeSelectable)::DownCast(_impl)->SetSelectable(val);
}
-char* SALOMEDS_AttributeSelectable_i::Store() {
- return CORBA::string_dup(IsSelectable()?"1":"0");
-}
-
-void SALOMEDS_AttributeSelectable_i::Restore(const char* value) {
- SetSelectable(value[0] == '1');
-}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeSelectable_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header:
#ifndef SALOMEDS_AttributeSelectable_i_HeaderFile
#define SALOMEDS_AttributeSelectable_i_HeaderFile
-#include "SALOMEDS_SelectableAttribute.hxx"
-#include "SALOMEDS_GenericAttribute_i.hxx"
-
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-DEFINE_DERIVED_ATTR(AttributeSelectable,SALOMEDS_SelectableAttribute,false);
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeSelectable.hxx"
-class SALOMEDS_AttributeSelectable_i:
- public virtual POA_SALOMEDS::AttributeSelectable,
- public virtual SALOMEDS_TAttributeSelectable_i
-{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeSelectable,SALOMEDS_SelectableAttribute);
+class SALOMEDS_AttributeSelectable_i: public virtual POA_SALOMEDS::AttributeSelectable,
+ public virtual SALOMEDS_GenericAttribute_i {
public:
+
+ SALOMEDS_AttributeSelectable_i(const Handle(SALOMEDSImpl_AttributeSelectable)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ ~SALOMEDS_AttributeSelectable_i() {};
+
CORBA::Boolean IsSelectable();
void SetSelectable(CORBA::Boolean value);
- char* Store();
- void Restore(const char*);
-
};
+
#endif
--- /dev/null
+// File : SALOMEDS_AttributeSequenceOfInteger.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeSequenceOfInteger.hxx"
+
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TColStd_HSequenceOfInteger.hxx>
+
+SALOMEDS_AttributeSequenceOfInteger
+::SALOMEDS_AttributeSequenceOfInteger(const Handle(SALOMEDSImpl_AttributeSequenceOfInteger)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeSequenceOfInteger::SALOMEDS_AttributeSequenceOfInteger(SALOMEDS::AttributeSequenceOfInteger_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeSequenceOfInteger::~SALOMEDS_AttributeSequenceOfInteger()
+{}
+
+void SALOMEDS_AttributeSequenceOfInteger::Assign(const std::vector<int>& other)
+{
+ int i, aLength = other.size();
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
+ for(i = 0; i < aLength; i++) aSeq->Append(other[i]);
+ Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)->Assign(aSeq);
+ }
+ else {
+ SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq();
+ aSeq->length(aLength);
+ for(i = 0; i < aLength; i++) aSeq[i] = other[i];
+ SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)->Assign(aSeq);
+ }
+}
+
+std::vector<int> SALOMEDS_AttributeSequenceOfInteger::CorbaSequence()
+{
+ std::vector<int> aVector;
+ int i, aLength;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeSequenceOfInteger) aSeqAttr;
+ aSeqAttr = Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl);
+ aLength = aSeqAttr->Length();
+ for(i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i));
+ }
+ else {
+ SALOMEDS::AttributeSequenceOfInteger_var aSeqAttr = SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl);
+ aLength = aSeqAttr->Length();
+ for(i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i));
+ }
+ return aVector;
+}
+
+void SALOMEDS_AttributeSequenceOfInteger::Add(int value)
+{
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)->Add(value);
+ else SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)->Add(value);
+}
+
+void SALOMEDS_AttributeSequenceOfInteger::Remove(int index)
+{
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)->Remove(index);
+ else SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)->Remove(index);
+}
+
+void SALOMEDS_AttributeSequenceOfInteger::ChangeValue(int index, int value)
+{
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)->ChangeValue(index, value);
+ else SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)->ChangeValue(index, value);
+}
+
+int SALOMEDS_AttributeSequenceOfInteger::Value(int index)
+{
+ int aValue;
+ if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)->Value(index);
+ else aValue = SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)->Value(index);
+ return aValue;
+}
+
+int SALOMEDS_AttributeSequenceOfInteger::Length()
+{
+ int aValue;
+ if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)-> Length();
+ else aValue = SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)-> Length();
+ return aValue;
+}
--- /dev/null
+// File : SALOMEDS_AttributeSequenceOfInteger.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeSequenceOfInteger_HeaderFile
+#define SALOMEDS_AttributeSequenceOfInteger_HeaderFile
+
+#include "SALOMEDSClient_AttributeSequenceOfInteger.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeSequenceOfInteger.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include <vector>
+
+class SALOMEDS_AttributeSequenceOfInteger: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeSequenceOfInteger
+{
+public:
+ SALOMEDS_AttributeSequenceOfInteger(const Handle(SALOMEDSImpl_AttributeSequenceOfInteger)& theAttr);
+ SALOMEDS_AttributeSequenceOfInteger(SALOMEDS::AttributeSequenceOfInteger_ptr theAttr);
+ ~SALOMEDS_AttributeSequenceOfInteger();
+
+ virtual void Assign(const std::vector<int>& other);
+ virtual std::vector<int> CorbaSequence();
+ virtual void Add(int value);
+ virtual void Remove(int index);
+ virtual void ChangeValue(int index, int value);
+ virtual int Value(int index);
+ virtual int Length();
+
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeSequenceOfInteger_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
+using namespace std;
#include "SALOMEDS_AttributeSequenceOfInteger_i.hxx"
+#include "SALOMEDS.hxx"
#include <TColStd_HSequenceOfInteger.hxx>
-using namespace std;
void SALOMEDS_AttributeSequenceOfInteger_i::Assign(const SALOMEDS::LongSeq& other)
{
+ SALOMEDS::Locker lock;
CheckLocked();
Handle(TColStd_HSequenceOfInteger) CasCadeSeq = new TColStd_HSequenceOfInteger;
for (int i = 0; i < other.length(); i++) {
CasCadeSeq->Append(other[i]);
}
- Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Assign(CasCadeSeq);
+ Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_impl)->Assign(CasCadeSeq);
}
SALOMEDS::LongSeq* SALOMEDS_AttributeSequenceOfInteger_i::CorbaSequence()
{
+ SALOMEDS::Locker lock;
SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
- Handle(SALOMEDS_SequenceOfIntegerAttribute) CasCadeSeq = Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeSequenceOfInteger) CasCadeSeq;
+ CasCadeSeq = Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_impl);
CorbaSeq->length(CasCadeSeq->Length());
for (int i = 0; i < CasCadeSeq->Length(); i++) {
CorbaSeq[i] = CasCadeSeq->Value(i+1);;
void SALOMEDS_AttributeSequenceOfInteger_i::Add(CORBA::Long value)
{
+ SALOMEDS::Locker lock;
CheckLocked();
- Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Add(value);
+ Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_impl)->Add(value);
}
void SALOMEDS_AttributeSequenceOfInteger_i::Remove(CORBA::Long index)
{
+ SALOMEDS::Locker lock;
CheckLocked();
- Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Remove(index);
+ Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_impl)->Remove(index);
}
void SALOMEDS_AttributeSequenceOfInteger_i::ChangeValue(CORBA::Long index, CORBA::Long value)
{
+ SALOMEDS::Locker lock;
CheckLocked();
- Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->ChangeValue(index, value);
+ Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_impl)->ChangeValue(index, value);
}
CORBA::Long SALOMEDS_AttributeSequenceOfInteger_i::Value(CORBA::Short index)
{
- return Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Value(index);
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_impl)->Value(index);
}
CORBA::Long SALOMEDS_AttributeSequenceOfInteger_i::Length()
-{
- return Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Length();
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_impl)->Length();
}
-char* SALOMEDS_AttributeSequenceOfInteger_i::Store() {
- Handle(SALOMEDS_SequenceOfIntegerAttribute) CasCadeSeq = Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr);
- Standard_Integer aLength = CasCadeSeq->Length();
- char* aResult = new char[aLength * 25];
- aResult[0] = 0;
- Standard_Integer aPosition = 0;
- for (int i = 1; i <= aLength; i++) {
- sprintf(aResult + aPosition , "%d ", CasCadeSeq->Value(i));
- aPosition += strlen(aResult + aPosition);
- }
- return aResult;
-}
-
-void SALOMEDS_AttributeSequenceOfInteger_i::Restore(const char* value) {
- Handle(TColStd_HSequenceOfInteger) CasCadeSeq = new TColStd_HSequenceOfInteger;
-
- char* aCopy = strdup(value);
- char* adr = strtok(aCopy, " ");
- while (adr) {
- CORBA::Long l = atol(adr);
- CasCadeSeq->Append(l);
- adr = strtok(NULL, " ");
- }
- free(aCopy);
- Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Assign(CasCadeSeq);
-}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeSequenceOfInteger_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#ifndef SALOMEDS_AttributeSequenceOfInteger_i_HeaderFile
#define SALOMEDS_AttributeSequenceOfInteger_i_HeaderFile
-#include "SALOMEDS_SequenceOfIntegerAttribute.hxx"
-#include "SALOMEDS_GenericAttribute_i.hxx"
-
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-DEFINE_DERIVED_ATTR(AttributeSequenceOfInteger,SALOMEDS_SequenceOfIntegerAttribute,true);
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeSequenceOfInteger.hxx"
-class SALOMEDS_AttributeSequenceOfInteger_i:
- public virtual POA_SALOMEDS::AttributeSequenceOfInteger,
- public virtual SALOMEDS_TAttributeSequenceOfInteger_i
-{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeSequenceOfInteger,SALOMEDS_SequenceOfIntegerAttribute);
+class SALOMEDS_AttributeSequenceOfInteger_i: public virtual POA_SALOMEDS::AttributeSequenceOfInteger,
+ public virtual SALOMEDS_GenericAttribute_i
+{
public:
+
+ SALOMEDS_AttributeSequenceOfInteger_i(const Handle(SALOMEDSImpl_AttributeSequenceOfInteger)& theAttr,CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ ~SALOMEDS_AttributeSequenceOfInteger_i() {};
+
void Assign(const SALOMEDS::LongSeq& other);
SALOMEDS::LongSeq* CorbaSequence();
void Add(CORBA::Long value);
CORBA::Long Value(CORBA::Short index);
CORBA::Long Length();
- char* Store();
- void Restore(const char*);
-
};
#endif
--- /dev/null
+// File : SALOMEDS_AttributeSequenceOfReal.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeSequenceOfReal.hxx"
+
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TColStd_HSequenceOfReal.hxx>
+
+SALOMEDS_AttributeSequenceOfReal
+::SALOMEDS_AttributeSequenceOfReal(const Handle(SALOMEDSImpl_AttributeSequenceOfReal)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeSequenceOfReal::SALOMEDS_AttributeSequenceOfReal(SALOMEDS::AttributeSequenceOfReal_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeSequenceOfReal::~SALOMEDS_AttributeSequenceOfReal()
+{}
+
+void SALOMEDS_AttributeSequenceOfReal::Assign(const std::vector<double>& other)
+{
+ int i, aLength = other.size();
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfReal) aSeq = new TColStd_HSequenceOfReal;
+ for(i = 0; i < aLength; i++) aSeq->Append(other[i]);
+ Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Assign(aSeq);
+ }
+ else {
+ SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq();
+ aSeq->length(aLength);
+ for(i = 0; i < aLength; i++) aSeq[i] = other[i];
+ SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Assign(aSeq);
+ }
+}
+
+std::vector<double> SALOMEDS_AttributeSequenceOfReal::CorbaSequence()
+{
+ std::vector<double> aVector;
+ int i, aLength;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeSequenceOfReal) aSeqAttr;
+ aSeqAttr = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl);
+ aLength = aSeqAttr->Length();
+ for(i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i));
+ }
+ else {
+ SALOMEDS::AttributeSequenceOfReal_var aSeqAttr = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl);
+ aLength = aSeqAttr->Length();
+ for(i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i));
+ }
+ return aVector;
+}
+
+void SALOMEDS_AttributeSequenceOfReal::Add(double value)
+{
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Add(value);
+ else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Add(value);
+}
+
+void SALOMEDS_AttributeSequenceOfReal::Remove(int index)
+{
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Remove(index);
+ else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Remove(index);
+}
+
+void SALOMEDS_AttributeSequenceOfReal::ChangeValue(int index, double value)
+{
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->ChangeValue(index, value);
+ else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->ChangeValue(index, value);
+}
+
+double SALOMEDS_AttributeSequenceOfReal::Value(int index)
+{
+ double aValue;
+ if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Value(index);
+ else aValue = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Value(index);
+ return aValue;
+}
+
+int SALOMEDS_AttributeSequenceOfReal::Length()
+{
+ int aValue;
+ if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)-> Length();
+ else aValue = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)-> Length();
+ return aValue;
+}
--- /dev/null
+// File : SALOMEDS_AttributeSequenceOfReal.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeSequenceOfReal_HeaderFile
+#define SALOMEDS_AttributeSequenceOfReal_HeaderFile
+
+#include "SALOMEDSClient_AttributeSequenceOfReal.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeSequenceOfReal.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include <vector>
+
+class SALOMEDS_AttributeSequenceOfReal: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeSequenceOfReal
+{
+public:
+ SALOMEDS_AttributeSequenceOfReal(const Handle(SALOMEDSImpl_AttributeSequenceOfReal)& theAttr);
+ SALOMEDS_AttributeSequenceOfReal(SALOMEDS::AttributeSequenceOfReal_ptr theAttr);
+ ~SALOMEDS_AttributeSequenceOfReal();
+
+ virtual void Assign(const std::vector<double>& other);
+ virtual std::vector<double> CorbaSequence();
+ virtual void Add(double value);
+ virtual void Remove(int index);
+ virtual void ChangeValue(int index, double value);
+ virtual double Value(int index);
+ virtual int Length();
+
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeSequenceOfReal_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
+using namespace std;
#include "SALOMEDS_AttributeSequenceOfReal_i.hxx"
+#include "SALOMEDS.hxx"
#include <TColStd_HSequenceOfReal.hxx>
-using namespace std;
-
void SALOMEDS_AttributeSequenceOfReal_i::Assign(const SALOMEDS::DoubleSeq& other)
{
+ SALOMEDS::Locker lock;
CheckLocked();
Handle(TColStd_HSequenceOfReal) CasCadeSeq = new TColStd_HSequenceOfReal;
for (int i = 0; i < other.length(); i++) {
CasCadeSeq->Append(other[i]);
}
- Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Assign(CasCadeSeq);
+ Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_impl)->Assign(CasCadeSeq);
}
SALOMEDS::DoubleSeq* SALOMEDS_AttributeSequenceOfReal_i::CorbaSequence()
{
+ SALOMEDS::Locker lock;
SALOMEDS::DoubleSeq_var CorbaSeq = new SALOMEDS::DoubleSeq;
- Handle(SALOMEDS_SequenceOfRealAttribute) CasCadeSeq = Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeSequenceOfReal) CasCadeSeq = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_impl);
CorbaSeq->length(CasCadeSeq->Length());
for (int i = 0; i < CasCadeSeq->Length(); i++) {
CorbaSeq[i] = CasCadeSeq->Value(i+1);;
void SALOMEDS_AttributeSequenceOfReal_i::Add(CORBA::Double value)
{
+ SALOMEDS::Locker lock;
CheckLocked();
- Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Add(value);
+ Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_impl)->Add(value);
}
void SALOMEDS_AttributeSequenceOfReal_i::Remove(CORBA::Long index)
{
+ SALOMEDS::Locker lock;
CheckLocked();
- Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Remove(index);
+ Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_impl)->Remove(index);
}
void SALOMEDS_AttributeSequenceOfReal_i::ChangeValue(CORBA::Long index, CORBA::Double value)
{
+ SALOMEDS::Locker lock;
CheckLocked();
- Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->ChangeValue(index, value);
+ Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_impl)->ChangeValue(index, value);
}
CORBA::Double SALOMEDS_AttributeSequenceOfReal_i::Value(CORBA::Short index)
{
- return Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Value(index);
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_impl)->Value(index);
}
CORBA::Long SALOMEDS_AttributeSequenceOfReal_i::Length()
{
- return Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Length();
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_impl)->Length();
}
-char* SALOMEDS_AttributeSequenceOfReal_i::Store() {
- Handle(SALOMEDS_SequenceOfRealAttribute) CasCadeSeq = Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr);
- Standard_Integer aLength = CasCadeSeq->Length();
- char* aResult = new char[aLength * 25];
- aResult[0] = 0;
- Standard_Integer aPosition = 0;
- for (int i = 1; i <= aLength; i++) {
- sprintf(aResult + aPosition , "%f ", CasCadeSeq->Value(i));
- aPosition += strlen(aResult + aPosition);
- }
- return aResult;
-}
-
-void SALOMEDS_AttributeSequenceOfReal_i::Restore(const char* value) {
- Handle(TColStd_HSequenceOfReal) CasCadeSeq = new TColStd_HSequenceOfReal;
-
- char* aCopy = strdup(value);
- char* adr = strtok(aCopy, " ");
- char *err = NULL;
- while (adr) {
- CORBA::Double r = strtod(adr, &err);
- if (err == adr) break;
- else CasCadeSeq->Append(r);
- adr = strtok(NULL, " ");
- }
- free(aCopy);
- Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Assign(CasCadeSeq);
-}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeSequenceOfSequenceOfReal_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#ifndef SALOMEDS_AttributeSequenceOfSequenceOfReal_i_HeaderFile
#define SALOMEDS_AttributeSequenceOfSequenceOfReal_i_HeaderFile
-#include "SALOMEDS_SequenceOfRealAttribute.hxx"
-#include "SALOMEDS_GenericAttribute_i.hxx"
-
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-DEFINE_DERIVED_ATTR(AttributeSequenceOfReal,SALOMEDS_SequenceOfRealAttribute,true);
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeSequenceOfReal.hxx"
-class SALOMEDS_AttributeSequenceOfReal_i:
- public virtual POA_SALOMEDS::AttributeSequenceOfReal,
- public virtual SALOMEDS_TAttributeSequenceOfReal_i
-{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeSequenceOfReal,SALOMEDS_SequenceOfRealAttribute);
+class SALOMEDS_AttributeSequenceOfReal_i: public virtual POA_SALOMEDS::AttributeSequenceOfReal,
+ public virtual SALOMEDS_GenericAttribute_i {
public:
+
+ SALOMEDS_AttributeSequenceOfReal_i(const Handle(SALOMEDSImpl_AttributeSequenceOfReal)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ ~SALOMEDS_AttributeSequenceOfReal_i() {};
+
void Assign(const SALOMEDS::DoubleSeq& other);
SALOMEDS::DoubleSeq* CorbaSequence();
void Add(CORBA::Double value);
CORBA::Double Value(CORBA::Short index);
CORBA::Long Length();
- char* Store();
- void Restore(const char*);
-
};
--- /dev/null
+// File : SALOMEDS_AttributeStudyProperties.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeStudyProperties.hxx"
+
+#include <string>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TColStd_HSequenceOfExtendedString.hxx>
+#include <TColStd_HSequenceOfInteger.hxx>
+
+SALOMEDS_AttributeStudyProperties
+::SALOMEDS_AttributeStudyProperties(const Handle(SALOMEDSImpl_AttributeStudyProperties)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeStudyProperties::SALOMEDS_AttributeStudyProperties(SALOMEDS::AttributeStudyProperties_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeStudyProperties::~SALOMEDS_AttributeStudyProperties()
+{
+}
+
+void SALOMEDS_AttributeStudyProperties::SetUserName(const std::string& theName)
+{
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetUserName((char*)theName.c_str());
+ else SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetUserName(theName.c_str());
+}
+
+std::string SALOMEDS_AttributeStudyProperties::GetUserName()
+{
+ std::string aName;
+ if(_isLocal) {
+ TCollection_AsciiString N = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetCreatorName();
+ aName = N.ToCString();
+ }
+ else aName = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetUserName();
+ return aName;
+}
+
+void SALOMEDS_AttributeStudyProperties::SetCreationDate(int theMinute, int theHour, int theDay, int theMonth, int theYear)
+{
+ if(_isLocal)
+ Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetModificationDate(theMinute,
+ theHour,
+ theDay,
+ theMonth,
+ theYear);
+ else
+ SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetCreationDate(theMinute,
+ theHour,
+ theDay,
+ theMonth,
+ theYear);
+}
+
+bool SALOMEDS_AttributeStudyProperties::GetCreationDate(int& theMinute,
+ int& theHour,
+ int& theDay,
+ int& theMonth,
+ int& theYear)
+{
+ bool ret;
+ if(_isLocal)
+ ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetCreationDate(theMinute,
+ theHour,
+ theDay,
+ theMonth,
+ theYear);
+ else {
+ CORBA::Long aMinute, anHour, aDay, aMonth, anYear;
+ ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetCreationDate(aMinute,
+ anHour,
+ aDay,
+ aMonth,
+ anYear);
+ theMinute = (int)aMinute; theHour = (int)anHour; theDay = (int)aDay; theMonth = (int)aMonth; theYear = (int)anYear;
+ }
+ return ret;
+}
+
+void SALOMEDS_AttributeStudyProperties::SetCreationMode(const std::string& theMode)
+{
+ if(_isLocal) {
+ if(theMode == "from scratch")
+ Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetCreationMode(1);
+ else if(theMode == "copy from")
+ Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetCreationMode(2);
+ else //Not defined
+ Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetCreationMode(0);
+ }
+ else SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetCreationMode(theMode.c_str());
+}
+
+std::string SALOMEDS_AttributeStudyProperties::GetCreationMode()
+{
+ std::string aMode;
+ if(_isLocal) {
+ int mode = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetCreationMode();
+ if(mode == 1) aMode = "from scratch";
+ if(mode == 2) aMode = "copy from";
+ }
+ else aMode = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetCreationMode();
+ return aMode;
+}
+
+void SALOMEDS_AttributeStudyProperties::SetModified(int theModified)
+{
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetModified(theModified);
+ else SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetModified(theModified);
+}
+
+bool SALOMEDS_AttributeStudyProperties::IsModified()
+{
+ bool ret;
+ if(_isLocal) ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->IsModified();
+ else ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->IsModified();
+ return ret;
+}
+
+int SALOMEDS_AttributeStudyProperties::GetModified()
+{
+ int isModified;
+ if(_isLocal) isModified = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetModified();
+ else isModified = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetModified();
+ return isModified;
+}
+
+void SALOMEDS_AttributeStudyProperties::SetLocked(bool theLocked)
+{
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetLocked(theLocked);
+ else SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetLocked(theLocked);
+}
+
+bool SALOMEDS_AttributeStudyProperties::IsLocked()
+{
+ bool ret;
+ if(_isLocal) ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->IsLocked();
+ else ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->IsLocked();
+ return ret;
+}
+
+void SALOMEDS_AttributeStudyProperties::SetModification(const std::string& theName,
+ int theMinute,
+ int theHour,
+ int theDay,
+ int theMonth,
+ int theYear)
+{
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetUserName((char*)theName.c_str());
+ Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetModificationDate(theMinute,
+ theHour,
+ theDay,
+ theMonth,
+ theYear);
+ }
+ else SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetModification(theName.c_str(),
+ theMinute,
+ theHour,
+ theDay,
+ theMonth,
+ theYear);
+}
+
+void SALOMEDS_AttributeStudyProperties::GetModificationsList(std::vector<std::string>& theNames,
+ std::vector<int>& theMinutes,
+ std::vector<int>& theHours,
+ std::vector<int>& theDays,
+ std::vector<int>& theMonths,
+ std::vector<int>& theYears,
+ bool theWithCreator)
+{
+
+ int i, aLength;
+
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aNames;
+ Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears;
+ aNames = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetUserNames();
+ Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetModificationDates(aMinutes,
+ aHours,
+ aDays,
+ aMonths,
+ aYears);
+ aLength = aNames->Length()-((theWithCreator)?0:1);
+ for(i = 0; i < aLength; i++)
+ {
+ theNames.push_back(TCollection_AsciiString(aNames->Value(i + 1 + ((theWithCreator)?0:1))).ToCString());
+ theMinutes.push_back(aMinutes->Value(i + 1 + ((theWithCreator)?0:1)));
+ theHours.push_back(aHours->Value(i + 1 + ((theWithCreator)?0:1)));
+ theDays.push_back(aDays->Value(i + 1 + ((theWithCreator)?0:1)));
+ theMonths.push_back(aMonths->Value(i + 1 + ((theWithCreator)?0:1)));
+ theYears.push_back(aYears->Value(i + 1 + ((theWithCreator)?0:1)));
+ }
+ }
+ else {
+ SALOMEDS::StringSeq_var aNames;
+ SALOMEDS::LongSeq_var aMinutes, aHours, aDays, aMonths, aYears;
+ SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetModificationsList(aNames.out(),
+ aMinutes.out(),
+ aHours.out(),
+ aDays.out(),
+ aMonths.out(),
+ aYears.out(),
+ theWithCreator);
+ aLength = aNames->length();
+ for(i = 0; i<aLength; i++) {
+ theNames.push_back(aNames[i].in());
+ theMinutes.push_back(aMinutes[i]);
+ theHours.push_back(aHours[i]);
+ theDays.push_back(aDays[i]);
+ theMonths.push_back(aMonths[i]);
+ theYears.push_back(aYears[i]);
+ }
+ }
+}
+
--- /dev/null
+// File : SALOMEDS_AttributeStudyProperties.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeStudyProperties_HeaderFile
+#define SALOMEDS_AttributeStudyProperties_HeaderFile
+
+#include <vector>
+#include <string>
+
+#include "SALOMEDSClient_AttributeStudyProperties.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeStudyProperties.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributeStudyProperties: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeStudyProperties
+{
+public:
+
+ SALOMEDS_AttributeStudyProperties(const Handle(SALOMEDSImpl_AttributeStudyProperties)& theAttr);
+ SALOMEDS_AttributeStudyProperties(SALOMEDS::AttributeStudyProperties_ptr theAttr);
+ ~SALOMEDS_AttributeStudyProperties();
+
+ virtual void SetUserName(const std::string& theName);
+ virtual std::string GetUserName();
+ virtual void SetCreationDate(int theMinute, int theHour, int theDay, int theMonth, int theYear);
+ virtual bool GetCreationDate(int& theMinute, int& theHour, int& theDay, int& theMonth, int& theYear);
+ virtual void SetCreationMode(const std::string& theMode);
+ virtual std::string GetCreationMode();
+ virtual void SetModified(int theModified);
+ virtual bool IsModified();
+ virtual int GetModified();
+ virtual void SetLocked(bool theLocked);
+ virtual bool IsLocked();
+ virtual void SetModification(const std::string& theName,
+ int theMinute,
+ int theHour,
+ int theDay,
+ int theMonth,
+ int theYear);
+ virtual void GetModificationsList(std::vector<std::string>& theNames,
+ std::vector<int>& theMinutes,
+ std::vector<int>& theHours,
+ std::vector<int>& theDays,
+ std::vector<int>& theMonths,
+ std::vector<int>& theYears,
+ bool theWithCreator);
+
+};
+
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
// File : SALOMEDS_AttributeStudyProperties_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
+using namespace std;
+#include "SALOMEDS_AttributeStudyProperties_i.hxx"
+#include "SALOMEDS.hxx"
#include <TColStd_HSequenceOfExtendedString.hxx>
#include <TColStd_HSequenceOfInteger.hxx>
#include <TCollection_ExtendedString.hxx>
-#include <TCollection_AsciiString.hxx>
-
-#include "SALOMEDS_AttributeStudyProperties_i.hxx"
#define CREATION_MODE_NOTDEFINED 0
#define CREATION_MODE_SCRATCH 1
#define CREATION_MODE_COPY 2
-using namespace std;
-
-void SALOMEDS_AttributeStudyProperties_i::SetUserName(const char* theName) {
+void SALOMEDS_AttributeStudyProperties_i::SetUserName(const char* theName)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
- Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
- aProp->SetFirstName(const_cast<char*>(theName));
+ Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->SetFirstName((char*)theName);
}
-char* SALOMEDS_AttributeStudyProperties_i::GetUserName() {
- TCollection_ExtendedString S = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->GetCreatorName();
+char* SALOMEDS_AttributeStudyProperties_i::GetUserName()
+{
+ SALOMEDS::Locker lock;
+ TCollection_ExtendedString S = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->GetCreatorName();
CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString());
return c_s._retn();
}
CORBA::Long theHour,
CORBA::Long theDay,
CORBA::Long theMonth,
- CORBA::Long theYear) {
+ CORBA::Long theYear)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
- Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl);
int aTmp;
if (aProp->GetCreationDate(aTmp, aTmp, aTmp, aTmp, aTmp)) return;
aProp->SetModificationDate(theMinute, theHour, theDay, theMonth, theYear);
CORBA::Long& theHour,
CORBA::Long& theDay,
CORBA::Long& theMonth,
- CORBA::Long& theYear) {
+ CORBA::Long& theYear)
+{
+ SALOMEDS::Locker lock;
Standard_Integer aMinute;
Standard_Integer aHour;
Standard_Integer aDay;
Standard_Integer aMonth;
Standard_Integer aYear;
- if (Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->GetCreationDate(aMinute, aHour, aDay,
- aMonth, aYear)) {
- theMinute = aMinute;
- theHour = aHour;
- theDay = aDay;
- theMonth = aMonth;
- theYear = aYear;
- return Standard_True;
- }
+ if (Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->GetCreationDate(aMinute, aHour, aDay,
+ aMonth, aYear))
+ {
+ theMinute = aMinute;
+ theHour = aHour;
+ theDay = aDay;
+ theMonth = aMonth;
+ theYear = aYear;
+ return Standard_True;
+ }
return Standard_False;
}
-void SALOMEDS_AttributeStudyProperties_i::SetCreationMode(const char* theMode) {
+void SALOMEDS_AttributeStudyProperties_i::SetCreationMode(const char* theMode)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
- Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl);
if (strcmp(theMode,"from scratch")==0) aProp->SetCreationMode(CREATION_MODE_SCRATCH);
else if (strcmp(theMode,"copy from")==0) aProp->SetCreationMode(CREATION_MODE_COPY);
else aProp->SetCreationMode(CREATION_MODE_NOTDEFINED);
}
-char* SALOMEDS_AttributeStudyProperties_i::GetCreationMode() {
+char* SALOMEDS_AttributeStudyProperties_i::GetCreationMode()
+{
+ SALOMEDS::Locker lock;
CORBA::String_var c_s;
- switch (Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->GetCreationMode()) {
+ switch (Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->GetCreationMode()) {
case CREATION_MODE_SCRATCH: c_s = "from scratch"; break;
case CREATION_MODE_COPY: c_s = "copy from"; break;
default: c_s = "";
return c_s._retn();
}
-void SALOMEDS_AttributeStudyProperties_i::SetModified(CORBA::Long theModified) {
- Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->SetModified(theModified);
+void SALOMEDS_AttributeStudyProperties_i::SetModified(CORBA::Long theModified)
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->SetModified(theModified);
}
-CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsModified() {
- return Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->IsModified();
+CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsModified()
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->IsModified();
}
-CORBA::Long SALOMEDS_AttributeStudyProperties_i::GetModified() {
- return Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->GetModified();
+CORBA::Long SALOMEDS_AttributeStudyProperties_i::GetModified()
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->GetModified();
}
-void SALOMEDS_AttributeStudyProperties_i::SetLocked(CORBA::Boolean theLocked) {
- Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->SetLocked(theLocked);
+void SALOMEDS_AttributeStudyProperties_i::SetLocked(CORBA::Boolean theLocked)
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->SetLocked(theLocked);
}
-CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsLocked() {
- return Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->IsLocked();
+CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsLocked()
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->IsLocked();
}
void SALOMEDS_AttributeStudyProperties_i::SetModification(const char* theName,
CORBA::Long theHour,
CORBA::Long theDay,
CORBA::Long theMonth,
- CORBA::Long theYear) {
+ CORBA::Long theYear)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
- Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
- aProp->SetUserName(const_cast<char*>(theName));
+ Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl);
+ aProp->SetUserName((char*)theName);
aProp->SetModificationDate((int)theMinute, (int)theHour, (int)theDay, (int)theMonth, (int)theYear);
}
void SALOMEDS_AttributeStudyProperties_i::GetModificationsList(SALOMEDS::StringSeq_out theNames,
SALOMEDS::LongSeq_out theDays,
SALOMEDS::LongSeq_out theMonths,
SALOMEDS::LongSeq_out theYears,
- CORBA::Boolean theWithCreator) {
+ CORBA::Boolean theWithCreator)
+{
+ SALOMEDS::Locker lock;
Handle(TColStd_HSequenceOfExtendedString) aNames;
Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears;
- Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl);
aNames = aProp->GetUserNames();
aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears);
int aLength = aNames->Length()-((theWithCreator)?0:1);
theNames = new SALOMEDS::StringSeq;
-// SALOMEDS::LongSeq *maminute = new SALOMEDS::LongSeq;
-// maminute->length(5);
theMinutes = new SALOMEDS::LongSeq;
theHours = new SALOMEDS::LongSeq;
theDays = new SALOMEDS::LongSeq;
int a;
for(a = 0; a < aLength; a++)
{
- (*theNames)[a] = CORBA::string_dup(TCollection_AsciiString(aNames->Value(a + 1 + ((theWithCreator)?0:1))).ToCString());
+ (*theNames)[a]=CORBA::string_dup(TCollection_AsciiString(aNames->Value(a + 1 + ((theWithCreator)?0:1))).ToCString());
(*theMinutes)[a] = aMinutes->Value(a + 1 + ((theWithCreator)?0:1));
(*theHours)[a] = aHours->Value(a + 1 + ((theWithCreator)?0:1));
(*theDays)[a] = aDays->Value(a + 1 + ((theWithCreator)?0:1));
}
}
-char* SALOMEDS_AttributeStudyProperties_i::Store() {
- Handle(TColStd_HSequenceOfExtendedString) aNames;
- Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears;
- Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
- aNames = aProp->GetUserNames();
- aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears);
-
- int aLength, anIndex;
- for(aLength = 0, anIndex = aNames->Length(); anIndex > 0; anIndex--) aLength += aNames->Value(anIndex).Length() + 1;
-
- char* aProperty = new char[3 + aLength + 12 * aNames->Length()];
-
- sprintf(aProperty,"%c%c", strlen(GetCreationMode())?GetCreationMode()[0]:'0', IsLocked()?'l':'u');
-
- aLength = aNames->Length();
- int a = 2;
- for(anIndex = 1; anIndex <= aLength; anIndex++) {
- sprintf(&(aProperty[a]),"%2d%2d%2d%2d%4d%s",
- (int)(aMinutes->Value(anIndex)),
- (int)(aHours->Value(anIndex)),
- (int)(aDays->Value(anIndex)),
- (int)(aMonths->Value(anIndex)),
- (int)(aYears->Value(anIndex)),
- (char*)(TCollection_AsciiString(aNames->Value(anIndex)).ToCString()));
- a = strlen(aProperty);
- aProperty[a++] = 1;
- }
- aProperty[a] = 0;
- return aProperty;
-}
-
-void SALOMEDS_AttributeStudyProperties_i::Restore(const char* value) {
- char* aCopy = strdup(value);
- if (aCopy[0] == 'f') SetCreationMode("from scratch");
- else if (aCopy[0] == 'c') SetCreationMode("copy from");
- else SetCreationMode("none");
-
- int anIndex;
- for(anIndex = 2; anIndex + 2 < strlen(value) ;) {
- char str[10];
- Standard_Integer aMinute, aHour, aDay, aMonth, aYear;
- str[0] = aCopy[anIndex++];
- str[1] = aCopy[anIndex++];
- str[2] = 0;
- aMinute = atoi(str);
- str[0] = aCopy[anIndex++];
- str[1] = aCopy[anIndex++];
- aHour = atoi(str);
- str[0] = aCopy[anIndex++];
- str[1] = aCopy[anIndex++];
- aDay = atoi(str);
- str[0] = aCopy[anIndex++];
- str[1] = aCopy[anIndex++];
- aMonth = atoi(str);
- str[0] = aCopy[anIndex++];
- str[1] = aCopy[anIndex++];
- str[2] = aCopy[anIndex++];
- str[3] = aCopy[anIndex++];
- str[4] = 0;
- aYear = atoi(str);
-
- int aNameSize;
- for(aNameSize = 0; aCopy[anIndex+aNameSize]!=1; aNameSize++);
- char *aName = new char[aNameSize+1];
- strncpy(aName, &(aCopy[anIndex]), aNameSize);
- aName[aNameSize] = 0;
- SetModification(aName, aMinute,aHour,aDay,aMonth,aYear);
- delete(aName);
- anIndex += aNameSize + 1;
- }
- if (aCopy[1] == 'l') {
- SetLocked(Standard_True);
- }
- SetModified(0);
- free(aCopy);
-}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
// File : SALOMEDS_AttributeStudyProperties_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#ifndef SALOMEDS_AttributeStudyProperties_i_HeaderFile
#define SALOMEDS_AttributeStudyProperties_i_HeaderFile
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-#include "SALOMEDS_StudyPropertiesAttribute.hxx"
#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeStudyProperties.hxx"
-DEFINE_DERIVED_ATTR(AttributeStudyProperties,SALOMEDS_StudyPropertiesAttribute,false);
-
-class SALOMEDS_AttributeStudyProperties_i:
- public virtual POA_SALOMEDS::AttributeStudyProperties,
- public virtual SALOMEDS_TAttributeStudyProperties_i
-{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeStudyProperties,SALOMEDS_StudyPropertiesAttribute);
+class SALOMEDS_AttributeStudyProperties_i: public virtual POA_SALOMEDS::AttributeStudyProperties,
+ public virtual SALOMEDS_GenericAttribute_i {
public:
+
+ SALOMEDS_AttributeStudyProperties_i(const Handle(SALOMEDSImpl_AttributeStudyProperties)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ ~SALOMEDS_AttributeStudyProperties_i() {};
+
virtual void SetUserName(const char* theName);
virtual char* GetUserName() ;
virtual void SetCreationDate(CORBA::Long theMinute, CORBA::Long theHour, CORBA::Long theDay, CORBA::Long theMonth, CORBA::Long theYear);
SALOMEDS::LongSeq_out theYears,
CORBA::Boolean theWithCreator);
- char* Store();
- void Restore(const char*);
-
};
--- /dev/null
+// File : SALOMEDS_AttributeTableOfInteger.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeTableOfInteger.hxx"
+
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TColStd_HSequenceOfInteger.hxx>
+#include <TColStd_HSequenceOfExtendedString.hxx>
+
+
+SALOMEDS_AttributeTableOfInteger
+::SALOMEDS_AttributeTableOfInteger(const Handle(SALOMEDSImpl_AttributeTableOfInteger)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeTableOfInteger::SALOMEDS_AttributeTableOfInteger(SALOMEDS::AttributeTableOfInteger_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeTableOfInteger::~SALOMEDS_AttributeTableOfInteger()
+{}
+
+
+void SALOMEDS_AttributeTableOfInteger::SetTitle(const std::string& theTitle)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetTitle((char*)theTitle.c_str());
+ else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetTitle(theTitle.c_str());
+}
+
+std::string SALOMEDS_AttributeTableOfInteger::GetTitle()
+{
+ std::string aStr;
+ if(_isLocal)
+ aStr = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetTitle()).ToCString();
+ else aStr = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetTitle();
+ return aStr;
+}
+
+void SALOMEDS_AttributeTableOfInteger::SetRowTitle(int theIndex, const std::string& theTitle)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetRowTitle(theIndex,
+ (char*)theTitle.c_str());
+ else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
+}
+
+void SALOMEDS_AttributeTableOfInteger::SetRowTitles(const std::vector<std::string>& theTitles)
+{
+ CheckLocked();
+ int aLength = theTitles.size(), i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
+ for(i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str());
+ Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetRowTitles(aSeq);
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
+ aSeq->length(aLength);
+ for(i = 0; i < aLength; i++) aSeq[i] = theTitles[i].c_str();
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowTitles(aSeq);
+ }
+
+}
+
+std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetRowTitles()
+{
+ std::vector<std::string> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aSeq;
+ aSeq = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetRowTitles();
+ aLength = aSeq->Length();
+ for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString((aSeq->Value(i))).ToCString());
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowTitles();
+ aLength = aSeq->length();
+ for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
+ }
+ return aVector;
+}
+
+void SALOMEDS_AttributeTableOfInteger::SetColumnTitle(int theIndex, const std::string& theTitle)
+{
+ CheckLocked();
+ if(_isLocal)
+ Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetColumnTitle(theIndex,
+ (char*)theTitle.c_str());
+ else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
+}
+
+void SALOMEDS_AttributeTableOfInteger::SetColumnTitles(const std::vector<std::string>& theTitles)
+{
+ CheckLocked();
+ int aLength = theTitles.size(), i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
+ for(i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str());
+ Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetColumnTitles(aSeq);
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
+ aSeq->length(aLength);
+ for(i = 0; i < aLength; i++) aSeq[i] = theTitles[i].c_str();
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumnTitles(aSeq);
+ }
+}
+
+std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetColumnTitles()
+{
+ std::vector<std::string> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aSeq;
+ aSeq = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetColumnTitles();
+ aLength = aSeq->Length();
+ for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetColumnTitles();
+ aLength = aSeq->length();
+ for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
+ }
+ return aVector;
+}
+
+void SALOMEDS_AttributeTableOfInteger::SetRowUnit(int theIndex, const std::string& theUnit)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetRowUnit(theIndex,
+ (char*)theUnit.c_str());
+ else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
+}
+
+void SALOMEDS_AttributeTableOfInteger::SetRowUnits(const std::vector<std::string>& theUnits)
+{
+ CheckLocked();
+ int aLength = theUnits.size(), i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
+ for(i = 0; i < aLength; i++) aSeq->Append((char*)theUnits[i].c_str());
+ Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetRowUnits(aSeq);
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
+ aSeq->length(aLength);
+ for(i = 0; i < aLength; i++) aSeq[i] = (char*)theUnits[i].c_str();
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowUnits(aSeq);
+ }
+}
+
+std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetRowUnits()
+{
+ std::vector<std::string> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aSeq;
+ aSeq = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetRowUnits();
+ aLength = aSeq->Length();
+ for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowUnits();
+ aLength = aSeq->length();
+ for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
+ }
+ return aVector;
+}
+
+int SALOMEDS_AttributeTableOfInteger::GetNbRows()
+{
+ int aNb;
+ if(_isLocal) aNb = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetNbRows();
+ else aNb = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetNbRows();
+ return aNb;
+}
+
+int SALOMEDS_AttributeTableOfInteger::GetNbColumns()
+{
+ int aNb;
+ if(_isLocal) aNb = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetNbColumns();
+ else aNb = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetNbColumns();
+ return aNb;
+
+}
+
+void SALOMEDS_AttributeTableOfInteger::AddRow(const std::vector<int>& theData)
+{
+ CheckLocked();
+ int aLength = theData.size(), i;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable;
+ aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl);
+ Handle(TColStd_HSequenceOfInteger) aRow = new TColStd_HSequenceOfInteger;
+ for (int i = 0; i < aLength; i++) aRow->Append(theData[i]);
+ try {
+ aTable->SetRowData(aTable->GetNbRows() + 1, aRow);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
+ }
+ }
+ else {
+ SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq();
+ aSeq->length(aLength);
+ for(i = 0; i < aLength; i++) aSeq[i] = theData[i];
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->AddRow(aSeq);
+ }
+}
+
+void SALOMEDS_AttributeTableOfInteger::SetRow(int theRow, const std::vector<int>& theData)
+{
+ CheckLocked();
+ int aLength = theData.size(), i;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable;
+ aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl);
+ Handle(TColStd_HSequenceOfInteger) aRow = new TColStd_HSequenceOfInteger;
+ for (int i = 0; i < aLength; i++) aRow->Append(theData[i]);
+ try {
+ aTable->SetRowData(theRow, aRow);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
+ }
+ }
+ else {
+ SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq();
+ aSeq->length(aLength);
+ for(i = 0; i < aLength; i++) aSeq[i] = theData[i];
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRow(theRow, aSeq);
+ }
+}
+
+std::vector<int> SALOMEDS_AttributeTableOfInteger::GetRow(int theRow)
+{
+ std::vector<int> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfInteger) aRow;
+ aRow = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetRowData(theRow);
+ aLength = aRow->Length();
+ for(i = 1; i<= aLength; i++) aVector.push_back(aRow->Value(i));
+ }
+ else {
+ SALOMEDS::LongSeq_var aRow = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRow(theRow);
+ for(i = 0; i < aLength; i++) aVector.push_back(aRow[i]);
+ }
+
+ return aVector;
+}
+
+void SALOMEDS_AttributeTableOfInteger::AddColumn(const std::vector<int>& theData)
+{
+ CheckLocked();
+ int aLength = theData.size(), i;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable;
+ aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl);
+ Handle(TColStd_HSequenceOfInteger) aColumn = new TColStd_HSequenceOfInteger;
+ for (int i = 0; i < aLength; i++) aColumn->Append(theData[i]);
+ try {
+ aTable->SetColumnData(aTable->GetNbColumns() + 1, aColumn);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
+ }
+ }
+ else {
+ SALOMEDS::LongSeq_var aColumn = new SALOMEDS::LongSeq();
+ aColumn->length(aLength);
+ for(i = 0; i < aLength; i++) aColumn[i] = theData[i];
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->AddColumn(aColumn);
+ }
+}
+
+void SALOMEDS_AttributeTableOfInteger::SetColumn(int theColumn, const std::vector<int>& theData)
+{
+ CheckLocked();
+ int aLength = theData.size(), i;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable;
+ aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl);
+ Handle(TColStd_HSequenceOfInteger) aColumn = new TColStd_HSequenceOfInteger;
+ for (int i = 0; i < aLength; i++) aColumn->Append(theData[i]);
+ try {
+ aTable->SetRowData(theColumn, aColumn);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
+ }
+ }
+ else {
+ SALOMEDS::LongSeq_var aColumn = new SALOMEDS::LongSeq();
+ aColumn->length(aLength);
+ for(i = 0; i < aLength; i++) aColumn[i] = theData[i];
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRow(theColumn, aColumn);
+ }
+}
+
+std::vector<int> SALOMEDS_AttributeTableOfInteger::GetColumn(int theColumn)
+{
+ std::vector<int> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfInteger) aColumn;
+ aColumn = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetColumnData(theColumn);
+ aLength = aColumn->Length();
+ for(i = 1; i<= aLength; i++) aVector.push_back(aColumn->Value(i));
+ }
+ else {
+ SALOMEDS::LongSeq_var aColumn = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetColumn(theColumn);
+ for(i = 0; i < aLength; i++) aVector.push_back(aColumn[i]);
+ }
+ return aVector;
+}
+
+void SALOMEDS_AttributeTableOfInteger::PutValue(int theValue, int theRow, int theColumn)
+{
+ CheckLocked();
+ if(_isLocal) {
+ try {
+ Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->PutValue(theValue, theRow, theColumn);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->PutValue(theValue, theRow, theColumn);
+ }
+}
+
+bool SALOMEDS_AttributeTableOfInteger::HasValue(int theRow, int theColumn)
+{
+ bool ret;
+ if(_isLocal) ret = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->HasValue(theRow, theColumn);
+ else ret = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->HasValue(theRow, theColumn);
+ return ret;
+}
+
+int SALOMEDS_AttributeTableOfInteger::GetValue(int theRow, int theColumn)
+{
+ int aValue;
+ if(_isLocal) {
+ try {
+ aValue = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetValue(theRow, theColumn);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
+ }
+ }
+ else {
+ aValue = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetValue(theRow, theColumn);
+ }
+ return aValue;
+}
+
+std::vector<int> SALOMEDS_AttributeTableOfInteger::GetRowSetIndices(int theRow)
+{
+ std::vector<int> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfInteger) aSet;
+ aSet = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetSetRowIndices(theRow);
+ aLength = aSet->Length();
+ for(i = 1; i<= aLength; i++) aVector.push_back(aSet->Value(i));
+ }
+ else {
+ SALOMEDS::LongSeq_var aSet = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowSetIndices(theRow);
+ for(i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
+ }
+ return aVector;
+}
+
+void SALOMEDS_AttributeTableOfInteger::SetNbColumns(int theNbColumns)
+{
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetNbColumns(theNbColumns);
+ else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetNbColumns(theNbColumns);
+}
--- /dev/null
+// File : SALOMEDS_AttributeTableOfInteger.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeTableOfInteger_HeaderFile
+#define SALOMEDS_AttributeTableOfInteger_HeaderFile
+
+#include "SALOMEDSClient_AttributeTableOfInteger.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeTableOfInteger.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include <vector>
+
+class SALOMEDS_AttributeTableOfInteger: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeTableOfInteger
+{
+public:
+ SALOMEDS_AttributeTableOfInteger(const Handle(SALOMEDSImpl_AttributeTableOfInteger)& theAttr);
+ SALOMEDS_AttributeTableOfInteger(SALOMEDS::AttributeTableOfInteger_ptr theAttr);
+ ~SALOMEDS_AttributeTableOfInteger();
+
+ virtual void SetTitle(const std::string& theTitle);
+ virtual std::string GetTitle();
+ virtual void SetRowTitle(int theIndex, const std::string& theTitle);
+ virtual void SetRowTitles(const std::vector<std::string>& theTitles);
+ virtual std::vector<std::string> GetRowTitles();
+ virtual void SetColumnTitle(int theIndex, const std::string& theTitle);
+ virtual void SetColumnTitles(const std::vector<std::string>& theTitles);
+ virtual std::vector<std::string> GetColumnTitles();
+
+ virtual void SetRowUnit(int theIndex, const std::string& theUnit);
+ virtual void SetRowUnits(const std::vector<std::string>& theUnits);
+ virtual std::vector<std::string> GetRowUnits();
+
+ virtual int GetNbRows();
+ virtual int GetNbColumns();
+ virtual void AddRow(const std::vector<int>& theData);
+ virtual void SetRow(int theRow, const std::vector<int>& theData);
+ virtual std::vector<int> GetRow(int theRow);
+ virtual void AddColumn(const std::vector<int>& theData);
+ virtual void SetColumn(int theColumn, const std::vector<int>& theData);
+ virtual std::vector<int> GetColumn(int theColumn);
+ virtual void PutValue(int theValue, int theRow, int theColumn);
+ virtual bool HasValue(int theRow, int theColumn);
+ virtual int GetValue(int theRow, int theColumn);
+
+ virtual std::vector<int> GetRowSetIndices(int theRow);
+ virtual void SetNbColumns(int theNbColumns);
+
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
// File : SALOMEDS_AttributeTableOfInteger_i.cxx
-// Author : Michael Ponikarov
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
+
+using namespace std;
+#include "SALOMEDS_AttributeTableOfInteger_i.hxx"
+#include "SALOMEDS.hxx"
#include <TColStd_HSequenceOfInteger.hxx>
-#include <TCollection_AsciiString.hxx>
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx>
-
-#include "SALOMEDS_AttributeTableOfInteger_i.hxx"
#include "Utils_ExceptHandlers.hxx"
#include <stdexcept>
#include <strstream>
#include <string>
-using namespace std;
-
-#define SEPARATOR '\1'
-
UNEXPECT_CATCH(ATI_IncorrectIndex, SALOMEDS::AttributeTableOfInteger::IncorrectIndex);
UNEXPECT_CATCH(ATI_IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength);
-static TCollection_ExtendedString getUnit(TCollection_ExtendedString theString)
+void SALOMEDS_AttributeTableOfInteger_i::SetTitle(const char* theTitle)
{
- TCollection_ExtendedString aString(theString);
- int aPos = aString.Search(SEPARATOR);
- if(aPos <= 0 || aPos == aString.Length() ) return TCollection_ExtendedString();
- return aString.Split(aPos);
-}
-
-static TCollection_ExtendedString getTitle(TCollection_ExtendedString theString)
-{
- TCollection_ExtendedString aString(theString);
- int aPos = aString.Search(SEPARATOR);
- if(aPos < 1) return aString;
- if(aPos == 1) return TCollection_ExtendedString();
- aString.Split(aPos-1);
- return aString;
-}
-
-void SALOMEDS_AttributeTableOfInteger_i::SetTitle(const char* theTitle) {
+ SALOMEDS::Locker lock;
CheckLocked();
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
CORBA::String_var aStr = CORBA::string_dup(theTitle);
- aTable->SetTitle(TCollection_ExtendedString(aStr));
+ Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl)->SetTitle(TCollection_ExtendedString(aStr));
}
-char* SALOMEDS_AttributeTableOfInteger_i::GetTitle() {
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+char* SALOMEDS_AttributeTableOfInteger_i::GetTitle()
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(aTable->GetTitle()).ToCString());
return c_s._retn();
}
void SALOMEDS_AttributeTableOfInteger_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch (ATI_IncorrectIndex);
CheckLocked();
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
- CORBA::String_var aStr = CORBA::string_dup(theTitle);
- TCollection_ExtendedString aTitle(aStr);
- TCollection_ExtendedString aUnit = getUnit(aTable->GetRowTitle(theIndex));
- if(aUnit.Length() > 0) {
- aTitle += SEPARATOR;
- aTitle += aUnit;
- }
-
- aTable->SetRowTitle(theIndex, aTitle);
+ aTable->SetRowTitle(theIndex, TCollection_ExtendedString((char*)theTitle));
}
void SALOMEDS_AttributeTableOfInteger_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch (ATI_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
for (int i = 0; i < theTitles.length(); i++) {
SetRowTitle(i + 1, theTitles[i]);
}
}
-SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowTitles() {
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowTitles()
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq;
aTitles->length(aTable->GetNbRows());
for(int i = 0; i < aTitles->length(); i++)
- aTitles[i] = CORBA::string_dup(TCollection_AsciiString(getTitle(aTable->GetRowTitle(i + 1))).ToCString());
+ aTitles[i] = CORBA::string_dup(TCollection_AsciiString(aTable->GetRowTitle(i + 1)).ToCString());
return aTitles._retn();
}
void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch (ATI_IncorrectIndex);
CheckLocked();
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
CORBA::String_var aStr = CORBA::string_dup(theTitle);
aTable->SetColumnTitle(theIndex, TCollection_ExtendedString(aStr));
void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
for (int i = 0; i < theTitles.length(); i++) {
- SetColumnTitle(i + 1, theTitles[i]);
+ aTable->SetColumnTitle(i + 1, (char*)theTitles[i].in());
}
}
-SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumnTitles() {
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumnTitles()
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq;
aTitles->length(aTable->GetNbColumns());
for(int i = 0; i < aTitles->length(); i++)
void SALOMEDS_AttributeTableOfInteger_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
{
- Unexpect aCatch (ATI_IncorrectIndex);
+ SALOMEDS::Locker lock;
+ Unexpect aCatch (ATI_IncorrectIndex);
CheckLocked();
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
- CORBA::String_var aStr = CORBA::string_dup(theUnit);
- TCollection_ExtendedString aTitle = getTitle(aTable->GetRowTitle(theIndex));
- TCollection_ExtendedString aUnit(aStr);
- aTitle += SEPARATOR;
- aTitle += aUnit;
- aTable->SetRowTitle(theIndex, aTitle);
+ aTable->SetRowUnit(theIndex, TCollection_ExtendedString((char*)theUnit));
}
void SALOMEDS_AttributeTableOfInteger_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch (ATI_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
for (int i = 0; i < theUnits.length(); i++) {
- SetRowUnit(i + 1, theUnits[i]);
+ aTable->SetRowUnit(i + 1, (char*)theUnits[i].in());
}
}
-SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowUnits() {
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowUnits()
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
SALOMEDS::StringSeq_var aUnits = new SALOMEDS::StringSeq;
aUnits->length(aTable->GetNbRows());
for(int i = 0; i < aUnits->length(); i++)
- aUnits[i] = CORBA::string_dup(TCollection_AsciiString(getUnit(aTable->GetRowTitle(i + 1))).ToCString());
+ aUnits[i] = CORBA::string_dup(TCollection_AsciiString(aTable->GetRowUnit(i + 1)).ToCString());
return aUnits._retn();
}
-CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetNbRows() {
- return Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr)->GetNbRows();
+CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetNbRows()
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl)->GetNbRows();
}
-CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetNbColumns() {
- return Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr)->GetNbColumns();
+
+CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetNbColumns()
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl)->GetNbColumns();
}
void SALOMEDS_AttributeTableOfInteger_i::AddRow(const SALOMEDS::LongSeq& theData)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
Handle(TColStd_HSequenceOfInteger) aRow = new TColStd_HSequenceOfInteger;
for (int i = 0; i < theData.length(); i++) aRow->Append(theData[i]);
void SALOMEDS_AttributeTableOfInteger_i::SetRow(CORBA::Long theRow, const SALOMEDS::LongSeq& theData)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
Handle(TColStd_HSequenceOfInteger) aRow = new TColStd_HSequenceOfInteger;
for (int i = 0; i < theData.length(); i++) aRow->Append(theData[i]);
SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetRow(CORBA::Long theRow)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectIndex);
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
void SALOMEDS_AttributeTableOfInteger_i::AddColumn(const SALOMEDS::LongSeq& theData)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
Handle(TColStd_HSequenceOfInteger) aColumn = new TColStd_HSequenceOfInteger;
for (int i = 0; i < theData.length(); i++) aColumn->Append(theData[i]);
void SALOMEDS_AttributeTableOfInteger_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::LongSeq& theData)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
Handle(TColStd_HSequenceOfInteger) aColumn = new TColStd_HSequenceOfInteger;
for (int i = 0; i < theData.length(); i++) aColumn->Append(theData[i]);
SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumn(CORBA::Long theColumn)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectIndex);
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
void SALOMEDS_AttributeTableOfInteger_i::PutValue(CORBA::Long theValue, CORBA::Long theRow, CORBA::Long theColumn)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectIndex);
CheckLocked();
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
try {
aTable->PutValue(theValue, theRow, theColumn);
}
}
-CORBA::Boolean SALOMEDS_AttributeTableOfInteger_i::HasValue(CORBA::Long theRow, CORBA::Long theColumn) {
- return Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr)->HasValue(theRow, theColumn);
+CORBA::Boolean SALOMEDS_AttributeTableOfInteger_i::HasValue(CORBA::Long theRow, CORBA::Long theColumn)
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl)->HasValue(theRow, theColumn);
}
CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectIndex);
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
CORBA::Long aValue;
SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowSetIndices(CORBA::Long theRow)
{
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
void SALOMEDS_AttributeTableOfInteger_i::SetNbColumns(CORBA::Long theNbColumns)
{
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
aTable->SetNbColumns(theNbColumns);
}
bool SALOMEDS_AttributeTableOfInteger_i::ReadFromFile(const SALOMEDS::TMPFile& theStream)
{
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
istrstream aStream((char*)&theStream[0], theStream.length());
return aTable->RestoreFromString(aStream);
SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfInteger_i::SaveToFile()
{
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_impl);
ostrstream ostr;
string aString;
return aStreamFile._retn();
}
-char* SALOMEDS_AttributeTableOfInteger_i::Store() {
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
-
- ostrstream ostr;
- aTable->ConvertToString(ostr);
- string aString = ostr.rdbuf()->str();
-
- CORBA::String_var aBuffer = CORBA::string_dup(aString.c_str());
- return aBuffer._retn();
-}
-
-void SALOMEDS_AttributeTableOfInteger_i::Restore(const char* value) {
- Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
- istrstream aStream(value, strlen(value));
- aTable->RestoreFromString(aStream);
-}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
// File : SALOMEDS_AttributeTableOfInteger_i.hxx
-// Author : Michael Ponikarov
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#ifndef SALOMEDS_AttributeTableOfInteger_i_HeaderFile
#define SALOMEDS_AttributeTableOfInteger_i_HeaderFile
-#include "SALOMEDS_TableOfIntegerAttribute.hxx"
-#include "SALOMEDS_GenericAttribute_i.hxx"
-
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-DEFINE_DERIVED_ATTR(AttributeTableOfInteger,SALOMEDS_TableOfIntegerAttribute,true);
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeTableOfInteger.hxx"
-class SALOMEDS_AttributeTableOfInteger_i:
- public virtual POA_SALOMEDS::AttributeTableOfInteger,
- public virtual SALOMEDS_TAttributeTableOfInteger_i
+class SALOMEDS_AttributeTableOfInteger_i: public virtual POA_SALOMEDS::AttributeTableOfInteger,
+ public virtual SALOMEDS_GenericAttribute_i
{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeTableOfInteger,SALOMEDS_TableOfIntegerAttribute);
+
public:
+
+ SALOMEDS_AttributeTableOfInteger_i(const Handle(SALOMEDSImpl_AttributeTableOfInteger)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ ~SALOMEDS_AttributeTableOfInteger_i() {};
+
virtual void SetTitle(const char* theTitle);
virtual char* GetTitle();
virtual void SetRowTitle(CORBA::Long theIndex, const char* theTitle)
virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream);
virtual SALOMEDS::TMPFile* SaveToFile();
-
- virtual char* Store();
- virtual void Restore(const char*);
-
};
#endif
--- /dev/null
+// File : SALOMEDS_AttributeTableOfReal.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeTableOfReal.hxx"
+
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TColStd_HSequenceOfInteger.hxx>
+#include <TColStd_HSequenceOfReal.hxx>
+#include <TColStd_HSequenceOfExtendedString.hxx>
+
+
+SALOMEDS_AttributeTableOfReal
+::SALOMEDS_AttributeTableOfReal(const Handle(SALOMEDSImpl_AttributeTableOfReal)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeTableOfReal::SALOMEDS_AttributeTableOfReal(SALOMEDS::AttributeTableOfReal_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeTableOfReal::~SALOMEDS_AttributeTableOfReal()
+{}
+
+
+void SALOMEDS_AttributeTableOfReal::SetTitle(const std::string& theTitle)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetTitle((char*)theTitle.c_str());
+ else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetTitle(theTitle.c_str());
+}
+
+std::string SALOMEDS_AttributeTableOfReal::GetTitle()
+{
+ std::string aStr;
+ if(_isLocal)
+ aStr = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetTitle()).ToCString();
+ else aStr = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetTitle();
+ return aStr;
+}
+
+void SALOMEDS_AttributeTableOfReal::SetRowTitle(int theIndex, const std::string& theTitle)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetRowTitle(theIndex,
+ (char*)theTitle.c_str());
+ else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
+}
+
+void SALOMEDS_AttributeTableOfReal::SetRowTitles(const std::vector<std::string>& theTitles)
+{
+ CheckLocked();
+ int aLength = theTitles.size(), i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
+ for(i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str());
+ Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetRowTitles(aSeq);
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
+ aSeq->length(aLength);
+ for(i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str();
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowTitles(aSeq);
+ }
+
+}
+
+std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetRowTitles()
+{
+ std::vector<std::string> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aSeq;
+ aSeq = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetRowTitles();
+ aLength = aSeq->Length();
+ for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowTitles();
+ aLength = aSeq->length();
+ for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
+ }
+ return aVector;
+}
+
+void SALOMEDS_AttributeTableOfReal::SetColumnTitle(int theIndex, const std::string& theTitle)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetColumnTitle(theIndex,
+ (char*)theTitle.c_str());
+ else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
+}
+
+void SALOMEDS_AttributeTableOfReal::SetColumnTitles(const std::vector<std::string>& theTitles)
+{
+ CheckLocked();
+ int aLength = theTitles.size(), i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
+ for(i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str());
+ Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetColumnTitles(aSeq);
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
+ aSeq->length(aLength);
+ for(i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str();
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumnTitles(aSeq);
+ }
+}
+
+std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetColumnTitles()
+{
+ std::vector<std::string> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aSeq;
+ aSeq = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetColumnTitles();
+ aLength = aSeq->Length();
+ for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetColumnTitles();
+ aLength = aSeq->length();
+ for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
+ }
+ return aVector;
+}
+
+void SALOMEDS_AttributeTableOfReal::SetRowUnit(int theIndex, const std::string& theUnit)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetRowUnit(theIndex,
+ (char*)theUnit.c_str());
+ else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
+}
+
+void SALOMEDS_AttributeTableOfReal::SetRowUnits(const std::vector<std::string>& theUnits)
+{
+ CheckLocked();
+ int aLength = theUnits.size(), i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
+ for(i = 0; i < aLength; i++) aSeq->Append((char*)theUnits[i].c_str());
+ Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetRowUnits(aSeq);
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
+ aSeq->length(aLength);
+ for(i = 0; i < aLength; i++) aSeq[i] = (char*)theUnits[i].c_str();
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowUnits(aSeq);
+ }
+}
+
+std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetRowUnits()
+{
+ std::vector<std::string> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aSeq;
+ aSeq = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetRowUnits();
+ aLength = aSeq->Length();
+ for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowUnits();
+ aLength = aSeq->length();
+ for(i = 0; i<aLength; i++) aVector.push_back(TCollection_AsciiString((char*)aSeq[i].in()).ToCString());
+ }
+ return aVector;
+}
+
+int SALOMEDS_AttributeTableOfReal::GetNbRows()
+{
+ int aNb;
+ if(_isLocal) aNb = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetNbRows();
+ else aNb = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetNbRows();
+ return aNb;
+}
+
+int SALOMEDS_AttributeTableOfReal::GetNbColumns()
+{
+ int aNb;
+ if(_isLocal) aNb = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetNbColumns();
+ else aNb = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetNbColumns();
+ return aNb;
+
+}
+
+void SALOMEDS_AttributeTableOfReal::AddRow(const std::vector<double>& theData)
+{
+ CheckLocked();
+ int aLength = theData.size(), i;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable;
+ aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl);
+ Handle(TColStd_HSequenceOfReal) aRow = new TColStd_HSequenceOfReal;
+ for (int i = 0; i < aLength; i++) aRow->Append(theData[i]);
+ try {
+ aTable->SetRowData(aTable->GetNbRows() + 1, aRow);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
+ }
+ }
+ else {
+ SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq();
+ aSeq->length(aLength);
+ for(i = 0; i < aLength; i++) aSeq[i] = theData[i];
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->AddRow(aSeq);
+ }
+}
+
+void SALOMEDS_AttributeTableOfReal::SetRow(int theRow, const std::vector<double>& theData)
+{
+ CheckLocked();
+ int aLength = theData.size(), i;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable;
+ aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl);
+ Handle(TColStd_HSequenceOfReal) aRow = new TColStd_HSequenceOfReal;
+ for (int i = 0; i < aLength; i++) aRow->Append(theData[i]);
+ try {
+ aTable->SetRowData(theRow, aRow);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
+ }
+ }
+ else {
+ SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq();
+ aSeq->length(aLength);
+ for(i = 0; i < aLength; i++) aSeq[i] = theData[i];
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRow(theRow, aSeq);
+ }
+}
+
+std::vector<double> SALOMEDS_AttributeTableOfReal::GetRow(int theRow)
+{
+ std::vector<double> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfReal) aRow;
+ aRow = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetRowData(theRow);
+ aLength = aRow->Length();
+ for(i = 1; i<= aLength; i++) aVector.push_back(aRow->Value(i));
+ }
+ else {
+ SALOMEDS::DoubleSeq_var aRow = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRow(theRow);
+ for(i = 0; i < aLength; i++) aVector.push_back(aRow[i]);
+ }
+
+ return aVector;
+}
+
+void SALOMEDS_AttributeTableOfReal::AddColumn(const std::vector<double>& theData)
+{
+ CheckLocked();
+ int aLength = theData.size(), i;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable;
+ aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl);
+ Handle(TColStd_HSequenceOfReal) aColumn = new TColStd_HSequenceOfReal;
+ for (int i = 0; i < aLength; i++) aColumn->Append(theData[i]);
+ try {
+ aTable->SetColumnData(aTable->GetNbColumns() + 1, aColumn);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
+ }
+ }
+ else {
+ SALOMEDS::DoubleSeq_var aColumn = new SALOMEDS::DoubleSeq();
+ aColumn->length(aLength);
+ for(i = 0; i < aLength; i++) aColumn[i] = theData[i];
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->AddColumn(aColumn);
+ }
+}
+
+void SALOMEDS_AttributeTableOfReal::SetColumn(int theColumn, const std::vector<double>& theData)
+{
+ CheckLocked();
+ int aLength = theData.size(), i;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable;
+ aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl);
+ Handle(TColStd_HSequenceOfReal) aColumn = new TColStd_HSequenceOfReal;
+ for (int i = 0; i < aLength; i++) aColumn->Append(theData[i]);
+ try {
+ aTable->SetRowData(theColumn, aColumn);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
+ }
+ }
+ else {
+ SALOMEDS::DoubleSeq_var aColumn = new SALOMEDS::DoubleSeq();
+ aColumn->length(aLength);
+ for(i = 0; i < aLength; i++) aColumn[i] = theData[i];
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRow(theColumn, aColumn);
+ }
+}
+
+std::vector<double> SALOMEDS_AttributeTableOfReal::GetColumn(int theColumn)
+{
+ std::vector<double> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfReal) aColumn;
+ aColumn = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetColumnData(theColumn);
+ aLength = aColumn->Length();
+ for(i = 1; i<= aLength; i++) aVector.push_back(aColumn->Value(i));
+ }
+ else {
+ SALOMEDS::DoubleSeq_var aColumn = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetColumn(theColumn);
+ for(i = 0; i < aLength; i++) aVector.push_back(aColumn[i]);
+ }
+ return aVector;
+}
+
+void SALOMEDS_AttributeTableOfReal::PutValue(double theValue, int theRow, int theColumn)
+{
+ CheckLocked();
+ if(_isLocal) {
+ try {
+ Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->PutValue(theValue, theRow, theColumn);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->PutValue(theValue, theRow, theColumn);
+ }
+}
+
+bool SALOMEDS_AttributeTableOfReal::HasValue(int theRow, int theColumn)
+{
+ bool ret;
+ if(_isLocal) ret = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->HasValue(theRow, theColumn);
+ else ret = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->HasValue(theRow, theColumn);
+ return ret;
+}
+
+double SALOMEDS_AttributeTableOfReal::GetValue(int theRow, int theColumn)
+{
+ double aValue;
+ if(_isLocal) {
+ try {
+ aValue = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetValue(theRow, theColumn);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
+ }
+ }
+ else {
+ aValue = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetValue(theRow, theColumn);
+ }
+ return aValue;
+}
+
+std::vector<int> SALOMEDS_AttributeTableOfReal::GetRowSetIndices(int theRow)
+{
+ std::vector<int> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfInteger) aSet;
+ aSet = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetSetRowIndices(theRow);
+ aLength = aSet->Length();
+ for(i = 1; i<= aLength; i++) aVector.push_back(aSet->Value(i));
+ }
+ else {
+ SALOMEDS::LongSeq_var aSet = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowSetIndices(theRow);
+ for(i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
+ }
+ return aVector;
+}
+
+void SALOMEDS_AttributeTableOfReal::SetNbColumns(int theNbColumns)
+{
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetNbColumns(theNbColumns);
+ else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetNbColumns(theNbColumns);
+}
--- /dev/null
+// File : SALOMEDS_AttributeTableOfReal.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeTableOfReal_HeaderFile
+#define SALOMEDS_AttributeTableOfReal_HeaderFile
+
+#include "SALOMEDSClient_AttributeTableOfReal.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeTableOfReal.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include <vector>
+
+class SALOMEDS_AttributeTableOfReal: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeTableOfReal
+{
+public:
+ SALOMEDS_AttributeTableOfReal(const Handle(SALOMEDSImpl_AttributeTableOfReal)& theAttr);
+ SALOMEDS_AttributeTableOfReal(SALOMEDS::AttributeTableOfReal_ptr theAttr);
+ ~SALOMEDS_AttributeTableOfReal();
+
+ virtual void SetTitle(const std::string& theTitle);
+ virtual std::string GetTitle();
+ virtual void SetRowTitle(int theIndex, const std::string& theTitle);
+ virtual void SetRowTitles(const std::vector<std::string>& theTitles);
+ virtual std::vector<std::string> GetRowTitles();
+ virtual void SetColumnTitle(int theIndex, const std::string& theTitle);
+ virtual void SetColumnTitles(const std::vector<std::string>& theTitles);
+ virtual std::vector<std::string> GetColumnTitles();
+
+ virtual void SetRowUnit(int theIndex, const std::string& theUnit);
+ virtual void SetRowUnits(const std::vector<std::string>& theUnits);
+ virtual std::vector<std::string> GetRowUnits();
+
+ virtual int GetNbRows();
+ virtual int GetNbColumns();
+ virtual void AddRow(const std::vector<double>& theData);
+ virtual void SetRow(int theRow, const std::vector<double>& theData);
+ virtual std::vector<double> GetRow(int theRow);
+ virtual void AddColumn(const std::vector<double>& theData);
+ virtual void SetColumn(int theColumn, const std::vector<double>& theData);
+ virtual std::vector<double> GetColumn(int theColumn);
+ virtual void PutValue(double theValue, int theRow, int theColumn);
+ virtual bool HasValue(int theRow, int theColumn);
+ virtual double GetValue(int theRow, int theColumn);
+
+ virtual std::vector<int> GetRowSetIndices(int theRow);
+ virtual void SetNbColumns(int theNbColumns);
+
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
// File : SALOMEDS_AttributeTableOfReal_i.cxx
-// Author : Michael Ponikarov
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
+using namespace std;
#include "SALOMEDS_AttributeTableOfReal_i.hxx"
+#include "SALOMEDS.hxx"
#include <TColStd_HSequenceOfReal.hxx>
-#include <TCollection_AsciiString.hxx>
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx>
UNEXPECT_CATCH(ATR_IncorrectIndex, SALOMEDS::AttributeTableOfReal::IncorrectIndex);
UNEXPECT_CATCH(ATR_IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength);
-#define SEPARATOR '\1'
-
-using namespace std;
-
-static TCollection_ExtendedString getUnit(TCollection_ExtendedString theString)
+void SALOMEDS_AttributeTableOfReal_i::SetTitle(const char* theTitle)
{
- TCollection_ExtendedString aString(theString);
- int aPos = aString.Search(SEPARATOR);
- if(aPos <= 0 || aPos == aString.Length() ) return TCollection_ExtendedString();
- return aString.Split(aPos);
-}
-
-static TCollection_ExtendedString getTitle(TCollection_ExtendedString theString)
-{
- TCollection_ExtendedString aString(theString);
- int aPos = aString.Search(SEPARATOR);
- if(aPos < 1) return aString;
- if(aPos == 1) return TCollection_ExtendedString();
- aString.Split(aPos-1);
- return aString;
-}
-
-void SALOMEDS_AttributeTableOfReal_i::SetTitle(const char* theTitle) {
+ SALOMEDS::Locker lock;
CheckLocked();
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
CORBA::String_var aStr = CORBA::string_dup(theTitle);
aTable->SetTitle(TCollection_ExtendedString(aStr));
}
-char* SALOMEDS_AttributeTableOfReal_i::GetTitle() {
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+char* SALOMEDS_AttributeTableOfReal_i::GetTitle()
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(aTable->GetTitle()).ToCString());
return c_s._retn();
}
void SALOMEDS_AttributeTableOfReal_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle)
throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch (ATR_IncorrectIndex);
CheckLocked();
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
- CORBA::String_var aStr = CORBA::string_dup(theTitle);
- TCollection_ExtendedString aTitle(aStr);
- TCollection_ExtendedString aUnit = getUnit(aTable->GetRowTitle(theIndex));
- if(aUnit.Length() > 0) {
- aTitle += SEPARATOR;
- aTitle += aUnit;
- }
-
- aTable->SetRowTitle(theIndex, aTitle);
+ aTable->SetRowTitle(theIndex, TCollection_ExtendedString((char*)theTitle));
}
void SALOMEDS_AttributeTableOfReal_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles)
throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch (ATR_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
for (int i = 0; i < theTitles.length(); i++) {
- SetRowTitle(i + 1, theTitles[i]);
+ aTable->SetRowTitle(i + 1, (char*)theTitles[i].in());
}
}
-SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetRowTitles() {
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetRowTitles()
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq;
aTitles->length(aTable->GetNbRows());
for(int i = 0; i < aTitles->length(); i++)
- aTitles[i] = CORBA::string_dup(TCollection_AsciiString(getTitle(aTable->GetRowTitle(i + 1))).ToCString());
+ aTitles[i] = CORBA::string_dup(TCollection_AsciiString(aTable->GetRowTitle(i + 1)).ToCString());
return aTitles._retn();
}
void SALOMEDS_AttributeTableOfReal_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle)
throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch (ATR_IncorrectIndex);
CheckLocked();
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
CORBA::String_var aStr = CORBA::string_dup(theTitle);
aTable->SetColumnTitle(theIndex, TCollection_ExtendedString(aStr));
void SALOMEDS_AttributeTableOfReal_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles)
throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATR_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
for (int i = 0; i < theTitles.length(); i++) {
- SetColumnTitle(i + 1, theTitles[i]);
+ aTable->SetColumnTitle(i + 1, (char*)theTitles[i].in());
}
}
-SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetColumnTitles() {
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetColumnTitles()
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq;
aTitles->length(aTable->GetNbColumns());
for(int i = 0; i < aTitles->length(); i++)
void SALOMEDS_AttributeTableOfReal_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit)
throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch (ATR_IncorrectIndex);
CheckLocked();
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
- CORBA::String_var aStr = CORBA::string_dup(theUnit);
- TCollection_ExtendedString aTitle = getTitle(aTable->GetRowTitle(theIndex));
- TCollection_ExtendedString aUnit(aStr);
- aTitle += SEPARATOR;
- aTitle += aUnit;
- aTable->SetRowTitle(theIndex, aTitle);
+ aTable->SetRowUnit(theIndex, TCollection_ExtendedString((char*)theUnit));
}
void SALOMEDS_AttributeTableOfReal_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits)
throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch (ATR_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
for (int i = 0; i < theUnits.length(); i++) {
- SetRowUnit(i + 1, theUnits[i]);
+ aTable->SetRowUnit(i + 1, (char*)theUnits[i].in());
}
}
-SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetRowUnits() {
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetRowUnits()
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
SALOMEDS::StringSeq_var aUnits = new SALOMEDS::StringSeq;
aUnits->length(aTable->GetNbRows());
for(int i = 0; i < aUnits->length(); i++)
- aUnits[i] = CORBA::string_dup(TCollection_AsciiString(getUnit(aTable->GetRowTitle(i + 1))).ToCString());
+ aUnits[i] = CORBA::string_dup(TCollection_AsciiString(aTable->GetRowTitle(i + 1)).ToCString());
return aUnits._retn();
}
-CORBA::Long SALOMEDS_AttributeTableOfReal_i::GetNbRows() {
- return Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr)->GetNbRows();
+CORBA::Long SALOMEDS_AttributeTableOfReal_i::GetNbRows()
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl)->GetNbRows();
}
-CORBA::Long SALOMEDS_AttributeTableOfReal_i::GetNbColumns() {
- return Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr)->GetNbColumns();
+
+CORBA::Long SALOMEDS_AttributeTableOfReal_i::GetNbColumns()
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl)->GetNbColumns();
}
void SALOMEDS_AttributeTableOfReal_i::AddRow(const SALOMEDS::DoubleSeq& theData)
throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATR_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
Handle(TColStd_HSequenceOfReal) aRow = new TColStd_HSequenceOfReal;
for (int i = 0; i < theData.length(); i++) aRow->Append(theData[i]);
void SALOMEDS_AttributeTableOfReal_i::SetRow(CORBA::Long theRow, const SALOMEDS::DoubleSeq& theData)
throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATR_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
Handle(TColStd_HSequenceOfReal) aRow = new TColStd_HSequenceOfReal;
for (int i = 0; i < theData.length(); i++) aRow->Append(theData[i]);
SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetRow(CORBA::Long theRow)
throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATR_IncorrectIndex);
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
SALOMEDS::DoubleSeq_var CorbaSeq = new SALOMEDS::DoubleSeq;
void SALOMEDS_AttributeTableOfReal_i::AddColumn(const SALOMEDS::DoubleSeq& theData)
throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATR_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
Handle(TColStd_HSequenceOfReal) aColumn = new TColStd_HSequenceOfReal;
for (int i = 0; i < theData.length(); i++) aColumn->Append(theData[i]);
void SALOMEDS_AttributeTableOfReal_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::DoubleSeq& theData)
throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATR_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
Handle(TColStd_HSequenceOfReal) aColumn = new TColStd_HSequenceOfReal;
for (int i = 0; i < theData.length(); i++) aColumn->Append(theData[i]);
SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetColumn(CORBA::Long theColumn)
throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATR_IncorrectIndex);
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
SALOMEDS::DoubleSeq_var CorbaSeq = new SALOMEDS::DoubleSeq;
void SALOMEDS_AttributeTableOfReal_i::PutValue(CORBA::Double theValue, CORBA::Long theRow, CORBA::Long theColumn)
throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATR_IncorrectIndex);
CheckLocked();
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
aTable->PutValue(theValue, theRow, theColumn);
}
-CORBA::Boolean SALOMEDS_AttributeTableOfReal_i::HasValue(CORBA::Long theRow, CORBA::Long theColumn) {
- return Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr)->HasValue(theRow, theColumn);
+CORBA::Boolean SALOMEDS_AttributeTableOfReal_i::HasValue(CORBA::Long theRow, CORBA::Long theColumn)
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl)->HasValue(theRow, theColumn);
}
CORBA::Double SALOMEDS_AttributeTableOfReal_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn)
throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATR_IncorrectIndex);
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
CORBA::Double aValue;
SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::GetRowSetIndices(CORBA::Long theRow)
{
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
void SALOMEDS_AttributeTableOfReal_i::SetNbColumns(CORBA::Long theNbColumns)
{
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
aTable->SetNbColumns(theNbColumns);
}
bool SALOMEDS_AttributeTableOfReal_i::ReadFromFile(const SALOMEDS::TMPFile& theStream)
{
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
istrstream aStream((char*)&theStream[0], theStream.length());
return aTable->RestoreFromString(aStream);
SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfReal_i::SaveToFile()
{
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_impl);
ostrstream ostr;
string aString;
return aStreamFile._retn();
}
-
-char* SALOMEDS_AttributeTableOfReal_i::Store() {
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
-
- ostrstream ostr;
- aTable->ConvertToString(ostr);
- string aString = ostr.rdbuf()->str();
-
- CORBA::String_var aBuffer = CORBA::string_dup(aString.c_str());
- return aBuffer._retn();
-}
-
-void SALOMEDS_AttributeTableOfReal_i::Restore(const char* value) {
- Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
-
- istrstream aStream(value, strlen(value));
- aTable->RestoreFromString(aStream);
-}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
// File : SALOMEDS_AttributeTableOfReal_i.hxx
// Author : Michael Ponikarov
// Module : SALOME
-// $Header$
#ifndef SALOMEDS_AttributeTableOfReal_i_HeaderFile
#define SALOMEDS_AttributeTableOfReal_i_HeaderFile
-#include "SALOMEDS_TableOfRealAttribute.hxx"
-#include "SALOMEDS_GenericAttribute_i.hxx"
-
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-DEFINE_DERIVED_ATTR(AttributeTableOfReal,SALOMEDS_TableOfRealAttribute,true);
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeTableOfReal.hxx"
-class SALOMEDS_AttributeTableOfReal_i:
- public virtual POA_SALOMEDS::AttributeTableOfReal,
- public virtual SALOMEDS_TAttributeTableOfReal_i
-{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeTableOfReal,SALOMEDS_TableOfRealAttribute);
+class SALOMEDS_AttributeTableOfReal_i: public virtual POA_SALOMEDS::AttributeTableOfReal,
+ public virtual SALOMEDS_GenericAttribute_i {
+
public:
- virtual void SetTitle(const char* theTitle);
+
+ SALOMEDS_AttributeTableOfReal_i(const Handle(SALOMEDSImpl_AttributeTableOfReal)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ ~SALOMEDS_AttributeTableOfReal_i() {};
+
+ virtual void SetTitle(const char* theTitle);
virtual char* GetTitle();
virtual void SetRowTitle(CORBA::Long theIndex, const char* theTitle)
throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex);
virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream);
virtual SALOMEDS::TMPFile* SaveToFile();
- virtual char* Store();
- virtual void Restore(const char*);
-
};
#endif
--- /dev/null
+// File : SALOMEDS_AttributeTableOfString.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeTableOfString.hxx"
+
+#include <string>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TColStd_HSequenceOfInteger.hxx>
+#include <TColStd_HSequenceOfReal.hxx>
+#include <TColStd_HSequenceOfExtendedString.hxx>
+
+SALOMEDS_AttributeTableOfString
+::SALOMEDS_AttributeTableOfString(const Handle(SALOMEDSImpl_AttributeTableOfString)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeTableOfString::SALOMEDS_AttributeTableOfString(SALOMEDS::AttributeTableOfString_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeTableOfString::~SALOMEDS_AttributeTableOfString()
+{}
+
+
+void SALOMEDS_AttributeTableOfString::SetTitle(const std::string& theTitle)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetTitle((char*)theTitle.c_str());
+ else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetTitle(theTitle.c_str());
+}
+
+std::string SALOMEDS_AttributeTableOfString::GetTitle()
+{
+ std::string aStr;
+ if(_isLocal)
+ aStr = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetTitle()).ToCString();
+ else aStr = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetTitle();
+ return aStr;
+}
+
+void SALOMEDS_AttributeTableOfString::SetRowTitle(int theIndex, const std::string& theTitle)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetRowTitle(theIndex,
+ (char*)theTitle.c_str());
+ else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
+}
+
+void SALOMEDS_AttributeTableOfString::SetRowTitles(const std::vector<std::string>& theTitles)
+{
+ CheckLocked();
+ int aLength = theTitles.size(), i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
+ for(i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str());
+ Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetRowTitles(aSeq);
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
+ aSeq->length(aLength);
+ for(i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str();
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowTitles(aSeq);
+ }
+
+}
+
+std::vector<std::string> SALOMEDS_AttributeTableOfString::GetRowTitles()
+{
+ std::vector<std::string> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aSeq;
+ aSeq = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetRowTitles();
+ aLength = aSeq->Length();
+ for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowTitles();
+ aLength = aSeq->length();
+ for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
+ }
+ return aVector;
+}
+
+void SALOMEDS_AttributeTableOfString::SetColumnTitle(int theIndex, const std::string& theTitle)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetColumnTitle(theIndex,
+ (char*)theTitle.c_str());
+ else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
+}
+
+void SALOMEDS_AttributeTableOfString::SetColumnTitles(const std::vector<std::string>& theTitles)
+{
+ CheckLocked();
+ int aLength = theTitles.size(), i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
+ for(i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str());
+ Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetColumnTitles(aSeq);
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
+ aSeq->length(aLength);
+ for(i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str();
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetColumnTitles(aSeq);
+ }
+}
+
+std::vector<std::string> SALOMEDS_AttributeTableOfString::GetColumnTitles()
+{
+ std::vector<std::string> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aSeq;
+ aSeq = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetColumnTitles();
+ aLength = aSeq->Length();
+ for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetColumnTitles();
+ aLength = aSeq->length();
+ for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
+ }
+ return aVector;
+}
+
+void SALOMEDS_AttributeTableOfString::SetRowUnit(int theIndex, const std::string& theUnit)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetRowUnit(theIndex,
+ (char*)theUnit.c_str());
+ else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
+}
+
+void SALOMEDS_AttributeTableOfString::SetRowUnits(const std::vector<std::string>& theUnits)
+{
+ CheckLocked();
+ int aLength = theUnits.size(), i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
+ for(i = 0; i < aLength; i++) aSeq->Append((char*)theUnits[i].c_str());
+ Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetRowUnits(aSeq);
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
+ aSeq->length(aLength);
+ for(i = 0; i < aLength; i++) aSeq[i] = (char*)theUnits[i].c_str();
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowUnits(aSeq);
+ }
+}
+
+std::vector<std::string> SALOMEDS_AttributeTableOfString::GetRowUnits()
+{
+ std::vector<std::string> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aSeq;
+ aSeq = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetRowUnits();
+ aLength = aSeq->Length();
+ for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowUnits();
+ aLength = aSeq->length();
+ for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
+ }
+ return aVector;
+}
+
+int SALOMEDS_AttributeTableOfString::GetNbRows()
+{
+ int aNb;
+ if(_isLocal) aNb = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetNbRows();
+ else aNb = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetNbRows();
+ return aNb;
+}
+
+int SALOMEDS_AttributeTableOfString::GetNbColumns()
+{
+ int aNb;
+ if(_isLocal) aNb = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetNbColumns();
+ else aNb = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetNbColumns();
+ return aNb;
+
+}
+
+void SALOMEDS_AttributeTableOfString::AddRow(const std::vector<std::string>& theData)
+{
+ CheckLocked();
+ int aLength = theData.size(), i;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable;
+ aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl);
+ Handle(TColStd_HSequenceOfExtendedString) aRow = new TColStd_HSequenceOfExtendedString;
+ for (int i = 0; i < aLength; i++) aRow->Append((char*)theData[i].c_str());
+ try {
+ aTable->SetRowData(aTable->GetNbRows() + 1, aRow);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
+ }
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
+ aSeq->length(aLength);
+ for(i = 0; i < aLength; i++) aSeq[i] = (char*)theData[i].c_str();
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->AddRow(aSeq);
+ }
+}
+
+void SALOMEDS_AttributeTableOfString::SetRow(int theRow, const std::vector<std::string>& theData)
+{
+ CheckLocked();
+ int aLength = theData.size(), i;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable;
+ aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl);
+ Handle(TColStd_HSequenceOfExtendedString) aRow = new TColStd_HSequenceOfExtendedString;
+ for (int i = 0; i < aLength; i++) aRow->Append((char*)theData[i].c_str());
+ try {
+ aTable->SetRowData(theRow, aRow);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
+ }
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
+ aSeq->length(aLength);
+ for(i = 0; i < aLength; i++) aSeq[i] = (char*)theData[i].c_str();
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRow(theRow, aSeq);
+ }
+}
+
+std::vector<std::string> SALOMEDS_AttributeTableOfString::GetRow(int theRow)
+{
+ std::vector<std::string> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aRow;
+ aRow = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetRowData(theRow);
+ aLength = aRow->Length();
+ for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aRow->Value(i)).ToCString());
+ }
+ else {
+ SALOMEDS::StringSeq_var aRow = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRow(theRow);
+ for(i = 0; i < aLength; i++) aVector.push_back((char*)aRow[i].in());
+ }
+
+ return aVector;
+}
+
+void SALOMEDS_AttributeTableOfString::AddColumn(const std::vector<std::string>& theData)
+{
+ CheckLocked();
+ int aLength = theData.size(), i;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable;
+ aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl);
+ Handle(TColStd_HSequenceOfExtendedString) aColumn = new TColStd_HSequenceOfExtendedString;
+ for (int i = 0; i < aLength; i++) aColumn->Append((char*)theData[i].c_str());
+ try {
+ aTable->SetColumnData(aTable->GetNbColumns() + 1, aColumn);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
+ }
+ }
+ else {
+ SALOMEDS::StringSeq_var aColumn = new SALOMEDS::StringSeq();
+ aColumn->length(aLength);
+ for(i = 0; i < aLength; i++) aColumn[i] = (char*)theData[i].c_str();
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->AddColumn(aColumn);
+ }
+}
+
+void SALOMEDS_AttributeTableOfString::SetColumn(int theColumn, const std::vector<std::string>& theData)
+{
+ CheckLocked();
+ int aLength = theData.size(), i;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable;
+ aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl);
+ Handle(TColStd_HSequenceOfExtendedString) aColumn = new TColStd_HSequenceOfExtendedString;
+ for (int i = 0; i < aLength; i++) aColumn->Append((char*)theData[i].c_str());
+ try {
+ aTable->SetRowData(theColumn, aColumn);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
+ }
+ }
+ else {
+ SALOMEDS::StringSeq_var aColumn = new SALOMEDS::StringSeq();
+ aColumn->length(aLength);
+ for(i = 0; i < aLength; i++) aColumn[i] = (char*)theData[i].c_str();
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRow(theColumn, aColumn);
+ }
+}
+
+std::vector<std::string> SALOMEDS_AttributeTableOfString::GetColumn(int theColumn)
+{
+ std::vector<std::string> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfExtendedString) aColumn;
+ aColumn = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetColumnData(theColumn);
+ aLength = aColumn->Length();
+ for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aColumn->Value(i)).ToCString());
+ }
+ else {
+ SALOMEDS::StringSeq_var aColumn = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetColumn(theColumn);
+ for(i = 0; i < aLength; i++) aVector.push_back(aColumn[i].in());
+ }
+ return aVector;
+}
+
+void SALOMEDS_AttributeTableOfString::PutValue(const std::string& theValue, int theRow, int theColumn)
+{
+ CheckLocked();
+ if(_isLocal) {
+ try {
+ Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->PutValue((char*)theValue.c_str(),
+ theRow,
+ theColumn);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->PutValue(theValue.c_str(), theRow, theColumn);
+ }
+}
+
+bool SALOMEDS_AttributeTableOfString::HasValue(int theRow, int theColumn)
+{
+ bool ret;
+ if(_isLocal) ret = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->HasValue(theRow, theColumn);
+ else ret = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->HasValue(theRow, theColumn);
+ return ret;
+}
+
+std::string SALOMEDS_AttributeTableOfString::GetValue(int theRow, int theColumn)
+{
+ std::string aValue;
+ if(_isLocal) {
+ try {
+ aValue =
+ TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetValue(theRow,
+ theColumn)).ToCString();
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
+ }
+ }
+ else {
+ aValue = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetValue(theRow, theColumn);
+ }
+ return aValue;
+}
+
+std::vector<int> SALOMEDS_AttributeTableOfString::GetRowSetIndices(int theRow)
+{
+ std::vector<int> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfInteger) aSet;
+ aSet = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetSetRowIndices(theRow);
+ aLength = aSet->Length();
+ for(i = 1; i<= aLength; i++) aVector.push_back(aSet->Value(i));
+ }
+ else {
+ SALOMEDS::LongSeq_var aSet = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowSetIndices(theRow);
+ for(i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
+ }
+ return aVector;
+}
+
+void SALOMEDS_AttributeTableOfString::SetNbColumns(int theNbColumns)
+{
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetNbColumns(theNbColumns);
+ else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetNbColumns(theNbColumns);
+}
--- /dev/null
+// File : SALOMEDS_AttributeTableOfString.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeTableOfString_HeaderFile
+#define SALOMEDS_AttributeTableOfString_HeaderFile
+
+#include "SALOMEDSClient_AttributeTableOfString.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeTableOfString.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include <vector>
+
+class SALOMEDS_AttributeTableOfString: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeTableOfString
+{
+public:
+ SALOMEDS_AttributeTableOfString(const Handle(SALOMEDSImpl_AttributeTableOfString)& theAttr);
+ SALOMEDS_AttributeTableOfString(SALOMEDS::AttributeTableOfString_ptr theAttr);
+ ~SALOMEDS_AttributeTableOfString();
+
+ virtual void SetTitle(const std::string& theTitle);
+ virtual std::string GetTitle();
+ virtual void SetRowTitle(int theIndex, const std::string& theTitle);
+ virtual void SetRowTitles(const std::vector<std::string>& theTitles);
+ virtual std::vector<std::string> GetRowTitles();
+ virtual void SetColumnTitle(int theIndex, const std::string& theTitle);
+ virtual void SetColumnTitles(const std::vector<std::string>& theTitles);
+ virtual std::vector<std::string> GetColumnTitles();
+
+ virtual void SetRowUnit(int theIndex, const std::string& theUnit);
+ virtual void SetRowUnits(const std::vector<std::string>& theUnits);
+ virtual std::vector<std::string> GetRowUnits();
+
+ virtual int GetNbRows();
+ virtual int GetNbColumns();
+ virtual void AddRow(const std::vector<std::string>& theData);
+ virtual void SetRow(int theRow, const std::vector<std::string>& theData);
+ virtual std::vector<std::string> GetRow(int theRow);
+ virtual void AddColumn(const std::vector<std::string>& theData);
+ virtual void SetColumn(int theColumn, const std::vector<std::string>& theData);
+ virtual std::vector<std::string> GetColumn(int theColumn);
+ virtual void PutValue(const std::string& theValue, int theRow, int theColumn);
+ virtual bool HasValue(int theRow, int theColumn);
+ virtual std::string GetValue(int theRow, int theColumn);
+
+ virtual std::vector<int> GetRowSetIndices(int theRow);
+ virtual void SetNbColumns(int theNbColumns);
+
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
// File : SALOMEDS_AttributeTableOfString_i.cxx
-// Author : Sergey Ruin
+// Author : Sergey RUIN
// Module : SALOME
+using namespace std;
#include <TCollection_ExtendedString.hxx>
#include <TCollection_AsciiString.hxx>
-#include <TColStd_HSequenceOfExtendedString.hxx>
+#include "SALOMEDS_AttributeTableOfString_i.hxx"
+#include "SALOMEDS.hxx"
+
+#include <TColStd_HSequenceOfExtendedString.hxx>
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx>
#include <strstream>
#include <string>
-#include "SALOMEDS_AttributeTableOfString_i.hxx"
-
#include "Utils_ExceptHandlers.hxx"
-
UNEXPECT_CATCH(ATS_IncorrectIndex, SALOMEDS::AttributeTableOfString::IncorrectIndex);
UNEXPECT_CATCH(ATS_IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectArgumentLength);
-using namespace std;
-#define SEPARATOR '\1'
-
-static TCollection_ExtendedString getUnit(TCollection_ExtendedString theString)
-{
- TCollection_ExtendedString aString(theString);
- int aPos = aString.Search(SEPARATOR);
- if(aPos <= 0 || aPos == aString.Length() ) return TCollection_ExtendedString();
- return aString.Split(aPos);
-}
-
-static TCollection_ExtendedString getTitle(TCollection_ExtendedString theString)
+void SALOMEDS_AttributeTableOfString_i::SetTitle(const char* theTitle)
{
- TCollection_ExtendedString aString(theString);
- int aPos = aString.Search(SEPARATOR);
- if(aPos < 1) return aString;
- if(aPos == 1) return TCollection_ExtendedString();
- aString.Split(aPos-1);
- return aString;
-}
-
-void SALOMEDS_AttributeTableOfString_i::SetTitle(const char* theTitle) {
+ SALOMEDS::Locker lock;
CheckLocked();
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
CORBA::String_var aStr = CORBA::string_dup(theTitle);
aTable->SetTitle(TCollection_ExtendedString(aStr));
}
-char* SALOMEDS_AttributeTableOfString_i::GetTitle() {
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+char* SALOMEDS_AttributeTableOfString_i::GetTitle()
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(aTable->GetTitle()).ToCString());
return c_s._retn();
}
void SALOMEDS_AttributeTableOfString_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle)
throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectIndex);
CheckLocked();
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
- CORBA::String_var aStr = CORBA::string_dup(theTitle);
- TCollection_ExtendedString aTitle(aStr);
- TCollection_ExtendedString aUnit = getUnit(aTable->GetRowTitle(theIndex));
- if(aUnit.Length() > 0) {
- aTitle += SEPARATOR;
- aTitle += aUnit;
- }
- aTable->SetRowTitle(theIndex, aTitle);
+ aTable->SetRowTitle(theIndex, TCollection_ExtendedString((char*)theTitle));
}
void SALOMEDS_AttributeTableOfString_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles)
throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
for (int i = 0; i < theTitles.length(); i++) {
- SetRowTitle(i + 1, CORBA::string_dup(theTitles[i]));
+ aTable->SetRowTitle(i + 1, TCollection_ExtendedString((char*)theTitles[i].in()));
}
}
-SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRowTitles() {
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRowTitles()
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq;
aTitles->length(aTable->GetNbRows());
for(int i = 0; i < aTitles->length(); i++)
- aTitles[i] = CORBA::string_dup(TCollection_AsciiString(getTitle(aTable->GetRowTitle(i + 1))).ToCString());
+ aTitles[i] =CORBA::string_dup(TCollection_AsciiString(aTable->GetRowTitle(i + 1)).ToCString());
return aTitles._retn();
}
void SALOMEDS_AttributeTableOfString_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle)
throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectIndex);
CheckLocked();
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
- CORBA::String_var aStr = CORBA::string_dup(theTitle);
- aTable->SetColumnTitle(theIndex, TCollection_ExtendedString(aStr));
+ aTable->SetColumnTitle(theIndex, TCollection_ExtendedString((char*)theTitle));
}
void SALOMEDS_AttributeTableOfString_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles)
throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
for (int i = 0; i < theTitles.length(); i++) {
- SetColumnTitle(i + 1, CORBA::string_dup(theTitles[i]));
+ aTable->SetColumnTitle(i + 1, TCollection_ExtendedString((char*)theTitles[i].in()));
}
}
-SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetColumnTitles() {
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetColumnTitles()
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq;
aTitles->length(aTable->GetNbColumns());
for(int i = 0; i < aTitles->length(); i++)
void SALOMEDS_AttributeTableOfString_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit)
throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectIndex);
CheckLocked();
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
- CORBA::String_var aStr = CORBA::string_dup(theUnit);
- TCollection_ExtendedString aTitle = getTitle(aTable->GetRowTitle(theIndex));
- TCollection_ExtendedString aUnit(aStr);
- aTitle += SEPARATOR;
- aTitle += aUnit;
- aTable->SetRowTitle(theIndex, aTitle);
+ aTable->SetRowUnit(theIndex, TCollection_ExtendedString((char*)theUnit));
}
void SALOMEDS_AttributeTableOfString_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits)
throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
for (int i = 0; i < theUnits.length(); i++) {
- SetRowUnit(i + 1, CORBA::string_dup(theUnits[i]));
+ aTable->SetRowUnit(i + 1, TCollection_ExtendedString((char*)theUnits[i].in()));
}
}
-SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRowUnits() {
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRowUnits()
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
SALOMEDS::StringSeq_var aUnits = new SALOMEDS::StringSeq;
aUnits->length(aTable->GetNbRows());
for(int i = 0; i < aUnits->length(); i++)
- aUnits[i] = CORBA::string_dup(TCollection_AsciiString(getUnit(aTable->GetRowTitle(i + 1))).ToCString());
+ aUnits[i] = CORBA::string_dup(TCollection_AsciiString(aTable->GetRowTitle(i + 1)).ToCString());
return aUnits._retn();
}
-CORBA::Long SALOMEDS_AttributeTableOfString_i::GetNbRows() {
- return Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr)->GetNbRows();
+CORBA::Long SALOMEDS_AttributeTableOfString_i::GetNbRows()
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl)->GetNbRows();
}
-CORBA::Long SALOMEDS_AttributeTableOfString_i::GetNbColumns() {
- return Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr)->GetNbColumns();
+
+CORBA::Long SALOMEDS_AttributeTableOfString_i::GetNbColumns()
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl)->GetNbColumns();
}
void SALOMEDS_AttributeTableOfString_i::AddRow(const SALOMEDS::StringSeq& theData)
throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
Handle(TColStd_HSequenceOfExtendedString) aRow = new TColStd_HSequenceOfExtendedString;
for (int i = 0; i < theData.length(); i++) aRow->Append(TCollection_AsciiString(CORBA::string_dup(theData[i])));
void SALOMEDS_AttributeTableOfString_i::SetRow(CORBA::Long theRow, const SALOMEDS::StringSeq& theData)
throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
Handle(TColStd_HSequenceOfExtendedString) aRow = new TColStd_HSequenceOfExtendedString;
for (int i = 0; i < theData.length(); i++) aRow->Append(TCollection_AsciiString(CORBA::string_dup(theData[i])));
SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRow(CORBA::Long theRow)
throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectIndex);
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
SALOMEDS::StringSeq_var CorbaSeq = new SALOMEDS::StringSeq;
void SALOMEDS_AttributeTableOfString_i::AddColumn(const SALOMEDS::StringSeq& theData)
throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
Handle(TColStd_HSequenceOfExtendedString) aColumn = new TColStd_HSequenceOfExtendedString;
for (int i = 0; i < theData.length(); i++) aColumn->Append(TCollection_AsciiString(CORBA::string_dup(theData[i])));
void SALOMEDS_AttributeTableOfString_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::StringSeq& theData)
throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectArgumentLength);
CheckLocked();
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
Handle(TColStd_HSequenceOfExtendedString) aColumn = new TColStd_HSequenceOfExtendedString;
for (int i = 0; i < theData.length(); i++) aColumn->Append(TCollection_AsciiString(CORBA::string_dup(theData[i])));
SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetColumn(CORBA::Long theColumn)
throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectIndex);
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
SALOMEDS::StringSeq_var CorbaSeq = new SALOMEDS::StringSeq;
void SALOMEDS_AttributeTableOfString_i::PutValue(const char* theValue, CORBA::Long theRow, CORBA::Long theColumn)
throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectIndex);
CheckLocked();
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
char* aValue = CORBA::string_dup(theValue);
aTable->PutValue(aValue, theRow, theColumn);
}
-CORBA::Boolean SALOMEDS_AttributeTableOfString_i::HasValue(CORBA::Long theRow, CORBA::Long theColumn) {
- return Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr)->HasValue(theRow, theColumn);
+CORBA::Boolean SALOMEDS_AttributeTableOfString_i::HasValue(CORBA::Long theRow, CORBA::Long theColumn)
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl)->HasValue(theRow, theColumn);
}
char* SALOMEDS_AttributeTableOfString_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn)
throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectIndex);
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
TCollection_AsciiString aValue;
SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfString_i::GetRowSetIndices(CORBA::Long theRow)
{
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
void SALOMEDS_AttributeTableOfString_i::SetNbColumns(CORBA::Long theNbColumns)
{
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
aTable->SetNbColumns(theNbColumns);
}
bool SALOMEDS_AttributeTableOfString_i::ReadFromFile(const SALOMEDS::TMPFile& theStream)
{
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
istrstream aStream((char*)&theStream[0], theStream.length());
return aTable->RestoreFromString(aStream);
SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfString_i::SaveToFile()
{
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_impl);
ostrstream ostr;
aTable->ConvertToString(ostr);
return aStreamFile._retn();
}
-char* SALOMEDS_AttributeTableOfString_i::Store() {
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
-
- ostrstream ostr;
- aTable->ConvertToString(ostr);
- string aString = ostr.rdbuf()->str();
-
- CORBA::String_var aBuffer = CORBA::string_dup(aString.c_str());
- return aBuffer._retn();
-}
-
-void SALOMEDS_AttributeTableOfString_i::Restore(const char* value) {
- Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
-
- istrstream aStream(value, strlen(value));
- aTable->RestoreFromString(aStream);
-}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
// File : SALOMEDS_AttributeTableOfString_i.hxx
-// Author : Sergey Ruin
+// Author : Sergey RUIN
// Module : SALOME
#ifndef SALOMEDS_AttributeTableOfString_i_HeaderFile
#define SALOMEDS_AttributeTableOfString_i_HeaderFile
-#include "SALOMEDS_TableOfStringAttribute.hxx"
-#include "SALOMEDS_GenericAttribute_i.hxx"
-
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-DEFINE_DERIVED_ATTR(AttributeTableOfString,SALOMEDS_TableOfStringAttribute,true);
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeTableOfString.hxx"
-class SALOMEDS_AttributeTableOfString_i:
- public virtual POA_SALOMEDS::AttributeTableOfString,
- public virtual SALOMEDS_TAttributeTableOfString_i
-{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeTableOfString,SALOMEDS_TableOfStringAttribute);
+class SALOMEDS_AttributeTableOfString_i: public virtual POA_SALOMEDS::AttributeTableOfString,
+ public virtual SALOMEDS_GenericAttribute_i {
+
public:
+
+ SALOMEDS_AttributeTableOfString_i(const Handle(SALOMEDSImpl_AttributeTableOfString)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ ~SALOMEDS_AttributeTableOfString_i() {};
+
virtual void SetTitle(const char* theTitle);
virtual char* GetTitle();
virtual void SetRowTitle(CORBA::Long theIndex, const char* theTitle)
virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream);
virtual SALOMEDS::TMPFile* SaveToFile();
- char* Store();
- void Restore(const char*);
-
};
#endif
--- /dev/null
+// File : SALOMEDS_AttributeTarget.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeTarget.hxx"
+
+#include <TColStd_HSequenceOfTransient.hxx>
+
+#include "SALOMEDSImpl_SObject.hxx"
+#include "SALOMEDS_SObject.hxx"
+
+
+SALOMEDS_AttributeTarget::SALOMEDS_AttributeTarget(const Handle(SALOMEDSImpl_AttributeTarget)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeTarget::SALOMEDS_AttributeTarget(SALOMEDS::AttributeTarget_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeTarget::~SALOMEDS_AttributeTarget()
+{}
+
+void SALOMEDS_AttributeTarget::Add(const _PTR(SObject)& theObject)
+{
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
+
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeTarget)::DownCast(_local_impl)->Add(aSO->GetLocalImpl());
+ else SALOMEDS::AttributeTarget::_narrow(_corba_impl)->Add(aSO->GetCORBAImpl());
+}
+
+std::vector<_PTR(SObject)> SALOMEDS_AttributeTarget::Get()
+{
+ std::vector<_PTR(SObject)> aVector;
+ int aLength, i;
+ SALOMEDSClient_SObject* aSO = NULL;
+
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfTransient) aSeq = Handle(SALOMEDSImpl_AttributeTarget)::DownCast(_local_impl)->Get();
+ aLength = aSeq->Length();
+ for(i=1; i<=aLength; i++) {
+ aSO = new SALOMEDS_SObject(Handle(SALOMEDSImpl_SObject)::DownCast(aSeq->Value(i)));
+ aVector.push_back(_PTR(SObject)(aSO));
+ }
+ }
+ else {
+ SALOMEDS::Study::ListOfSObject_var aSeq = SALOMEDS::AttributeTarget::_narrow(_corba_impl)->Get();
+ aLength = aSeq->length();
+ aSO = new SALOMEDS_SObject(aSeq[i].in());
+ for(i = 0; i<aLength; i++) aVector.push_back(_PTR(SObject)(aSO));
+ }
+
+ return aVector;
+}
+
+void SALOMEDS_AttributeTarget::Remove(const _PTR(SObject)& theObject)
+{
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
+
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeTarget)::DownCast(_local_impl)->Remove(aSO->GetLocalImpl());
+ else SALOMEDS::AttributeTarget::_narrow(_corba_impl)->Remove(aSO->GetCORBAImpl());
+}
+
--- /dev/null
+// File : SALOMEDS_AttributeTarget.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeTarget_HeaderFile
+#define SALOMEDS_AttributeTarget_HeaderFile
+
+#include <vector>
+
+#include "SALOMEDSClient.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeTarget.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributeTarget: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeTarget
+{
+public:
+ SALOMEDS_AttributeTarget(const Handle(SALOMEDSImpl_AttributeTarget)& theAttr);
+ SALOMEDS_AttributeTarget(SALOMEDS::AttributeTarget_ptr theAttr);
+ ~SALOMEDS_AttributeTarget();
+
+ virtual void Add(const _PTR(SObject)& theObject);
+ virtual std::vector<_PTR(SObject)> Get();
+ virtual void Remove(const _PTR(SObject)& theObject);
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeTarget_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
-#include <TDF_ListIteratorOfLabelList.hxx>
-#include <TDF_LabelList.hxx>
-#include <TDF_Label.hxx>
-#include <TDF_Tool.hxx>
+using namespace std;
#include "SALOMEDS_AttributeTarget_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
+#include "SALOMEDSImpl_SObject.hxx"
+#include "SALOMEDSImpl_Study.hxx"
+#include "SALOMEDS.hxx"
-using namespace std;
+#include <TColStd_HSequenceOfTransient.hxx>
-void SALOMEDS_AttributeTarget_i::Add(SALOMEDS::SObject_ptr anObject)
+void SALOMEDS_AttributeTarget_i::Add(SALOMEDS::SObject_ptr anObject)
{
+ SALOMEDS::Locker lock;
TDF_Label aLabel;
- TDF_Tool::Label(_myAttr->Label().Data(),anObject->GetID(),aLabel,1);
- _myAttr->Append(aLabel);
+ TDF_Tool::Label(_impl->Label().Data(),anObject->GetID(),aLabel,1);
+ (Handle(SALOMEDSImpl_AttributeTarget)::DownCast(_impl))->Add(SALOMEDSImpl_Study::SObject(aLabel));
}
-SALOMEDS::Study::ListOfSObject* SALOMEDS_AttributeTarget_i::Get() {
- TDF_LabelList aLList;
-
- _myAttr->Get(aLList);
+SALOMEDS::Study::ListOfSObject* SALOMEDS_AttributeTarget_i::Get()
+{
+ SALOMEDS::Locker lock;
+ Handle(TColStd_HSequenceOfTransient) aSeq = (Handle(SALOMEDSImpl_AttributeTarget)::DownCast(_impl))->Get();
SALOMEDS::Study::ListOfSObject_var aSList = new SALOMEDS::Study::ListOfSObject;
-
- if (aLList.Extent() == 0)
- return aSList._retn();
-
- aSList->length(aLList.Extent());
- TDF_ListIteratorOfLabelList anIter(aLList);
- SALOMEDS_Study_i* aStudy = _mySObject->GetStudyServant();
- for(int index = 0; anIter.More(); anIter.Next(), index++){
- const TDF_Label& aLabel = anIter.Value();
- aSList[index] = SALOMEDS_SObject_i::NewRef(aStudy,aLabel)._retn();
+ int aLength = aSeq->Length(), i;
+ if (aLength == 0) return aSList._retn();
+ aSList->length(aLength);
+ for(i=1; i <=aLength; i++) {
+ SALOMEDS::SObject_var anSO = SALOMEDS_SObject_i::New(Handle(SALOMEDSImpl_SObject)::DownCast(aSeq->Value(i)), _orb);
+ aSList[i-1] = anSO;
}
return aSList._retn();
}
-void SALOMEDS_AttributeTarget_i::Remove(SALOMEDS::SObject_ptr anObject) {
+void SALOMEDS_AttributeTarget_i::Remove(SALOMEDS::SObject_ptr anObject)
+{
+ SALOMEDS::Locker lock;
TDF_Label aLabel;
- CORBA::String_var anID = anObject->GetID();
- TDF_Tool::Label(_myAttr->Label().Data(),anID.inout(),aLabel,1);
- _myAttr->Remove(aLabel);
+ TDF_Tool::Label(_impl->Label().Data(),anObject->GetID(),aLabel,1);
+ (Handle(SALOMEDSImpl_AttributeTarget)::DownCast(_impl))->Remove(SALOMEDSImpl_Study::SObject(aLabel));
}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeTarget_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header:
#ifndef SALOMEDS_AttributeTarget_i_HeaderFile
#define SALOMEDS_AttributeTarget_i_HeaderFile
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-
-#include "SALOMEDS_TargetAttribute.hxx"
#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeTarget.hxx"
-DEFINE_DERIVED_ATTR(AttributeTarget,SALOMEDS_TargetAttribute,false);
-
-class SALOMEDS_AttributeTarget_i:
- public virtual POA_SALOMEDS::AttributeTarget,
- public virtual SALOMEDS_TAttributeTarget_i
+class SALOMEDS_AttributeTarget_i: public virtual POA_SALOMEDS::AttributeTarget,
+ public virtual SALOMEDS_GenericAttribute_i
{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeTarget,SALOMEDS_TargetAttribute);
public:
+
+ SALOMEDS_AttributeTarget_i(const Handle(SALOMEDSImpl_AttributeTarget)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ ~SALOMEDS_AttributeTarget_i() {};
+
virtual void Add(SALOMEDS::SObject_ptr anObject) ;
virtual SALOMEDS::Study::ListOfSObject* Get();
virtual void Remove(SALOMEDS::SObject_ptr anObject);
-
};
-
-
#endif
--- /dev/null
+// File : SALOMEDS_AttributeTextColor.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeTextColor.hxx"
+
+#include <TColStd_HArray1OfReal.hxx>
+
+SALOMEDS_AttributeTextColor::SALOMEDS_AttributeTextColor(const Handle(SALOMEDSImpl_AttributeTextColor)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeTextColor::SALOMEDS_AttributeTextColor(SALOMEDS::AttributeTextColor_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeTextColor::~SALOMEDS_AttributeTextColor()
+{}
+
+
+STextColor SALOMEDS_AttributeTextColor::TextColor()
+{
+ STextColor aColor;
+ if(_isLocal) {
+ Handle(TColStd_HArray1OfReal) aSeq = Handle(SALOMEDSImpl_AttributeTextColor)::DownCast(_local_impl)->TextColor();
+ aColor.R = aSeq->Value(1);
+ aColor.G = aSeq->Value(2);
+ aColor.B = aSeq->Value(3);
+ }
+ else {
+ SALOMEDS::Color anImplColor = SALOMEDS::AttributeTextColor::_narrow(_corba_impl)->TextColor();
+ aColor.R = anImplColor.R;
+ aColor.G = anImplColor.G;
+ aColor.B = anImplColor.B;
+ }
+ return aColor;
+}
+
+void SALOMEDS_AttributeTextColor::SetTextColor(STextColor value)
+{
+ CheckLocked();
+ if(_isLocal) {
+ Handle(TColStd_HArray1OfReal) aSeq = new TColStd_HArray1OfReal(1, 3);
+ aSeq->SetValue(1, value.R);
+ aSeq->SetValue(2, value.G);
+ aSeq->SetValue(3, value.B);
+ Handle(SALOMEDSImpl_AttributeTextColor)::DownCast(_local_impl)->ChangeArray(aSeq);
+ }
+ else {
+ SALOMEDS::Color aColor;
+ aColor.R = value.R;
+ aColor.G = value.G;
+ aColor.B = value.B;
+ SALOMEDS::AttributeTextColor::_narrow(_corba_impl)->SetTextColor(aColor);
+ }
+}
--- /dev/null
+// File : SALOMEDS_AttributeTextColor.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeTextColor_HeaderFile
+#define SALOMEDS_AttributeTextColor_HeaderFile
+
+#include "SALOMEDSClient_AttributeTextColor.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeTextColor.hxx"
+#include "SALOMEDSClient_definitions.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include <vector>
+
+class SALOMEDS_AttributeTextColor: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeTextColor
+{
+public:
+ SALOMEDS_AttributeTextColor(const Handle(SALOMEDSImpl_AttributeTextColor)& theAttr);
+ SALOMEDS_AttributeTextColor(SALOMEDS::AttributeTextColor_ptr theAttr);
+ ~SALOMEDS_AttributeTextColor();
+
+ virtual STextColor TextColor();
+ virtual void SetTextColor(STextColor value);
+
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeTextColor_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
+using namespace std;
#include "SALOMEDS_AttributeTextColor_i.hxx"
+#include "SALOMEDS.hxx"
#include <TColStd_HArray1OfReal.hxx>
-using namespace std;
-
-SALOMEDS::Color SALOMEDS_AttributeTextColor_i::TextColor() {
+SALOMEDS::Color SALOMEDS_AttributeTextColor_i::TextColor()
+{
+ SALOMEDS::Locker lock;
SALOMEDS::Color TextColor;
- Handle(TColStd_HArray1OfReal) anArray = Handle(SALOMEDS_TextColorAttribute)::DownCast(_myAttr)->Array();
+ Handle(TColStd_HArray1OfReal) anArray = Handle(SALOMEDSImpl_AttributeTextColor)::DownCast(_impl)->TextColor();
if (anArray.IsNull() || anArray->Length()!=3) {
TextColor.R = 0;
TextColor.G = 0;
return TextColor;
}
-void SALOMEDS_AttributeTextColor_i::SetTextColor(const SALOMEDS::Color& value) {
+void SALOMEDS_AttributeTextColor_i::SetTextColor(const SALOMEDS::Color& value)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
Handle(TColStd_HArray1OfReal) anArray = new TColStd_HArray1OfReal(1,3);
anArray->SetValue(1, value.R);
anArray->SetValue(2, value.G);
anArray->SetValue(3, value.B);
- Handle(SALOMEDS_TextColorAttribute)::DownCast(_myAttr)->ChangeArray(anArray);
+ Handle(SALOMEDSImpl_AttributeTextColor)::DownCast(_impl)->ChangeArray(anArray);
}
-char* SALOMEDS_AttributeTextColor_i::Store() {
- SALOMEDS::Color aColor = TextColor();
- char *Val = new char[75];
- sprintf(Val, "%f %f %f", (float)aColor.R, (float)aColor.G, (float)aColor.B);
- return Val;
-}
-
-void SALOMEDS_AttributeTextColor_i::Restore(const char* value) {
- SALOMEDS::Color aColor;
- float r, g, b;
- sscanf(value, "%f %f %f", &r, &g, &b);
- aColor.R = r;
- aColor.G = g;
- aColor.B = b;
- SetTextColor(aColor);
-}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeTextColor_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
// $Header$
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-#include "SALOMEDS_TextColorAttribute.hxx"
#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeTextColor.hxx"
-DEFINE_DERIVED_ATTR(AttributeTextColor,SALOMEDS_TextColorAttribute,false);
-
-class SALOMEDS_AttributeTextColor_i:
- public virtual POA_SALOMEDS::AttributeTextColor,
- public virtual SALOMEDS_TAttributeTextColor_i
+class SALOMEDS_AttributeTextColor_i: public virtual POA_SALOMEDS::AttributeTextColor,
+ public virtual SALOMEDS_GenericAttribute_i
{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeTextColor,SALOMEDS_TextColorAttribute);
public:
+
+ SALOMEDS_AttributeTextColor_i(const Handle(SALOMEDSImpl_AttributeTextColor)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ ~SALOMEDS_AttributeTextColor_i() {};
+
SALOMEDS::Color TextColor();
void SetTextColor(const SALOMEDS::Color& value);
- char* Store();
- void Restore(const char*);
-
};
--- /dev/null
+// File : SALOMEDS_AttributeTextHighlightColor.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeTextHighlightColor.hxx"
+
+#include <TColStd_HArray1OfReal.hxx>
+
+SALOMEDS_AttributeTextHighlightColor::SALOMEDS_AttributeTextHighlightColor(const Handle(SALOMEDSImpl_AttributeTextHighlightColor)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeTextHighlightColor::SALOMEDS_AttributeTextHighlightColor(SALOMEDS::AttributeTextHighlightColor_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeTextHighlightColor::~SALOMEDS_AttributeTextHighlightColor()
+{}
+
+
+STextColor SALOMEDS_AttributeTextHighlightColor::TextHighlightColor()
+{
+ STextColor aColor;
+ if(_isLocal) {
+ Handle(TColStd_HArray1OfReal) aSeq;
+ aSeq = Handle(SALOMEDSImpl_AttributeTextHighlightColor)::DownCast(_local_impl)->TextHighlightColor();
+ aColor.R = aSeq->Value(1);
+ aColor.G = aSeq->Value(2);
+ aColor.B = aSeq->Value(3);
+ }
+ else {
+ SALOMEDS::Color anImplColor = SALOMEDS::AttributeTextHighlightColor::_narrow(_corba_impl)->TextHighlightColor();
+ aColor.R = anImplColor.R;
+ aColor.G = anImplColor.G;
+ aColor.B = anImplColor.B;
+ }
+ return aColor;
+}
+
+void SALOMEDS_AttributeTextHighlightColor::SetTextHighlightColor(STextColor value)
+{
+ if(_isLocal) {
+ Handle(TColStd_HArray1OfReal) aSeq = new TColStd_HArray1OfReal(1, 3);
+ aSeq->SetValue(1, value.R);
+ aSeq->SetValue(2, value.G);
+ aSeq->SetValue(3, value.B);
+ Handle(SALOMEDSImpl_AttributeTextHighlightColor)::DownCast(_local_impl)->ChangeArray(aSeq);
+ }
+ else {
+ SALOMEDS::Color aColor;
+ aColor.R = value.R;
+ aColor.G = value.G;
+ aColor.B = value.B;
+ SALOMEDS::AttributeTextHighlightColor::_narrow(_corba_impl)->SetTextHighlightColor(aColor);
+ }
+}
--- /dev/null
+// File : SALOMEDS_AttributeTextHighlightColor.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeTextHighlightColor_HeaderFile
+#define SALOMEDS_AttributeTextHighlightColor_HeaderFile
+
+#include "SALOMEDSClient_AttributeTextHighlightColor.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeTextHighlightColor.hxx"
+#include "SALOMEDSClient_definitions.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include <vector>
+
+class SALOMEDS_AttributeTextHighlightColor: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeTextHighlightColor
+{
+public:
+ SALOMEDS_AttributeTextHighlightColor(const Handle(SALOMEDSImpl_AttributeTextHighlightColor)& theAttr);
+ SALOMEDS_AttributeTextHighlightColor(SALOMEDS::AttributeTextHighlightColor_ptr theAttr);
+ ~SALOMEDS_AttributeTextHighlightColor();
+
+ virtual STextColor TextHighlightColor();
+ virtual void SetTextHighlightColor(STextColor value);
+
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeTextHighlightColor_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
+using namespace std;
#include "SALOMEDS_AttributeTextHighlightColor_i.hxx"
+#include "SALOMEDS.hxx"
#include <TColStd_HArray1OfReal.hxx>
-using namespace std;
-
-SALOMEDS::Color SALOMEDS_AttributeTextHighlightColor_i::TextHighlightColor() {
+SALOMEDS::Color SALOMEDS_AttributeTextHighlightColor_i::TextHighlightColor()
+{
+ SALOMEDS::Locker lock;
SALOMEDS::Color TextHighlightColor;
- Handle(TColStd_HArray1OfReal) anArray = Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(_myAttr)->Array();
+ Handle(TColStd_HArray1OfReal) anArray=Handle(SALOMEDSImpl_AttributeTextHighlightColor)::DownCast(_impl)->TextHighlightColor();
if (anArray.IsNull() || anArray->Length()!=3) {
TextHighlightColor.R = 0;
TextHighlightColor.G = 0;
return TextHighlightColor;
}
-void SALOMEDS_AttributeTextHighlightColor_i::SetTextHighlightColor(const SALOMEDS::Color& value) {
+void SALOMEDS_AttributeTextHighlightColor_i::SetTextHighlightColor(const SALOMEDS::Color& value)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
Handle(TColStd_HArray1OfReal) anArray = new TColStd_HArray1OfReal(1,3);
anArray->SetValue(1, value.R);
anArray->SetValue(2, value.G);
anArray->SetValue(3, value.B);
- Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(_myAttr)->ChangeArray(anArray);
-}
-
-char* SALOMEDS_AttributeTextHighlightColor_i::Store() {
- SALOMEDS::Color aColor = TextHighlightColor();
- char *Val = new char[75];
- sprintf(Val, "%f %f %f", (float)aColor.R, (float)aColor.G, (float)aColor.B);
- return Val;
-}
-
-void SALOMEDS_AttributeTextHighlightColor_i::Restore(const char* value) {
- SALOMEDS::Color aColor;
- float r, g, b;
- sscanf(value, "%f %f %f", &r, &g, &b);
- aColor.R = r;
- aColor.G = g;
- aColor.B = b;
- SetTextHighlightColor(aColor);
+ Handle(SALOMEDSImpl_AttributeTextHighlightColor)::DownCast(_impl)->ChangeArray(anArray);
}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeTextHighlightColor_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#ifndef SALOMEDS_AttributeTextHighlightColor_i_HeaderFile
#define SALOMEDS_AttributeTextHighlightColor_i_HeaderFile
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-#include "SALOMEDS_TextHighlightColorAttribute.hxx"
#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeTextHighlightColor.hxx"
-DEFINE_DERIVED_ATTR(AttributeTextHighlightColor,SALOMEDS_TextHighlightColorAttribute,false);
-
-class SALOMEDS_AttributeTextHighlightColor_i:
- public virtual POA_SALOMEDS::AttributeTextHighlightColor,
- public virtual SALOMEDS_TAttributeTextHighlightColor_i
+class SALOMEDS_AttributeTextHighlightColor_i: public virtual POA_SALOMEDS::AttributeTextHighlightColor,
+ public virtual SALOMEDS_GenericAttribute_i
{
- DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeTextHighlightColor,SALOMEDS_TextHighlightColorAttribute);
public:
- SALOMEDS::Color TextHighlightColor();
- void SetTextHighlightColor(const SALOMEDS::Color& value);
+
+ SALOMEDS_AttributeTextHighlightColor_i(const Handle(SALOMEDSImpl_AttributeTextHighlightColor)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
- char* Store();
- void Restore(const char*);
+ ~SALOMEDS_AttributeTextHighlightColor_i() {};
+ SALOMEDS::Color TextHighlightColor();
+ void SetTextHighlightColor(const SALOMEDS::Color& value);
};
--- /dev/null
+// File : SALOMEDS_AttributeTreeNode.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeTreeNode.hxx"
+
+#include <string>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <Standard_GUID.hxx>
+#include <TDF_Label.hxx>
+#include <TDF_Tool.hxx>
+
+#include "SALOMEDSImpl_AttributeTreeNode.hxx"
+#include "SALOMEDS_AttributeTreeNode.hxx"
+
+SALOMEDS_AttributeTreeNode::SALOMEDS_AttributeTreeNode(const Handle(SALOMEDSImpl_AttributeTreeNode)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeTreeNode::SALOMEDS_AttributeTreeNode(SALOMEDS::AttributeTreeNode_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeTreeNode::~SALOMEDS_AttributeTreeNode()
+{}
+
+void SALOMEDS_AttributeTreeNode::SetFather(const _PTR(AttributeTreeNode)& value)
+{
+ SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aFather;
+ aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ aFather = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+ aNode->SetFather(aFather);
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ SALOMEDS::AttributeTreeNode_var aFather = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
+ aNode->SetFather(aFather);
+ }
+}
+
+bool SALOMEDS_AttributeTreeNode::HasFather()
+{
+ bool ret;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ ret = aNode->HasFather();
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ ret = aNode->HasFather();
+ }
+ return ret;
+}
+
+_PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetFather()
+{
+ SALOMEDSClient_AttributeTreeNode* aTN = NULL;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFather());
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFather());
+ }
+ return _PTR(AttributeTreeNode)(aTN);
+}
+
+void SALOMEDS_AttributeTreeNode::SetPrevious(const _PTR(AttributeTreeNode)& value)
+{
+ SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aPrev;
+ aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ aPrev = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+ aNode->SetPrevious(aPrev);
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ SALOMEDS::AttributeTreeNode_var aPrev = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
+ aNode->SetPrevious(aPrev);
+ }
+}
+
+bool SALOMEDS_AttributeTreeNode::HasPrevious()
+{
+ bool ret;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ ret = aNode->HasPrevious();
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ ret = aNode->HasPrevious();
+ }
+ return ret;
+}
+
+_PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetPrevious()
+{
+ SALOMEDSClient_AttributeTreeNode* aTN = NULL;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ aTN = new SALOMEDS_AttributeTreeNode(aNode->GetPrevious());
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ aTN = new SALOMEDS_AttributeTreeNode(aNode->GetPrevious());
+ }
+ return _PTR(AttributeTreeNode)(aTN);
+}
+
+void SALOMEDS_AttributeTreeNode::SetNext(const _PTR(AttributeTreeNode)& value)
+{
+ SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aNext;
+ aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ aNext = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+ aNode->SetNext(aNext);
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ SALOMEDS::AttributeTreeNode_var aNext = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
+ aNode->SetNext(aNext);
+ }
+}
+
+bool SALOMEDS_AttributeTreeNode::HasNext()
+{
+ bool ret;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ ret = aNode->HasNext();
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ ret = aNode->HasNext();
+ }
+ return ret;
+}
+
+_PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetNext()
+{
+ SALOMEDSClient_AttributeTreeNode* aTN = NULL;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ aTN = new SALOMEDS_AttributeTreeNode(aNode->GetNext());
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ aTN = new SALOMEDS_AttributeTreeNode(aNode->GetNext());
+ }
+ return _PTR(AttributeTreeNode)(aTN);
+}
+
+void SALOMEDS_AttributeTreeNode::SetFirst(const _PTR(AttributeTreeNode)& value)
+{
+ SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aFirst;
+ aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ aFirst = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+ aNode->SetFirst(aFirst);
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ SALOMEDS::AttributeTreeNode_var aFirst = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
+ aNode->SetFirst(aFirst);
+ }
+}
+
+bool SALOMEDS_AttributeTreeNode::HasFirst()
+{
+ bool ret;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ ret = aNode->HasFirst();
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ ret = aNode->HasFirst();
+ }
+ return ret;
+}
+
+_PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetFirst()
+{
+ SALOMEDSClient_AttributeTreeNode* aTN = NULL;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFirst());
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFirst());
+ }
+ return _PTR(AttributeTreeNode)(aTN);
+}
+
+void SALOMEDS_AttributeTreeNode::SetTreeID(const std::string& value)
+{
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ aNode->SetTreeID(Standard_GUID((char*)value.c_str()));
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ aNode->SetTreeID(value.c_str());
+ }
+}
+
+std::string SALOMEDS_AttributeTreeNode::GetTreeID()
+{
+ TCollection_AsciiString aGUID;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ char guid[40];
+ aNode->GetTreeID().ToCString(guid);
+ aGUID = TCollection_AsciiString(guid);
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ aGUID = TCollection_AsciiString(aNode->GetTreeID());
+ }
+
+ return std::string(aGUID.ToCString());
+}
+
+void SALOMEDS_AttributeTreeNode::Append(const _PTR(AttributeTreeNode)& value)
+{
+ SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
+ aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+ aNode->Append(anOther);
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
+ aNode->Append(anOther);
+ }
+}
+
+void SALOMEDS_AttributeTreeNode::Prepend(const _PTR(AttributeTreeNode)& value)
+{
+ SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
+ aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+ aNode->Prepend(anOther);
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
+ aNode->Prepend(anOther);
+ }
+}
+
+void SALOMEDS_AttributeTreeNode::InsertBefore(const _PTR(AttributeTreeNode)& value)
+{
+ SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
+ aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+ aNode->InsertBefore(anOther);
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
+ aNode->InsertBefore(anOther);
+ }
+}
+
+void SALOMEDS_AttributeTreeNode::InsertAfter(const _PTR(AttributeTreeNode)& value)
+{
+ SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
+ aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+ aNode->InsertAfter(anOther);
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
+ aNode->InsertAfter(anOther);
+ }
+}
+
+void SALOMEDS_AttributeTreeNode::Remove()
+{
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl)->Remove();
+ else SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Remove();
+}
+
+int SALOMEDS_AttributeTreeNode::Depth()
+{
+ int aDepth;
+ if(_isLocal) aDepth = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl)->Depth();
+ else aDepth = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Depth();
+ return aDepth;
+}
+
+bool SALOMEDS_AttributeTreeNode::IsRoot()
+{
+ bool ret;
+ if(_isLocal) ret = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl)->IsRoot();
+ else ret = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->IsRoot();
+ return ret;
+}
+
+bool SALOMEDS_AttributeTreeNode::IsDescendant(const _PTR(AttributeTreeNode)& value)
+{
+ bool ret;
+ SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
+ aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+ ret = aNode->IsDescendant(anOther);
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
+ ret = aNode->IsDescendant(anOther);
+ }
+ return ret;
+}
+
+bool SALOMEDS_AttributeTreeNode::IsFather(const _PTR(AttributeTreeNode)& value)
+{
+ bool ret;
+ SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
+ aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+ ret = aNode->IsFather(anOther);
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
+ ret = aNode->IsFather(anOther);
+ }
+ return ret;
+}
+
+bool SALOMEDS_AttributeTreeNode::IsChild(const _PTR(AttributeTreeNode)& value)
+{
+ bool ret;
+ SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
+ aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+ anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+ ret = aNode->IsChild(anOther);
+ }
+ else {
+ SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
+ SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
+ ret = aNode->IsChild(anOther);
+ }
+ return ret;
+}
+
+std::string SALOMEDS_AttributeTreeNode::Label()
+{
+ TCollection_AsciiString aLabel;
+ if(_isLocal) TDF_Tool::Entry(_local_impl->Label(), aLabel);
+ else aLabel = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Label();
+ return std::string(aLabel.ToCString());
+}
+
+
--- /dev/null
+// File : SALOMEDS_AttributeTreeNode.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeTreeNode_HeaderFile
+#define SALOMEDS_AttributeTreeNode_HeaderFile
+
+#include "SALOMEDSClient_AttributeTreeNode.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeTreeNode.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributeTreeNode: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeTreeNode
+{
+public:
+ SALOMEDS_AttributeTreeNode(const Handle(SALOMEDSImpl_AttributeTreeNode)& theAttr);
+ SALOMEDS_AttributeTreeNode(SALOMEDS::AttributeTreeNode_ptr theAttr);
+ ~SALOMEDS_AttributeTreeNode();
+
+ virtual void SetFather(const _PTR(AttributeTreeNode)& value);
+ virtual bool HasFather();
+ virtual _PTR(AttributeTreeNode) GetFather();
+ virtual void SetPrevious(const _PTR(AttributeTreeNode)& value);
+ virtual bool HasPrevious();
+ virtual _PTR(AttributeTreeNode) GetPrevious();
+ virtual void SetNext(const _PTR(AttributeTreeNode)& value);
+ virtual bool HasNext();
+ virtual _PTR(AttributeTreeNode) GetNext();
+ virtual void SetFirst(const _PTR(AttributeTreeNode)& value);
+ virtual bool HasFirst();
+ virtual _PTR(AttributeTreeNode) GetFirst();
+ virtual void SetTreeID(const std::string& value);
+ virtual std::string GetTreeID();
+ virtual void Append(const _PTR(AttributeTreeNode)& value);
+ virtual void Prepend(const _PTR(AttributeTreeNode)& value);
+ virtual void InsertBefore(const _PTR(AttributeTreeNode)& value);
+ virtual void InsertAfter(const _PTR(AttributeTreeNode)& value);
+ virtual void Remove();
+ virtual int Depth();
+ virtual bool IsRoot();
+ virtual bool IsDescendant(const _PTR(AttributeTreeNode)& value);
+ virtual bool IsFather(const _PTR(AttributeTreeNode)& value);
+ virtual bool IsChild(const _PTR(AttributeTreeNode)& value);
+ virtual std::string Label();
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeTreeNode_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
-
-#include <TDocStd_Document.hxx>
-#include <TDF_Tool.hxx>
+using namespace std;
#include "SALOMEDS_AttributeTreeNode_i.hxx"
-
#include "utilities.h"
+#include "SALOMEDS.hxx"
+#include <TDocStd_Document.hxx>
+#include <TDF_Attribute.hxx>
+#include <TDF_Tool.hxx>
+#include <TDF_Data.hxx>
-using namespace std;
-
-static Handle(TDataStd_TreeNode) GetNode(SALOMEDS::AttributeTreeNode_ptr value,
- const Handle(TDataStd_TreeNode)& aNode)
+static Handle(SALOMEDSImpl_AttributeTreeNode) GetNode(SALOMEDS::AttributeTreeNode_ptr value,
+ const Handle(SALOMEDSImpl_AttributeTreeNode)& aNode)
{
- Handle(TDataStd_TreeNode) aResult = new TDataStd_TreeNode;
- CORBA::String_var aString = CORBA::string_dup(value->Label());
+ Handle(SALOMEDSImpl_AttributeTreeNode) aResult = new SALOMEDSImpl_AttributeTreeNode;
+ TCollection_AsciiString anEntry = value->Label();
TDF_Label aLabel;
- TDF_Tool::Label(aNode->Label().Data(), TCollection_AsciiString(aString), aLabel, 0);
+ TDF_Tool::Label(aNode->Label().Data(), anEntry, aLabel);
if (aLabel.IsNull()) {
MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such label")
MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such label")
return aResult;
}
-void SALOMEDS_AttributeTreeNode_i::SetFather(SALOMEDS::AttributeTreeNode_ptr theValue) {
+void SALOMEDS_AttributeTreeNode_i::SetFather(SALOMEDS::AttributeTreeNode_ptr value)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
- _myAttr->SetFather(GetNode(theValue,_myAttr));
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
+ aNode->SetFather(GetNode(value, aNode));
}
-CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasFather() {
- return _myAttr->HasFather();
+CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasFather()
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->HasFather();
}
-SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetFather() {
- SALOMEDS_AttributeTreeNode_i* aTreeNode =
- new SALOMEDS_AttributeTreeNode_i(_myAttr->Father(),_mySObject);
- return aTreeNode->_this();
+SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetFather()
+{
+ SALOMEDS::Locker lock;
+ SALOMEDS_AttributeTreeNode_i* aFather;
+ aFather = new SALOMEDS_AttributeTreeNode_i(Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->GetFather(), _orb);
+ return aFather->POA_SALOMEDS::AttributeTreeNode::_this();
}
-void SALOMEDS_AttributeTreeNode_i::SetPrevious(SALOMEDS::AttributeTreeNode_ptr theValue) {
+void SALOMEDS_AttributeTreeNode_i::SetPrevious(SALOMEDS::AttributeTreeNode_ptr value)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
- _myAttr->SetPrevious(GetNode(theValue,_myAttr));
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
+ aNode->SetPrevious(GetNode(value, aNode));
}
-CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasPrevious() {
- return _myAttr->HasPrevious();
+CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasPrevious()
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->HasPrevious();
}
-SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetPrevious() {
- SALOMEDS_AttributeTreeNode_i* aTreeNode =
- new SALOMEDS_AttributeTreeNode_i(_myAttr->Previous(),_mySObject);
- return aTreeNode->_this();
+SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetPrevious()
+{
+ SALOMEDS::Locker lock;
+ SALOMEDS_AttributeTreeNode_i* aPrevious;
+ aPrevious=new SALOMEDS_AttributeTreeNode_i(Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->GetPrevious(), _orb);
+ return aPrevious->POA_SALOMEDS::AttributeTreeNode::_this();
}
-void SALOMEDS_AttributeTreeNode_i::SetNext(SALOMEDS::AttributeTreeNode_ptr theValue) {
+void SALOMEDS_AttributeTreeNode_i::SetNext(SALOMEDS::AttributeTreeNode_ptr value)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
- _myAttr->SetNext(GetNode(theValue,_myAttr));
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
+ aNode->SetNext(GetNode(value, aNode));
}
-CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasNext() {
- return _myAttr->HasNext();
+CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasNext()
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->HasNext();
}
-SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetNext() {
- SALOMEDS_AttributeTreeNode_i* aTreeNode =
- new SALOMEDS_AttributeTreeNode_i(_myAttr->Next(),_mySObject);
- return aTreeNode->_this();
+SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetNext()
+{
+ SALOMEDS::Locker lock;
+ SALOMEDS_AttributeTreeNode_i* aNext;
+ aNext = new SALOMEDS_AttributeTreeNode_i(Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->GetNext(), _orb);
+ return aNext->POA_SALOMEDS::AttributeTreeNode::_this();
}
-void SALOMEDS_AttributeTreeNode_i::SetFirst(SALOMEDS::AttributeTreeNode_ptr theValue) {
+void SALOMEDS_AttributeTreeNode_i::SetFirst(SALOMEDS::AttributeTreeNode_ptr value)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
- _myAttr->SetFirst(GetNode(theValue,_myAttr));
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
+ aNode->SetFirst(GetNode(value, aNode));
}
-CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasFirst() {
- return _myAttr->HasFirst();
+CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasFirst()
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->HasFirst();
}
-SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetFirst() {
- SALOMEDS_AttributeTreeNode_i* aTreeNode =
- new SALOMEDS_AttributeTreeNode_i(_myAttr->First(),_mySObject);
- return aTreeNode->_this();
+SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetFirst()
+{
+ SALOMEDS::Locker lock;
+ SALOMEDS_AttributeTreeNode_i* aFirst;
+ aFirst = new SALOMEDS_AttributeTreeNode_i(Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->GetFirst(), _orb);
+ return aFirst->POA_SALOMEDS::AttributeTreeNode::_this();
}
-void SALOMEDS_AttributeTreeNode_i::SetTreeID(const char* value) {
+void SALOMEDS_AttributeTreeNode_i::SetTreeID(const char* value)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
- _myAttr->SetTreeID(Standard_GUID(_myAttr->ID()));
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
+ aNode->SetTreeID(Standard_GUID(aNode->ID()));
}
-char* SALOMEDS_AttributeTreeNode_i::GetTreeID() {
+char* SALOMEDS_AttributeTreeNode_i::GetTreeID()
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
char aGUID[40];
- _myAttr->ID().ToCString(aGUID);
- return CORBA::string_dup(aGUID);
+ aNode->ID().ToCString(aGUID);
+ return CORBA::String_var(CORBA::string_dup(aGUID))._retn();
}
-void SALOMEDS_AttributeTreeNode_i::Append(SALOMEDS::AttributeTreeNode_ptr theValue) {
+void SALOMEDS_AttributeTreeNode_i::Append(SALOMEDS::AttributeTreeNode_ptr value)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
- _myAttr->Append(GetNode(theValue,_myAttr));
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
+ aNode->Append(GetNode(value, aNode));
}
-void SALOMEDS_AttributeTreeNode_i::Prepend(SALOMEDS::AttributeTreeNode_ptr theValue) {
+void SALOMEDS_AttributeTreeNode_i::Prepend(SALOMEDS::AttributeTreeNode_ptr value)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
- _myAttr->Prepend(GetNode(theValue,_myAttr));
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
+ aNode->Prepend(GetNode(value, aNode));
}
-void SALOMEDS_AttributeTreeNode_i::InsertBefore(SALOMEDS::AttributeTreeNode_ptr theValue) {
+void SALOMEDS_AttributeTreeNode_i::InsertBefore(SALOMEDS::AttributeTreeNode_ptr value)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
- _myAttr->InsertBefore(GetNode(theValue,_myAttr));
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
+ aNode->InsertBefore(GetNode(value, aNode));
}
-void SALOMEDS_AttributeTreeNode_i::InsertAfter(SALOMEDS::AttributeTreeNode_ptr theValue) {
+void SALOMEDS_AttributeTreeNode_i::InsertAfter(SALOMEDS::AttributeTreeNode_ptr value)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
- _myAttr->InsertAfter(GetNode(theValue,_myAttr));
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
+ aNode->InsertAfter(GetNode(value, aNode));
}
-void SALOMEDS_AttributeTreeNode_i::Remove() {
+void SALOMEDS_AttributeTreeNode_i::Remove()
+{
+ SALOMEDS::Locker lock;
CheckLocked();
- _myAttr->Remove();
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
+ aNode->Remove();
}
-CORBA::Long SALOMEDS_AttributeTreeNode_i::Depth() {
- return _myAttr->Depth();
+CORBA::Long SALOMEDS_AttributeTreeNode_i::Depth()
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
+ return aNode->Depth();
}
-CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsRoot() {
- return _myAttr->IsRoot();
+CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsRoot()
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
+ return aNode->IsRoot();
}
-CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsDescendant(SALOMEDS::AttributeTreeNode_ptr theValue) {
- return _myAttr->IsDescendant(GetNode(theValue,_myAttr));
+CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsDescendant(SALOMEDS::AttributeTreeNode_ptr value)
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
+ return aNode->IsDescendant(GetNode(value, aNode));
}
-CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsFather(SALOMEDS::AttributeTreeNode_ptr theValue) {
- return _myAttr->IsFather(GetNode(theValue,_myAttr));
+CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsFather(SALOMEDS::AttributeTreeNode_ptr value)
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
+ return aNode->IsFather(GetNode(value, aNode));
}
-CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsChild(SALOMEDS::AttributeTreeNode_ptr theValue) {
- return _myAttr->IsChild(GetNode(theValue,_myAttr));
+CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsChild(SALOMEDS::AttributeTreeNode_ptr value)
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
+ return aNode->IsChild(GetNode(value, aNode));
}
-char* SALOMEDS_AttributeTreeNode_i::Label() {
+char* SALOMEDS_AttributeTreeNode_i::Label()
+{
+ SALOMEDS::Locker lock;
TCollection_AsciiString aLabelName;
- TDF_Tool::Entry(_myAttr->Label(),aLabelName);
- return CORBA::string_dup(aLabelName.ToCString());
-}
-
-char* SALOMEDS_AttributeTreeNode_i::Store() {
- char* aStr[4];
-
- if (HasFather()) aStr[0] = GetFather()->Label(); else aStr[0] = "!";
- if (HasPrevious()) aStr[1] = GetPrevious()->Label(); else aStr[1] = "!";
- if (HasNext()) aStr[2] = GetNext()->Label(); else aStr[2] = "!";
- if (HasFirst()) aStr[3] = GetFirst()->Label(); else aStr[3] = "!";
-
- int aLength = 4;
- aLength += strlen(aStr[0]) + strlen(aStr[1]) + strlen(aStr[2]) + strlen(aStr[3]);
- CORBA::String_var aResult = new char[aLength];
- sprintf(aResult, "%s %s %s %s", aStr[0], aStr[1], aStr[2], aStr[3]);
- return aResult._retn();
+ TDF_Tool::Entry(_impl->Label(),aLabelName);
+ return CORBA::String_var(CORBA::string_dup(aLabelName.ToCString()))._retn();
}
-void SALOMEDS_AttributeTreeNode_i::Restore(const char* value) {
- Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr);
- Handle(TDF_Data) DF = TDocStd_Document::Get(_myAttr->Label())->GetData();
-
- char* aCopy = strdup(value);
- char* adr = strtok(aCopy, " ");
-
- TDF_Label aLabel;
- Handle(TDataStd_TreeNode) aDepNode;
-
- if (adr && adr[0] != '!') {
- TDF_Tool::Label(DF, adr, aLabel, 1);
- if (!aLabel.FindAttribute(aNode->ID(), aDepNode)) aDepNode = TDataStd_TreeNode::Set(aLabel, aNode->ID());
- aNode->SetFather(aDepNode);
- }
-
- adr = strtok(NULL, " ");
- if (adr && adr[0] != '!') {
- TDF_Tool::Label(DF, adr, aLabel, 1);
- if (!aLabel.FindAttribute(aNode->ID(), aDepNode)) aDepNode = TDataStd_TreeNode::Set(aLabel, aNode->ID());
- aNode->SetPrevious(aDepNode);
- }
-
- adr = strtok(NULL, " ");
- if (adr && adr[0] != '!') {
- TDF_Tool::Label(DF, adr, aLabel, 1);
- if (!aLabel.FindAttribute(aNode->ID(), aDepNode)) aDepNode = TDataStd_TreeNode::Set(aLabel, aNode->ID());
- aNode->SetNext(aDepNode);
- }
-
- adr = strtok(NULL, " ");
- if (adr && adr[0] != '!') {
- TDF_Tool::Label(DF, adr, aLabel, 1);
- if (!aLabel.FindAttribute(aNode->ID(), aDepNode)) aDepNode = TDataStd_TreeNode::Set(aLabel, aNode->ID());
- aNode->SetFirst(aDepNode);
- }
-}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeTreeNode_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header:
#ifndef SALOMEDS_AttributeTreeNode_i_HeaderFile
#define SALOMEDS_AttributeTreeNode_i_HeaderFile
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-#include <TDataStd_TreeNode.hxx>
#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeTreeNode.hxx"
-DEFINE_DERIVED_ATTR(AttributeTreeNode,TDataStd_TreeNode,false);
-
-class SALOMEDS_AttributeTreeNode_i:
- public virtual POA_SALOMEDS::AttributeTreeNode,
- public virtual SALOMEDS_TAttributeTreeNode_i
-{
- DEFINE_DERIVED_ATTR_METH(AttributeTreeNode,TDataStd_TreeNode::GetDefaultTreeID());
-
+class SALOMEDS_AttributeTreeNode_i: public virtual POA_SALOMEDS::AttributeTreeNode,
+ public virtual SALOMEDS_GenericAttribute_i {
public:
+
+ SALOMEDS_AttributeTreeNode_i(const Handle(SALOMEDSImpl_AttributeTreeNode)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ ~SALOMEDS_AttributeTreeNode_i() {};
+
void SetFather(SALOMEDS::AttributeTreeNode_ptr value);
CORBA::Boolean HasFather();
SALOMEDS::AttributeTreeNode_ptr GetFather();
CORBA::Boolean IsChild(SALOMEDS::AttributeTreeNode_ptr value);
char* Label();
- char* Store();
- void Restore(const char*);
-
};
-
#endif
--- /dev/null
+// File : SALOMEDS_AttributeUserID.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeUserID.hxx"
+
+#include <string>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <Standard_GUID.hxx>
+
+SALOMEDS_AttributeUserID::SALOMEDS_AttributeUserID(const Handle(SALOMEDSImpl_AttributeUserID)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeUserID::SALOMEDS_AttributeUserID(SALOMEDS::AttributeUserID_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+SALOMEDS_AttributeUserID::~SALOMEDS_AttributeUserID()
+{}
+
+std::string SALOMEDS_AttributeUserID::Value()
+{
+ std::string aValue;
+ if(_isLocal) {
+ char guid[40];
+ Handle(SALOMEDSImpl_AttributeUserID)::DownCast(_local_impl)->Value().ToCString(guid);
+ aValue = std::string(guid);
+ }
+ else aValue = SALOMEDS::AttributeUserID::_narrow(_corba_impl)->Value();
+ return aValue;
+}
+
+void SALOMEDS_AttributeUserID::SetValue(const std::string& value)
+{
+ CheckLocked();
+ if(_isLocal) Handle(SALOMEDSImpl_AttributeUserID)::DownCast(_local_impl)->SetValue(Standard_GUID((char*)value.c_str()));
+ else SALOMEDS::AttributeUserID::_narrow(_corba_impl)->SetValue(value.c_str());
+}
--- /dev/null
+// File : SALOMEDS_AttributeUserID.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeUserID_HeaderFile
+#define SALOMEDS_AttributeUserID_HeaderFile
+
+#include "SALOMEDSClient_AttributeUserID.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeUserID.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributeUserID: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeUserID
+{
+public:
+ SALOMEDS_AttributeUserID(const Handle(SALOMEDSImpl_AttributeUserID)& theAttr);
+ SALOMEDS_AttributeUserID(SALOMEDS::AttributeUserID_ptr theAttr);
+ ~SALOMEDS_AttributeUserID();
+
+ virtual std::string Value();
+ virtual void SetValue(const std::string& value);
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeName_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
+using namespace std;
#include "SALOMEDS_AttributeUserID_i.hxx"
+#include "SALOMEDS.hxx"
#include <TCollection_ExtendedString.hxx>
-using namespace std;
-
-char* SALOMEDS_AttributeUserID_i::Value() {
+char* SALOMEDS_AttributeUserID_i::Value()
+{
+ SALOMEDS::Locker lock;
char aGUID[40];
- Handle(TDataStd_UAttribute)::DownCast(_myAttr)->ID().ToCString(aGUID);
+ Handle(SALOMEDSImpl_AttributeUserID)::DownCast(_impl)->ID().ToCString(aGUID);
CORBA::String_var c_s = CORBA::string_dup(aGUID);
return c_s._retn();
}
-void SALOMEDS_AttributeUserID_i::SetValue(const char* value) {
+void SALOMEDS_AttributeUserID_i::SetValue(const char* value)
+{
+ SALOMEDS::Locker lock;
CheckLocked();
CORBA::String_var Str = CORBA::string_dup(value);
- Handle(TDataStd_UAttribute)::DownCast(_myAttr)->SetID(Standard_GUID(Standard_CString(Str)));
+ Handle(SALOMEDSImpl_AttributeUserID)::DownCast(_impl)->SetValue(Standard_GUID(Standard_CString(Str)));
}
-char* SALOMEDS_AttributeUserID_i::Store() {
- return "";
-}
-
-void SALOMEDS_AttributeUserID_i::Restore(const char* value) {
-}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_AttributeUserID_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header:
#ifndef SALOMEDS_AttributeUserID_i_HeaderFile
#define SALOMEDS_AttributeUserID_i_HeaderFile
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-#include <TDataStd_UAttribute.hxx>
#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeUserID.hxx"
-DEFINE_DERIVED_ATTR(AttributeUserID,TDataStd_UAttribute,false);
+class SALOMEDS_AttributeUserID_i: public virtual POA_SALOMEDS::AttributeUserID,
+ public virtual SALOMEDS_GenericAttribute_i {
+public:
+
+ SALOMEDS_AttributeUserID_i(const Handle(SALOMEDSImpl_AttributeUserID)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
-class SALOMEDS_AttributeUserID_i:
- public virtual POA_SALOMEDS::AttributeUserID,
- public virtual SALOMEDS_TAttributeUserID_i
-{
- DEFINE_DERIVED_ATTR_METH(AttributeUserID,"FFFFFFFF-D9CD-11d6-945D-1050DA506788");
+ ~SALOMEDS_AttributeUserID_i() {};
-public:
char* Value();
void SetValue(const char* value);
- char* Store();
- void Restore(const char*);
+ static const Standard_GUID& DefaultID() {
+ return SALOMEDSImpl_AttributeUserID::DefaultID();
+ }
};
+
+
#endif
--- /dev/null
+// File : SALOMEDS_Attributes.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef __SALOMEDS_ATTRIBUTES__H__
+#define __SALOMEDS_ATTRIBUTES__H__
+
+#include "SALOMEDSImpl_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeName.hxx"
+#include "SALOMEDSImpl_AttributeComment.hxx"
+#include "SALOMEDSImpl_AttributeInteger.hxx"
+#include "SALOMEDSImpl_AttributeReal.hxx"
+#include "SALOMEDSImpl_AttributeTreeNode.hxx"
+#include "SALOMEDSImpl_AttributeUserID.hxx"
+#include "SALOMEDSImpl_AttributeReference.hxx"
+#include "SALOMEDSImpl_AttributeSequenceOfReal.hxx"
+#include "SALOMEDSImpl_AttributeSequenceOfInteger.hxx"
+#include "SALOMEDSImpl_AttributeIOR.hxx"
+#include "SALOMEDSImpl_AttributePersistentRef.hxx"
+#include "SALOMEDSImpl_AttributeDrawable.hxx"
+#include "SALOMEDSImpl_AttributeSelectable.hxx"
+#include "SALOMEDSImpl_AttributeExpandable.hxx"
+#include "SALOMEDSImpl_AttributeOpened.hxx"
+#include "SALOMEDSImpl_AttributeTextColor.hxx"
+#include "SALOMEDSImpl_AttributeTextHighlightColor.hxx"
+#include "SALOMEDSImpl_AttributePixMap.hxx"
+#include "SALOMEDSImpl_AttributeLocalID.hxx"
+#include "SALOMEDSImpl_AttributeTarget.hxx"
+#include "SALOMEDSImpl_AttributeTableOfInteger.hxx"
+#include "SALOMEDSImpl_AttributeTableOfReal.hxx"
+#include "SALOMEDSImpl_AttributeTableOfString.hxx"
+#include "SALOMEDSImpl_AttributeStudyProperties.hxx"
+#include "SALOMEDSImpl_AttributePythonObject.hxx"
+#include "SALOMEDSImpl_AttributeExternalFileDef.hxx"
+#include "SALOMEDSImpl_AttributeFileType.hxx"
+#include "SALOMEDSImpl_AttributeFlags.hxx"
+#include "SALOMEDSImpl_AttributeGraphic.hxx"
+
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDS_AttributeName_i.hxx"
+#include "SALOMEDS_AttributeComment_i.hxx"
+#include "SALOMEDS_AttributeInteger_i.hxx"
+#include "SALOMEDS_AttributeReal_i.hxx"
+#include "SALOMEDS_AttributeTreeNode_i.hxx"
+#include "SALOMEDS_AttributeUserID_i.hxx"
+#include "SALOMEDS_AttributeSequenceOfReal_i.hxx"
+#include "SALOMEDS_AttributeSequenceOfInteger_i.hxx"
+#include "SALOMEDS_AttributeIOR_i.hxx"
+#include "SALOMEDS_AttributePersistentRef_i.hxx"
+#include "SALOMEDS_AttributeDrawable_i.hxx"
+#include "SALOMEDS_AttributeSelectable_i.hxx"
+#include "SALOMEDS_AttributeExpandable_i.hxx"
+#include "SALOMEDS_AttributeOpened_i.hxx"
+#include "SALOMEDS_AttributeTextColor_i.hxx"
+#include "SALOMEDS_AttributeTextHighlightColor_i.hxx"
+#include "SALOMEDS_AttributePixMap_i.hxx"
+#include "SALOMEDS_AttributeLocalID_i.hxx"
+#include "SALOMEDS_AttributeTarget_i.hxx"
+#include "SALOMEDS_AttributeTableOfInteger_i.hxx"
+#include "SALOMEDS_AttributeTableOfReal_i.hxx"
+#include "SALOMEDS_AttributeTableOfString_i.hxx"
+#include "SALOMEDS_AttributeStudyProperties_i.hxx"
+#include "SALOMEDS_AttributePythonObject_i.hxx"
+#include "SALOMEDS_AttributeExternalFileDef_i.hxx"
+#include "SALOMEDS_AttributeFileType_i.hxx"
+#include "SALOMEDS_AttributeFlags_i.hxx"
+#include "SALOMEDS_AttributeGraphic_i.hxx"
+
+#define __CreateCORBAAttribute(CORBA_Name) if (strcmp(aTypeOfAttribute, #CORBA_Name) == 0) { \
+ Handle(SALOMEDSImpl_##CORBA_Name) A = Handle(SALOMEDSImpl_##CORBA_Name)::DownCast(theAttr); \
+ SALOMEDS_##CORBA_Name##_i* Attr = new SALOMEDS_##CORBA_Name##_i(A, theOrb); \
+ attr_servant = Attr; \
+ anAttribute = Attr->CORBA_Name::_this(); \
+ }
+
+
+#define __CreateGenericCORBAAttribute \
+__CreateCORBAAttribute(AttributeReal) \
+__CreateCORBAAttribute(AttributeInteger) \
+__CreateCORBAAttribute(AttributeSequenceOfReal) \
+__CreateCORBAAttribute(AttributeSequenceOfInteger) \
+__CreateCORBAAttribute(AttributeName) \
+__CreateCORBAAttribute(AttributeComment) \
+__CreateCORBAAttribute(AttributeIOR) \
+__CreateCORBAAttribute(AttributePixMap) \
+__CreateCORBAAttribute(AttributeLocalID) \
+__CreateCORBAAttribute(AttributeTableOfInteger) \
+__CreateCORBAAttribute(AttributeTableOfReal) \
+__CreateCORBAAttribute(AttributeTableOfString) \
+__CreateCORBAAttribute(AttributePythonObject) \
+__CreateCORBAAttribute(AttributePersistentRef) \
+__CreateCORBAAttribute(AttributeDrawable) \
+__CreateCORBAAttribute(AttributeSelectable) \
+__CreateCORBAAttribute(AttributeExpandable) \
+__CreateCORBAAttribute(AttributeOpened) \
+__CreateCORBAAttribute(AttributeTextColor) \
+__CreateCORBAAttribute(AttributeTextHighlightColor) \
+__CreateCORBAAttribute(AttributeTarget) \
+__CreateCORBAAttribute(AttributeStudyProperties) \
+__CreateCORBAAttribute(AttributeExternalFileDef) \
+__CreateCORBAAttribute(AttributeFileType) \
+__CreateCORBAAttribute(AttributeFlags) \
+__CreateCORBAAttribute(AttributeGraphic) \
+__CreateCORBAAttribute(AttributeTreeNode) \
+__CreateCORBAAttribute(AttributeUserID)
+
+#endif
--- /dev/null
+// File : SALOMEDS_ChildIterator.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+using namespace std;
+
+#include "SALOMEDS_ChildIterator.hxx"
+#include "SALOMEDS_SObject.hxx"
+
+SALOMEDS_ChildIterator::SALOMEDS_ChildIterator(const Handle(SALOMEDSImpl_ChildIterator)& theIterator)
+{
+ _isLocal = true;
+ _local_impl = theIterator;
+ _corba_impl = SALOMEDS::ChildIterator::_nil();
+}
+
+SALOMEDS_ChildIterator::SALOMEDS_ChildIterator(SALOMEDS::ChildIterator_ptr theIterator)
+{
+ _isLocal = false;
+ _local_impl = NULL;
+ _corba_impl = SALOMEDS::ChildIterator::_duplicate(theIterator);
+}
+
+SALOMEDS_ChildIterator::~SALOMEDS_ChildIterator()
+{
+ if(!_isLocal) _corba_impl->Destroy();
+}
+
+void SALOMEDS_ChildIterator::Init()
+{
+ if(_isLocal) _local_impl->Init();
+ else _corba_impl->Init();
+}
+
+void SALOMEDS_ChildIterator::InitEx(bool theAllLevels)
+{
+ if(_isLocal) _local_impl->InitEx(theAllLevels);
+ else _corba_impl->InitEx(theAllLevels);
+}
+
+bool SALOMEDS_ChildIterator::More()
+{
+ bool ret;
+ if(_isLocal) ret = _local_impl->More();
+ else ret = _corba_impl->More();
+ return ret;
+}
+
+void SALOMEDS_ChildIterator::Next()
+{
+ if(_isLocal) _local_impl->Next();
+ else _corba_impl->Next();
+}
+
+_PTR(SObject) SALOMEDS_ChildIterator::Value()
+{
+ SALOMEDSClient_SObject* aSO;
+ if(_isLocal) aSO = new SALOMEDS_SObject(_local_impl->Value());
+ else aSO = new SALOMEDS_SObject(_corba_impl->Value());
+ return _PTR(SObject)(aSO);
+}
--- /dev/null
+// File : SALOMEDS_ChildIterator.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef __SALOMEDS_CHILDITERATOR_H__
+#define __SALOMEDS_CHILDITERATOR_H__
+
+#include "SALOMEDSClient.hxx"
+#include "SALOMEDSImpl_ChildIterator.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+
+class SALOMEDS_ChildIterator: public SALOMEDSClient_ChildIterator
+{
+private:
+ bool _isLocal;
+ Handle(SALOMEDSImpl_ChildIterator) _local_impl;
+ SALOMEDS::ChildIterator_var _corba_impl;
+
+public:
+
+ SALOMEDS_ChildIterator(const Handle(SALOMEDSImpl_ChildIterator)& theIterator);
+ SALOMEDS_ChildIterator(SALOMEDS::ChildIterator_ptr theIterator);
+ ~SALOMEDS_ChildIterator();
+
+ virtual void Init();
+ virtual void InitEx(bool theAllLevels);
+ virtual bool More();
+ virtual void Next();
+ virtual _PTR(SObject) Value();
+};
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_ChildIterator_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
-
-#include <TDF_Tool.hxx>
+using namespace std;
#include "SALOMEDS_ChildIterator_i.hxx"
#include "SALOMEDS_SObject_i.hxx"
+#include "SALOMEDS.hxx"
+#include "SALOMEDSImpl_SObject.hxx"
+#include "SALOMEDSImpl_Study.hxx"
#include "utilities.h"
-using namespace std;
-
//============================================================================
/*! Function : constructor
* Purpose :
*/
//============================================================================
-SALOMEDS_ChildIterator_i::SALOMEDS_ChildIterator_i(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel,
- bool theIsAllLevels):
- _it(theLabel,theIsAllLevels),
- _lab(theLabel),
- _study(theStudy)
+SALOMEDS_ChildIterator_i::SALOMEDS_ChildIterator_i(const Handle(SALOMEDSImpl_ChildIterator)& theImpl,
+ CORBA::ORB_ptr orb)
+ : _it(theImpl)
{
+ SALOMEDS::Locker lock;
+ _orb = CORBA::ORB::_duplicate(orb);
}
//============================================================================
//============================================================================
void SALOMEDS_ChildIterator_i::Init()
{
- _it.Initialize(_lab);
+ SALOMEDS::Locker lock;
+ _it->Init();
}
//============================================================================
*
*/
//============================================================================
-void SALOMEDS_ChildIterator_i::InitEx(CORBA::Boolean theIsAllLevels)
+void SALOMEDS_ChildIterator_i::InitEx(CORBA::Boolean allLevels)
{
- _it.Initialize(_lab,theIsAllLevels);
+ SALOMEDS::Locker lock;
+ _it->InitEx (allLevels);
}
//============================================================================
//============================================================================
CORBA::Boolean SALOMEDS_ChildIterator_i::More()
{
- return _it.More();
+ SALOMEDS::Locker lock;
+ return _it->More();
}
//============================================================================
//============================================================================
void SALOMEDS_ChildIterator_i::Next()
{
- _it.Next();
+ SALOMEDS::Locker lock;
+ _it->Next();
}
//============================================================================
-/*! Function :
+/*! Function : Value
* Purpose :
*/
//============================================================================
SALOMEDS::SObject_ptr SALOMEDS_ChildIterator_i::Value()
{
- return SALOMEDS_SObject_i::NewRef(_study,_it.Value())._retn();
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_SObject) aSO = _it->Value();
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
+ return so._retn();
}
-SALOMEDS_SObject_i* SALOMEDS_ChildIterator_i::GetValue()
-{
- return SALOMEDS_SObject_i::NewPtr(_study,_it.Value());
-}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_ChildIterator_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#ifndef __SALOMEDS_CHILDITERATOR_I_H__
#define __SALOMEDS_CHILDITERATOR_I_H__
+// std C++ headers
+#include <iostream.h>
+
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS)
+#include <SALOME_GenericObj_i.hh>
// Cascade headers
-#include <TDF_ChildIterator.hxx>
-#include <TDF_Label.hxx>
-
-class SALOMEDS_Study_i;
-class SALOMEDS_SObject_i;
+#include "SALOMEDSImpl_ChildIterator.hxx"
+#include <stdio.h>
-class SALOMEDS_ChildIterator_i: public POA_SALOMEDS::ChildIterator,
- public PortableServer::RefCountServantBase
+class SALOMEDS_ChildIterator_i: public virtual POA_SALOMEDS::ChildIterator,
+ public virtual PortableServer::RefCountServantBase,
+ public virtual SALOME::GenericObj_i
{
- SALOMEDS_ChildIterator_i(); // Not implemented
- void operator=(const SALOMEDS_ChildIterator_i&); // Not implemented
-
private:
- SALOMEDS_Study_i* _study;
- TDF_Label _lab;
- TDF_ChildIterator _it;
-
+ CORBA::ORB_ptr _orb;
+ Handle(SALOMEDSImpl_ChildIterator) _it;
public:
- SALOMEDS_ChildIterator_i(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel,
- bool theIsAllLevels = false);
+ //! standard constructor
+ SALOMEDS_ChildIterator_i(const Handle(SALOMEDSImpl_ChildIterator)&, CORBA::ORB_ptr);
+
+ //! standard destructor
~SALOMEDS_ChildIterator_i();
- SALOMEDS_SObject_i* GetValue();
-
virtual void Init();
virtual void InitEx(CORBA::Boolean);
virtual CORBA::Boolean More();
virtual void Next();
virtual SALOMEDS::SObject_ptr Value();
};
-
-
#endif
#include "SALOMEDS_StudyManager_i.hxx"
#include "utilities.h"
#include "SALOMEDS_AttributeName_i.hxx"
+#include "HDFOI.hxx"
using namespace std;
//============================================================================
--- /dev/null
+// File : SALOMEDS_Attributes.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef __SALOMEDSCLIENT_ATTRIBUTES__H__
+#define __SALOMEDSCLIENT_ATTRIBUTES__H__
+
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include "SALOMEDSImpl_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeName.hxx"
+#include "SALOMEDSImpl_AttributeComment.hxx"
+#include "SALOMEDSImpl_AttributeInteger.hxx"
+#include "SALOMEDSImpl_AttributeReal.hxx"
+#include "SALOMEDSImpl_AttributeTreeNode.hxx"
+#include "SALOMEDSImpl_AttributeUserID.hxx"
+#include "SALOMEDSImpl_AttributeSequenceOfReal.hxx"
+#include "SALOMEDSImpl_AttributeSequenceOfInteger.hxx"
+#include "SALOMEDSImpl_AttributeIOR.hxx"
+#include "SALOMEDSImpl_AttributePersistentRef.hxx"
+#include "SALOMEDSImpl_AttributeDrawable.hxx"
+#include "SALOMEDSImpl_AttributeSelectable.hxx"
+#include "SALOMEDSImpl_AttributeExpandable.hxx"
+#include "SALOMEDSImpl_AttributeOpened.hxx"
+#include "SALOMEDSImpl_AttributeTextColor.hxx"
+#include "SALOMEDSImpl_AttributeTextHighlightColor.hxx"
+#include "SALOMEDSImpl_AttributePixMap.hxx"
+#include "SALOMEDSImpl_AttributeLocalID.hxx"
+#include "SALOMEDSImpl_AttributeTarget.hxx"
+#include "SALOMEDSImpl_AttributeTableOfInteger.hxx"
+#include "SALOMEDSImpl_AttributeTableOfReal.hxx"
+#include "SALOMEDSImpl_AttributeTableOfString.hxx"
+#include "SALOMEDSImpl_AttributeStudyProperties.hxx"
+#include "SALOMEDSImpl_AttributePythonObject.hxx"
+#include "SALOMEDSImpl_AttributeExternalFileDef.hxx"
+#include "SALOMEDSImpl_AttributeFileType.hxx"
+#include "SALOMEDSImpl_AttributeFlags.hxx"
+#include "SALOMEDSImpl_AttributeGraphic.hxx"
+
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDS_AttributeName.hxx"
+#include "SALOMEDS_AttributeComment.hxx"
+#include "SALOMEDS_AttributeInteger.hxx"
+#include "SALOMEDS_AttributeReal.hxx"
+#include "SALOMEDS_AttributeTreeNode.hxx"
+#include "SALOMEDS_AttributeUserID.hxx"
+#include "SALOMEDS_AttributeSequenceOfReal.hxx"
+#include "SALOMEDS_AttributeSequenceOfInteger.hxx"
+#include "SALOMEDS_AttributeIOR.hxx"
+#include "SALOMEDS_AttributePersistentRef.hxx"
+#include "SALOMEDS_AttributeDrawable.hxx"
+#include "SALOMEDS_AttributeSelectable.hxx"
+#include "SALOMEDS_AttributeExpandable.hxx"
+#include "SALOMEDS_AttributeOpened.hxx"
+#include "SALOMEDS_AttributeTextColor.hxx"
+#include "SALOMEDS_AttributeTextHighlightColor.hxx"
+#include "SALOMEDS_AttributePixMap.hxx"
+#include "SALOMEDS_AttributeLocalID.hxx"
+#include "SALOMEDS_AttributeTarget.hxx"
+#include "SALOMEDS_AttributeTableOfInteger.hxx"
+#include "SALOMEDS_AttributeTableOfReal.hxx"
+#include "SALOMEDS_AttributeTableOfString.hxx"
+#include "SALOMEDS_AttributeStudyProperties.hxx"
+#include "SALOMEDS_AttributePythonObject.hxx"
+#include "SALOMEDS_AttributeExternalFileDef.hxx"
+#include "SALOMEDS_AttributeFileType.hxx"
+#include "SALOMEDS_AttributeFlags.hxx"
+#include "SALOMEDS_AttributeGraphic.hxx"
+
+#define __CreateClientAttributeLocal(CORBA_Name) if (strcmp(aTypeOfAttribute.c_str(), #CORBA_Name) == 0) { \
+ Handle(SALOMEDSImpl_##CORBA_Name) A = Handle(SALOMEDSImpl_##CORBA_Name)::DownCast(theGA); \
+ aGA = new SALOMEDS_##CORBA_Name(A); \
+ }
+
+#define __CreateClientAttributeCORBA(CORBA_Name) if (strcmp(aTypeOfAttribute.c_str(), #CORBA_Name) == 0) { \
+ SALOMEDS::CORBA_Name##_var A = SALOMEDS::CORBA_Name::_narrow(theGA); \
+ aGA = new SALOMEDS_##CORBA_Name(A); \
+ }
+
+#define __CreateGenericClientAttributeLocal \
+__CreateClientAttributeLocal(AttributeReal) \
+__CreateClientAttributeLocal(AttributeInteger) \
+__CreateClientAttributeLocal(AttributeSequenceOfReal) \
+__CreateClientAttributeLocal(AttributeSequenceOfInteger) \
+__CreateClientAttributeLocal(AttributeName) \
+__CreateClientAttributeLocal(AttributeComment) \
+__CreateClientAttributeLocal(AttributeIOR) \
+__CreateClientAttributeLocal(AttributePixMap) \
+__CreateClientAttributeLocal(AttributeLocalID) \
+__CreateClientAttributeLocal(AttributeTableOfInteger) \
+__CreateClientAttributeLocal(AttributeTableOfReal) \
+__CreateClientAttributeLocal(AttributeTableOfString) \
+__CreateClientAttributeLocal(AttributePythonObject) \
+__CreateClientAttributeLocal(AttributePersistentRef) \
+__CreateClientAttributeLocal(AttributeDrawable) \
+__CreateClientAttributeLocal(AttributeSelectable) \
+__CreateClientAttributeLocal(AttributeExpandable) \
+__CreateClientAttributeLocal(AttributeOpened) \
+__CreateClientAttributeLocal(AttributeTextColor) \
+__CreateClientAttributeLocal(AttributeTextHighlightColor) \
+__CreateClientAttributeLocal(AttributeTarget) \
+__CreateClientAttributeLocal(AttributeStudyProperties) \
+__CreateClientAttributeLocal(AttributeExternalFileDef) \
+__CreateClientAttributeLocal(AttributeFileType) \
+__CreateClientAttributeLocal(AttributeFlags) \
+__CreateClientAttributeLocal(AttributeGraphic) \
+__CreateClientAttributeLocal(AttributeTreeNode) \
+__CreateClientAttributeLocal(AttributeUserID)
+
+#define __CreateGenericClientAttributeCORBA \
+__CreateClientAttributeCORBA(AttributeReal) \
+__CreateClientAttributeCORBA(AttributeInteger) \
+__CreateClientAttributeCORBA(AttributeSequenceOfReal) \
+__CreateClientAttributeCORBA(AttributeSequenceOfInteger) \
+__CreateClientAttributeCORBA(AttributeName) \
+__CreateClientAttributeCORBA(AttributeComment) \
+__CreateClientAttributeCORBA(AttributeIOR) \
+__CreateClientAttributeCORBA(AttributePixMap) \
+__CreateClientAttributeCORBA(AttributeLocalID) \
+__CreateClientAttributeCORBA(AttributeTableOfInteger) \
+__CreateClientAttributeCORBA(AttributeTableOfReal) \
+__CreateClientAttributeCORBA(AttributeTableOfString) \
+__CreateClientAttributeCORBA(AttributePythonObject) \
+__CreateClientAttributeCORBA(AttributePersistentRef) \
+__CreateClientAttributeCORBA(AttributeDrawable) \
+__CreateClientAttributeCORBA(AttributeSelectable) \
+__CreateClientAttributeCORBA(AttributeExpandable) \
+__CreateClientAttributeCORBA(AttributeOpened) \
+__CreateClientAttributeCORBA(AttributeTextColor) \
+__CreateClientAttributeCORBA(AttributeTextHighlightColor) \
+__CreateClientAttributeCORBA(AttributeTarget) \
+__CreateClientAttributeCORBA(AttributeStudyProperties) \
+__CreateClientAttributeCORBA(AttributeExternalFileDef) \
+__CreateClientAttributeCORBA(AttributeFileType) \
+__CreateClientAttributeCORBA(AttributeFlags) \
+__CreateClientAttributeCORBA(AttributeGraphic) \
+__CreateClientAttributeCORBA(AttributeTreeNode) \
+__CreateClientAttributeCORBA(AttributeUserID)
+
+#endif
--- /dev/null
+using namespace std;
+
+#include "SALOMEDS_Driver_i.hxx"
+#include "utilities.h"
+#include "SALOMEDS_SObject_i.hxx"
+#include "SALOMEDS_SComponent_i.hxx"
+#include "SALOMEDS_Study_i.hxx"
+#include "SALOMEDS.hxx"
+#include <stdlib.h>
+
+SALOMEDS_Driver_i::~SALOMEDS_Driver_i()
+{
+}
+
+unsigned char* SALOMEDS_Driver_i::Save(const Handle(SALOMEDSImpl_SComponent)& theComponent,
+ const TCollection_AsciiString& theURL,
+ long& theStreamLength,
+ bool isMultiFile)
+{
+ SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (theComponent, _orb);
+ SALOMEDS::TMPFile_var aStream;
+ CORBA::String_var url = CORBA::string_dup(theURL.ToCString());
+ SALOMEDS::unlock();
+ aStream = _driver->Save(sco.in(), url, isMultiFile);
+ SALOMEDS::lock();
+ theStreamLength = aStream->length();
+ unsigned char* aRetStream = NULL;
+ if(theStreamLength > 0) {
+ aRetStream = new unsigned char[theStreamLength];
+ memcpy(aRetStream, aStream->NP_data(), theStreamLength);
+ }
+ return aRetStream;
+}
+
+unsigned char* SALOMEDS_Driver_i::SaveASCII(const Handle(SALOMEDSImpl_SComponent)& theComponent,
+ const TCollection_AsciiString& theURL,
+ long& theStreamLength,
+ bool isMultiFile)
+{
+ SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (theComponent, _orb);
+ SALOMEDS::TMPFile_var aStream;
+ CORBA::String_var url = CORBA::string_dup(theURL.ToCString());
+ SALOMEDS::unlock();
+ aStream = _driver->SaveASCII(sco.in(), url, isMultiFile);
+ SALOMEDS::lock();
+ theStreamLength = aStream->length();
+ unsigned char* aRetStream = NULL;
+ if(theStreamLength > 0) {
+ aRetStream = new unsigned char[theStreamLength];
+ memcpy(aRetStream, aStream->NP_data(), theStreamLength);
+ }
+ return aRetStream;
+}
+
+bool SALOMEDS_Driver_i::Load(const Handle(SALOMEDSImpl_SComponent)& theComponent,
+ const unsigned char* theStream,
+ const long theStreamLength,
+ const TCollection_AsciiString& theURL,
+ bool isMultiFile)
+{
+ SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (theComponent, _orb);
+ CORBA::String_var url = CORBA::string_dup(theURL.ToCString());
+ CORBA::Octet* anOctetBuf = (CORBA::Octet*)theStream;
+
+ SALOMEDS::TMPFile_var aStream;
+ if(theStreamLength > 0)
+ aStream = new SALOMEDS::TMPFile(theStreamLength, theStreamLength, anOctetBuf, 0);
+ else
+ aStream = new SALOMEDS::TMPFile(0);
+
+ SALOMEDS::unlock();
+ return _driver->Load(sco.in(), aStream.in(), url, isMultiFile);
+}
+
+bool SALOMEDS_Driver_i::LoadASCII(const Handle(SALOMEDSImpl_SComponent)& theComponent,
+ const unsigned char* theStream,
+ const long theStreamLength,
+ const TCollection_AsciiString& theURL,
+ bool isMultiFile)
+{
+ SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (theComponent, _orb);
+ CORBA::String_var url = CORBA::string_dup(theURL.ToCString());
+ CORBA::Octet* anOctetBuf = (CORBA::Octet*)theStream;
+
+ SALOMEDS::TMPFile_var aStream;
+ if(theStreamLength > 0)
+ aStream = new SALOMEDS::TMPFile(theStreamLength, theStreamLength, anOctetBuf, 0);
+ else
+ aStream = new SALOMEDS::TMPFile(0);
+
+ SALOMEDS::unlock();
+ return _driver->LoadASCII(sco.in(), aStream.in(), url, isMultiFile);
+}
+
+void SALOMEDS_Driver_i::Close(const Handle(SALOMEDSImpl_SComponent)& theComponent)
+{
+ SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (theComponent, _orb);
+ SALOMEDS::unlock();
+ _driver->Close(sco.in());
+ SALOMEDS::lock();
+}
+
+
+
+TCollection_AsciiString SALOMEDS_Driver_i::IORToLocalPersistentID(const Handle(SALOMEDSImpl_SObject)& theSObject,
+ const TCollection_AsciiString& IORString,
+ bool isMultiFile,
+ bool isASCII)
+{
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (theSObject, _orb);
+ CORBA::String_var ior = CORBA::string_dup(IORString.ToCString());
+ SALOMEDS::unlock();
+ CORBA::String_var pers_string =_driver->IORToLocalPersistentID(so.in(), ior.in(), isMultiFile, isASCII);
+ SALOMEDS::lock();
+ return TCollection_AsciiString(pers_string);
+}
+
+
+TCollection_AsciiString SALOMEDS_Driver_i::LocalPersistentIDToIOR(const Handle(SALOMEDSImpl_SObject)& theObject,
+ const TCollection_AsciiString& aLocalPersistentID,
+ bool isMultiFile,
+ bool isASCII)
+{
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (theObject, _orb);
+ CORBA::String_var pers_string = CORBA::string_dup(aLocalPersistentID.ToCString());
+ SALOMEDS::unlock();
+ CORBA::String_var IOR =_driver->LocalPersistentIDToIOR(so.in(), pers_string.in(), isMultiFile, isASCII);
+ SALOMEDS::lock();
+ return TCollection_AsciiString(IOR);
+}
+
+bool SALOMEDS_Driver_i::CanCopy(const Handle(SALOMEDSImpl_SObject)& theObject)
+{
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (theObject, _orb);
+ SALOMEDS::unlock();
+ return _driver->CanCopy(so.in());
+}
+
+/*
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+*/
+
+unsigned char* SALOMEDS_Driver_i::CopyFrom(const Handle(SALOMEDSImpl_SObject)& theObject,
+ int& theObjectID,
+ long& theStreamLength)
+{
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (theObject, _orb);
+ SALOMEDS::TMPFile_var aStream;
+ CORBA::Long anObjectID;
+
+ SALOMEDS::unlock();
+ aStream = _driver->CopyFrom(so.in(), anObjectID);
+ SALOMEDS::lock();
+
+ theObjectID = anObjectID;
+ theStreamLength = aStream->length();
+
+ unsigned char* aRetStream = NULL;
+ if(theStreamLength > 0) {
+ aRetStream = new unsigned char[theStreamLength];
+ memcpy(aRetStream, aStream->NP_data(), theStreamLength);
+ }
+
+/*
+ int fd = open("/dn05/salome/srn/sh_copy.brep", O_CREAT | O_WRONLY);
+ cout << "Written " << write(fd, (char*)aRetStream, theStreamLength) << endl;
+ close(fd);
+*/
+ return aRetStream;
+}
+
+bool SALOMEDS_Driver_i::CanPaste(const TCollection_AsciiString& theComponentName, int theObjectID)
+{
+ SALOMEDS::unlock();
+ return _driver->CanPaste(theComponentName.ToCString(), theObjectID);
+}
+
+TCollection_AsciiString SALOMEDS_Driver_i::PasteInto(const unsigned char* theStream,
+ const long theStreamLength,
+ int theObjectID,
+ const Handle(SALOMEDSImpl_SObject)& theObject)
+{
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (theObject, _orb);
+ CORBA::Octet* anOctetBuf = (CORBA::Octet*)theStream;
+
+ SALOMEDS::TMPFile_var aStream;
+ if(theStreamLength > 0)
+ aStream = new SALOMEDS::TMPFile(theStreamLength, theStreamLength, anOctetBuf, 0);
+ else
+ aStream = new SALOMEDS::TMPFile(0);
+
+ SALOMEDS::unlock();
+ SALOMEDS::SObject_var ret_so = _driver->PasteInto(aStream.in(), theObjectID, so.in());
+ SALOMEDS::lock();
+
+ return TCollection_AsciiString((char*)ret_so->GetID());
+}
+
+unsigned char* SALOMEDS_Driver_i::DumpPython(const Handle(SALOMEDSImpl_Study)& theStudy,
+ bool isPublished,
+ bool& isValidScript,
+ long& theStreamLength)
+{
+ SALOMEDS_Study_i * st_servant = new SALOMEDS_Study_i (theStudy, _orb);
+ SALOMEDS::Study_var st = SALOMEDS::Study::_narrow(st_servant->_this());
+ Engines::TMPFile_var aStream;
+ CORBA::Boolean aValidScript, aPublished;
+ aPublished = isPublished;
+ Engines::Component_ptr aComponent = Engines::Component::_narrow(_driver);
+ SALOMEDS::unlock();
+ aStream = aComponent->DumpPython(st.in(), aPublished, aValidScript);
+ SALOMEDS::lock();
+ isValidScript = aValidScript;
+ theStreamLength = aStream->length();
+ unsigned char* aRetStream = NULL;
+
+ if(theStreamLength > 0) {
+ aRetStream = new unsigned char[theStreamLength];
+ memcpy(aRetStream, aStream->NP_data(), theStreamLength);
+ }
+
+ return aRetStream;
+}
+
+//###############################################################################################################
+// SALOMEDS_DriverFactory
+//###############################################################################################################
+
+SALOMEDSImpl_Driver* SALOMEDS_DriverFactory_i::GetDriverByType(const TCollection_AsciiString& theComponentType)
+{
+ CORBA::Object_var obj;
+
+ TCollection_AsciiString aFactoryType;
+ if (theComponentType == "SUPERV") aFactoryType = "SuperVisionContainer";
+ else aFactoryType = "FactoryServer";
+
+ obj = SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component(aFactoryType.ToCString(),
+ theComponentType.ToCString());
+
+ if (CORBA::is_nil(obj)) {
+ obj = SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component("FactoryServerPy", theComponentType.ToCString());
+ }
+
+ if (!CORBA::is_nil(obj)) {
+ SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(obj);
+ return new SALOMEDS_Driver_i(aDriver, _orb);
+ }
+
+ return NULL;
+}
+
+SALOMEDSImpl_Driver* SALOMEDS_DriverFactory_i::GetDriverByIOR(const TCollection_AsciiString& theIOR)
+{
+ CORBA::Object_var obj;
+ obj = _orb->string_to_object(theIOR.ToCString());
+
+ if (!CORBA::is_nil(obj)) {
+ SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(obj);
+ return new SALOMEDS_Driver_i(aDriver, _orb);
+ }
+
+ return NULL;
+}
--- /dev/null
+#ifndef __SALOMEDS_DRIVER_I_H__
+#define __SALOMEDS_DRIVER_I_H__
+
+#include <CORBA.h>
+#include <TCollection_AsciiString.hxx>
+#include "SALOMEDSImpl_Driver.hxx"
+#include "SALOMEDSImpl_SComponent.hxx"
+#include "SALOMEDSImpl_SObject.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOME_Component)
+
+class SALOMEDS_Driver_i : public virtual SALOMEDSImpl_Driver
+{
+protected:
+ SALOMEDS::Driver_var _driver;
+ CORBA::ORB_var _orb;
+
+public:
+
+ SALOMEDS_Driver_i(SALOMEDS::Driver_ptr theDriver, CORBA::ORB_ptr theORB)
+ {
+ _driver = SALOMEDS::Driver::_duplicate(theDriver);
+ _orb = CORBA::ORB::_duplicate(theORB);
+ }
+
+ ~SALOMEDS_Driver_i();
+
+ virtual TCollection_AsciiString GetIOR()
+ {
+ CORBA::String_var ior = _orb->object_to_string(_driver);
+ return TCollection_AsciiString(ior);
+ }
+
+ virtual unsigned char* Save(const Handle(SALOMEDSImpl_SComponent)& theComponent,
+ const TCollection_AsciiString& theURL,
+ long& theStreamLength,
+ bool isMultiFile);
+
+ virtual unsigned char* SaveASCII(const Handle(SALOMEDSImpl_SComponent)& theComponent,
+ const TCollection_AsciiString& theURL,
+ long& theStreamLength,
+ bool isMultiFile);
+
+ virtual bool Load(const Handle(SALOMEDSImpl_SComponent)& theComponent,
+ const unsigned char* theStream,
+ const long theStreamLength,
+ const TCollection_AsciiString& theURL,
+ bool isMultiFile);
+
+ virtual bool LoadASCII(const Handle(SALOMEDSImpl_SComponent)& theComponent,
+ const unsigned char* theStream,
+ const long theStreamLength,
+ const TCollection_AsciiString& theURL,
+ bool isMultiFile);
+
+ virtual void Close(const Handle(SALOMEDSImpl_SComponent)& theComponent);
+
+ virtual TCollection_AsciiString ComponentDataType()
+ {
+ CORBA::String_var ior = _driver->ComponentDataType();
+ return TCollection_AsciiString(ior);
+ }
+
+
+ virtual TCollection_AsciiString IORToLocalPersistentID(const Handle(SALOMEDSImpl_SObject)& theSObject,
+ const TCollection_AsciiString& IORString,
+ bool isMultiFile,
+ bool isASCII);
+
+ virtual TCollection_AsciiString LocalPersistentIDToIOR(const Handle(SALOMEDSImpl_SObject)& theSObject,
+ const TCollection_AsciiString& aLocalPersistentID,
+ bool isMultiFile,
+ bool isASCII);
+
+ virtual bool CanCopy(const Handle(SALOMEDSImpl_SObject)& theObject);
+
+ virtual unsigned char* CopyFrom(const Handle(SALOMEDSImpl_SObject)& theObject,
+ int& theObjectID,
+ long& theStreamLength);
+
+ virtual bool CanPaste(const TCollection_AsciiString& theComponentName, int theObjectID);
+
+ virtual TCollection_AsciiString PasteInto(const unsigned char* theStream,
+ const long theStreamLength,
+ int theObjectID,
+ const Handle(SALOMEDSImpl_SObject)& theObject);
+
+ virtual unsigned char* DumpPython(const Handle(SALOMEDSImpl_Study)& theStudy,
+ bool isPublished,
+ bool& isValidScript,
+ long& theStreamLength);
+};
+
+#include "SALOME_NamingService.hxx"
+#include "SALOME_LifeCycleCORBA.hxx"
+
+class SALOMEDS_DriverFactory_i : public virtual SALOMEDSImpl_DriverFactory
+{
+protected:
+ CORBA::ORB_ptr _orb;
+ SALOME_NamingService* _name_service;
+
+public:
+
+ SALOMEDS_DriverFactory_i(CORBA::ORB_ptr theORB)
+ {
+ _orb = CORBA::ORB::_duplicate(theORB);
+ _name_service = new SALOME_NamingService(_orb);
+ }
+
+
+ ~SALOMEDS_DriverFactory_i()
+ {
+ delete _name_service;
+ }
+
+ virtual SALOMEDSImpl_Driver* GetDriverByType(const TCollection_AsciiString& theComponentType);
+
+ virtual SALOMEDSImpl_Driver* GetDriverByIOR(const TCollection_AsciiString& theIOR);
+};
+
+#endif
--- /dev/null
+// File : SALOMEDS_GenericAttribute.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+using namespace std;
+
+#include <string>
+#include <TCollection_AsciiString.hxx>
+
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_SObject.hxx"
+#include "SALOMEDS_SObject.hxx"
+#include "SALOMEDS_ClientAttributes.hxx"
+
+#ifdef WIN32
+#include <process.h>
+#else
+#include <sys/types.h>
+#include <unistd.h>
+#endif
+
+#include "OpUtil.hxx"
+
+SALOMEDS_GenericAttribute::SALOMEDS_GenericAttribute(const Handle(SALOMEDSImpl_GenericAttribute)& theGA)
+{
+ _isLocal = true;
+ _local_impl = theGA;
+ _corba_impl = SALOMEDS::GenericAttribute::_nil();
+}
+
+SALOMEDS_GenericAttribute::SALOMEDS_GenericAttribute(SALOMEDS::GenericAttribute_ptr theGA)
+{
+#ifdef WIN32
+ long pid = (long)_getpid();
+#else
+ long pid = (long)getpid();
+#endif
+
+ long addr = theGA->GetLocalImpl(GetHostname().c_str(), pid, _isLocal);
+ if(_isLocal) {
+ _local_impl = ((SALOMEDSImpl_GenericAttribute*)(addr));
+ _corba_impl = SALOMEDS::GenericAttribute::_nil();
+ }
+ else {
+ _local_impl = NULL;
+ _corba_impl = SALOMEDS::GenericAttribute::_duplicate(theGA);
+ }
+}
+
+SALOMEDS_GenericAttribute::~SALOMEDS_GenericAttribute()
+{
+ if (!_isLocal) {
+ _corba_impl->Destroy();
+ }
+}
+
+void SALOMEDS_GenericAttribute::CheckLocked()
+{
+ if(_isLocal) {
+ try {
+ _local_impl->CheckLocked();
+ }
+ catch(...) {
+ throw SALOMEDS::GenericAttribute::LockProtection();
+ }
+ }
+ else {
+ _corba_impl->CheckLocked();
+ }
+}
+
+std::string SALOMEDS_GenericAttribute::Type()
+{
+ std::string aType;
+ if(_isLocal) {
+ aType = _local_impl->Type().ToCString();
+ }
+ else {
+ aType = _corba_impl->Type();
+ }
+ return aType;
+}
+
+std::string SALOMEDS_GenericAttribute::GetClassType()
+{
+ std::string aType;
+ if(_isLocal) {
+ aType = _local_impl->GetClassType().ToCString();
+ }
+ else {
+ aType = _corba_impl->GetClassType();
+ }
+ return aType;
+}
+
+_PTR(SObject) SALOMEDS_GenericAttribute::GetSObject()
+{
+ SALOMEDSClient_SObject* aSO = NULL;
+ if(_isLocal) {
+ aSO = new SALOMEDS_SObject(_local_impl->GetSObject());
+ }
+ else {
+ aSO = new SALOMEDS_SObject(_corba_impl->GetSObject());
+ }
+
+ return _PTR(SObject)(aSO);
+}
+
+
+SALOMEDS_GenericAttribute* SALOMEDS_GenericAttribute::CreateAttribute(const Handle(SALOMEDSImpl_GenericAttribute)& theGA)
+{
+ SALOMEDS_GenericAttribute* aGA = NULL;
+ std::string aTypeOfAttribute = theGA->GetClassType().ToCString();
+ __CreateGenericClientAttributeLocal
+ return aGA;
+}
+
+SALOMEDS_GenericAttribute* SALOMEDS_GenericAttribute::CreateAttribute(SALOMEDS::GenericAttribute_ptr theGA)
+{
+ SALOMEDS_GenericAttribute* aGA = NULL;
+ std::string aTypeOfAttribute = theGA->GetClassType();
+ __CreateGenericClientAttributeCORBA
+ return aGA;
+}
+
--- /dev/null
+// File : SALOMEDS_GenericAttribute.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef _GENERIC_ATTRIBUTE_HXX_
+#define _GENERIC_ATTRIBUTE_HXX_
+
+#include <exception>
+#include "SALOMEDSClient.hxx"
+#include "SALOMEDSImpl_GenericAttribute.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+
+
+class SALOMEDS_GenericAttribute: public virtual SALOMEDSClient_GenericAttribute
+{
+protected:
+ bool _isLocal;
+ Handle(SALOMEDSImpl_GenericAttribute) _local_impl;
+ SALOMEDS::GenericAttribute_var _corba_impl;
+
+public:
+ SALOMEDS_GenericAttribute(const Handle(SALOMEDSImpl_GenericAttribute)& theGA);
+ SALOMEDS_GenericAttribute(SALOMEDS::GenericAttribute_ptr theGA);
+ virtual ~SALOMEDS_GenericAttribute();
+
+ void CheckLocked();
+ std::string Type();
+ std::string GetClassType();
+ _PTR(SObject) GetSObject();
+
+ static SALOMEDS_GenericAttribute* CreateAttribute(const Handle(SALOMEDSImpl_GenericAttribute)& theGA);
+ static SALOMEDS_GenericAttribute* CreateAttribute(SALOMEDS::GenericAttribute_ptr theGA);
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
// File : SALOMEDS_GenericAttribute_i.cxx
-// Author : Mikhail PONIKAROV
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
-
-#include "SALOMEDS_GenericAttribute_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
-#include "SALOMEDS_Study_i.hxx"
using namespace std;
-
-
-SALOMEDS_GenericAttribute_i::SALOMEDS_GenericAttribute_i(const Handle(TDF_Attribute)& theAttr,
- SALOMEDS_SObject_i* theSObject):
- _myBasicAttr(theAttr),
- _mySObject(theSObject)
-{
-}
-
-
-SALOMEDS_GenericAttribute_i::~SALOMEDS_GenericAttribute_i()
+#include "utilities.h"
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDS_Attributes.hxx"
+#include "SALOMEDS.hxx"
+#include "SALOMEDSImpl_SObject.hxx"
+#include "SALOMEDSImpl_Study.hxx"
+#include "Utils_ExceptHandlers.hxx"
+#include <TCollection_AsciiString.hxx>
+#include <map>
+
+#ifdef WIN32
+#include <process.h>
+#else
+#include <sys/types.h>
+#include <unistd.h>
+#endif
+
+#include "OpUtil.hxx"
+
+UNEXPECT_CATCH(GALockProtection, SALOMEDS::GenericAttribute::LockProtection);
+
+SALOMEDS_GenericAttribute_i::SALOMEDS_GenericAttribute_i(const Handle(TDF_Attribute)& theImpl, CORBA::ORB_ptr theOrb)
{
+ _orb = CORBA::ORB::_duplicate(theOrb);
+ _impl = theImpl;
}
-
-char* SALOMEDS_GenericAttribute_i::Store()
+void SALOMEDS_GenericAttribute_i::CheckLocked() throw (SALOMEDS::GenericAttribute::LockProtection)
{
- return CORBA::string_dup("");
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(GALockProtection);
+
+ if (!_impl.IsNull() && _impl->IsValid() && !CORBA::is_nil(_orb)) {
+ try {
+ SALOMEDSImpl_GenericAttribute::Impl_CheckLocked(_impl);
+ }
+ catch (...) {
+ throw SALOMEDS::GenericAttribute::LockProtection();
+ }
+ }
}
-
-void SALOMEDS_GenericAttribute_i::Restore(const char*)
+SALOMEDS::SObject_ptr SALOMEDS_GenericAttribute_i::GetSObject()
{
+ SALOMEDS::Locker lock;
+ if (_impl.IsNull() || _impl->Label().IsNull()) return SALOMEDS::SObject::_nil();
+ Handle(SALOMEDSImpl_SObject) so_impl = SALOMEDSImpl_Study::SObject(_impl->Label());
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (so_impl, _orb);
+ return so._retn();
}
char* SALOMEDS_GenericAttribute_i::Type()
{
- return CORBA::string_dup(SALOMEDS::GetType(_myBasicAttr).c_str());
-}
+ SALOMEDS::Locker lock;
+ if (!_impl.IsNull()) {
+ return CORBA::string_dup(SALOMEDSImpl_GenericAttribute::Impl_GetType(_impl));
+ }
+ return "";
+}
-SALOMEDS::SObject_ptr SALOMEDS_GenericAttribute_i::GetSObject()
+char* SALOMEDS_GenericAttribute_i::GetClassType()
{
- return _mySObject->_this();;
-}
+ SALOMEDS::Locker lock;
+ if (!_impl.IsNull()) {
+ return CORBA::string_dup(SALOMEDSImpl_GenericAttribute::Impl_GetClassType(_impl));
+ }
+
+ return "";
+}
-void SALOMEDS_GenericAttribute_i::CheckLocked()
- throw (SALOMEDS::GenericAttribute::LockProtection)
+SALOMEDS::GenericAttribute_ptr SALOMEDS_GenericAttribute_i::CreateAttribute(const Handle(TDF_Attribute)& theAttr,
+ CORBA::ORB_ptr theOrb)
+{
+/*
+ SALOMEDS::Locker lock;
+
+ static std::map<TDF_Attribute*, SALOMEDS_GenericAttribute_i*> _mapOfAttrib;
+ SALOMEDS::GenericAttribute_var anAttribute;
+ SALOMEDS_GenericAttribute_i* attr_servant = NULL;
+
+ if(_mapOfAttrib.find(theAttr.operator->()) != _mapOfAttrib.end()) {
+ attr_servant = _mapOfAttrib[theAttr.operator->()];
+ anAttribute = SALOMEDS::GenericAttribute::_narrow(attr_servant->_this());
+ }
+ else {
+ char* aTypeOfAttribute = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(theAttr)->GetClassType().ToCString();
+ __CreateGenericCORBAAttribute
+ _mapOfAttrib[theAttr.operator->()] = attr_servant;
+ }
+*/
+ // mpv: now servants Destroyed by common algos of CORBA
+ char* aTypeOfAttribute = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(theAttr)->GetClassType().ToCString();
+ SALOMEDS::GenericAttribute_var anAttribute;
+ SALOMEDS_GenericAttribute_i* attr_servant = NULL;
+ __CreateGenericCORBAAttribute
+
+ return anAttribute._retn();
+}
+
+//===========================================================================
+// PRIVATE FUNCTIONS
+//===========================================================================
+long SALOMEDS_GenericAttribute_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
{
- _mySObject->GetStudyServant()->CheckLocked();
+#ifdef WIN32
+ long pid = (long)_getpid();
+#else
+ long pid = (long)getpid();
+#endif
+ isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0;
+ TDF_Attribute* local_impl = _impl.operator->();
+ return ((long)local_impl);
}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_GenericAttribute_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#ifndef _GENERIC_ATTRIBUTE_I_HXX_
#define _GENERIC_ATTRIBUTE_I_HXX_
-#include <TDF_Attribute.hxx>
-#include <Standard_GUID.hxx>
-
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS)
+#include <SALOME_GenericObj_i.hh>
+#include <TDF_Attribute.hxx>
+#include "SALOMEDS_SObject_i.hxx"
+#include "SALOMEDSImpl_GenericAttribute.hxx"
-class SALOMEDS_SObject_i;
-
-class SALOMEDS_GenericAttribute_i:
- public virtual POA_SALOMEDS::GenericAttribute,
- public virtual PortableServer::RefCountServantBase
-{
-private:
- friend class SALOMEDS_SObject_i;
-
- SALOMEDS_GenericAttribute_i(); // Not implemented
- void operator=(const SALOMEDS_GenericAttribute_i&); //Not implemented
+class SALOMEDS_GenericAttribute_i: public virtual POA_SALOMEDS::GenericAttribute,
+ public virtual PortableServer::RefCountServantBase,
+ public virtual SALOME::GenericObj_i
+{
protected:
- SALOMEDS_SObject_i* _mySObject;
- Handle(TDF_Attribute) _myBasicAttr;
-
- SALOMEDS_GenericAttribute_i(const Handle(TDF_Attribute)& theAttr,
- SALOMEDS_SObject_i* theSObject);
-
- virtual ~SALOMEDS_GenericAttribute_i();
+ Handle(TDF_Attribute) _impl;
+ CORBA::ORB_ptr _orb;
- void SetBasicAttribute(const Handle(TDF_Attribute)& theAttr){
- _myBasicAttr = theAttr;
- }
-
public:
- void Restore(const char*);
-
- char* Store();
+ SALOMEDS_GenericAttribute_i(const Handle(TDF_Attribute)& theImpl, CORBA::ORB_ptr theOrb);
+ virtual ~SALOMEDS_GenericAttribute_i() {};
- char* Type();
+ void CheckLocked() throw (SALOMEDS::GenericAttribute::LockProtection);
- SALOMEDS::SObject_ptr GetSObject();
-
- void CheckLocked()
- throw (SALOMEDS::GenericAttribute::LockProtection);
-
- virtual void SetAttribute(const Handle(TDF_Attribute)& theAttr) = 0;
-
- virtual const Handle(TDF_Attribute)& GetAttribute() const = 0;
-
-};
+ virtual char* Type();
+ char* GetClassType();
-template<class TDFAttribute, class TStoreTDFAttribute, bool TIsCheckLockedStudy = true>
-class SALOMEDS_TGenericAttribute_i:
- public virtual SALOMEDS_GenericAttribute_i
-{
-public:
- typedef TDFAttribute TAttr;
- typedef TStoreTDFAttribute TStoreAttr;
-
- virtual void SetAttribute(const Handle(TDF_Attribute)& theAttr){
- _myAttr = TStoreAttr::DownCast(theAttr);
- SetBasicAttribute(theAttr);
- }
- virtual const Handle(TDF_Attribute)& GetAttribute() const{
- return _myAttr;
- }
- static bool IsCheckLockedStudy(){
- return TIsCheckLockedStudy;
- }
- static Handle(TDF_Attribute) NewAttribute(){
- return new TAttr;
- }
-
-protected:
- TStoreAttr _myAttr;
-
- SALOMEDS_TGenericAttribute_i(const Handle(TDF_Attribute)& theAttr,
- SALOMEDS_SObject_i* theSObject):
- SALOMEDS_GenericAttribute_i(theAttr,theSObject),
- _myAttr(TStoreAttr::DownCast(theAttr))
- {
- }
+ SALOMEDS::SObject_ptr GetSObject();
-private:
- friend class SALOMEDS_SObject_i;
+ virtual Handle(TDF_Attribute) GetImpl() { return _impl; }
- SALOMEDS_TGenericAttribute_i(); //Not implemented
- void operator=(const SALOMEDS_TGenericAttribute_i&); //Not implemented
+ static SALOMEDS::GenericAttribute_ptr CreateAttribute(const Handle(TDF_Attribute)& theAttr, CORBA::ORB_ptr theOrb);
+ virtual long GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal);
};
-
-#define DEFINE_DERIVED_ATTR(TName,TAttr,TCheck) \
- typedef SALOMEDS_TGenericAttribute_i<TAttr,Handle_##TAttr,TCheck> \
- SALOMEDS_T##TName##_i
-
-
-#define DEFINE_DERIVED_ATTR_METH_BASE(TName) \
-public: \
- friend class SALOMEDS_SObject_i; \
- static SALOMEDS_GenericAttribute_i* \
- NewInstance(const Handle(TDF_Attribute)& theAttr, \
- SALOMEDS_SObject_i* theSObject) \
- { return new SALOMEDS_##TName##_i(theAttr,theSObject);} \
-private: \
- SALOMEDS_##TName##_i(const Handle(TDF_Attribute)& theAttr, \
- SALOMEDS_SObject_i* theSObject): \
- SALOMEDS_GenericAttribute_i(theAttr,theSObject), \
- SALOMEDS_T##TName##_i(theAttr,theSObject) \
- {} \
- void operator=(const SALOMEDS_##TName##_i&); \
- SALOMEDS_##TName##_i()
-
-
-#define DEFINE_DERIVED_ATTR_METH_DEFAULT(TName,TAttr) \
-DEFINE_DERIVED_ATTR_METH_BASE(TName); \
-public: \
- static Standard_GUID GetGUID(){ return TAttr::GetID(); } \
-private:
-
-
-#define DEFINE_DERIVED_ATTR_METH(TName,theGUID) \
-DEFINE_DERIVED_ATTR_METH_BASE(TName); \
-public: \
- static Standard_GUID GetGUID(){ return theGUID; } \
-private:
-
-
#endif
--- /dev/null
+// File : SALOMEDS_SComponent.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+using namespace std;
+
+#include "SALOMEDS_SComponent.hxx"
+#include "SALOMEDS_SComponent_i.hxx"
+#include <string>
+#include <TCollection_AsciiString.hxx>
+
+SALOMEDS_SComponent::SALOMEDS_SComponent(SALOMEDS::SComponent_ptr theSComponent)
+:SALOMEDS_SObject(theSComponent)
+{}
+
+SALOMEDS_SComponent::SALOMEDS_SComponent(const Handle(SALOMEDSImpl_SComponent)& theSComponent)
+:SALOMEDS_SObject(theSComponent)
+{}
+
+SALOMEDS_SComponent::~SALOMEDS_SComponent()
+{}
+
+std::string SALOMEDS_SComponent::ComponentDataType()
+{
+ std::string aType;
+ if(_isLocal) {
+ aType = (Handle(SALOMEDSImpl_SComponent)::DownCast(GetLocalImpl()))->ComponentDataType().ToCString();
+ }
+ else aType = (SALOMEDS::SComponent::_narrow(GetCORBAImpl()))->ComponentDataType();
+
+ return aType;
+}
+
+bool SALOMEDS_SComponent::ComponentIOR(std::string& theID)
+{
+ bool ret;
+ if(_isLocal) {
+ TCollection_AsciiString anIOR;
+ ret = (Handle(SALOMEDSImpl_SComponent)::DownCast(GetLocalImpl()))->ComponentIOR(anIOR);
+ theID = anIOR.ToCString();
+ }
+ else {
+ CORBA::String_var anIOR;
+ ret = (SALOMEDS::SComponent::_narrow(GetCORBAImpl()))->ComponentIOR(anIOR.out());
+ theID = std::string(anIOR.in());
+ }
+
+ return ret;
+}
+
+SALOMEDS::SComponent_ptr SALOMEDS_SComponent::GetSComponent()
+{
+ if(_isLocal) {
+ if(!CORBA::is_nil(_corba_impl)) return SALOMEDS::SComponent::_narrow(GetCORBAImpl());
+ SALOMEDS::SComponent_var aSCO = SALOMEDS_SComponent_i::New(Handle(SALOMEDSImpl_SComponent)::DownCast(GetLocalImpl()),
+ _orb);
+ return aSCO._retn();
+ }
+ else {
+ return SALOMEDS::SComponent::_narrow(GetCORBAImpl());
+ }
+
+ return SALOMEDS::SComponent::_nil();
+}
+
--- /dev/null
+// File : SALOMEDS_SComponent.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef __SALOMEDS_SCOMPONENT_H__
+#define __SALOMEDS_SCOMPONENT_H__
+
+#include "SALOMEDSClient_SComponent.hxx"
+#include "SALOMEDS_SObject.hxx"
+#include "SALOMEDSImpl_SComponent.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+
+class SALOMEDS_SComponent: public SALOMEDS_SObject, public SALOMEDSClient_SComponent
+{
+public:
+
+ SALOMEDS_SComponent(const Handle(SALOMEDSImpl_SComponent)& theSComponent);
+ SALOMEDS_SComponent(SALOMEDS::SComponent_ptr theSComponent);
+ ~SALOMEDS_SComponent();
+
+ virtual std::string ComponentDataType();
+ virtual bool ComponentIOR(std::string& theID);
+
+ SALOMEDS::SComponent_ptr GetSComponent();
+};
+#endif
--- /dev/null
+// File : SALOMEDS_SComponentIterator.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_SComponentIterator.hxx"
+#include "SALOMEDSImpl_SComponent.hxx"
+#include "SALOMEDS_SComponent.hxx"
+
+SALOMEDS_SComponentIterator::SALOMEDS_SComponentIterator(const SALOMEDSImpl_SComponentIterator& theIterator)
+:_local_impl(theIterator)
+{
+ _isLocal = true;
+ _corba_impl = SALOMEDS::SComponentIterator::_nil();
+}
+
+SALOMEDS_SComponentIterator::SALOMEDS_SComponentIterator(SALOMEDS::SComponentIterator_ptr theIterator)
+{
+ _isLocal = false;
+ _corba_impl = SALOMEDS::SComponentIterator::_duplicate(theIterator);
+}
+
+SALOMEDS_SComponentIterator::~SALOMEDS_SComponentIterator()
+{
+ if(!_isLocal) _corba_impl->Destroy();
+}
+
+void SALOMEDS_SComponentIterator::Init()
+{
+ if(_isLocal) _local_impl.Init();
+ else _corba_impl->Init();
+}
+
+bool SALOMEDS_SComponentIterator::More()
+{
+ bool ret;
+ if(_isLocal) ret = _local_impl.More();
+ else ret = _corba_impl->More();
+ return ret;
+}
+
+void SALOMEDS_SComponentIterator::Next()
+{
+ if(_isLocal) _local_impl.Next();
+ else _corba_impl->Next();
+}
+
+_PTR(SComponent) SALOMEDS_SComponentIterator::Value()
+{
+ SALOMEDSClient_SComponent* aSCO = NULL;
+ if(_isLocal) aSCO = new SALOMEDS_SComponent(_local_impl.Value());
+ else aSCO = new SALOMEDS_SComponent(_corba_impl->Value());
+ return _PTR(SComponent)(aSCO);
+}
--- /dev/null
+// File : SALOMEDS_SComponentIterator.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef __SALOMEDS_SCOMPONENTITERATOR_H__
+#define __SALOMEDS_SCOMPONENTITERATOR_H__
+
+#include "SALOMEDSClient.hxx"
+#include "SALOMEDSImpl_SComponentIterator.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+
+class SALOMEDS_SComponentIterator: public SALOMEDSClient_SComponentIterator
+{
+public:
+ SALOMEDS_SComponentIterator(const SALOMEDSImpl_SComponentIterator& theIterator);
+ SALOMEDS_SComponentIterator(SALOMEDS::SComponentIterator_ptr theIterator);
+ ~SALOMEDS_SComponentIterator();
+
+private:
+ bool _isLocal;
+ SALOMEDSImpl_SComponentIterator _local_impl;
+ SALOMEDS::SComponentIterator_var _corba_impl;
+
+public:
+ virtual void Init();
+ virtual bool More();
+ virtual void Next();
+ virtual _PTR(SComponent) Value();
+};
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_SComponentIterator_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
-
-#include "SALOMEDS_SComponentIterator_i.hxx"
-#include "SALOMEDS_SComponent_i.hxx"
using namespace std;
+#include "SALOMEDS_SComponentIterator_i.hxx"
+#include "SALOMEDS.hxx"
+#include "SALOMEDSImpl_SComponent.hxx"
//============================================================================
/*! Function : constructor
*/
//============================================================================
-SALOMEDS_SComponentIterator_i::SALOMEDS_SComponentIterator_i(SALOMEDS_Study_i* theStudy,
- const Handle(TDocStd_Document)& theDocument):
- _it(theDocument->Main()),
- _lab(theDocument->Main()),
- _study(theStudy)
+SALOMEDS_SComponentIterator_i::SALOMEDS_SComponentIterator_i(const SALOMEDSImpl_SComponentIterator& theImpl,
+ CORBA::ORB_ptr orb)
+:_impl(theImpl)
{
+ _orb = CORBA::ORB::_duplicate(orb);
}
//============================================================================
//============================================================================
void SALOMEDS_SComponentIterator_i::Init()
{
- _it.Initialize (_lab);
+ SALOMEDS::Locker lock;
+ _impl.Init();
}
//============================================================================
//============================================================================
CORBA::Boolean SALOMEDS_SComponentIterator_i::More()
{
- if (!_it.More())
- return false;
- TDF_Label L = _it.Value();
- if (SALOMEDS_SComponent_i::IsA(L))
- return true;
-
- return _it.More();
+ SALOMEDS::Locker lock;
+ return _impl.More();
}
//============================================================================
*/
//============================================================================
void SALOMEDS_SComponentIterator_i::Next()
-{
- _it.Next();
+{
+ SALOMEDS::Locker lock;
+ _impl.Next();
}
//============================================================================
SALOMEDS::SComponent_ptr SALOMEDS_SComponentIterator_i::Value()
{
- return SALOMEDS_SComponent_i::NewRef(_study,_it.Value())._retn();
+ SALOMEDS::Locker lock;
+ SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (_impl.Value(), _orb);
+ return sco._retn();
}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_SComponentIterator_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#ifndef __SALOMEDS_SCOMPONENTITERATOR_I_H__
#define __SALOMEDS_SCOMPONENTITERATOR_I_H__
+// std C++ headers
+#include <iostream.h>
+
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS)
+#include <SALOME_GenericObj_i.hh>
-// Cascade headers
-#include <TDocStd_Document.hxx>
-#include <TDF_ChildIterator.hxx>
-#include <TDF_Label.hxx>
-
-class SALOMEDS_Study_i;
+//SALOMEDS headers
+#include "SALOMEDS_SComponent_i.hxx"
+#include "SALOMEDSImpl_SComponentIterator.hxx"
class SALOMEDS_SComponentIterator_i:public virtual POA_SALOMEDS::SComponentIterator,
- public virtual PortableServer::RefCountServantBase
+ public virtual PortableServer::RefCountServantBase,
+ public virtual SALOME::GenericObj_i
{
- SALOMEDS_SComponentIterator_i(); // Not implemented
- void operator=(const SALOMEDS_SComponentIterator_i&); // Not implemented
private:
- TDF_ChildIterator _it;
- TDF_Label _lab;
- SALOMEDS_Study_i* _study;
+
+ CORBA::ORB_ptr _orb;
+ SALOMEDSImpl_SComponentIterator _impl;
public:
- SALOMEDS_SComponentIterator_i(SALOMEDS_Study_i* theStudy,
- const Handle(TDocStd_Document)& theDocument);
+
+ SALOMEDS_SComponentIterator_i(const SALOMEDSImpl_SComponentIterator& theImpl, CORBA::ORB_ptr);
~SALOMEDS_SComponentIterator_i();
- TDF_Label GetValue() { return _it.Value();}
-
virtual void Init();
virtual CORBA::Boolean More();
virtual void Next();
virtual SALOMEDS::SComponent_ptr Value();
};
-
-
#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_SComponent_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
+using namespace std;
#include "SALOMEDS_SComponent_i.hxx"
-#include "SALOMEDS_Study_i.hxx"
-
+#include "SALOMEDS.hxx"
#include "utilities.h"
+#include <map>
-using namespace std;
-
-SALOMEDS_Study_i::TSObjectHolder
-SALOMEDS_SComponent_i::New(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel)
+SALOMEDS::SComponent_ptr SALOMEDS_SComponent_i::New(const Handle(SALOMEDSImpl_SComponent)& theImpl, CORBA::ORB_ptr theORB)
{
- SALOMEDS_Study_i::TSObjectHolder aSObjectHolder;
- SALOMEDS_Study_i::TSObjectMap& anSObjectMap = theStudy->GetSObjectMap();
- SALOMEDS_Study_i::TSObjectMap::const_iterator anIter = anSObjectMap.find(theLabel);
- if(anIter != anSObjectMap.end()){
- aSObjectHolder = anIter->second;
- SALOMEDS_SObject_i* aSObject = aSObjectHolder.first;
- if(dynamic_cast<SALOMEDS_SComponent_i*>(aSObject))
- return aSObjectHolder;
- }
- TCollection_AsciiString anEntry;
- TDF_Tool::Entry(theLabel,anEntry);
- SALOMEDS_SComponent_i* aSComponent = new SALOMEDS_SComponent_i(theStudy,theLabel);
- aSObjectHolder.first = aSComponent;
- aSObjectHolder.second = aSComponent->_this();
- anSObjectMap[theLabel] = aSObjectHolder;
+/*
+ static std::map<SALOMEDSImpl_SComponent*, SALOMEDS_SComponent_i*> _mapOfSCO;
+ SALOMEDS::SComponent_var sco;
+ SALOMEDS_SComponent_i* sco_servant = NULL;
- return aSObjectHolder;
-}
+ if(_mapOfSCO.find(theImpl.operator->()) != _mapOfSCO.end()) {
+ sco_servant = _mapOfSCO[theImpl.operator->()];
+ }
+ else {
+ sco_servant = new SALOMEDS_SComponent_i(theImpl, theORB);
+ _mapOfSCO[theImpl.operator->()] = sco_servant;
+ }
-SALOMEDS_SComponent_i*
-SALOMEDS_SComponent_i::NewPtr(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel)
-{
- return dynamic_cast<SALOMEDS_SComponent_i*>(New(theStudy,theLabel).first);
-}
+ sco = SALOMEDS::SComponent::_narrow(sco_servant->SComponent::_this());
+*/
+ SALOMEDS_SComponent_i* sco_servant = new SALOMEDS_SComponent_i(theImpl, theORB);
+ SALOMEDS::SComponent_var sco = SALOMEDS::SComponent::_narrow(sco_servant->SComponent::_this());
-SALOMEDS::SComponent_var
-SALOMEDS_SComponent_i::NewRef(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel)
-{
- return SALOMEDS::SComponent::_narrow(New(theStudy,theLabel).second);
-}
+ return sco._retn();
+}
//============================================================================
/*! Function : constructor
* Purpose :
*/
//============================================================================
-SALOMEDS_SComponent_i::SALOMEDS_SComponent_i(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel):
- SALOMEDS_SObject_i(theStudy,theLabel)
-{
-}
+SALOMEDS_SComponent_i::SALOMEDS_SComponent_i(const Handle(SALOMEDSImpl_SComponent)& theImpl, CORBA::ORB_ptr orb)
+ :SALOMEDS_SObject_i(theImpl, orb)
+{}
//============================================================================
/*! Function : destructor
*/
//============================================================================
SALOMEDS_SComponent_i::~SALOMEDS_SComponent_i()
-{
-}
-
-
+{}
+
//============================================================================
/*! Function : ComponentDataType
* Purpose :
//============================================================================
char* SALOMEDS_SComponent_i::ComponentDataType()
{
- //DEB
- // MESSAGE("In SALOMEDS_SComponent_i::ComponentDataType");
- // TCollection_AsciiString anEntry;
- // TDF_Tool::Entry (_lab,anEntry);
- // MESSAGE("in SALOMEDS_SComponent_i, Entry :"<<anEntry);
- // END DEB
-
- Standard_CString res = "";
- Handle(TDataStd_Comment) type;
- if ( _lab.FindAttribute(TDataStd_Comment::GetID(),type) ) {
- TCollection_AsciiString ch(type->Get());
- res = ch.ToCString();
- }
-
- return CORBA::string_dup(res);
+ SALOMEDS::Locker lock;
+ TCollection_AsciiString aType = Handle(SALOMEDSImpl_SComponent)::DownCast(_impl)->ComponentDataType();
+ return CORBA::string_dup(aType.ToCString());
}
//============================================================================
CORBA::Boolean SALOMEDS_SComponent_i::ComponentIOR(CORBA::String_out IOR)
{
- Handle(SALOMEDS_IORAttribute) ior;
- if (!_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(),ior) )
- return false;
- TCollection_AsciiString ch(ior->Get());
- IOR = CORBA::string_dup(ch.ToCString());
+ SALOMEDS::Locker lock;
+ TCollection_AsciiString ior;
+ if(!Handle(SALOMEDSImpl_SComponent)::DownCast(_impl)->ComponentIOR(ior)) return false;
+ IOR = CORBA::string_dup(ior.ToCString());
return true;
}
-
-
-//============================================================================
-/*! Function : IsA
- * Purpose :
- */
-//============================================================================
-Standard_Boolean SALOMEDS_SComponent_i::IsA(const TDF_Label& Lab)
-{
- Handle(TDF_Attribute) Att;
- // scomponent must contain comment and belong to the 2th depth label
- if ( Lab.FindAttribute(TDataStd_Comment::GetID(), Att) && Lab.Depth() == 2) {
- return Standard_True;
- }
- return Standard_False;
-}
-
-
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_SComponent_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#ifndef __SALOMEDS_SCOMPONENT_I_H__
#define __SALOMEDS_SCOMPONENT_I_H__
-#include "SALOMEDS_SObject_i.hxx"
+// std C++ headers
+#include <iostream.h>
-class SALOMEDS_SComponent_i: public virtual POA_SALOMEDS::SComponent,
- public virtual SALOMEDS_SObject_i
-{
- SALOMEDS_SComponent_i(); // Not implemented
- void operator=(const SALOMEDS_SComponent_i&); // Not implemented
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
- SALOMEDS_SComponent_i(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel);
-
-public:
+//SALOMEDS headers
+#include "SALOMEDS_SObject_i.hxx"
- static
- SALOMEDS_Study_i::TSObjectHolder
- New(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel);
+#include "SALOMEDSImpl_SObject.hxx"
+#include "SALOMEDSImpl_SComponent.hxx"
- static
- SALOMEDS_SComponent_i*
- NewPtr(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel);
+class SALOMEDS_SComponent_i: public POA_SALOMEDS::SComponent,
+ public SALOMEDS_SObject_i
+{
- static
- SALOMEDS::SComponent_var
- NewRef(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel);
+public:
- ~SALOMEDS_SComponent_i();
+ static SALOMEDS::SComponent_ptr New(const Handle(SALOMEDSImpl_SComponent)&, CORBA::ORB_ptr);
- virtual char* ComponentDataType();
+ SALOMEDS_SComponent_i(const Handle(SALOMEDSImpl_SComponent)&, CORBA::ORB_ptr);
+
+ virtual ~SALOMEDS_SComponent_i();
+ virtual char* ComponentDataType();
virtual CORBA::Boolean ComponentIOR(CORBA::String_out theID);
-
- static Standard_Boolean IsA(const TDF_Label& Lab);
};
-
-
#endif
--- /dev/null
+// File : SALOMEDS_SObject.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+using namespace std;
+
+#include <string>
+#include <TCollection_AsciiString.hxx>
+#include <TColStd_HSequenceOfTransient.hxx>
+
+#include "SALOMEDS_SObject.hxx"
+#include "SALOMEDS_SComponent.hxx"
+#include "SALOMEDSImpl_SComponent.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_GenericAttribute.hxx"
+#include "SALOMEDS_Study.hxx"
+#include "SALOMEDSImpl_Study.hxx"
+
+#include "Utils_ORB_INIT.hxx"
+#include "Utils_SINGLETON.hxx"
+
+#ifdef WIN32
+#include <process.h>
+#else
+#include <sys/types.h>
+#include <unistd.h>
+#endif
+
+#include "OpUtil.hxx"
+
+SALOMEDS_SObject::SALOMEDS_SObject(SALOMEDS::SObject_ptr theSObject)
+{
+#ifdef WIN32
+ long pid = (long)_getpid();
+#else
+ long pid = (long)getpid();
+#endif
+
+ long addr = theSObject->GetLocalImpl(GetHostname().c_str(), pid, _isLocal);
+ if(_isLocal) {
+ _local_impl = ((SALOMEDSImpl_SObject*)(addr));
+ _corba_impl = SALOMEDS::SObject::_duplicate(theSObject);
+ }
+ else {
+ _local_impl = NULL;
+ _corba_impl = SALOMEDS::SObject::_duplicate(theSObject);
+ }
+
+ init_orb();
+}
+
+SALOMEDS_SObject::SALOMEDS_SObject(const Handle(SALOMEDSImpl_SObject)& theSObject)
+:_isLocal(true)
+{
+ _corba_impl = SALOMEDS::SObject::_nil();
+ _local_impl = theSObject;
+
+ init_orb();
+}
+
+SALOMEDS_SObject::~SALOMEDS_SObject()
+{
+ if (!_isLocal) {
+ _corba_impl->Destroy();
+ }
+}
+
+std::string SALOMEDS_SObject::GetID()
+{
+ std::string aValue;
+ if(_isLocal) aValue = _local_impl->GetID().ToCString();
+ else aValue = _corba_impl->GetID();
+ return aValue;
+}
+
+_PTR(SComponent) SALOMEDS_SObject::GetFatherComponent()
+{
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_SComponent) aSCO = Handle(SALOMEDSImpl_SComponent)::DownCast(_local_impl->GetFatherComponent());
+ return _PTR(SComponent)(new SALOMEDS_SComponent(aSCO));
+ }
+ return _PTR(SComponent)(new SALOMEDS_SComponent(_corba_impl->GetFatherComponent()));
+}
+
+_PTR(SObject) SALOMEDS_SObject::GetFather()
+{
+ if(_isLocal) return _PTR(SObject)(new SALOMEDS_SObject(_local_impl->GetFather()));
+ return _PTR(SObject)(new SALOMEDS_SObject(_corba_impl->GetFather()));
+}
+
+bool SALOMEDS_SObject::FindAttribute(_PTR(GenericAttribute)& anAttribute, const std::string& aTypeOfAttribute)
+{
+ bool ret = false;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_GenericAttribute) anAttr;
+ ret = _local_impl->FindAttribute(anAttr, (char*)aTypeOfAttribute.c_str());
+ if(ret) anAttribute = _PTR(GenericAttribute)(SALOMEDS_GenericAttribute::CreateAttribute(anAttr));
+ }
+ else {
+ SALOMEDS::GenericAttribute_var anAttr;
+ ret = _corba_impl->FindAttribute(anAttr.out(), aTypeOfAttribute.c_str());
+ if(ret) anAttribute = _PTR(GenericAttribute)(SALOMEDS_GenericAttribute::CreateAttribute(anAttr));
+ }
+
+ return ret;
+}
+
+bool SALOMEDS_SObject::ReferencedObject(_PTR(SObject)& theObject)
+{
+ bool ret = false;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_SObject) aSO;
+ ret = _local_impl->ReferencedObject(aSO);
+ if(ret) theObject = _PTR(SObject)(new SALOMEDS_SObject(aSO));
+ }
+ else {
+ SALOMEDS::SObject_var aSO;
+ ret = _corba_impl->ReferencedObject(aSO.out());
+ if(ret) theObject = _PTR(SObject)(new SALOMEDS_SObject(aSO));
+ }
+
+ return ret;
+}
+
+
+bool SALOMEDS_SObject::FindSubObject(int theTag, _PTR(SObject)& theObject)
+{
+ bool ret = false;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_SObject) aSO;
+ ret = _local_impl->FindSubObject(theTag, aSO);
+ if(ret) theObject = _PTR(SObject)(new SALOMEDS_SObject(aSO));
+ }
+ else {
+ SALOMEDS::SObject_var aSO;
+ ret = _corba_impl->FindSubObject(theTag, aSO.out());
+ if(ret) theObject = _PTR(SObject)(new SALOMEDS_SObject(aSO));
+ }
+
+ return ret;
+}
+
+_PTR(Study) SALOMEDS_SObject::GetStudy()
+{
+ if(_isLocal) return _PTR(Study)(new SALOMEDS_Study(_local_impl->GetStudy()));
+ return _PTR(Study)(new SALOMEDS_Study(_corba_impl->GetStudy()));
+}
+
+std::string SALOMEDS_SObject::Name()
+{
+ std::string aName;
+ if(_isLocal) aName = _local_impl->Name().ToCString();
+ else aName = _corba_impl->Name();
+
+ return aName;
+}
+
+void SALOMEDS_SObject::Name(const std::string& theName)
+{
+ if(_isLocal) _local_impl->Name((char*)theName.c_str());
+ else _corba_impl->Name(theName.c_str());
+}
+
+vector<_PTR(GenericAttribute)> SALOMEDS_SObject::GetAllAttributes()
+{
+ vector<_PTR(GenericAttribute)> aVector;
+ int aLength = 0;
+ SALOMEDSClient_GenericAttribute* anAttr;
+
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfTransient) aSeq = _local_impl->GetAllAttributes();
+ aLength = aSeq->Length();
+ for(int i = 1; i <= aLength; i++) {
+ anAttr = SALOMEDS_GenericAttribute::CreateAttribute(Handle(SALOMEDSImpl_GenericAttribute)::DownCast(aSeq->Value(i)));
+ aVector.push_back(_PTR(GenericAttribute)(anAttr));
+ }
+ }
+ else {
+ SALOMEDS::ListOfAttributes_var aSeq = _corba_impl->GetAllAttributes();
+ aLength = aSeq->length();
+ for(int i = 0; i < aLength; i++) {
+ anAttr = SALOMEDS_GenericAttribute::CreateAttribute(aSeq[i]);
+ aVector.push_back(_PTR(GenericAttribute)(anAttr));
+ }
+ }
+
+ return aVector;
+}
+
+std::string SALOMEDS_SObject::GetName()
+{
+ std::string aName;
+ if(_isLocal) aName = _local_impl->GetName().ToCString();
+ else aName = _corba_impl->GetName();
+
+ return aName;
+}
+
+std::string SALOMEDS_SObject::GetComment()
+{
+ std::string aComment;
+ if(_isLocal) aComment = _local_impl->GetComment().ToCString();
+ else aComment = _corba_impl->GetComment();
+
+ return aComment;
+}
+
+std::string SALOMEDS_SObject::GetIOR()
+{
+ std::string anIOR;
+ if(_isLocal) anIOR = _local_impl->GetIOR().ToCString();
+ else anIOR = _corba_impl->GetIOR();
+
+ return anIOR;
+}
+
+int SALOMEDS_SObject::Tag()
+{
+ if(_isLocal) return _local_impl->Tag();
+ return _corba_impl->Tag();
+}
+
+int SALOMEDS_SObject::Depth()
+{
+ if(_isLocal) return _local_impl->Depth();
+ return _corba_impl->Depth();
+}
+
+CORBA::Object_ptr SALOMEDS_SObject::GetObject()
+{
+ CORBA::Object_var obj;
+ if(_isLocal) {
+ std::string anIOR = GetIOR();
+ obj = _orb->string_to_object(anIOR.c_str());
+ return obj._retn();
+ }
+ else {
+ obj = _corba_impl->GetObject();
+ return obj._retn();
+ }
+
+ return CORBA::Object::_nil();
+}
+
+SALOMEDS::SObject_ptr SALOMEDS_SObject::GetSObject()
+{
+ if(_isLocal) {
+ if(!CORBA::is_nil(_corba_impl)) return _corba_impl;
+ SALOMEDS::SObject_var aSO = SALOMEDS_SObject_i::New(_local_impl, _orb);
+ return aSO._retn();
+ }
+ else {
+ return _corba_impl;
+ }
+ return SALOMEDS::SObject::_nil();
+}
+
+
+void SALOMEDS_SObject::init_orb()
+{
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
+ _orb = init(0 , 0 ) ;
+}
--- /dev/null
+// File : SALOMEDS_SObject.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef __SALOMEDS_SOBJECT_H__
+#define __SALOMEDS_SOBJECT_H__
+
+// std C++ headers
+#include <vector>
+
+#include <SALOMEDSClient.hxx>
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+
+#include "SALOMEDS_SObject_i.hxx"
+#include "SALOMEDSImpl_SObject.hxx"
+
+class SALOMEDS_SObject: public virtual SALOMEDSClient_SObject
+{
+protected:
+
+ bool _isLocal;
+ Handle(SALOMEDSImpl_SObject) _local_impl;
+ SALOMEDS::SObject_var _corba_impl;
+ CORBA::ORB_var _orb;
+
+public:
+
+ SALOMEDS_SObject(SALOMEDS::SObject_ptr theSObject);
+ SALOMEDS_SObject(const Handle(SALOMEDSImpl_SObject)& theSObject);
+ virtual ~SALOMEDS_SObject();
+
+ virtual std::string GetID();
+ virtual _PTR(SComponent) GetFatherComponent();
+ virtual _PTR(SObject) GetFather();
+ virtual bool FindAttribute(_PTR(GenericAttribute)& anAttribute, const std::string& aTypeOfAttribute);
+ virtual bool ReferencedObject(_PTR(SObject)& theObject);
+ virtual bool FindSubObject(int theTag, _PTR(SObject)& theObject);
+ virtual _PTR(Study) GetStudy();
+ virtual std::string Name();
+ virtual void Name(const std::string& theName);
+ virtual vector<_PTR(GenericAttribute)> GetAllAttributes();
+ virtual std::string GetName();
+ virtual std::string GetComment();
+ virtual std::string GetIOR();
+ virtual int Tag();
+ virtual int Depth();
+
+ CORBA::Object_ptr GetObject();
+ SALOMEDS::SObject_ptr GetSObject();
+
+ SALOMEDS::SObject_ptr GetCORBAImpl() { return SALOMEDS::SObject::_duplicate(_corba_impl); }
+ Handle(SALOMEDSImpl_SObject) GetLocalImpl() { return _local_impl; }
+
+private:
+ void init_orb();
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_SObject_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
-#include <TDF_Tool.hxx>
-#include <TDF_Attribute.hxx>
-#include <TDF_Reference.hxx>
-#include <Standard_GUID.hxx>
-#include <Standard_NoSuchObject.hxx>
-#include <TDataStd_Name.hxx>
-#include <TDataStd_Comment.hxx>
-#include <TDataStd_Integer.hxx>
-#include <TDataStd_Real.hxx>
-#include <TDataStd_TreeNode.hxx>
-#include <TDataStd_UAttribute.hxx>
-
-#include <TCollection_AsciiString.hxx>
-#include <TDF_AttributeIterator.hxx>
+using namespace std;
+#include "utilities.h"
#include "SALOMEDS_SObject_i.hxx"
-
-//SALOMEDS Headers
-#include "SALOMEDS_Study_i.hxx"
-#include "SALOMEDS_StudyManager_i.hxx"
#include "SALOMEDS_SComponent_i.hxx"
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDS_StudyManager_i.hxx"
+#include "SALOMEDS.hxx"
+#include "SALOMEDSImpl_GenericAttribute.hxx"
+#include "SALOMEDSImpl_SComponent.hxx"
+#include "SALOMEDSImpl_Study.hxx"
+#include "SALOMEDSImpl_AttributeIOR.hxx"
-#include "SALOMEDS_AttributeComment_i.hxx"
-
-#include "SALOMEDS_AttributeTreeNode_i.hxx"
-#include "SALOMEDS_AttributeUserID_i.hxx"
-
-#include "SALOMEDS_AttributePersistentRef_i.hxx"
-#include "SALOMEDS_AttributeIOR_i.hxx"
-#include "SALOMEDS_AttributeExternalFileDef_i.hxx"
-#include "SALOMEDS_AttributeFileType_i.hxx"
-#include "SALOMEDS_AttributeName_i.hxx"
-#include "SALOMEDS_AttributeSequenceOfInteger_i.hxx"
-#include "SALOMEDS_AttributeSequenceOfReal_i.hxx"
-#include "SALOMEDS_AttributeTableOfInteger_i.hxx"
-#include "SALOMEDS_AttributeTableOfReal_i.hxx"
-#include "SALOMEDS_AttributeTableOfString_i.hxx"
-#include "SALOMEDS_AttributeInteger_i.hxx"
-#include "SALOMEDS_AttributeReal_i.hxx"
-#include "SALOMEDS_AttributeDrawable_i.hxx"
-#include "SALOMEDS_AttributeSelectable_i.hxx"
-#include "SALOMEDS_AttributeExpandable_i.hxx"
-#include "SALOMEDS_AttributeOpened_i.hxx"
-#include "SALOMEDS_AttributeTextColor_i.hxx"
-#include "SALOMEDS_AttributeTextHighlightColor_i.hxx"
-#include "SALOMEDS_AttributePixMap_i.hxx"
-#include "SALOMEDS_AttributeTarget_i.hxx"
-#include "SALOMEDS_AttributeLocalID_i.hxx"
-#include "SALOMEDS_AttributeStudyProperties_i.hxx"
-#include "SALOMEDS_AttributePythonObject_i.hxx"
-
-#include "SALOMEDS_AttributeGraphic_i.hxx"
-#include "SALOMEDS_AttributeFlags_i.hxx"
-
-#include "Utils_ExceptHandlers.hxx"
-UNEXPECT_CATCH(GALockProtection, SALOMEDS::GenericAttribute::LockProtection);
-
-#include "utilities.h"
+// OCC Headers
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TColStd_HSequenceOfTransient.hxx>
+#include <map>
-using namespace std;
-using namespace SALOMEDS;
+#ifdef WIN32
+#include <process.h>
+#else
+#include <sys/types.h>
+#include <unistd.h>
+#endif
+#include "OpUtil.hxx"
-inline bool operator<(const Standard_GUID& theLeft, const Standard_GUID& theRight)
+SALOMEDS::SObject_ptr SALOMEDS_SObject_i::New(const Handle(SALOMEDSImpl_SObject)& theImpl, CORBA::ORB_ptr theORB)
{
- char aLeft[40] = "";
- theLeft.ToCString(aLeft);
+ SALOMEDS_SObject_i* so_servant = new SALOMEDS_SObject_i(theImpl, theORB);
+ SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this());
- char aRight[40] = "";
- theRight.ToCString(aRight);
-
- return strcmp(aLeft,aRight) < 0;
-}
-
-
-namespace SALOMEDS{
-
- const char* Str(const TCollection_ExtendedString& theString)
- {
- return TCollection_AsciiString(theString).ToCString();
- }
-
- typedef std::string TAttributeID;
+ return so;
+}
- typedef Standard_GUID (*TGetGUID)();
- typedef bool (*TIsCheckLockedStudy)();
- typedef Handle(TDF_Attribute) (*TNewAttribute)();
- typedef SALOMEDS_GenericAttribute_i* (*TNewInstance)(const Handle(TDF_Attribute)&, SALOMEDS_SObject_i*);
-
- struct TAttrFun{
- TAttrFun(const TGetGUID& theGetGUID,
- const TIsCheckLockedStudy& theIsCheckLockedStudy,
- const TNewAttribute& theNewAttribute,
- const TNewInstance& theNewInstance):
- myGetGUID(theGetGUID),
- myIsCheckLockedStudy(theIsCheckLockedStudy),
- myNewAttribute(theNewAttribute),
- myNewInstance(theNewInstance)
- {
- }
-
- TGetGUID myGetGUID;
- TIsCheckLockedStudy myIsCheckLockedStudy;
- TNewAttribute myNewAttribute;
- TNewInstance myNewInstance;
- };
-
- typedef std::map<TAttributeID,TAttrFun> TAttrID2FunMap;
- static TAttrID2FunMap __AttrID2FunMap__;
-
-
- typedef std::map<Standard_GUID,TAttributeID> TGUID2AttrIDMap;
- static TGUID2AttrIDMap __GUID2AttrIDMap__;
-
- bool Init()
- {
-
-#define ADD_ATTRID2FUNMAP_ITEM(theName) \
- __AttrID2FunMap__.insert( \
- TAttrID2FunMap::value_type(#theName,TAttrFun( \
- &(SALOMEDS_##theName##_i::GetGUID), \
- &(SALOMEDS_##theName##_i::IsCheckLockedStudy), \
- &(SALOMEDS_##theName##_i::NewAttribute), \
- &(SALOMEDS_##theName##_i::NewInstance) \
- )))
-
- ADD_ATTRID2FUNMAP_ITEM(AttributeName);
- ADD_ATTRID2FUNMAP_ITEM(AttributeComment);
- ADD_ATTRID2FUNMAP_ITEM(AttributeIOR);
- ADD_ATTRID2FUNMAP_ITEM(AttributeReal);
- ADD_ATTRID2FUNMAP_ITEM(AttributeInteger);
- ADD_ATTRID2FUNMAP_ITEM(AttributeSequenceOfInteger);
- ADD_ATTRID2FUNMAP_ITEM(AttributeSequenceOfReal);
- ADD_ATTRID2FUNMAP_ITEM(AttributeTableOfInteger);
- ADD_ATTRID2FUNMAP_ITEM(AttributeTableOfReal);
- ADD_ATTRID2FUNMAP_ITEM(AttributeTableOfString);
- ADD_ATTRID2FUNMAP_ITEM(AttributeLocalID);
- ADD_ATTRID2FUNMAP_ITEM(AttributePythonObject);
-
- ADD_ATTRID2FUNMAP_ITEM(AttributeUserID);
- ADD_ATTRID2FUNMAP_ITEM(AttributeTreeNode);
-
- ADD_ATTRID2FUNMAP_ITEM(AttributePersistentRef);
- ADD_ATTRID2FUNMAP_ITEM(AttributeDrawable);
- ADD_ATTRID2FUNMAP_ITEM(AttributeSelectable);
- ADD_ATTRID2FUNMAP_ITEM(AttributeExpandable);
- ADD_ATTRID2FUNMAP_ITEM(AttributeOpened);
- ADD_ATTRID2FUNMAP_ITEM(AttributeTextColor);
- ADD_ATTRID2FUNMAP_ITEM(AttributeTextHighlightColor);
- ADD_ATTRID2FUNMAP_ITEM(AttributePixMap);
- ADD_ATTRID2FUNMAP_ITEM(AttributeTarget);
- ADD_ATTRID2FUNMAP_ITEM(AttributeStudyProperties);
- ADD_ATTRID2FUNMAP_ITEM(AttributeExternalFileDef);
- ADD_ATTRID2FUNMAP_ITEM(AttributeFileType);
-
- ADD_ATTRID2FUNMAP_ITEM(AttributeGraphic);
- ADD_ATTRID2FUNMAP_ITEM(AttributeFlags);
-
- TAttrID2FunMap::const_iterator anIter = __AttrID2FunMap__.begin();
- TAttrID2FunMap::const_iterator anEnd = __AttrID2FunMap__.end();
- for(; anIter != anEnd; anIter++){
- const TAttrID2FunMap::key_type& aKey = anIter->first;
- const TAttrID2FunMap::mapped_type& aValue = anIter->second;
- __GUID2AttrIDMap__[aValue.myGetGUID()] = aKey;
- };
-
-#undef ADD_ATTRID2FUNMAP_ITEM
- return true;
- }
-
-
- static bool __IsInitilized__ = Init();
-
-
- //============================================================================
- bool GetAttrFun(const Standard_GUID& theGUID, TAttrFun& theAttrFun)
- {
- TGUID2AttrIDMap::const_iterator anIter = __GUID2AttrIDMap__.find(theGUID);
- if(anIter != __GUID2AttrIDMap__.end())
- {
- const TAttributeID& anAttributeID = anIter->second;
- TAttrID2FunMap::const_iterator anIter2 = __AttrID2FunMap__.find(anAttributeID);
- if(anIter2 != __AttrID2FunMap__.end())
- {
- theAttrFun = anIter2->second;
- return true;
- }
- }
- return false;
- }
-
-
- //============================================================================
- Standard_GUID GetGUID(const char* theType)
- {
- TAttrID2FunMap::const_iterator anIter = __AttrID2FunMap__.find(theType);
- if(anIter != __AttrID2FunMap__.end()){
- const TAttrID2FunMap::mapped_type& aValue = anIter->second;
- return aValue.myGetGUID();
- }
- // create tree node GUID by name
- if(strncmp(theType,"AttributeTreeNodeGUID",21) == 0){
- char aGUIDString[40] = "";
- sprintf(aGUIDString,&theType[21]);
- return aGUIDString;
- }
-
- return Standard_GUID();
- }
-
-
- //============================================================================
- std::string GetType(const Handle(TDF_Attribute)& theAttr)
- {
- if(theAttr.IsNull())
- return CORBA::string_dup("");
-
- Standard_GUID aGUID = theAttr->ID();
- TGUID2AttrIDMap::const_iterator anIter = __GUID2AttrIDMap__.find(aGUID);
- if(anIter != __GUID2AttrIDMap__.end())
- {
- const TAttributeID& anAttributeID = anIter->second;
- return anAttributeID;
- }
-
- char aType[60] = "";
- {
- Handle(TDataStd_TreeNode) anAttr = Handle(TDataStd_TreeNode)::DownCast(theAttr);
- if (!anAttr.IsNull()) {
- char aGUID[40] = "";
- anAttr->ID().ToCString(aGUID);
- sprintf(aType, "AttributeTreeNodeGUID%s",aGUID);
- return aType;
- }
- }
- {
- Handle(TDataStd_UAttribute) anAttr = Handle(TDataStd_UAttribute)::DownCast(theAttr);
- if (!anAttr.IsNull()) {
- char aGUID[40] = "";
- anAttr->ID().ToCString(aGUID);
- sprintf(aType, "AttributeUserID_%s",aGUID);
- return aType;
- }
- }
- return aType;
- }
-
-}
-
-//============================================================================
-SALOMEDS_Study_i::TSObjectHolder
-SALOMEDS_SObject_i::New(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel)
-{
- SALOMEDS_Study_i::TSObjectHolder aSObjectHolder;
- SALOMEDS_Study_i::TSObjectMap& anSObjectMap = theStudy->GetSObjectMap();
- SALOMEDS_Study_i::TSObjectMap::const_iterator anIter = anSObjectMap.find(theLabel);
- if(anIter != anSObjectMap.end())
- aSObjectHolder = anIter->second;
- else{
- SALOMEDS_SObject_i* aSObject = new SALOMEDS_SObject_i(theStudy,theLabel);
- aSObjectHolder.first = aSObject;
- aSObjectHolder.second = aSObject->_this();
- anSObjectMap[theLabel] = aSObjectHolder;
-
- //TCollection_AsciiString anEntry;
- //TDF_Tool::Entry(theLabel,anEntry);
- //cout<<"APO - SALOMEDS_SObject_i::New - anEntry = "<<anEntry.ToCString()<<endl;
- }
- return aSObjectHolder;
-}
-
-SALOMEDS_SObject_i*
-SALOMEDS_SObject_i::NewPtr(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel)
-{
- return New(theStudy,theLabel).first;
-}
-
-SALOMEDS::SObject_var
-SALOMEDS_SObject_i::NewRef(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel)
-{
- return New(theStudy,theLabel).second;
-}
//============================================================================
/*! Function : constructor
* Purpose :
*/
//============================================================================
-SALOMEDS_SObject_i::SALOMEDS_SObject_i(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel):
- _lab(theLabel),
- _study(theStudy)
+SALOMEDS_SObject_i::SALOMEDS_SObject_i(const Handle(SALOMEDSImpl_SObject)& impl, CORBA::ORB_ptr orb)
+ : _impl(impl)
{
+ _orb = CORBA::ORB::_duplicate(orb);
+ //SALOME::GenericObj_i::myPOA = SALOMEDS_StudyManager_i::GetPOA(GetStudy());
}
+
//============================================================================
/*! Function : destructor
*/
//============================================================================
SALOMEDS_SObject_i::~SALOMEDS_SObject_i()
-{
-}
+{}
+
-
-//============================================================================
-CORBA::ORB_var SALOMEDS_SObject_i::GetORB() const
-{
- return _study->GetORB();
-}
-
-
-//============================================================================
-PortableServer::POA_var SALOMEDS_SObject_i::GetPOA() const
-{
- return _study->GetPOA();
-}
-
-
//============================================================================
-/*! Function :
+/*! Function :GetID
* Purpose :
*/
//============================================================================
char* SALOMEDS_SObject_i::GetID()
{
- TCollection_AsciiString anEntry;
- TDF_Tool::Entry(_lab,anEntry);
- return CORBA::string_dup(anEntry.ToCString());
+ SALOMEDS::Locker lock;
+ return CORBA::string_dup(_impl->GetID().ToCString());
}
//============================================================================
-/*! Function :
+/*! Function : GetFatherComponent
* Purpose :
*/
//============================================================================
-TDF_Label SALOMEDS_SObject_i::GetFatherComponentLabel()
-{
- TDF_Label aLabel = _lab;
- while(!SALOMEDS_SComponent_i::IsA(aLabel) && !aLabel.IsRoot())
- aLabel = aLabel.Father();
-
- return aLabel;
-}
-
SALOMEDS::SComponent_ptr SALOMEDS_SObject_i::GetFatherComponent()
{
- TDF_Label aSCompLabel = GetFatherComponentLabel();
-
- return SALOMEDS_SComponent_i::NewRef(_study,aSCompLabel)._retn();
+ SALOMEDS::Locker lock;
+ SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (_impl->GetFatherComponent(), _orb);
+ return sco._retn();
}
//============================================================================
-/*! Function :
+/*! Function : GetFather
* Purpose :
*/
//============================================================================
SALOMEDS::SObject_ptr SALOMEDS_SObject_i::GetFather()
{
- return SALOMEDS_SObject_i::NewRef(_study,_lab.Father())._retn();
+ SALOMEDS::Locker lock;
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (_impl->GetFather(), _orb);
+ return so._retn();
}
//============================================================================
//============================================================================
SALOMEDS::Study_ptr SALOMEDS_SObject_i::GetStudy()
{
- return _study->_this();
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_Study) aStudy = _impl->GetStudy();
+ if(aStudy.IsNull()) {
+ MESSAGE("Problem GetStudy");
+ return SALOMEDS::Study::_nil();
+ }
+
+ TCollection_AsciiString IOR = aStudy->GetTransientReference();
+ CORBA::Object_var obj = _orb->string_to_object(IOR.ToCString());
+ SALOMEDS::Study_var Study = SALOMEDS::Study::_narrow(obj) ;
+ ASSERT(!CORBA::is_nil(Study));
+ return SALOMEDS::Study::_duplicate(Study);
+}
+
+//============================================================================
+/*! Function : FindAttribute
+ * Purpose : Find attribute of given type on this SObject
+ */
+//============================================================================
+CORBA::Boolean SALOMEDS_SObject_i::FindAttribute (SALOMEDS::GenericAttribute_out anAttribute,
+ const char* aTypeOfAttribute)
+{
+ SALOMEDS::Locker lock;
+ Handle(TDF_Attribute) anAttr;
+ if(_impl->FindAttribute(anAttr, (char*)aTypeOfAttribute)) {
+ anAttribute = SALOMEDS::GenericAttribute::_duplicate(SALOMEDS_GenericAttribute_i::CreateAttribute(anAttr, _orb));
+ return Standard_True;
+ }
+
+ return Standard_False;
}
+//============================================================================
+/*! Function : GetAllAttributes
+ * Purpose : Returns list of all attributes for this sobject
+ */
+//============================================================================
+
+SALOMEDS::ListOfAttributes* SALOMEDS_SObject_i::GetAllAttributes()
+{
+ SALOMEDS::Locker lock;
+ Handle(TColStd_HSequenceOfTransient) aSeq = _impl->GetAllAttributes();
+ SALOMEDS::ListOfAttributes_var SeqOfAttr = new SALOMEDS::ListOfAttributes;
+ Standard_Integer length = aSeq->Length();
+
+ SeqOfAttr->length(length);
+
+ if (length != 0) {
+ for(int i = 1; i<= length; i++) {
+ Handle(SALOMEDSImpl_GenericAttribute) anAttr = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(aSeq->Value(i));
+ SALOMEDS::GenericAttribute_var anAttribute;
+ anAttribute = SALOMEDS::GenericAttribute::_duplicate(SALOMEDS_GenericAttribute_i::CreateAttribute(anAttr, _orb));
+ if (!CORBA::is_nil(anAttribute)) {
+ SeqOfAttr[i - 1] = anAttribute;
+ }
+ }
+ }
+ return SeqOfAttr._retn();
+}
+
+
//============================================================================
/*! Function : ReferencedObject
* Purpose :
*/
//============================================================================
-CORBA::Boolean SALOMEDS_SObject_i::ReferencedObject(SALOMEDS::SObject_out theSObject)
+CORBA::Boolean SALOMEDS_SObject_i::ReferencedObject(SALOMEDS::SObject_out obj)
{
- Handle(TDF_Reference) aRef;
- if (!_lab.FindAttribute(TDF_Reference::GetID(),aRef))
- return false;
-
- theSObject = SALOMEDS_SObject_i::NewRef(_study,aRef->Get())._retn();
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_SObject) aRefObj;
+ if(!_impl->ReferencedObject(aRefObj)) return false;
+
+ obj = SALOMEDS_SObject_i::New (aRefObj, _orb);
return true;
}
//============================================================================
-/*! Function :
+/*! Function : FindSubObject
* Purpose :
*/
//============================================================================
-CORBA::Boolean SALOMEDS_SObject_i::FindSubObject(CORBA::Long theTag, SALOMEDS::SObject_out theSObject)
+CORBA::Boolean SALOMEDS_SObject_i::FindSubObject(long atag, SALOMEDS::SObject_out obj)
{
- TDF_Label aLabel = _lab.FindChild(theTag,false);
- if(aLabel.IsNull())
- return false;
-
- theSObject = SALOMEDS_SObject_i::NewRef(_study,aLabel)._retn();
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_SObject) aSubObj;
+ if(!_impl->FindSubObject(atag, aSubObj)) return false;
+
+ obj = SALOMEDS_SObject_i::New (aSubObj, _orb);
return true;
+
}
//============================================================================
-/*! Function :
- * Purpose :
+/*! Function : Name
+ * Purpose : gets a name
*/
//============================================================================
char* SALOMEDS_SObject_i::Name()
{
- return CORBA::string_dup(_name.c_str());
+ SALOMEDS::Locker lock;
+ return CORBA::string_dup(_impl->Name().ToCString());
}
//============================================================================
-/*! Function :
- * Purpose :
+/*! Function : Name
+ * Purpose : sets a name
*/
//============================================================================
-void SALOMEDS_SObject_i::Name(const char* theName)
+void SALOMEDS_SObject_i::Name(const char* name)
{
- _name = theName;
+ SALOMEDS::Locker lock;
+ TCollection_AsciiString aName((char*)name);
+ _impl->Name(aName);
}
//============================================================================
-/*! Function :
+/*! Function : Tag
* Purpose :
*/
//============================================================================
CORBA::Short SALOMEDS_SObject_i::Tag()
{
- return _lab.Tag();
+ SALOMEDS::Locker lock;
+ return _impl->Tag();
}
//============================================================================
-/*! Function :
+/*! Function : Depth
* Purpose :
*/
//============================================================================
CORBA::Short SALOMEDS_SObject_i::Depth()
{
- return _lab.Depth();
+ SALOMEDS::Locker lock;
+ return _impl->Depth();
}
//============================================================================
-/*! Function :
+/*! Function : GetObject
* Purpose :
*/
//============================================================================
CORBA::Object_ptr SALOMEDS_SObject_i::GetObject()
{
+ SALOMEDS::Locker lock;
+ CORBA::Object_ptr obj = CORBA::Object::_nil();
try {
- Handle(SALOMEDS_IORAttribute) anAttr;
- if(_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(),anAttr)){
- CORBA::ORB_var anORB = _study->GetStudyManager()->GetORB();
- return anORB->string_to_object(Str(anAttr->Get()));
- }
- }catch(...){
- }
- return CORBA::Object::_nil();
-}
-
-//============================================================================
-/*! Function :
- * Purpose :
- */
-//============================================================================
-char* SALOMEDS_SObject_i::GetName() {
- Handle(TDataStd_Name) anAttr;
- if(_lab.FindAttribute(TDataStd_Name::GetID(),anAttr))
- return CORBA::string_dup(Str(anAttr->Get()));
-
- return CORBA::string_dup("");
-}
-
-//============================================================================
-/*! Function :
- * Purpose :
- */
-//============================================================================
-char* SALOMEDS_SObject_i::GetComment() {
- Handle(TDataStd_Comment) anAttr;
- if(_lab.FindAttribute(TDataStd_Comment::GetID(), anAttr))
- return CORBA::string_dup(Str(anAttr->Get()));
-
- return CORBA::string_dup("");
+ TCollection_AsciiString IOR = _impl->GetIOR();
+ char* c_ior = CORBA::string_dup(IOR.ToCString());
+ obj = _orb->string_to_object(c_ior);
+ CORBA::string_free(c_ior);
+ } catch(...) {}
+ return obj;
}
//============================================================================
-/*! Function :
+/*! Function : GetName
* Purpose :
*/
//============================================================================
-char* SALOMEDS_SObject_i::GetIOR() {
- Handle(SALOMEDS_IORAttribute) anAttr;
- if(_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(),anAttr))
- return CORBA::string_dup(Str(anAttr->Get()));
-
- return CORBA::string_dup("");
-}
-
-
-//============================================================================
-/*! Function : GetAllAttributes
- * Purpose : Returns list of all attributes for this sobject
- */
-//============================================================================
-SALOMEDS_SObject_i::TAttrHolder
-SALOMEDS_SObject_i::_FindGenAttribute(const Handle(TDF_Attribute)& theAttr)
-{
- std::string aType = GetType(theAttr);
- return _FindGenAttribute(aType.c_str());
-}
-
-
-SALOMEDS::ListOfAttributes* SALOMEDS_SObject_i::GetAllAttributes()
-{
- SALOMEDS::ListOfAttributes_var aSeqOfAttr = new SALOMEDS::ListOfAttributes;
- if(_lab.NbAttributes() > 0){
- Standard_Integer i = 0;
- for(TDF_AttributeIterator iter(_lab); iter.More(); iter.Next()) {
- Handle(TDF_Attribute) anAttr = iter.Value();
- TAttrHolder anAttrHolder = _FindGenAttribute(anAttr);
- SALOMEDS::GenericAttribute_var anGenAttr = anAttrHolder.second;
- if(!anGenAttr->_is_nil())
- {
- aSeqOfAttr->length(++i);
- aSeqOfAttr[i-1] = anGenAttr._retn();
- }
- }
- }
-
- return aSeqOfAttr._retn();
-}
-
-
-//============================================================================
-/*! Function : FindAttribute
- * Purpose : Find attribute of given type on this SObject
- */
-//============================================================================
-SALOMEDS_SObject_i::TAttrHolder
-SALOMEDS_SObject_i::_CreateGenAttribute(const Handle(TDF_Attribute)& theAttr,
- const char* theType)
-{
- SALOMEDS_GenericAttribute_i* anAttr;
- TAttrID2FunMap::const_iterator anIter = __AttrID2FunMap__.find(theType);
- if(anIter != __AttrID2FunMap__.end()){
- const TAttrID2FunMap::mapped_type& aValue = anIter->second;
-
- //if(aValue.myIsCheckLockedStudy()) // mpv 03.02.05: creation of CORBA objects does not modify the study
- // _study->CheckLocked();
-
- anAttr = aValue.myNewInstance(theAttr,this);
- return TAttrHolder(anAttr,anAttr->_this());
- }
-
- if(strncmp(theType,"AttributeTreeNode",17) == 0){
- anAttr = new SALOMEDS_AttributeTreeNode_i(theAttr,this);
- return TAttrHolder(anAttr,anAttr->_this());
- }
-
- if(strncmp(theType,"AttributeUserID",15) == 0){
- anAttr = new SALOMEDS_AttributeUserID_i(theAttr,this);
- return TAttrHolder(anAttr,anAttr->_this());
- }
-
- return TAttrHolder();
-}
-
-
-SALOMEDS_SObject_i::TAttrHolder
-SALOMEDS_SObject_i::_FindGenAttribute(const char* theType)
-{
- TAttrHolder anAttrHolder;
- TAttrMap::const_iterator anIter = myAttrMap.find(theType);
- if(anIter != myAttrMap.end())
- anAttrHolder = anIter->second;
-
- Standard_GUID aGUID = ::GetGUID(theType);
- Handle(TDF_Attribute) anAttr;
-
- if(_lab.FindAttribute(aGUID,anAttr)){
- SALOMEDS_GenericAttribute_i* aGenAttr = anAttrHolder.first;
- if(aGenAttr != NULL){
- if(aGenAttr->GetAttribute() != anAttr)
- aGenAttr->SetAttribute(anAttr);
- }else{
- anAttrHolder = _CreateGenAttribute(anAttr,theType);
- }
- aGenAttr = anAttrHolder.first;
- if(aGenAttr != NULL)
- myAttrMap[theType] = anAttrHolder;
- }else{
- //myAttrMap.erase(theType);
- //if(anGenAttr != NULL)
- // anGenAttr->Destroy();
- return TAttrHolder();
- }
-
- return anAttrHolder;
-}
-
-
-CORBA::Boolean
-SALOMEDS_SObject_i::FindAttribute(SALOMEDS::GenericAttribute_out theAttribute,
- const char* theType)
+char* SALOMEDS_SObject_i::GetName()
{
- TAttrHolder anAttr = _FindGenAttribute(theType);
- SALOMEDS::GenericAttribute_var anGenAttr = anAttr.second;
- if(!CORBA::is_nil(anGenAttr)){
- theAttribute = SALOMEDS::GenericAttribute::_duplicate(anGenAttr);
- return true;
- }
- return false;
+ SALOMEDS::Locker lock;
+ CORBA::String_var aStr = CORBA::string_dup(_impl->GetName().ToCString());
+ return aStr._retn();
}
-
//============================================================================
-/*! Function : FindAttribute
- * Purpose : Find attribute of given type on this SObject
+/*! Function : GetComment
+ * Purpose :
*/
//============================================================================
-Handle(TDF_Attribute)
- SALOMEDS_SObject_i::_AddAttribute(const char* theType)
-{
- Handle(TDF_Attribute) anAttr;
- TAttrID2FunMap::const_iterator anIter = __AttrID2FunMap__.find(theType);
- if(anIter != __AttrID2FunMap__.end()){
- const TAttrID2FunMap::mapped_type& aValue = anIter->second;
-
- if(aValue.myIsCheckLockedStudy())
- _study->CheckLocked();
-
- anAttr = aValue.myNewAttribute();
- _lab.AddAttribute(anAttr);
- return anAttr;
- }
-
- if(strncmp(theType, "AttributeTreeNode",17) == 0){
- Standard_GUID aGUID;
- if(strcmp(theType, "AttributeTreeNode") == 0){
- aGUID = TDataStd_TreeNode::GetDefaultTreeID();
- }else{
- char aString[40] = "";
- sprintf(aString, &theType[21]);
- aGUID = Standard_GUID(aString); // create tree node GUID by name
- }
- if(!_lab.FindAttribute(aGUID,anAttr)){
- _study->CheckLocked();
- anAttr = TDataStd_TreeNode::Set(_lab,aGUID);
- return anAttr;
- }
- }
-
- if(strncmp(theType, "AttributeUserID",15) == 0){
- Standard_GUID aGUID = SALOMEDS_AttributeUserID_i::GetGUID();
- if(!_lab.FindAttribute(aGUID,anAttr)){
- _study->CheckLocked();
- anAttr = TDataStd_UAttribute::Set(_lab,aGUID);
- return anAttr;
- }
- }
-
-
- return anAttr;
-}
-
-
-SALOMEDS::GenericAttribute_ptr
-SALOMEDS_SObject_i::FindOrCreateAttribute(const char* theType)
+char* SALOMEDS_SObject_i::GetComment()
{
- TAttrHolder anAttrHolder = _FindGenAttribute(theType);
- SALOMEDS::GenericAttribute_var anGenAttr = anAttrHolder.second;
- if(!anGenAttr->_is_nil())
- return anGenAttr._retn();
-
- Handle(TDF_Attribute) anAttr = _AddAttribute(theType);
- if(!anAttr.IsNull()){
- anAttrHolder = _CreateGenAttribute(anAttr,theType);
- anGenAttr = anAttrHolder.second;
- if(!anGenAttr->_is_nil())
- return anGenAttr._retn();
- }
-
- return SALOMEDS::GenericAttribute::_nil();
+ SALOMEDS::Locker lock;
+ CORBA::String_var aStr = CORBA::string_dup(_impl->GetComment().ToCString());
+ return aStr._retn();
}
-
//============================================================================
-/*! Function : FindAttribute
- * Purpose : Find attribute of given type on this SObject
+/*! Function : GetIOR
+ * Purpose :
*/
//============================================================================
-void SALOMEDS_SObject_i::RemoveAttribute(const char* theType)
+char* SALOMEDS_SObject_i::GetIOR()
{
- _study->CheckLocked();
- if(strcmp(theType, "AttributeIOR") == 0) { // postponed removing of CORBA objects
- Handle(SALOMEDS_IORAttribute) anAttr;
- if(_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr))
- _study->AddPostponed(Str(anAttr->Get()));
- else
- return;
- }
- TAttrMap::iterator anIter = myAttrMap.find(theType);
- if(anIter != myAttrMap.end()){
- //myAttrMap.erase(anIter);
- }
- _lab.ForgetAttribute(::GetGUID(theType));
+ SALOMEDS::Locker lock;
+ CORBA::String_var aStr = CORBA::string_dup(_impl->GetIOR().ToCString());
+ return aStr._retn();
}
-
-void SALOMEDS_SObject_i::OnRemove()
+//===========================================================================
+// PRIVATE FUNCTIONS
+//===========================================================================
+long SALOMEDS_SObject_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
{
- Handle(TDF_Reference) aReference;
- if(_lab.FindAttribute(TDF_Reference::GetID(),aReference)){
- Handle(SALOMEDS_TargetAttribute) aTarget;
- if(aReference->Get().FindAttribute(SALOMEDS_TargetAttribute::GetID(),aTarget))
- aTarget->Remove(_lab);
- }
-
- Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects
- if(_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(),anAttr)){
- _study->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
- }
-
- //myAttrMap.clear();
-
- //SALOMEDS_Study_i::TSObjectMap& anSObjectMap = _study->GetSObjectMap();
- //anSObjectMap.erase(_lab);
+#ifdef WIN32
+ long pid = (long)_getpid();
+#else
+ long pid = (long)getpid();
+#endif
+ isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0;
+ SALOMEDSImpl_SObject* local_impl = _impl.operator->();
+ return ((long)local_impl);
}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_SObject_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#ifndef __SALOMEDS_SOBJECT_I_H__
#define __SALOMEDS_SOBJECT_I_H__
-#include <map>
-#include <string>
-
-// Cascade headers
-#include <TDF_Label.hxx>
-#include <TDocStd_Document.hxx>
-#include <Standard_GUID.hxx>
-
-#include "SALOMEDS_Study_i.hxx"
+// std C++ headers
+#include <iostream.h>
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS)
+#include <SALOME_GenericObj_i.hh>
-class SALOMEDS_GenericAttribute_i;
-
-
-namespace SALOMEDS
-{
- const char* Str(const TCollection_ExtendedString& theString);
-
- std::string GetType(const Handle(TDF_Attribute)& theAttr);
-
- Standard_GUID GetGUID(const char* theType);
-
-}
-
+// Cascade headers
+#include "SALOMEDSImpl_SObject.hxx"
class SALOMEDS_SObject_i: public virtual POA_SALOMEDS::SObject,
- public virtual PortableServer::RefCountServantBase
+ public virtual PortableServer::RefCountServantBase,
+ public virtual SALOME::GenericObj_i
{
-public:
- static
- SALOMEDS_Study_i::TSObjectHolder
- New(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel);
-
- static
- SALOMEDS_SObject_i*
- NewPtr(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel);
+protected:
+ CORBA::ORB_ptr _orb;
+ Handle(SALOMEDSImpl_SObject) _impl;
- static
- SALOMEDS::SObject_var
- NewRef(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel);
+public:
- virtual SALOMEDS::SObject_ptr GetFather() ;
+ static SALOMEDS::SObject_ptr New(const Handle(SALOMEDSImpl_SObject)&, CORBA::ORB_ptr);
+
+ SALOMEDS_SObject_i(const Handle(SALOMEDSImpl_SObject)&, CORBA::ORB_ptr);
+
+ virtual ~SALOMEDS_SObject_i();
+
+ virtual char* GetID();
virtual SALOMEDS::SComponent_ptr GetFatherComponent();
- virtual CORBA::Boolean ReferencedObject(SALOMEDS::SObject_out theSObject);
- virtual CORBA::Boolean FindSubObject(CORBA::Long theTag, SALOMEDS::SObject_out theSObject);
+ virtual SALOMEDS::SObject_ptr GetFather() ;
+ virtual CORBA::Boolean FindAttribute(SALOMEDS::GenericAttribute_out anAttribute, const char* aTypeOfAttribute);
+ virtual CORBA::Boolean ReferencedObject(SALOMEDS::SObject_out obj) ;
+ virtual CORBA::Boolean FindSubObject(long atag, SALOMEDS::SObject_out obj );
- virtual SALOMEDS::Study_ptr GetStudy();
+ virtual SALOMEDS::Study_ptr GetStudy() ;
+ virtual char* Name();
+ virtual void Name(const char*);
virtual SALOMEDS::ListOfAttributes* GetAllAttributes();
virtual CORBA::Object_ptr GetObject();
- virtual char* GetID();
- virtual CORBA::Short Tag();
- virtual CORBA::Short Depth();
-
- virtual char* Name();
- virtual void Name(const char* theName);
-
virtual char* GetName();
virtual char* GetComment();
virtual char* GetIOR();
- CORBA::Boolean
- FindAttribute(SALOMEDS::GenericAttribute_out theAttribute,
- const char* theTypeOfAttribute);
-
- SALOMEDS::GenericAttribute_ptr
- FindOrCreateAttribute(const char* theTypeOfAttribute);
-
- void RemoveAttribute(const char* theTypeOfAttribute);
- void OnRemove();
-
- SALOMEDS_Study_i* GetStudyServant(){ return _study;}
-
- TDF_Label GetLabel(){ return _lab;}
- TDF_Label GetFatherLabel(){ return _lab.Father();}
- TDF_Label GetFatherComponentLabel();
-
- CORBA::ORB_var GetORB() const;
-
- PortableServer::POA_var GetPOA() const;
-
-protected:
- friend class SALOMEDS_GenericAttribute_i;
-
- typedef std::string TAttributeID;
- typedef std::pair<SALOMEDS_GenericAttribute_i*,SALOMEDS::GenericAttribute_var> TAttrHolder;
- typedef std::map<TAttributeID,TAttrHolder> TAttrMap;
- TAttrMap myAttrMap;
-
- TAttrHolder
- _FindGenAttribute(const Handle(TDF_Attribute)& theAttr);
-
- TAttrHolder
- _CreateGenAttribute(const Handle(TDF_Attribute)& theAttr,
- const char* theTypeOfAttribute);
-
- TAttrHolder
- _FindGenAttribute(const char* theTypeOfAttribute);
-
- Handle(TDF_Attribute)
- _AddAttribute(const char* theTypeOfAttribute);
-
- SALOMEDS_Study_i* _study;
- std::string _name;
- TDF_Label _lab;
-
- SALOMEDS_SObject_i(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel);
-
- ~SALOMEDS_SObject_i();
-
-private:
- SALOMEDS_SObject_i(); // Not implemented
- void operator=(const SALOMEDS_SObject_i&); // Not implemented
+ virtual CORBA::Short Tag();
+ virtual CORBA::Short Depth();
+ virtual long GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal);
};
-
#endif
try
{
// Initialise the ORB.
+#if OMNIORB_VERSION >= 4
+ const char* options[][2] = { { "giopMaxMsgSize", "104857600" }, { 0, 0 } };
+ CORBA::ORB_var orb = CORBA::ORB_init( argc , argv , "omniORB4", options) ;
+#else
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB3");
omniORB::MaxMessageSize(100 * 1024 * 1024);
+#endif
// Obtain a reference to the root POA.
- //
long TIMESleep = 500000000;
int NumberOfTries = 40;
int a;
--- /dev/null
+// File : SALOMEDS_Study.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+using namespace std;
+
+#include "utilities.h"
+
+#include "SALOMEDS_Study.hxx"
+#include "SALOMEDS_SComponent.hxx"
+#include "SALOMEDSImpl_SComponent.hxx"
+#include "SALOMEDS_SObject.hxx"
+#include "SALOMEDSImpl_SObject.hxx"
+#include "SALOMEDS_StudyBuilder.hxx"
+#include "SALOMEDSImpl_StudyBuilder.hxx"
+#include "SALOMEDS_ChildIterator.hxx"
+#include "SALOMEDSImpl_ChildIterator.hxx"
+#include "SALOMEDS_SComponentIterator.hxx"
+#include "SALOMEDSImpl_SComponentIterator.hxx"
+#include "SALOMEDS_AttributeStudyProperties.hxx"
+#include "SALOMEDSImpl_AttributeStudyProperties.hxx"
+#include "SALOMEDS_UseCaseBuilder.hxx"
+#include "SALOMEDSImpl_UseCaseBuilder.hxx"
+
+#include "SALOMEDS_Driver_i.hxx"
+#include "SALOMEDS_Study_i.hxx"
+
+#include <TCollection_AsciiString.hxx>
+#include <TColStd_HSequenceOfAsciiString.hxx>
+#include <TColStd_HSequenceOfTransient.hxx>
+
+#include "Utils_ORB_INIT.hxx"
+#include "Utils_SINGLETON.hxx"
+
+#ifdef WIN32
+#include <process.h>
+#else
+#include <sys/types.h>
+#include <unistd.h>
+#endif
+
+#include "OpUtil.hxx"
+
+SALOMEDS_Study::SALOMEDS_Study(const Handle(SALOMEDSImpl_Study)& theStudy)
+{
+ _isLocal = true;
+ _local_impl = theStudy;
+ _corba_impl = SALOMEDS::Study::_nil();
+ init_orb();
+}
+
+SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy)
+{
+#ifdef WIN32
+ long pid = (long)_getpid();
+#else
+ long pid = (long)getpid();
+#endif
+
+ long addr = theStudy->GetLocalImpl(GetHostname().c_str(), pid, _isLocal);
+ if(_isLocal) {
+ _local_impl = ((SALOMEDSImpl_Study*)(addr));
+ _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
+ }
+ else {
+ _local_impl = NULL;
+ _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
+ }
+
+ init_orb();
+}
+
+SALOMEDS_Study::~SALOMEDS_Study()
+{
+}
+
+std::string SALOMEDS_Study::GetPersistentReference()
+{
+ std::string aRef;
+ if(_isLocal) aRef = _local_impl->GetPersistentReference().ToCString();
+ else aRef = _corba_impl->GetPersistentReference();
+ return aRef;
+}
+
+std::string SALOMEDS_Study::GetTransientReference()
+{
+ std::string aRef;
+ if(_isLocal) aRef = _local_impl->GetTransientReference().ToCString();
+ else aRef = _corba_impl->GetTransientReference();
+ return aRef;
+}
+
+bool SALOMEDS_Study::IsEmpty()
+{
+ bool ret;
+ if(_isLocal) ret = _local_impl->IsEmpty();
+ else ret = _corba_impl->IsEmpty();
+ return ret;
+}
+
+_PTR(SComponent) SALOMEDS_Study::FindComponent (const std::string& aComponentName)
+{
+ SALOMEDSClient_SComponent* aSCO = NULL;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_SComponent) aSCO_impl =_local_impl->FindComponent((char*)aComponentName.c_str());
+ if(aSCO_impl.IsNull()) return _PTR(SComponent)(aSCO);
+ aSCO = new SALOMEDS_SComponent(aSCO_impl);
+ }
+ else {
+ SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponent((char*)aComponentName.c_str());
+ if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
+ aSCO = new SALOMEDS_SComponent(aSCO_impl);
+ }
+ return _PTR(SComponent)(aSCO);
+}
+
+_PTR(SComponent) SALOMEDS_Study::FindComponentID(const std::string& aComponentID)
+{
+ SALOMEDSClient_SComponent* aSCO = NULL;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_SComponent) aSCO_impl =_local_impl->FindComponentID((char*)aComponentID.c_str());
+ if(aSCO_impl.IsNull()) return _PTR(SComponent)(aSCO);
+ aSCO = new SALOMEDS_SComponent(aSCO_impl);
+ }
+ else {
+ SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponentID((char*)aComponentID.c_str());
+ if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
+ aSCO = new SALOMEDS_SComponent(aSCO_impl);
+ }
+ return _PTR(SComponent)(aSCO);
+
+}
+
+_PTR(SObject) SALOMEDS_Study::FindObject(const std::string& anObjectName)
+{
+ SALOMEDSClient_SObject* aSO = NULL;
+
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObject((char*)anObjectName.c_str());
+ if(aSO_impl.IsNull()) return _PTR(SObject)(aSO);
+ Handle(SALOMEDSImpl_SComponent) aSCO_impl = Handle(SALOMEDSImpl_SComponent)::DownCast(aSO_impl);
+ if(!aSCO_impl.IsNull()) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
+ aSO = new SALOMEDS_SObject(aSO_impl);
+ }
+ else {
+ SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObject((char*)anObjectName.c_str());
+ if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
+ SALOMEDS::SComponent_var aSCO_impl = SALOMEDS::SComponent::_narrow(aSO_impl);
+ if(!CORBA::is_nil(aSCO_impl)) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
+ aSO = new SALOMEDS_SObject(aSO_impl);
+ }
+
+ return _PTR(SObject)(aSO);
+}
+
+std::vector<_PTR(SObject)> SALOMEDS_Study::FindObjectByName(const std::string& anObjectName,
+ const std::string& aComponentName)
+{
+ std::vector<_PTR(SObject)> aVector;
+ int i, aLength = 0;
+
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfTransient) aSeq = _local_impl->FindObjectByName((char*)anObjectName.c_str(), (char*)aComponentName.c_str());
+ aLength = aSeq->Length();
+ for(i = 1; i<= aLength; i++)
+ aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(Handle(SALOMEDSImpl_SObject)::DownCast(aSeq->Value(i)))));
+ }
+ else {
+ SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindObjectByName((char*)anObjectName.c_str(),
+ (char*)aComponentName.c_str());
+ aLength = aSeq->length();
+ for(i = 0; i< aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
+ }
+
+ return aVector;
+}
+
+_PTR(SObject) SALOMEDS_Study::FindObjectID(const std::string& anObjectID)
+{
+ SALOMEDSClient_SObject* aSO = NULL;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObjectID((char*)anObjectID.c_str());
+ if(aSO_impl.IsNull()) return _PTR(SObject)(aSO);
+ return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
+ }
+ else {
+ SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectID((char*)anObjectID.c_str());
+ if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
+ return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
+ }
+ return _PTR(SObject)(aSO);
+}
+
+_PTR(SObject) SALOMEDS_Study::CreateObjectID(const std::string& anObjectID)
+{
+ SALOMEDSClient_SObject* aSO = NULL;
+ if(_isLocal) aSO = new SALOMEDS_SObject(_local_impl->CreateObjectID((char*)anObjectID.c_str()));
+ else aSO = new SALOMEDS_SObject(_corba_impl->CreateObjectID((char*)anObjectID.c_str()));
+ return _PTR(SObject)(aSO);
+}
+
+_PTR(SObject) SALOMEDS_Study::FindObjectIOR(const std::string& anObjectIOR)
+{
+ SALOMEDSClient_SObject* aSO = NULL;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObjectIOR((char*)anObjectIOR.c_str());
+ if(aSO_impl.IsNull()) return _PTR(SObject)(aSO);
+ aSO = new SALOMEDS_SObject(aSO_impl);
+ }
+ else {
+ SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectIOR((char*)anObjectIOR.c_str());
+ if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
+ aSO = new SALOMEDS_SObject(aSO_impl);
+ }
+ return _PTR(SObject)(aSO);
+}
+
+_PTR(SObject) SALOMEDS_Study::FindObjectByPath(const std::string& thePath)
+{
+ SALOMEDSClient_SObject* aSO = NULL;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObjectByPath((char*)thePath.c_str());
+ if(aSO_impl.IsNull()) return _PTR(SObject)(aSO);
+ aSO = new SALOMEDS_SObject(aSO_impl);
+ }
+ else {
+ SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectByPath((char*)thePath.c_str());
+ if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
+ aSO = new SALOMEDS_SObject(aSO_impl);
+ }
+ return _PTR(SObject)(aSO);
+}
+
+std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO)
+{
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
+ std::string aPath;
+ if(_isLocal) aPath = _local_impl->GetObjectPath(aSO->GetLocalImpl()).ToCString();
+ else aPath = _corba_impl->GetObjectPath(aSO->GetCORBAImpl());
+ return aPath;
+}
+
+void SALOMEDS_Study::SetContext(const std::string& thePath)
+{
+ if(_isLocal) _local_impl->SetContext((char*)thePath.c_str());
+ else _corba_impl->SetContext((char*)thePath.c_str());
+}
+
+std::string SALOMEDS_Study::GetContext()
+{
+ std::string aPath;
+ if(_isLocal) aPath = _local_impl->GetContext().ToCString();
+ else aPath = _corba_impl->GetContext();
+ return aPath;
+}
+
+std::vector<std::string> SALOMEDS_Study::GetObjectNames(const std::string& theContext)
+{
+ std::vector<std::string> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetObjectNames((char*)theContext.c_str());
+ aLength = aSeq->Length();
+ for(i = 1; i<=aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
+ }
+ else {
+ SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetObjectNames((char*)theContext.c_str());
+ aLength = aSeq->length();
+ for(i = 0; i<aLength; i++) aVector.push_back(std::string((std::string)aSeq[i].in()));
+ }
+ return aVector;
+}
+
+std::vector<std::string> SALOMEDS_Study::GetDirectoryNames(const std::string& theContext)
+{
+ std::vector<std::string> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetDirectoryNames((char*)theContext.c_str());
+ aLength = aSeq->Length();
+ for(i = 1; i<=aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
+ }
+ else {
+ SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetDirectoryNames((char*)theContext.c_str());
+ aLength = aSeq->length();
+ for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
+ }
+ return aVector;
+}
+
+std::vector<std::string> SALOMEDS_Study::GetFileNames(const std::string& theContext)
+{
+ std::vector<std::string> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetFileNames((char*)theContext.c_str());
+ aLength = aSeq->Length();
+ for(i = 1; i<=aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
+ }
+ else {
+ SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetFileNames((char*)theContext.c_str());
+ aLength = aSeq->length();
+
+ for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
+ }
+ return aVector;
+}
+
+std::vector<std::string> SALOMEDS_Study::GetComponentNames(const std::string& theContext)
+{
+ std::vector<std::string> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetComponentNames((char*)theContext.c_str());
+ aLength = aSeq->Length();
+ for(i = 1; i<=aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
+ }
+ else {
+ SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetComponentNames((char*)theContext.c_str());
+ aLength = aSeq->length();
+ for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
+ }
+ return aVector;
+}
+
+_PTR(ChildIterator) SALOMEDS_Study::NewChildIterator(const _PTR(SObject)& theSO)
+{
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
+ SALOMEDSClient_ChildIterator* aCI = NULL;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_ChildIterator) aCIimpl = _local_impl->NewChildIterator(aSO->GetLocalImpl());
+ aCI = new SALOMEDS_ChildIterator(aCIimpl);
+ }
+ else {
+ SALOMEDS::ChildIterator_var aCIimpl = _corba_impl->NewChildIterator(aSO->GetCORBAImpl());
+ aCI = new SALOMEDS_ChildIterator(aCIimpl);
+ }
+
+ return _PTR(ChildIterator)(aCI);
+}
+
+_PTR(SComponentIterator) SALOMEDS_Study::NewComponentIterator()
+{
+ SALOMEDSClient_SComponentIterator* aCI = NULL;
+ if(_isLocal) {
+ SALOMEDSImpl_SComponentIterator aCIimpl = _local_impl->NewComponentIterator();
+ aCI = new SALOMEDS_SComponentIterator(aCIimpl);
+ }
+ else {
+ SALOMEDS::SComponentIterator_var aCIimpl = _corba_impl->NewComponentIterator();
+ aCI = new SALOMEDS_SComponentIterator(aCIimpl);
+ }
+
+ return _PTR(SComponentIterator)(aCI);
+}
+
+_PTR(StudyBuilder) SALOMEDS_Study::NewBuilder()
+{
+ SALOMEDSClient_StudyBuilder* aSB = NULL;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_StudyBuilder) aSBimpl = _local_impl->NewBuilder();
+ aSB = new SALOMEDS_StudyBuilder(aSBimpl);
+ }
+ else {
+ SALOMEDS::StudyBuilder_var aSBimpl = _corba_impl->NewBuilder();
+ aSB = new SALOMEDS_StudyBuilder(aSBimpl);
+ }
+
+ return _PTR(StudyBuilder)(aSB);
+}
+
+std::string SALOMEDS_Study::Name()
+{
+ std::string aName;
+ if(_isLocal) aName = _local_impl->Name().ToCString();
+ else aName = _corba_impl->Name();
+ return aName;
+}
+
+void SALOMEDS_Study::Name(const std::string& theName)
+{
+ if(_isLocal) _local_impl->Name((char*)theName.c_str());
+ else _corba_impl->Name((char*)theName.c_str());
+}
+
+bool SALOMEDS_Study::IsSaved()
+{
+ bool isSaved;
+ if(_isLocal) isSaved = _local_impl->IsSaved();
+ else isSaved = _corba_impl->IsSaved();
+ return isSaved;
+}
+
+void SALOMEDS_Study::IsSaved(bool save)
+{
+ if(_isLocal) _local_impl->IsSaved(save);
+ else _corba_impl->IsSaved(save);
+}
+
+bool SALOMEDS_Study::IsModified()
+{
+ bool isModified;
+ if(_isLocal) isModified = _local_impl->IsModified();
+ else isModified = _corba_impl->IsModified();
+ return isModified;
+}
+
+std::string SALOMEDS_Study::URL()
+{
+ std::string aURL;
+ if(_isLocal) aURL = _local_impl->URL().ToCString();
+ else aURL = _corba_impl->URL();
+ return aURL;
+}
+
+void SALOMEDS_Study::URL(const std::string& url)
+{
+ if(_isLocal) _local_impl->URL((char*)url.c_str());
+ else _corba_impl->URL((char*)url.c_str());
+}
+
+int SALOMEDS_Study::StudyId()
+{
+ int anID;
+ if(_isLocal) anID = _local_impl->StudyId();
+ else anID = _corba_impl->StudyId();
+ return anID;
+}
+
+void SALOMEDS_Study::StudyId(int id)
+{
+ if(_isLocal) _local_impl->StudyId(id);
+ else _corba_impl->StudyId(id);
+}
+
+std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)& theSO)
+{
+ std::vector<_PTR(SObject)> aVector;
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfTransient) aSeq = _local_impl->FindDependances(aSO->GetLocalImpl());
+ aLength = aSeq->Length();
+ for(i=1; i<=aLength; i++)
+ aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(Handle(SALOMEDSImpl_SObject)::DownCast(aSeq->Value(i)))));
+ }
+ else {
+ SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindDependances(aSO->GetCORBAImpl());
+ aLength = aSeq->length();
+ for(i=0; i<aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
+ }
+ return aVector;
+}
+
+_PTR(AttributeStudyProperties) SALOMEDS_Study::GetProperties()
+{
+ SALOMEDSClient_AttributeStudyProperties* aProp;
+ if(_isLocal) aProp = new SALOMEDS_AttributeStudyProperties(_local_impl->GetProperties());
+ else aProp = new SALOMEDS_AttributeStudyProperties(_corba_impl->GetProperties());
+ return _PTR(AttributeStudyProperties)(aProp);
+}
+
+std::string SALOMEDS_Study::GetLastModificationDate()
+{
+ std::string aDate;
+ if(_isLocal) aDate = _local_impl->GetLastModificationDate().ToCString();
+ else aDate = _corba_impl->GetLastModificationDate();
+ return aDate;
+}
+
+std::vector<std::string> SALOMEDS_Study::GetModificationsDate()
+{
+ std::vector<std::string> aVector;
+ int aLength, i;
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetModificationsDate();
+ aLength = aSeq->Length();
+ for(i=1; i<=aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
+ }
+ else {
+ SALOMEDS::ListOfDates_var aSeq = _corba_impl->GetModificationsDate();
+ aLength = aSeq->length();
+ for(i=0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
+ }
+ return aVector;
+}
+
+_PTR(UseCaseBuilder) SALOMEDS_Study::GetUseCaseBuilder()
+{
+ SALOMEDSClient_UseCaseBuilder* aUB = NULL;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_UseCaseBuilder) aUBimpl = _local_impl->GetUseCaseBuilder();
+ aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
+ }
+ else {
+ SALOMEDS::UseCaseBuilder_var aUBimpl = _corba_impl->GetUseCaseBuilder();
+ aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
+ }
+
+ return _PTR(UseCaseBuilder)(aUB);
+}
+
+void SALOMEDS_Study::Close()
+{
+ if(_isLocal) _local_impl->Close();
+ else _corba_impl->Close();
+}
+
+void SALOMEDS_Study::EnableUseCaseAutoFilling(bool isEnabled)
+{
+ if(_isLocal) _local_impl->EnableUseCaseAutoFilling(isEnabled);
+ else _corba_impl->EnableUseCaseAutoFilling(isEnabled);
+}
+
+bool SALOMEDS_Study::DumpStudy(const std::string& thePath, const std::string& theBaseName, bool isPublished)
+{
+ bool ret;
+ if(_isLocal) {
+ SALOMEDS_DriverFactory_i* aFactory = new SALOMEDS_DriverFactory_i(_orb);
+ ret = _local_impl->DumpStudy((char*)thePath.c_str(), (char*)theBaseName.c_str(), isPublished, aFactory);
+ delete aFactory;
+ }
+ else ret = _corba_impl->DumpStudy((char*)thePath.c_str(), (char*)theBaseName.c_str(), isPublished);
+ return ret;
+}
+
+std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject)
+{
+ return _orb->object_to_string(theObject);
+}
+
+CORBA::Object_ptr SALOMEDS_Study::ConvertIORToObject(const std::string& theIOR)
+{
+ return _orb->string_to_object(theIOR.c_str());
+}
+
+void SALOMEDS_Study::init_orb()
+{
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
+ _orb = init(0 , 0 ) ;
+}
+
+SALOMEDS::Study_ptr SALOMEDS_Study::GetStudy()
+{
+ if(_isLocal) {
+ if(!CORBA::is_nil(_corba_impl)) return _corba_impl;
+ std::string anIOR = _local_impl->GetTransientReference().ToCString();
+ SALOMEDS::Study_var aStudy;
+ if(!_local_impl->IsError() && anIOR != "") {
+ aStudy = SALOMEDS::Study::_narrow(_orb->string_to_object(anIOR.c_str()));
+ }
+ else {
+ SALOMEDS_Study_i *aStudy_servant = new SALOMEDS_Study_i(_local_impl, _orb);
+ aStudy = aStudy_servant->_this();
+ _local_impl->SetTransientReference(_orb->object_to_string(aStudy));
+ }
+ return aStudy._retn();
+ }
+ else {
+ return _corba_impl;
+ }
+
+ return SALOMEDS::Study::_nil();
+}
--- /dev/null
+// File : SALOMEDS_Study.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef __SALOMEDS_STUDY_H__
+#define __SALOMEDS_STUDY_H__
+
+#include <vector>
+#include <string>
+
+#include "SALOMEDSClient.hxx"
+#include "SALOMEDSImpl_Study.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+
+class SALOMEDS_Study: public SALOMEDSClient_Study
+{
+
+private:
+ bool _isLocal;
+ Handle(SALOMEDSImpl_Study) _local_impl;
+ SALOMEDS::Study_var _corba_impl;
+ CORBA::ORB_var _orb;
+
+public:
+
+ SALOMEDS_Study(const Handle(SALOMEDSImpl_Study)& theStudy);
+ SALOMEDS_Study(SALOMEDS::Study_ptr theStudy);
+ ~SALOMEDS_Study();
+
+ virtual std::string GetPersistentReference();
+ virtual std::string GetTransientReference();
+ virtual bool IsEmpty();
+ virtual _PTR(SComponent) FindComponent (const std::string& aComponentName);
+ virtual _PTR(SComponent) FindComponentID(const std::string& aComponentID);
+ virtual _PTR(SObject) FindObject(const std::string& anObjectName);
+ virtual std::vector<_PTR(SObject)> FindObjectByName( const std::string& anObjectName, const std::string& aComponentName ) ;
+ virtual _PTR(SObject) FindObjectID(const std::string& anObjectID);
+ virtual _PTR(SObject) CreateObjectID(const std::string& anObjectID);
+ virtual _PTR(SObject) FindObjectIOR(const std::string& anObjectIOR);
+ virtual _PTR(SObject) FindObjectByPath(const std::string& thePath);
+ virtual std::string GetObjectPath(const _PTR(SObject)& theSO);
+ virtual void SetContext(const std::string& thePath);
+ virtual std::string GetContext();
+ virtual std::vector<std::string> GetObjectNames(const std::string& theContext);
+ virtual std::vector<std::string> GetDirectoryNames(const std::string& theContext);
+ virtual std::vector<std::string> GetFileNames(const std::string& theContext);
+ virtual std::vector<std::string> GetComponentNames(const std::string& theContext);
+ virtual _PTR(ChildIterator) NewChildIterator(const _PTR(SObject)& theSO);
+ virtual _PTR(SComponentIterator) NewComponentIterator();
+ virtual _PTR(StudyBuilder) NewBuilder();
+ virtual std::string Name();
+ virtual void Name(const std::string& name);
+ virtual bool IsSaved();
+ virtual void IsSaved(bool save);
+ virtual bool IsModified();
+ virtual std::string URL();
+ virtual void URL(const std::string& url);
+ virtual int StudyId();
+ virtual void StudyId(int id);
+ virtual std::vector<_PTR(SObject)> FindDependances(const _PTR(SObject)& theSO);
+ virtual _PTR(AttributeStudyProperties) GetProperties();
+ virtual std::string GetLastModificationDate();
+ virtual std::vector<std::string> GetModificationsDate();
+ virtual _PTR(UseCaseBuilder) GetUseCaseBuilder();
+ virtual void Close();
+ virtual void EnableUseCaseAutoFilling(bool isEnabled);
+ virtual bool DumpStudy(const std::string& thePath, const std::string& theBaseName, bool isPublished);
+
+ std::string ConvertObjectToIOR(CORBA::Object_ptr theObject);
+ CORBA::Object_ptr ConvertIORToObject(const std::string& theIOR);
+
+ SALOMEDS::Study_ptr GetStudy();
+
+private:
+ void init_orb();
+
+};
+#endif
--- /dev/null
+// File : SALOMEDS_StudyBuilder.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+using namespace std;
+
+#include "utilities.h"
+
+#include "SALOMEDS_StudyBuilder.hxx"
+#include "SALOMEDS_SObject.hxx"
+#include "SALOMEDSImpl_SObject.hxx"
+#include "SALOMEDS_SComponent.hxx"
+#include "SALOMEDSImpl_SComponent.hxx"
+#include "SALOMEDS_Driver_i.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_GenericAttribute.hxx"
+#include <string>
+#include <TCollection_AsciiString.hxx>
+#include <TDF_Attribute.hxx>
+#include "SALOMEDS_StudyManager.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "Utils_ORB_INIT.hxx"
+#include "Utils_SINGLETON.hxx"
+
+SALOMEDS_StudyBuilder::SALOMEDS_StudyBuilder(const Handle(SALOMEDSImpl_StudyBuilder)& theBuilder)
+{
+ _isLocal = true;
+ _local_impl = theBuilder;
+ _corba_impl = SALOMEDS::StudyBuilder::_nil();
+
+ init_orb();
+}
+
+SALOMEDS_StudyBuilder::SALOMEDS_StudyBuilder(SALOMEDS::StudyBuilder_ptr theBuilder)
+{
+ _isLocal = false;
+ _local_impl = NULL;
+ _corba_impl = SALOMEDS::StudyBuilder::_duplicate(theBuilder);
+
+ init_orb();
+}
+
+SALOMEDS_StudyBuilder::~SALOMEDS_StudyBuilder()
+{
+}
+
+_PTR(SComponent) SALOMEDS_StudyBuilder::NewComponent(const std::string& ComponentDataType)
+{
+ CheckLocked();
+
+ SALOMEDSClient_SComponent* aSCO = NULL;
+
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_SComponent) aSCO_impl =_local_impl->NewComponent((char*)ComponentDataType.c_str());
+ if(aSCO_impl.IsNull()) return _PTR(SComponent)(aSCO);
+ aSCO = new SALOMEDS_SComponent(aSCO_impl);
+ }
+ else {
+ SALOMEDS::SComponent_var aSCO_impl = _corba_impl->NewComponent((char*)ComponentDataType.c_str());
+ if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
+ aSCO = new SALOMEDS_SComponent(aSCO_impl);
+ }
+
+ return _PTR(SComponent)(aSCO);
+}
+
+void SALOMEDS_StudyBuilder::DefineComponentInstance (const _PTR(SComponent)& theSCO,
+ const std::string& ComponentIOR)
+{
+ CheckLocked();
+
+ SALOMEDS_SComponent* aSCO = dynamic_cast<SALOMEDS_SComponent*>(theSCO.get());
+ if(_isLocal) _local_impl->DefineComponentInstance(Handle(SALOMEDSImpl_SComponent)::DownCast(aSCO->GetLocalImpl()),
+ (char*)ComponentIOR.c_str());
+ else {
+ CORBA::Object_var obj = _orb->string_to_object(ComponentIOR.c_str());
+ _corba_impl->DefineComponentInstance(SALOMEDS::SComponent::_narrow(aSCO->GetCORBAImpl()), obj);
+ }
+}
+
+void SALOMEDS_StudyBuilder::RemoveComponent(const _PTR(SComponent)& theSCO)
+{
+ CheckLocked();
+
+ SALOMEDS_SComponent* aSCO = dynamic_cast<SALOMEDS_SComponent*>(theSCO.get());
+ if(_isLocal) _local_impl->RemoveComponent(Handle(SALOMEDSImpl_SComponent)::DownCast(aSCO->GetLocalImpl()));
+ else _corba_impl->RemoveComponent(SALOMEDS::SComponent::_narrow(aSCO->GetCORBAImpl()));
+}
+
+_PTR(SObject) SALOMEDS_StudyBuilder::NewObject(const _PTR(SObject)& theFatherObject)
+{
+ CheckLocked();
+
+ SALOMEDSClient_SObject* aSO = NULL;
+ SALOMEDS_SObject* father = dynamic_cast< SALOMEDS_SObject*>(theFatherObject.get());
+ if(father == NULL) return _PTR(SObject)(aSO);
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->NewObject(father->GetLocalImpl());
+ if(aSO_impl.IsNull()) return _PTR(SObject)(aSO);
+ aSO = new SALOMEDS_SObject(aSO_impl);
+ }
+ else {
+ SALOMEDS::SObject_var aSO_impl = _corba_impl->NewObject(father->GetCORBAImpl());
+ if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
+ aSO = new SALOMEDS_SObject(aSO_impl);
+ }
+
+ return _PTR(SObject)(aSO);
+}
+
+_PTR(SObject) SALOMEDS_StudyBuilder::NewObjectToTag(const _PTR(SObject)& theFatherObject, int theTag)
+{
+ CheckLocked();
+
+ SALOMEDSClient_SObject* aSO = NULL;
+ SALOMEDS_SObject* father = dynamic_cast< SALOMEDS_SObject*>(theFatherObject.get());
+ if(father == NULL) return _PTR(SObject)(aSO);
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->NewObjectToTag(father->GetLocalImpl(), theTag);
+ if(aSO_impl.IsNull()) return _PTR(SObject)(aSO);
+ aSO = new SALOMEDS_SObject(aSO_impl);
+ }
+ else {
+ SALOMEDS::SObject_var aSO_impl = _corba_impl->NewObjectToTag(father->GetCORBAImpl(), theTag);
+ if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
+ aSO = new SALOMEDS_SObject(aSO_impl);
+ }
+
+ return _PTR(SObject)(aSO);
+
+}
+
+void SALOMEDS_StudyBuilder::AddDirectory(const std::string& thePath)
+{
+ CheckLocked();
+
+ if(_isLocal) {
+ _local_impl->AddDirectory((char*)thePath.c_str());
+ if(_local_impl->IsError()) {
+ std::string anErrorCode = _local_impl->GetErrorCode().ToCString();
+ if(anErrorCode == "StudyNameAlreadyUsed") throw SALOMEDS::Study::StudyNameAlreadyUsed();
+ if(anErrorCode == "StudyInvalidDirectory") throw SALOMEDS::Study::StudyInvalidDirectory();
+ if(anErrorCode == "StudyInvalidComponent") throw SALOMEDS::Study::StudyInvalidComponent();
+ }
+ }
+ else _corba_impl->AddDirectory((char*)thePath.c_str());
+}
+
+void SALOMEDS_StudyBuilder::LoadWith(const _PTR(SComponent)& theSCO, const std::string& theIOR)
+{
+ SALOMEDS_SComponent* aSCO = dynamic_cast<SALOMEDS_SComponent*>(theSCO.get());
+ CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str());
+ SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(obj);
+
+ if(_isLocal) {
+ SALOMEDS_Driver_i* drv = new SALOMEDS_Driver_i(aDriver, _orb);
+ Handle(SALOMEDSImpl_SComponent) aSCO_impl = Handle(SALOMEDSImpl_SComponent)::DownCast(aSCO->GetLocalImpl());
+ bool isDone = _local_impl->LoadWith(aSCO_impl, drv);
+ delete drv;
+ if(!isDone && _local_impl->IsError())
+ THROW_SALOME_CORBA_EXCEPTION(_local_impl->GetErrorCode().ToCString(),SALOME::BAD_PARAM);
+ }
+ else {
+ _corba_impl->LoadWith(SALOMEDS::SComponent::_narrow(aSCO->GetCORBAImpl()), aDriver);
+ }
+}
+
+void SALOMEDS_StudyBuilder::Load(const _PTR(SObject)& theSCO)
+{
+ SALOMEDS_SComponent* aSCO = dynamic_cast<SALOMEDS_SComponent*>(theSCO.get());
+ if(_isLocal) _local_impl->Load(Handle(SALOMEDSImpl_SComponent)::DownCast(aSCO->GetLocalImpl()));
+ else _corba_impl->Load(SALOMEDS::SComponent::_narrow(aSCO->GetCORBAImpl()));
+}
+
+void SALOMEDS_StudyBuilder::RemoveObject(const _PTR(SObject)& theSO)
+{
+ CheckLocked();
+
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
+ if(_isLocal) _local_impl->RemoveObject(aSO->GetLocalImpl());
+ else _corba_impl->RemoveObject(aSO->GetCORBAImpl());
+}
+
+void SALOMEDS_StudyBuilder::RemoveObjectWithChildren(const _PTR(SObject)& theSO)
+{
+ CheckLocked();
+
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
+ if(_isLocal) _local_impl->RemoveObjectWithChildren(aSO->GetLocalImpl());
+ else _corba_impl->RemoveObjectWithChildren(aSO->GetCORBAImpl());
+}
+
+_PTR(GenericAttribute) SALOMEDS_StudyBuilder::FindOrCreateAttribute(const _PTR(SObject)& theSO,
+ const std::string& aTypeOfAttribute)
+{
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
+ SALOMEDSClient_GenericAttribute* anAttr = NULL;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_GenericAttribute) aGA;
+ try {
+ aGA=Handle(SALOMEDSImpl_GenericAttribute)::DownCast(_local_impl->FindOrCreateAttribute(aSO->GetLocalImpl(),
+ (char*)aTypeOfAttribute.c_str()));
+ }
+ catch (...) {
+ throw SALOMEDS::StudyBuilder::LockProtection();
+ }
+ anAttr = SALOMEDS_GenericAttribute::CreateAttribute(aGA);
+ }
+ else {
+ SALOMEDS::GenericAttribute_var aGA = _corba_impl->FindOrCreateAttribute(aSO->GetCORBAImpl(), (char*)aTypeOfAttribute.c_str());
+ anAttr = SALOMEDS_GenericAttribute::CreateAttribute(aGA);
+ }
+
+ return _PTR(GenericAttribute)(anAttr);
+}
+
+bool SALOMEDS_StudyBuilder::FindAttribute(const _PTR(SObject)& theSO,
+ _PTR(GenericAttribute)& anAttribute,
+ const std::string& aTypeOfAttribute)
+{
+ bool ret;
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_GenericAttribute) aGA;
+ ret = _local_impl->FindAttribute(aSO->GetLocalImpl(), aGA, (char*)aTypeOfAttribute.c_str());
+ if(ret) anAttribute = _PTR(GenericAttribute)(SALOMEDS_GenericAttribute::CreateAttribute(aGA));
+ }
+ else {
+ SALOMEDS::GenericAttribute_var aGA;
+ ret = _corba_impl->FindAttribute(aSO->GetCORBAImpl(), aGA.out(), (char*)aTypeOfAttribute.c_str());
+ if(ret) anAttribute = _PTR(GenericAttribute)(SALOMEDS_GenericAttribute::CreateAttribute(aGA));
+ }
+
+ return ret;
+}
+
+void SALOMEDS_StudyBuilder::RemoveAttribute(const _PTR(SObject)& theSO, const std::string& aTypeOfAttribute)
+{
+ CheckLocked();
+
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
+ if(_isLocal) _local_impl->RemoveAttribute(aSO->GetLocalImpl(), (char*)aTypeOfAttribute.c_str());
+ else _corba_impl->RemoveAttribute(aSO->GetCORBAImpl(), (char*)aTypeOfAttribute.c_str());
+}
+
+void SALOMEDS_StudyBuilder::Addreference(const _PTR(SObject)& me, const _PTR(SObject)& thereferencedObject)
+{
+ CheckLocked();
+
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(me.get());
+ SALOMEDS_SObject* aRefSO = dynamic_cast<SALOMEDS_SObject*>(thereferencedObject.get());
+ if(_isLocal) _local_impl->Addreference(aSO->GetLocalImpl(), aRefSO->GetLocalImpl());
+ else _corba_impl->Addreference(aSO->GetCORBAImpl(), aRefSO->GetCORBAImpl());
+}
+
+void SALOMEDS_StudyBuilder::RemoveReference(const _PTR(SObject)& me)
+{
+ CheckLocked();
+
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(me.get());
+ if(_isLocal) _local_impl->RemoveReference(aSO->GetLocalImpl());
+ else _corba_impl->RemoveReference(aSO->GetCORBAImpl());
+}
+
+void SALOMEDS_StudyBuilder::SetGUID(const _PTR(SObject)& theSO, const std::string& theGUID)
+{
+ CheckLocked();
+
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
+ if(_isLocal) _local_impl->SetGUID(aSO->GetLocalImpl(), (char*)theGUID.c_str());
+ else _corba_impl->SetGUID(aSO->GetCORBAImpl(), (char*)theGUID.c_str());
+}
+
+bool SALOMEDS_StudyBuilder::IsGUID(const _PTR(SObject)& theSO, const std::string& theGUID)
+{
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
+ bool ret;
+ if(_isLocal) ret = _local_impl->IsGUID(aSO->GetLocalImpl(), (char*)theGUID.c_str());
+ else ret = _corba_impl->IsGUID(aSO->GetCORBAImpl(), (char*)theGUID.c_str());
+
+ return ret;
+}
+
+void SALOMEDS_StudyBuilder::NewCommand()
+{
+ if(_isLocal) _local_impl->NewCommand();
+ else _corba_impl->NewCommand();
+}
+
+void SALOMEDS_StudyBuilder::CommitCommand()
+{
+ if(_isLocal) {
+ try {
+ _local_impl->CommitCommand();
+ }
+ catch(...) {
+ throw SALOMEDS::StudyBuilder::LockProtection();
+ }
+ }
+ else _corba_impl->CommitCommand();
+}
+
+bool SALOMEDS_StudyBuilder::HasOpenCommand()
+{
+ bool ret;
+ if(_isLocal) ret = _local_impl->HasOpenCommand();
+ else ret = _corba_impl->HasOpenCommand();
+ return ret;
+}
+
+void SALOMEDS_StudyBuilder::AbortCommand()
+{
+ if(_isLocal) _local_impl->AbortCommand();
+ else _corba_impl->AbortCommand();
+}
+
+void SALOMEDS_StudyBuilder::Undo()
+{
+ if(_isLocal) {
+ try {
+ _local_impl->Undo();
+ }
+ catch(...) {
+ throw SALOMEDS::StudyBuilder::LockProtection();
+ }
+ }
+ else _corba_impl->Undo();
+}
+
+void SALOMEDS_StudyBuilder::Redo()
+{
+ if(_isLocal) {
+ try {
+ _local_impl->Redo();
+ }
+ catch(...) {
+ throw SALOMEDS::StudyBuilder::LockProtection();
+ }
+ }
+ else _corba_impl->Redo();
+}
+
+bool SALOMEDS_StudyBuilder::GetAvailableUndos()
+{
+ bool ret;
+ if(_isLocal) ret = _local_impl->GetAvailableUndos();
+ else ret = _corba_impl->GetAvailableUndos();
+ return ret;
+}
+
+bool SALOMEDS_StudyBuilder::GetAvailableRedos()
+{
+ bool ret;
+ if(_isLocal) ret = _local_impl->GetAvailableRedos();
+ else ret = _corba_impl->GetAvailableRedos();
+ return ret;
+}
+
+int SALOMEDS_StudyBuilder::UndoLimit()
+{
+ int aLimit;
+ if(_isLocal) aLimit = _local_impl->UndoLimit();
+ else aLimit = _corba_impl->UndoLimit();
+ return aLimit;
+}
+
+void SALOMEDS_StudyBuilder::UndoLimit(int theLimit)
+{
+ CheckLocked();
+
+ if(_isLocal) _local_impl->UndoLimit(theLimit);
+ else _corba_impl->UndoLimit(theLimit);
+}
+
+void SALOMEDS_StudyBuilder::CheckLocked()
+{
+ //There is only local part as CORBA part throws the correct exeception
+ if(_isLocal) {
+ try {
+ _local_impl->CheckLocked();
+ }
+ catch(...) {
+ throw SALOMEDS::StudyBuilder::LockProtection();
+ }
+ }
+}
+
+void SALOMEDS_StudyBuilder::SetName(const _PTR(SObject)& theSO, const std::string& theValue)
+{
+ CheckLocked();
+
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
+ if(_isLocal) _local_impl->SetName(aSO->GetLocalImpl(), (char*)theValue.c_str());
+ else _corba_impl->SetName(aSO->GetCORBAImpl(), (char*)theValue.c_str());
+}
+
+void SALOMEDS_StudyBuilder::SetComment(const _PTR(SObject)& theSO, const std::string& theValue)
+{
+ CheckLocked();
+
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
+ if(_isLocal) _local_impl->SetComment(aSO->GetLocalImpl(), (char*)theValue.c_str());
+ else _corba_impl->SetComment(aSO->GetCORBAImpl(), (char*)theValue.c_str());
+}
+
+void SALOMEDS_StudyBuilder::SetIOR(const _PTR(SObject)& theSO, const std::string& theValue)
+{
+ CheckLocked();
+
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
+ if(_isLocal) _local_impl->SetIOR(aSO->GetLocalImpl(), (char*)theValue.c_str());
+ else _corba_impl->SetIOR(aSO->GetCORBAImpl(), (char*)theValue.c_str());
+}
+
+void SALOMEDS_StudyBuilder::init_orb()
+{
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
+ _orb = init(0 , 0 ) ;
+}
--- /dev/null
+// File : SALOMEDS_StudyBuilder.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef __SALOMEDS_STUDYBUILDER_H__
+#define __SALOMEDS_STUDYBUILDER_H__
+
+#include "SALOMEDSClient.hxx"
+#include "SALOMEDSImpl_StudyBuilder.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+
+
+class SALOMEDS_StudyBuilder: public SALOMEDSClient_StudyBuilder
+{
+private:
+ bool _isLocal;
+ Handle(SALOMEDSImpl_StudyBuilder) _local_impl;
+ SALOMEDS::StudyBuilder_var _corba_impl;
+ CORBA::ORB_var _orb;
+
+public:
+
+ SALOMEDS_StudyBuilder(const Handle(SALOMEDSImpl_StudyBuilder)& theBuilder);
+ SALOMEDS_StudyBuilder(SALOMEDS::StudyBuilder_ptr theBuilder);
+ ~SALOMEDS_StudyBuilder();
+
+ virtual _PTR(SComponent) NewComponent(const std::string& ComponentDataType);
+ virtual void DefineComponentInstance (const _PTR(SComponent)&, const std::string& ComponentIOR);
+ virtual void RemoveComponent(const _PTR(SComponent)& theSCO);
+ virtual _PTR(SObject) NewObject(const _PTR(SObject)& theFatherObject);
+ virtual _PTR(SObject) NewObjectToTag(const _PTR(SObject)& theFatherObject, int theTag);
+ virtual void AddDirectory(const std::string& thePath);
+ virtual void LoadWith(const _PTR(SComponent)& theSCO, const std::string& theIOR);
+ virtual void Load(const _PTR(SObject)& theSCO);
+ virtual void RemoveObject(const _PTR(SObject)& theSO);
+ virtual void RemoveObjectWithChildren(const _PTR(SObject)& theSO);
+ virtual _PTR(GenericAttribute) FindOrCreateAttribute(const _PTR(SObject)& theSO,
+ const std::string& aTypeOfAttribute);
+ virtual bool FindAttribute(const _PTR(SObject)& theSO,
+ _PTR(GenericAttribute)& theAttribute,
+ const std::string& aTypeOfAttribute);
+ virtual void RemoveAttribute(const _PTR(SObject)& theSO, const std::string& aTypeOfAttribute);
+ virtual void Addreference(const _PTR(SObject)& me, const _PTR(SObject)& thereferencedObject);
+ virtual void RemoveReference(const _PTR(SObject)& me);
+ virtual void SetGUID(const _PTR(SObject)& theSO, const std::string& theGUID);
+ virtual bool IsGUID(const _PTR(SObject)& theSO, const std::string& theGUID);
+ virtual void NewCommand();
+ virtual void CommitCommand();
+ virtual bool HasOpenCommand();
+ virtual void AbortCommand();
+ virtual void Undo();
+ virtual void Redo();
+ virtual bool GetAvailableUndos();
+ virtual bool GetAvailableRedos();
+ virtual int UndoLimit();
+ virtual void UndoLimit(int theLimit);
+ virtual void SetName(const _PTR(SObject)& theSO, const std::string& theValue);
+ virtual void SetComment(const _PTR(SObject)& theSO, const std::string& theValue);
+ virtual void SetIOR(const _PTR(SObject)& theSO, const std::string& theValue);
+
+private:
+ void CheckLocked();
+ void init_orb();
+};
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_StudyBuilder_i.cxx
-// Author : Yves FRICAUD
+// Author : Seregy RUIN
// Module : SALOME
-// $Header$
+using namespace std;
+#include "utilities.h"
#include "SALOMEDS_StudyBuilder_i.hxx"
-#include "SALOMEDS_StudyManager_i.hxx"
#include "SALOMEDS_Study_i.hxx"
-
#include "SALOMEDS_SObject_i.hxx"
#include "SALOMEDS_SComponent_i.hxx"
-#include "SALOMEDS_ChildIterator_i.hxx"
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDS_Driver_i.hxx"
+#include "SALOMEDS.hxx"
-#include "SALOMEDS_TargetAttribute.hxx"
-#include "SALOMEDS_IORAttribute.hxx"
-#include "SALOMEDS_PersRefAttribute.hxx"
-#include "SALOMEDS_LocalIDAttribute.hxx"
-#include "SALOMEDS_StudyPropertiesAttribute.hxx"
-
-#include "SALOMEDS_Tool.hxx"
+#include "SALOMEDSImpl_Study.hxx"
+#include "SALOMEDSImpl_SObject.hxx"
+#include "SALOMEDSImpl_SComponent.hxx"
#include "Utils_CorbaException.hxx"
#include "Utils_ExceptHandlers.hxx"
-#include <TDF_ChildIterator.hxx>
-#include <TDF_Label.hxx>
-#include <TDataStd_Name.hxx>
-#include <TDataStd_Comment.hxx>
-#include <TDataStd_UAttribute.hxx>
-#include <TDataStd_Real.hxx>
-#include <TDF_Tool.hxx>
-#include <TDF_Reference.hxx>
-#include <TDF_Data.hxx>
-#include <TDataStd_ChildNodeIterator.hxx>
-#include <TDF_ListIteratorOfAttributeList.hxx>
-
-#include <HDFOI.hxx>
+#include <TDF_Attribute.hxx>
#include <stdlib.h>
-#define USE_CASE_LABEL_TAG 2
-#define DIRECTORYID 16661
-#define FILELOCALID 26662
-
-#include "utilities.h"
-
-using namespace std;
-
UNEXPECT_CATCH(SBSalomeException, SALOME::SALOME_Exception);
UNEXPECT_CATCH(SBLockProtection, SALOMEDS::StudyBuilder::LockProtection);
* Purpose :
*/
//============================================================================
-SALOMEDS_StudyBuilder_i::SALOMEDS_StudyBuilder_i(SALOMEDS_Study_i* theStudy,
- const Handle(TDocStd_Document)& theDocument):
- _study(theStudy),
- _doc(theDocument)
+SALOMEDS_StudyBuilder_i::SALOMEDS_StudyBuilder_i(const Handle(SALOMEDSImpl_StudyBuilder) theImpl,
+ CORBA::ORB_ptr orb)
{
+ _orb = CORBA::ORB::_duplicate(orb);
+ _impl = theImpl;
}
//============================================================================
*/
//============================================================================
SALOMEDS_StudyBuilder_i::~SALOMEDS_StudyBuilder_i()
-{
-}
-
-
-//============================================================================
-CORBA::ORB_var SALOMEDS_StudyBuilder_i::GetORB() const
-{
- return _study->GetORB();
-}
-
-
-//============================================================================
-PortableServer::POA_var SALOMEDS_StudyBuilder_i::GetPOA() const
-{
- return _study->GetPOA();
-}
-
+{}
//============================================================================
/*! Function : NewComponent
* Purpose : Create a new component (Scomponent)
*/
//============================================================================
-SALOMEDS::SComponent_ptr
-SALOMEDS_StudyBuilder_i::NewComponent(const char* DataType)
+SALOMEDS::SComponent_ptr SALOMEDS_StudyBuilder_i::NewComponent(const char* DataType)
{
+ SALOMEDS::Locker lock;
CheckLocked();
- //Always create component under main label.
- TDF_Label L = _doc->Main();
-
- // YFR DEBUG : 13/02/2002 TDF_Label NL = L.NewChild();
-
- Standard_Integer imax = 0;
- for (TDF_ChildIterator it(L); it.More(); it.Next()) {
- if (it.Value().Tag() > imax)
- imax = it.Value().Tag();
- }
- imax++;
- TDF_Label NL = L.FindChild(imax);
-
- TDataStd_Comment::Set(NL,Standard_CString(DataType));
- // TDataStd_Comment::Set(NL,Standard_CString(CORBA::string_dup(DataType)));
-
- SALOMEDS::SComponent_var aSComponent = SALOMEDS_SComponent_i::NewRef(_study,NL);
-
- OnAddSObject(aSComponent);
+ //char* aDataType = CORBA::string_dup(DataType);
+ Handle(SALOMEDSImpl_SComponent) aSCO = _impl->NewComponent(TCollection_AsciiString((char*)DataType));
+ //CORBA::free_string(aDataType);
+ if(aSCO.IsNull()) return SALOMEDS::SComponent::_nil();
- return aSComponent._retn();
+ SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aSCO,_orb);
+ return sco._retn();
}
//============================================================================
* Purpose : Add IOR attribute of a Scomponent
*/
//============================================================================
-void SALOMEDS_StudyBuilder_i::DefineComponentInstance(SALOMEDS::SComponent_ptr theComponent,
- CORBA::Object_ptr theObject)
+void SALOMEDS_StudyBuilder_i::DefineComponentInstance(SALOMEDS::SComponent_ptr aComponent,
+ CORBA::Object_ptr IOR)
{
+ SALOMEDS::Locker lock;
CheckLocked();
+ Handle(SALOMEDSImpl_SComponent) aSCO;
+ aSCO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSComponent((char*)aComponent->GetID());
- if(CORBA::is_nil(theComponent) || CORBA::is_nil(theObject))
- return;
-
- //Find label
- TDF_Label Lab;
- CORBA::String_var aString = theComponent->GetID();
- TDF_Tool::Label(_doc->GetData(),const_cast<char*>(aString.in()),Lab);
-
- //add theObject definition
- aString = GetORB()->object_to_string(theObject);
- SALOMEDS_IORAttribute::Set(Lab,const_cast<char*>(aString.in()),_study);
+ CORBA::String_var iorstr = _orb->object_to_string(IOR);
+ _impl->DefineComponentInstance(aSCO, (char*)iorstr);
}
//============================================================================
* Purpose : Delete a Scomponent
*/
//============================================================================
-void
-SALOMEDS_StudyBuilder_i::RemoveComponent(SALOMEDS::SComponent_ptr theComponent)
+void SALOMEDS_StudyBuilder_i::RemoveComponent(SALOMEDS::SComponent_ptr aComponent)
{
+ SALOMEDS::Locker lock;
CheckLocked();
- RemoveObject(theComponent);
+ ASSERT(!CORBA::is_nil(aComponent));
+ Handle(SALOMEDSImpl_SComponent) aSCO;
+ aSCO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSComponent((char*)aComponent->GetID());
+ _impl->RemoveComponent(aSCO);
}
//============================================================================
* Purpose : Create a new SObject
*/
//============================================================================
-SALOMEDS::SObject_ptr
-SALOMEDS_StudyBuilder_i::NewObject(SALOMEDS::SObject_ptr theFatherObject)
+SALOMEDS::SObject_ptr SALOMEDS_StudyBuilder_i::NewObject(SALOMEDS::SObject_ptr theFatherObject)
{
+ SALOMEDS::Locker lock;
CheckLocked();
-
- if(CORBA::is_nil(theFatherObject))
- return SALOMEDS::SObject::_nil();
-
- //Find label of father
- TDF_Label aLabel;
- TCollection_AsciiString anEntry;
- CORBA::String_var aFatherID = theFatherObject->GetID();
- TDF_Tool::Label(_doc->GetData(),aFatherID,aLabel);
-
- //Create a new label
- //YFR DEBUG : 13/02/2002 TDF_Label NewLab = Lab.NewChild();
- Standard_Integer imax = 0;
- for (TDF_ChildIterator it(aLabel); it.More(); it.Next()) {
- if (it.Value().Tag() > imax)
- imax = it.Value().Tag();
- }
- imax++;
- TDF_Label aNewLabel = aLabel.FindChild(imax);
-
- SALOMEDS::SObject_var aSObject = SALOMEDS_SObject_i::NewRef(_study,aNewLabel);
-
- OnAddSObject(aSObject);
+ Handle(SALOMEDSImpl_SObject) aFO, aSO;
+ aFO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSObject((char*)theFatherObject->GetID());
+ aSO = _impl->NewObject(aFO);
+ if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO,_orb);
- return aSObject._retn();
+ return so._retn();
}
//============================================================================
* Purpose :
*/
//============================================================================
-SALOMEDS::SObject_ptr
-SALOMEDS_StudyBuilder_i::NewObjectToTag(SALOMEDS::SObject_ptr theFatherObject,
- CORBA::Long theTag)
+SALOMEDS::SObject_ptr SALOMEDS_StudyBuilder_i::NewObjectToTag(SALOMEDS::SObject_ptr theFatherObject,
+ CORBA::Long atag)
{
+ SALOMEDS::Locker lock;
CheckLocked();
-
- if(CORBA::is_nil(theFatherObject))
- return SALOMEDS::SObject::_nil();
-
- //Find label of father
- TDF_Label Lab;
- CORBA::String_var aFatherID = theFatherObject->GetID();
- TDF_Tool::Label(_doc->GetData(),aFatherID,Lab);
-
- //Create or find label
- TDF_Label aNewLab = Lab.FindChild(theTag,1);
-
- SALOMEDS::SObject_var aSObject = SALOMEDS_SObject_i::NewRef(_study,aNewLab);
-
- OnAddSObject(aSObject);
-
- return aSObject._retn();
+ Handle(SALOMEDSImpl_SObject) aFO, aSO;
+ aFO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSObject((char*)theFatherObject->GetID());
+ aSO = _impl->NewObjectToTag(aFO, atag);
+ if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
+ return so._retn();
}
//============================================================================
* Purpose :
*/
//============================================================================
-void SALOMEDS_StudyBuilder_i::RemoveObject(SALOMEDS::SObject_ptr theSObject)
-{
- RemoveSObject(theSObject);
-}
-
-SALOMEDS_SObject_i*
-SALOMEDS_StudyBuilder_i::RemoveSObject(SALOMEDS::SObject_ptr theSObject,
- bool theIsForgetAllAttributes)
+void SALOMEDS_StudyBuilder_i::RemoveObject(SALOMEDS::SObject_ptr anObject)
{
+ SALOMEDS::Locker lock;
CheckLocked();
-
- if(SALOMEDS_SObject_i* aSObject = _study->DownCast(theSObject)){
- OnRemoveSObject(theSObject);
- aSObject->OnRemove();
- if(theIsForgetAllAttributes){
- TDF_Label aLabel = aSObject->GetLabel();
- aLabel.ForgetAllAttributes();
- }
- return aSObject;
- }
-
- return NULL;
+ Handle(SALOMEDSImpl_SObject) aSO;
+ aSO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSObject((char*)anObject->GetID());
+ _impl->RemoveObject(aSO);
}
//============================================================================
* Purpose :
*/
//============================================================================
-void SALOMEDS_StudyBuilder_i::RemoveObjectWithChildren(SALOMEDS::SObject_ptr theSObject)
-{
- if(SALOMEDS_SObject_i* aSObject = RemoveSObject(theSObject,false)){
- SALOMEDS_ChildIterator_i aChildIter(_study,aSObject->GetLabel(),true);
- for(; aChildIter.More(); aChildIter.Next()){
- if(SALOMEDS_SObject_i* aSObj = aChildIter.GetValue())
- aSObj->OnRemove();
- }
- TDF_Label aLabel = aSObject->GetLabel();
- aLabel.ForgetAllAttributes(Standard_True);
- }
-}
-
-//============================================================================
-/*! Function : Translate_persistentID_to_IOR
- * Purpose :
- */
-//============================================================================
-static void Translate_persistentID_to_IOR(TDF_Label theLabel,
- SALOMEDS::Driver_ptr theDriver,
- SALOMEDS_Study_i* theStudy,
- CORBA::Boolean theIsMultiFile,
- CORBA::Boolean theIsASCII)
+void SALOMEDS_StudyBuilder_i::RemoveObjectWithChildren(SALOMEDS::SObject_ptr anObject)
{
- if(CORBA::is_nil(theDriver))
- return;
-
- for (TDF_ChildIterator aChildIter (theLabel); aChildIter.More(); aChildIter.Next()){
- TDF_Label aCurrentLabel = aChildIter.Value();
- Handle(TDF_Attribute) anAttr;
- if(aCurrentLabel.FindAttribute(SALOMEDS_PersRefAttribute::GetID(),anAttr)){
- Handle(SALOMEDS_LocalIDAttribute) anID;
- if (aCurrentLabel.FindAttribute(SALOMEDS_LocalIDAttribute::GetID(),anID))
- if (anID->Get() == FILELOCALID) continue; //SRN: This attribute store a file name, skip it
-
- TCollection_ExtendedString res = Handle(TDataStd_Comment)::DownCast(anAttr)->Get();
- TCollection_AsciiString ch(res);
-
- SALOMEDS::SObject_var aSObject = SALOMEDS_SObject_i::NewRef(theStudy,aCurrentLabel);
-
- CORBA::String_var anIOR =
- theDriver->LocalPersistentIDToIOR(aSObject,ch.ToCString(),theIsMultiFile,theIsASCII);
- SALOMEDS_IORAttribute::Set(aCurrentLabel,const_cast<char*>(anIOR.in()),theStudy);
- }
-
- Translate_persistentID_to_IOR(aCurrentLabel,theDriver,theStudy,theIsMultiFile,theIsASCII);
- }
+ SALOMEDS::Locker lock;
+ CheckLocked();
+ Handle(SALOMEDSImpl_SObject) aSO;
+ aSO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSObject((char*)anObject->GetID());
+ _impl->RemoveObjectWithChildren(aSO);
}
//============================================================================
* Purpose :
*/
//============================================================================
-
-//============================================================================
-void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr theSComponent,
- SALOMEDS::Driver_ptr theDriver)
- throw(SALOME::SALOME_Exception)
+void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO,
+ SALOMEDS::Driver_ptr aDriver) throw(SALOME::SALOME_Exception)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(SBSalomeException);
- if(CORBA::is_nil(theSComponent))
- return;
+ Handle(SALOMEDSImpl_SComponent) aSCO;
+ aSCO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSComponent((char*)anSCO->GetID());
+ SALOMEDS_Driver_i* driver = new SALOMEDS_Driver_i(aDriver, _orb);
+ bool isDone = _impl->LoadWith(aSCO, driver);
+ delete driver;
- TDF_Label Lab;
- CORBA::String_var aString = theSComponent->GetID();
- TDF_Tool::Label(_doc->GetData(),const_cast<char*>(aString.in()),Lab);
-
- //Find the current Url of the study
- Handle(TDF_Attribute) Att;
- if (_doc->Main().FindAttribute(SALOMEDS_PersRefAttribute::GetID(),Att)) {
- if(CORBA::is_nil(theDriver))
- return;
-
- int aLocked = _study->GetProperties()->IsLocked();
- if(aLocked)
- _study->GetProperties()->SetLocked(false);
-
- // mpv 06.03.2003: SAL1927 - if component data if already loaded, it is not necessary to do it again
- if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), Att)) {
- if(aLocked)
- _study->GetProperties()->SetLocked(true);
- return;
- }
- DefineComponentInstance (theSComponent,theDriver);
-
- TCollection_AsciiString aHDFPath(Handle(TDataStd_Comment)::DownCast(Att)->Get());
-
- bool isASCII = false;
- std::ostringstream anURLStream;
- if(HDFascii::isASCII(aHDFPath.ToCString())){
- isASCII = true;
- auto_ptr<char> aResultPath(HDFascii::ConvertFromASCIIToHDF(aHDFPath.ToCString()));
- anURLStream<<aResultPath.get()<<"hdf_from_ascii.hdf";
- } else {
- anURLStream<<aHDFPath.ToCString();
- }
- std::string aHDFUrl = anURLStream.str();
-
- //Open the Study HDF file
- auto_ptr<HDFfile> hdf_file(new HDFfile(const_cast<char*>(aHDFUrl.c_str())));
-
- char aMultifileState[2];
- char ASCIIfileState[2];
- try {
- CORBA::String_var scoid = theSComponent->GetID();
- hdf_file->OpenOnDisk(HDF_RDONLY);
- HDFgroup *hdf_group = new HDFgroup("DATACOMPONENT",hdf_file.get());
- hdf_group->OpenOnDisk();
- HDFgroup *hdf_sco_group = new HDFgroup(scoid, hdf_group);
- hdf_sco_group->OpenOnDisk();
-
- SALOMEDS::TMPFile_var aStreamFile;
- if (hdf_sco_group->ExistInternalObject("FILE_STREAM")) {
- HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group);
- hdf_dataset->OpenOnDisk();
- int aStreamSize = hdf_dataset->GetSize();
- unsigned char* aBuffer = new unsigned char[aStreamSize];
- if(aBuffer == NULL)
- throw HDFexception("Unable to open dataset FILE_STREAM");
- hdf_dataset->ReadFromDisk(aBuffer);
- aStreamFile = new SALOMEDS::TMPFile(aStreamSize, aStreamSize, aBuffer, 1);
- hdf_dataset->CloseOnDisk();
- hdf_dataset = 0;
- } else
- aStreamFile = new SALOMEDS::TMPFile(0);
-
- HDFdataset *multifile_hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group);
- multifile_hdf_dataset->OpenOnDisk();
- multifile_hdf_dataset->ReadFromDisk(aMultifileState);
-
- HDFdataset *ascii_hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group);
- ascii_hdf_dataset->OpenOnDisk();
- ascii_hdf_dataset->ReadFromDisk(ASCIIfileState);
-
- // set path without file name from URL
- std::string aDir(aHDFPath.ToCString());
- aDir = aDir.substr(0,aDir.rfind('/') + 1);
-
- CORBA::Boolean aResult = (ASCIIfileState[0]=='A')?
- theDriver->LoadASCII(theSComponent, aStreamFile.in(), aDir.c_str(), aMultifileState[0]=='M'):
- theDriver->Load(theSComponent, aStreamFile.in(), aDir.c_str(), aMultifileState[0]=='M');
- if(!aResult) {
- RemoveAttribute( theSComponent, "AttributeIOR" );
- if (isASCII) {
- SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
- aFilesToRemove->length(1);
- std::string aDir = SALOMEDS_Tool::GetDirFromPath(aHDFUrl);
- aFilesToRemove[0] = CORBA::string_dup(&aHDFUrl[strlen(aDir.c_str())]);
- SALOMEDS_Tool::RemoveTemporaryFiles(aDir,aFilesToRemove,true);
- }
- MESSAGE("Can't load component");
- THROW_SALOME_CORBA_EXCEPTION("Unable to load component data",SALOME::BAD_PARAM);
- }
-
- multifile_hdf_dataset->CloseOnDisk();
- multifile_hdf_dataset = 0;
- ascii_hdf_dataset->CloseOnDisk();
- ascii_hdf_dataset = 0;
- hdf_sco_group->CloseOnDisk();
- hdf_sco_group = 0;
- hdf_group->CloseOnDisk();
- hdf_group = 0;
- hdf_file->CloseOnDisk();
-
- if (isASCII) {
- SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
- aFilesToRemove->length(1);
- std::string aDir = SALOMEDS_Tool::GetDirFromPath(aHDFUrl);
- aFilesToRemove[0] = CORBA::string_dup(&aHDFUrl[strlen(aDir.c_str())]);
- SALOMEDS_Tool::RemoveTemporaryFiles(aDir,aFilesToRemove,true);
- }
- }
- catch (HDFexception) {
- INFOS("No persistent file Name");
- if (isASCII) {
- SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
- aFilesToRemove->length(1);
- std::string aDir = SALOMEDS_Tool::GetDirFromPath(aHDFUrl);
- aFilesToRemove[0] = CORBA::string_dup(&aHDFUrl[strlen(aDir.c_str())]);
- SALOMEDS_Tool::RemoveTemporaryFiles(aDir,aFilesToRemove,true);
- }
- if(aLocked)
- _study->GetProperties()->SetLocked(true);
- THROW_SALOME_CORBA_EXCEPTION("No persistent file Name found",SALOME::BAD_PARAM);
- }
-
- try {
- Translate_persistentID_to_IOR(Lab,theDriver,_study,aMultifileState[0]=='M',ASCIIfileState[0] == 'A');
- } catch (SALOME::SALOME_Exception) {
- INFOS("Can't translate PersRef to IOR");
- if (aLocked)
- _study->GetProperties()->SetLocked(true);
- THROW_SALOME_CORBA_EXCEPTION("Unable to convert component persistent data to the transient",SALOME::BAD_PARAM);
- // throw HDFexception("Unable to load component data");
- }
- if(aLocked)
- _study->GetProperties()->SetLocked(true);
- } else
- MESSAGE("No persistent file Name");
+ if(!isDone && _impl->IsError()) {
+ THROW_SALOME_CORBA_EXCEPTION(_impl->GetErrorCode().ToCString(),SALOME::BAD_PARAM);
+ }
}
* existing one
*/
//============================================================================
-SALOMEDS::GenericAttribute_ptr
-SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SALOMEDS::SObject_ptr theObject,
- const char* theTypeOfAttribute)
+SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SALOMEDS::SObject_ptr anObject,
+ const char* aTypeOfAttribute)
{
- if(SALOMEDS_SObject_i* aSObject = _study->DownCast(theObject))
- return aSObject->FindOrCreateAttribute(theTypeOfAttribute);
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_SObject) aSO;
+ char* anID = anObject->GetID();
+ aSO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSObject(anID);
+ delete anID;
+ Handle(TDF_Attribute) anAttr;
+ try {
+ anAttr = _impl->FindOrCreateAttribute(aSO, TCollection_AsciiString((char*)aTypeOfAttribute));
+ }
+ catch (...) {
+ throw SALOMEDS::StudyBuilder::LockProtection();
+ }
- return SALOMEDS::GenericAttribute::_nil();
+ SALOMEDS::GenericAttribute_var anAttribute;
+ anAttribute = SALOMEDS::GenericAttribute::_duplicate(SALOMEDS_GenericAttribute_i::CreateAttribute(anAttr, _orb));
+
+ return anAttribute._retn();
}
//============================================================================
*/
//============================================================================
-CORBA::Boolean SALOMEDS_StudyBuilder_i::FindAttribute(SALOMEDS::SObject_ptr theObject,
- SALOMEDS::GenericAttribute_out theAttr,
- const char* theTypeOfAttribute)
+CORBA::Boolean SALOMEDS_StudyBuilder_i::FindAttribute(SALOMEDS::SObject_ptr anObject,
+ SALOMEDS::GenericAttribute_out anAttribute,
+ const char* aTypeOfAttribute)
{
- if(SALOMEDS_SObject_i* aSObject = _study->DownCast(theObject))
- return aSObject->FindAttribute(theAttr,theTypeOfAttribute);
+ SALOMEDS::Locker lock;
+ ASSERT(!CORBA::is_nil(anObject));
+ Handle(SALOMEDSImpl_SObject) aSO;
+ aSO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSObject((char*)anObject->GetID());
+ Handle(TDF_Attribute) anAttr;
- return Standard_False;
+ if(!_impl->FindAttribute(aSO, anAttr, TCollection_AsciiString((char*)aTypeOfAttribute))) return false;
+
+ anAttribute = SALOMEDS::GenericAttribute::_duplicate(SALOMEDS_GenericAttribute_i::CreateAttribute(anAttr, _orb));
+ return true;
}
//============================================================================
*/
//============================================================================
-void SALOMEDS_StudyBuilder_i::RemoveAttribute(SALOMEDS::SObject_ptr theSObject,
+void SALOMEDS_StudyBuilder_i::RemoveAttribute(SALOMEDS::SObject_ptr anObject,
const char* aTypeOfAttribute)
{
+ SALOMEDS::Locker lock;
CheckLocked();
-
- if(CORBA::is_nil(theSObject))
- return;
-
- TDF_Label Lab;
- CORBA::String_var anobid = theSObject->GetID();
- TDF_Tool::Label(_doc->GetData(),anobid,Lab);
-
- if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0) { // postponed removing of CORBA objects
- Handle(SALOMEDS_IORAttribute) anAttr;
- if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr))
- _study->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
- else
- return;
- }
-
- Lab.ForgetAttribute(SALOMEDS::GetGUID(aTypeOfAttribute));
+ ASSERT(!CORBA::is_nil(anObject));
+ Handle(SALOMEDSImpl_SObject) aSO;
+ aSO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSObject((char*)anObject->GetID());
+ _impl->RemoveAttribute(aSO, TCollection_AsciiString((char*)aTypeOfAttribute));
}
//============================================================================
* Purpose :
*/
//============================================================================
-void
-SALOMEDS_StudyBuilder_i::Addreference(SALOMEDS::SObject_ptr me,
- SALOMEDS::SObject_ptr theReferencedObject)
+void SALOMEDS_StudyBuilder_i::Addreference(SALOMEDS::SObject_ptr me,
+ SALOMEDS::SObject_ptr theReferencedObject)
{
+ SALOMEDS::Locker lock;
CheckLocked();
- if(CORBA::is_nil(me) || CORBA::is_nil(theReferencedObject))
- return;
-
- TDF_Label Lab;
- CORBA::String_var meid = me->GetID();
- TDF_Tool::Label(_doc->GetData(),meid,Lab);
-
- TDF_Label RefLab;
- CORBA::String_var roid = theReferencedObject->GetID();
- TDF_Tool::Label(_doc->GetData(),roid,RefLab);
-
- TDF_Reference::Set(Lab,RefLab);
- SALOMEDS_TargetAttribute::Set(RefLab)->Append(Lab);
-
- if(Lab.IsDescendant(_doc->Main()))
- OnRemoveSObject(me);
+ ASSERT(!CORBA::is_nil(me));
+ ASSERT(!CORBA::is_nil(theReferencedObject));
+
+ Handle(SALOMEDSImpl_SObject) aSO, aRefSO;
+ aSO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSObject((char*)me->GetID());
+ aRefSO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSObject((char*)theReferencedObject->GetID());
+ _impl->Addreference(aSO, aRefSO);
}
//============================================================================
//============================================================================
void SALOMEDS_StudyBuilder_i::RemoveReference(SALOMEDS::SObject_ptr me)
{
- SALOMEDS::SObject_var theReferencedObject;
- if(!me->ReferencedObject(theReferencedObject)) return; //No reference is found
-
- if(CORBA::is_nil(me) || CORBA::is_nil(theReferencedObject))
- return;
-
+ SALOMEDS::Locker lock;
CheckLocked();
- TDF_Label Lab;
- CORBA::String_var meid = me->GetID();
- TDF_Tool::Label(_doc->GetData(),meid,Lab);
-
- Lab.ForgetAttribute(TDF_Reference::GetID());
-
- TDF_Label RefLab;
- CORBA::String_var roid = theReferencedObject->GetID();
- TDF_Tool::Label(_doc->GetData(),roid,RefLab);
-
- RemoveAttribute(theReferencedObject, "AttributeTarget");
+ ASSERT(!CORBA::is_nil(me));
+ Handle(SALOMEDSImpl_SObject) aSO;
+ aSO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSObject((char*)me->GetID());
+ _impl->RemoveReference(aSO);
}
-
//============================================================================
/*! Function : AddDirectory
* Purpose : adds a new directory with a path = thePath
//============================================================================
void SALOMEDS_StudyBuilder_i::AddDirectory(const char* thePath)
{
+ SALOMEDS::Locker lock;
CheckLocked();
if(thePath == NULL || strlen(thePath) == 0) throw SALOMEDS::Study::StudyInvalidDirectory();
-
- TCollection_AsciiString aPath(CORBA::string_dup(thePath)), aContext(""), aFatherPath;
- Handle(TDataStd_Name) aName;
- TDF_Label aLabel;
- SALOMEDS::SObject_var anObject = SALOMEDS_SObject_i::NewRef(_study,_doc->Main());
-
- try {
- anObject = _study->FindObjectByPath(thePath); //Check if the directory already exists
- }
- catch(...) { }
-
- if(!anObject->_is_nil()) throw SALOMEDS::Study::StudyNameAlreadyUsed();
-
- if(aPath.Value(1) != '/') { //Relative path
- aPath.Prepend('/');
- aPath = TCollection_AsciiString(_study->GetContext()) + aPath;
- }
-
- TCollection_AsciiString aToken = aPath.Token("/", 1);
- if(aToken.Length() == 0) aFatherPath = "/";
-
- int i = 1;
- while(aToken.Length() != 0) {
- if(aPath.Token("/", i+1).Length() > 0) {
- aFatherPath += "/";
- aFatherPath += aToken;
- }
- aToken = aPath.Token("/", ++i);
- }
-
- anObject = SALOMEDS::SObject::_nil();
- try {
- anObject = _study->FindObjectByPath(aFatherPath.ToCString()); //Check if the father directory exists
+ if(!_impl->AddDirectory(TCollection_AsciiString((char*)thePath))) {
+ TCollection_AsciiString anErrorCode = _impl->GetErrorCode();
+ if(anErrorCode == "StudyNameAlreadyUsed") throw SALOMEDS::Study::StudyNameAlreadyUsed();
+ if(anErrorCode == "StudyInvalidDirectory") throw SALOMEDS::Study::StudyInvalidDirectory();
+ if(anErrorCode == "StudyInvalidComponent") throw SALOMEDS::Study::StudyInvalidComponent();
}
- catch(...) { ; }
- if(anObject->_is_nil())
- throw SALOMEDS::Study::StudyInvalidDirectory();
-
- SALOMEDS::SObject_var aNewObject = NewObject(anObject);
- TDF_Tool::Label(_doc->GetData(), aNewObject->GetID(), aLabel);
- if(aLabel.IsNull()) {
- MESSAGE("### NULL label");
- throw SALOMEDS::Study::StudyInvalidComponent();
- }
-
- TDataStd_Name::Set(aLabel, aPath.Token("/", i-1));
-
- //Set LocalID attribute to identify the directory object
- SALOMEDS::GenericAttribute_var anAttr = FindOrCreateAttribute(aNewObject, "AttributeLocalID");
- SALOMEDS::AttributeLocalID_var aPersRef = SALOMEDS::AttributeLocalID::_narrow(anAttr);
- if(aPersRef->_is_nil())
- throw SALOMEDS::Study::StudyInvalidDirectory();
-
- aPersRef->SetValue(DIRECTORYID);
}
//============================================================================
void SALOMEDS_StudyBuilder_i::SetGUID(SALOMEDS::SObject_ptr anObject, const char* theGUID)
{
+ SALOMEDS::Locker lock;
CheckLocked();
-
- if(CORBA::is_nil(anObject))
- return;
-
- TDF_Label aLabel;
- CORBA::String_var anEntry = anObject->GetID();
- TDF_Tool::Label(_doc->GetData(), anEntry, aLabel);
- TDataStd_UAttribute::Set(aLabel, (char*)theGUID);
+ ASSERT(!CORBA::is_nil(anObject));
+ Handle(SALOMEDSImpl_SObject) aSO;
+ aSO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSObject((char*)anObject->GetID());
+ _impl->SetGUID(aSO, TCollection_AsciiString((char*)theGUID));
}
//============================================================================
//============================================================================
bool SALOMEDS_StudyBuilder_i::IsGUID(SALOMEDS::SObject_ptr anObject, const char* theGUID)
{
- if(CORBA::is_nil(anObject))
- return false;
-
- TDF_Label aLabel;
- CORBA::String_var anEntry = anObject->GetID();
- TDF_Tool::Label(_doc->GetData(), anEntry, aLabel);
- return aLabel.IsAttribute((char*)theGUID);
+ SALOMEDS::Locker lock;
+ ASSERT(!CORBA::is_nil(anObject));
+ Handle(SALOMEDSImpl_SObject) aSO;
+ aSO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSObject((char*)anObject->GetID());
+ return _impl->IsGUID(aSO, TCollection_AsciiString((char*)theGUID));
}
//============================================================================
void SALOMEDS_StudyBuilder_i::NewCommand()
{
- // mpv: for SAL2114 - unset "lock changed" flag at the operation start
- Handle(SALOMEDS_StudyPropertiesAttribute) anAttr;
- if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) {
- anAttr = new SALOMEDS_StudyPropertiesAttribute;
- _doc->Main().AddAttribute(anAttr);
- }
- anAttr->IsLockChanged(true);
-
- _doc->NewCommand();
+ SALOMEDS::Locker lock;
+ _impl->NewCommand();
}
//============================================================================
//============================================================================
void SALOMEDS_StudyBuilder_i::CommitCommand() throw (SALOMEDS::StudyBuilder::LockProtection)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(SBLockProtection);
- Handle(SALOMEDS_StudyPropertiesAttribute) anAttr;
- if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) {
- anAttr = new SALOMEDS_StudyPropertiesAttribute;
- _doc->Main().AddAttribute(anAttr);
+ try {
+ _impl->CommitCommand();
}
- if (anAttr->IsLocked() && !anAttr->IsLockChanged(true)) {
+ catch(...) {
MESSAGE("Locked document modification !!!");
- AbortCommand();
throw SALOMEDS::StudyBuilder::LockProtection();
- } else {
- _study->RemovePostponed(_doc->GetUndoLimit());
-
- int aModif = anAttr->GetModified();
- if (aModif < 0) aModif = 1000; // if user make undo and then - new transaction "modify" will never be zero
- anAttr->SetModified(aModif+1);
- _doc->CommitCommand();
}
}
//============================================================================
CORBA::Boolean SALOMEDS_StudyBuilder_i::HasOpenCommand()
{
- return _doc->HasOpenCommand();
+ SALOMEDS::Locker lock;
+ return _impl->HasOpenCommand();
}
//============================================================================
//============================================================================
void SALOMEDS_StudyBuilder_i::AbortCommand()
{
- _study->UndoPostponed(0);
-
- _doc->AbortCommand();
+ SALOMEDS::Locker lock;
+ _impl->AbortCommand();
}
//============================================================================
//============================================================================
void SALOMEDS_StudyBuilder_i::Undo() throw (SALOMEDS::StudyBuilder::LockProtection)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(SBLockProtection);
- Handle(SALOMEDS_StudyPropertiesAttribute) anAttr;
- if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) {
- anAttr = new SALOMEDS_StudyPropertiesAttribute;
- _doc->Main().AddAttribute(anAttr);
- }
- if (anAttr->IsLocked()) {
+ try {
+ _impl->Undo();
+ }
+ catch(...) {
MESSAGE("Locked document modification !!!");
throw SALOMEDS::StudyBuilder::LockProtection();
- } else {
- _study->UndoPostponed(1);
- _doc->Undo();
- anAttr->SetModified(anAttr->GetModified()-1);
}
}
//============================================================================
void SALOMEDS_StudyBuilder_i::Redo() throw (SALOMEDS::StudyBuilder::LockProtection)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(SBLockProtection);
- Handle(SALOMEDS_StudyPropertiesAttribute) anAttr;
- if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) {
- anAttr = new SALOMEDS_StudyPropertiesAttribute;
- _doc->Main().AddAttribute(anAttr);
+ try {
+ _impl->Redo();
}
-
- if (anAttr->IsLocked()) {
+ catch(...) {
MESSAGE("Locked document modification !!!");
throw SALOMEDS::StudyBuilder::LockProtection();
- } else {
- _doc->Redo();
- _study->UndoPostponed(-1);
- anAttr->SetModified(anAttr->GetModified()+1);
}
- }
+}
//============================================================================
/*! Function : GetAvailableUndos
//============================================================================
CORBA::Boolean SALOMEDS_StudyBuilder_i::GetAvailableUndos()
{
- return _doc->GetAvailableUndos();
+ SALOMEDS::Locker lock;
+ return _impl->GetAvailableUndos();
}
//============================================================================
//============================================================================
CORBA::Boolean SALOMEDS_StudyBuilder_i::GetAvailableRedos()
{
- return _doc->GetAvailableRedos();
+ SALOMEDS::Locker lock;
+ return _impl->GetAvailableRedos();
}
//============================================================================
//============================================================================
CORBA::Long SALOMEDS_StudyBuilder_i::UndoLimit()
{
- return _doc->GetUndoLimit();
+ SALOMEDS::Locker lock;
+ return _impl->UndoLimit();
}
//============================================================================
//============================================================================
void SALOMEDS_StudyBuilder_i::UndoLimit(CORBA::Long n)
{
+ SALOMEDS::Locker lock;
CheckLocked();
- _doc->SetUndoLimit (n);
-}
-
-//============================================================================
-/*! Function : SetOnAddSObject
- * Purpose :
- */
-//============================================================================
-SALOMEDS::Callback_ptr SALOMEDS_StudyBuilder_i::SetOnAddSObject(SALOMEDS::Callback_ptr theCallback)
-{
- return _study->SetOnAddSObject(theCallback);
-}
-
-void SALOMEDS_StudyBuilder_i::OnAddSObject(SALOMEDS::SObject_ptr theObject)
-{
- _study->OnAddSObject(theObject);
-}
-
-//============================================================================
-/*! Function : SetOnNewSObject
- * Purpose :
- */
-//============================================================================
-SALOMEDS::Callback_ptr SALOMEDS_StudyBuilder_i::SetOnRemoveSObject(SALOMEDS::Callback_ptr theCallback)
-{
- return _study->SetOnRemoveSObject(theCallback);
-}
-
-void SALOMEDS_StudyBuilder_i::OnRemoveSObject(SALOMEDS::SObject_ptr theObject)
-{
- _study->OnRemoveSObject(theObject);
+ _impl->UndoLimit(n);
}
//============================================================================
* Purpose :
*/
//============================================================================
-void SALOMEDS_StudyBuilder_i::CheckLocked() throw (SALOMEDS::StudyBuilder::LockProtection) {
- _study->CheckLocked();
+void SALOMEDS_StudyBuilder_i::CheckLocked() throw (SALOMEDS::StudyBuilder::LockProtection)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(SBLockProtection);
+ try {
+ _impl->CheckLocked();
+ }
+ catch(...) {
+ throw SALOMEDS::StudyBuilder::LockProtection();
+ }
}
//============================================================================
void SALOMEDS_StudyBuilder_i::SetName(SALOMEDS::SObject_ptr theSO, const char* theValue)
throw(SALOMEDS::StudyBuilder::LockProtection)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(SBLockProtection);
CheckLocked();
-
- if(CORBA::is_nil(theSO))
- return;
-
- //Find label
- TDF_Label aLabel;
- CORBA::String_var aSOID = theSO->GetID();
- TDF_Tool::Label(_doc->GetData(), aSOID, aLabel);
- TDataStd_Name::Set(aLabel, (char*)theValue);
+
+ Handle(SALOMEDSImpl_SObject) aSO;
+ aSO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSObject((char*)theSO->GetID());
+ _impl->SetName(aSO, TCollection_AsciiString((char*)theValue));
}
//============================================================================
*/
//============================================================================
void SALOMEDS_StudyBuilder_i::SetComment(SALOMEDS::SObject_ptr theSO, const char* theValue)
- throw(SALOMEDS::StudyBuilder::LockProtection)
+ throw(SALOMEDS::StudyBuilder::LockProtection)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(SBLockProtection);
CheckLocked();
- if(CORBA::is_nil(theSO))
- return;
-
- //Find label
- TDF_Label aLabel;
- CORBA::String_var aSOID = theSO->GetID();
- TDF_Tool::Label(_doc->GetData(), aSOID, aLabel);
- TDataStd_Comment::Set(aLabel, (char*)theValue);
+ Handle(SALOMEDSImpl_SObject) aSO;
+ aSO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSObject((char*)theSO->GetID());
+ _impl->SetComment(aSO, TCollection_AsciiString((char*)theValue));
}
//============================================================================
void SALOMEDS_StudyBuilder_i::SetIOR(SALOMEDS::SObject_ptr theSO, const char* theValue)
throw(SALOMEDS::StudyBuilder::LockProtection)
{
+ SALOMEDS::Locker lock;
Unexpect aCatch(SBLockProtection);
CheckLocked();
- if(CORBA::is_nil(theSO))
- return;
-
- //Find label
- TDF_Label aLabel;
- CORBA::String_var aSOID = theSO->GetID();
- TDF_Tool::Label(_doc->GetData(), aSOID, aLabel);
- SALOMEDS_IORAttribute::Set(aLabel, TCollection_ExtendedString((char*)theValue),_study);
+ Handle(SALOMEDSImpl_SObject) aSO;
+ aSO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSObject((char*)theSO->GetID());
+ _impl->SetIOR(aSO, TCollection_AsciiString((char*)theValue));
}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_StudyBuilder_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
-#ifndef __SALOMEDS_STUDYBUIlDER_I_H__
+#ifndef __SALOMEDS_STUDYBUILDER_I_H__
#define __SALOMEDS_STUDYBUILDER_I_H__
+// std C++ headers
+#include <iostream.h>
+
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS)
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+#include "SALOMEDSImpl_StudyBuilder.hxx"
+
// Cascade header
#include <TDocStd_Document.hxx>
-class SALOMEDS_Study_i;
-class SALOMEDS_SObject_i;
-class SALOMEDS_Callback_i;
-
-class SALOMEDS_StudyBuilder_i: public virtual POA_SALOMEDS::StudyBuilder,
- public virtual PortableServer::RefCountServantBase
+class SALOMEDS_StudyBuilder_i: public POA_SALOMEDS::StudyBuilder,
+ public PortableServer::RefCountServantBase
{
- SALOMEDS_StudyBuilder_i(); // Not implemented
- void operator=(const SALOMEDS_StudyBuilder_i&); // Not implemented
-
- SALOMEDS_Study_i* _study;
- Handle(TDocStd_Document) _doc; // OCAF Document
-
- void OnAddSObject(SALOMEDS::SObject_ptr theObject);
- void OnRemoveSObject(SALOMEDS::SObject_ptr theObject);
-
+private:
+ CORBA::ORB_ptr _orb;
+ Handle(SALOMEDSImpl_StudyBuilder) _impl; // OCAF Document
public:
- SALOMEDS_StudyBuilder_i(SALOMEDS_Study_i* theStudy,
- const Handle(TDocStd_Document)& theDocument);
+
+ SALOMEDS_StudyBuilder_i(const Handle(SALOMEDSImpl_StudyBuilder), CORBA::ORB_ptr);
~SALOMEDS_StudyBuilder_i();
- CORBA::ORB_var GetORB() const;
- PortableServer::POA_var GetPOA() const;
-
//! NewComponent
/*!
\param ComponentDataType
throw(SALOME::SALOME_Exception);
virtual void Load(SALOMEDS::SObject_ptr sco);
- SALOMEDS_SObject_i* RemoveSObject(SALOMEDS::SObject_ptr theSObject,
- bool theIsForgetAllAttributes = true);
virtual void RemoveObject(SALOMEDS::SObject_ptr anObject);
virtual void RemoveObjectWithChildren(SALOMEDS::SObject_ptr anObject);
void CheckLocked() throw (SALOMEDS::StudyBuilder::LockProtection);
- virtual SALOMEDS::Callback_ptr SetOnAddSObject(SALOMEDS::Callback_ptr theCallback);
- virtual SALOMEDS::Callback_ptr SetOnRemoveSObject(SALOMEDS::Callback_ptr theCallback);
-
virtual void SetName(SALOMEDS::SObject_ptr theSO, const char* theValue) throw(SALOMEDS::StudyBuilder::LockProtection);
virtual void SetComment(SALOMEDS::SObject_ptr theSO, const char* theValue) throw(SALOMEDS::StudyBuilder::LockProtection);
virtual void SetIOR(SALOMEDS::SObject_ptr theSO, const char* theValue) throw(SALOMEDS::StudyBuilder::LockProtection);
--- /dev/null
+// File : SALOMEDSClient_StudyManager.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+using namespace std;
+#include "SALOMEDS_StudyManager.hxx"
+
+#include "SALOMEDSImpl_Study.hxx"
+#include "SALOMEDS_Study.hxx"
+#include "SALOMEDS_SObject.hxx"
+#include "SALOMEDS_Driver_i.hxx"
+
+#include "Utils_ORB_INIT.hxx"
+#include "Utils_SINGLETON.hxx"
+
+#ifdef WIN32
+#include <process.h>
+#else
+#include <sys/types.h>
+#include <unistd.h>
+#endif
+
+#include <string>
+#include <TCollection_AsciiString.hxx>
+#include <TColStd_HSequenceOfTransient.hxx>
+
+#include "OpUtil.hxx"
+
+SALOMEDS_Driver_i* GetDriver(const Handle(SALOMEDSImpl_SObject)& theObject, CORBA::ORB_ptr orb);
+
+SALOMEDS_StudyManager::SALOMEDS_StudyManager(SALOMEDS::StudyManager_ptr theManager)
+{
+
+#ifdef WIN32
+ long pid = (long)_getpid();
+#else
+ long pid = (long)getpid();
+#endif
+
+ long addr = theManager->GetLocalImpl(GetHostname().c_str(), pid, _isLocal);
+ if(_isLocal) {
+ _local_impl = ((SALOMEDSImpl_StudyManager*)(addr));
+ _corba_impl = SALOMEDS::StudyManager::_duplicate(theManager);
+ }
+ else {
+ _local_impl = NULL;
+ _corba_impl = SALOMEDS::StudyManager::_duplicate(theManager);
+ }
+
+ init_orb();
+}
+
+SALOMEDS_StudyManager::SALOMEDS_StudyManager()
+{
+ init_orb();
+
+ SALOME_NamingService namingService(_orb);
+ CORBA::Object_var obj = namingService.Resolve( "/myStudyManager" );
+ SALOMEDS::StudyManager_var theManager = SALOMEDS::StudyManager::_narrow( obj );
+ ASSERT( !CORBA::is_nil(theManager) );
+
+#ifdef WIN32
+ long pid = (long)_getpid();
+#else
+ long pid = (long)getpid();
+#endif
+
+ long addr = theManager->GetLocalImpl(GetHostname().c_str(), pid, _isLocal);
+ if(_isLocal) {
+ _local_impl = ((SALOMEDSImpl_StudyManager*)(addr));
+ _corba_impl = SALOMEDS::StudyManager::_duplicate(theManager);
+ }
+ else {
+ _local_impl = NULL;
+ _corba_impl = SALOMEDS::StudyManager::_duplicate(theManager);
+ }
+}
+
+SALOMEDS_StudyManager::~SALOMEDS_StudyManager()
+{
+}
+
+_PTR(Study) SALOMEDS_StudyManager::NewStudy(const std::string& study_name)
+{
+ SALOMEDSClient_Study* aStudy = NULL;
+
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_Study) aStudy_impl = _local_impl->NewStudy((char*)study_name.c_str());
+ if(aStudy_impl.IsNull()) return _PTR(Study)(aStudy);
+ aStudy = new SALOMEDS_Study(aStudy_impl);
+ }
+ else {
+ SALOMEDS::Study_var aStudy_impl = _corba_impl->NewStudy((char*)study_name.c_str());
+ if(CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy);
+ aStudy = new SALOMEDS_Study(aStudy_impl);
+ }
+
+ return _PTR(Study)(aStudy);
+}
+
+_PTR(Study) SALOMEDS_StudyManager::Open(const std::string& theStudyUrl)
+{
+ SALOMEDSClient_Study* aStudy = NULL;
+
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_Study) aStudy_impl = _local_impl->Open((char*)theStudyUrl.c_str());
+ if(aStudy_impl.IsNull()) return _PTR(Study)(aStudy);
+ aStudy = new SALOMEDS_Study(aStudy_impl);
+ }
+ else {
+ SALOMEDS::Study_var aStudy_impl = _corba_impl->Open((char*)theStudyUrl.c_str());
+ if(CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy);
+
+ aStudy = new SALOMEDS_Study(aStudy_impl.in());
+ }
+
+ return _PTR(Study)(aStudy);
+}
+
+void SALOMEDS_StudyManager::Close(const _PTR(Study)& theStudy)
+{
+ //SRN: Pure CORBA close as it does more cleaning then the local one
+ SALOMEDS::Study_var aStudy = _corba_impl->GetStudyByID(theStudy->StudyId());
+ _corba_impl->Close(aStudy);
+}
+
+void SALOMEDS_StudyManager::Save(const _PTR(Study)& theStudy, bool theMultiFile)
+{
+ //SRN: Pure CORBA save as the save operation require CORBA in any case
+ SALOMEDS::Study_var aStudy = _corba_impl->GetStudyByID(theStudy->StudyId());
+ _corba_impl->Save(aStudy, theMultiFile);
+}
+
+void SALOMEDS_StudyManager::SaveASCII(const _PTR(Study)& theStudy, bool theMultiFile)
+{
+ //SRN: Pure CORBA save as the save operation require CORBA in any case
+ SALOMEDS::Study_var aStudy = _corba_impl->GetStudyByID(theStudy->StudyId());
+ _corba_impl->SaveASCII(aStudy, theMultiFile);
+}
+
+void SALOMEDS_StudyManager::SaveAs(const std::string& theUrl, const _PTR(Study)& theStudy, bool theMultiFile)
+{
+ //SRN: Pure CORBA save as the save operation require CORBA in any case
+ SALOMEDS::Study_var aStudy = _corba_impl->GetStudyByID(theStudy->StudyId());
+ _corba_impl->SaveAs((char*)theUrl.c_str(), aStudy, theMultiFile);
+}
+
+void SALOMEDS_StudyManager::SaveAsASCII(const std::string& theUrl, const _PTR(Study)& theStudy, bool theMultiFile)
+{
+ //SRN: Pure CORBA save as the save operation require CORBA in any case
+ SALOMEDS::Study_var aStudy = _corba_impl->GetStudyByID(theStudy->StudyId());
+ _corba_impl->SaveAsASCII((char*)theUrl.c_str(), aStudy, theMultiFile);
+}
+
+std::vector<std::string> SALOMEDS_StudyManager::GetOpenStudies()
+{
+ std::vector<std::string> aVector;
+ int aLength, i;
+
+ if(_isLocal) {
+ Handle(TColStd_HSequenceOfTransient) aSeq = _local_impl->GetOpenStudies();
+ aLength = aSeq->Length();
+ for(i = 1; i <= aLength; i++)
+ aVector.push_back(Handle(SALOMEDSImpl_Study)::DownCast(aSeq->Value(i))->Name().ToCString());
+ }
+ else {
+ SALOMEDS::ListOfOpenStudies_var aSeq = _corba_impl->GetOpenStudies();
+ aLength = aSeq->length();
+ for(i = 0; i < aLength; i++)
+ aVector.push_back(aSeq[i].in());
+ }
+ return aVector;
+}
+
+_PTR(Study) SALOMEDS_StudyManager::GetStudyByName(const std::string& theStudyName)
+{
+ SALOMEDSClient_Study* aStudy = NULL;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_Study) aStudy_impl = _local_impl->GetStudyByName((char*)theStudyName.c_str());
+ if(aStudy_impl.IsNull()) return _PTR(Study)(aStudy);
+ aStudy = new SALOMEDS_Study(aStudy_impl);
+ }
+ else {
+ SALOMEDS::Study_var aStudy_impl = _corba_impl->GetStudyByName((char*)theStudyName.c_str());
+ if(CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy);
+ aStudy = new SALOMEDS_Study(aStudy_impl);
+ }
+ return _PTR(Study)(aStudy);
+}
+
+_PTR(Study) SALOMEDS_StudyManager::GetStudyByID(int theStudyID)
+{
+ SALOMEDSClient_Study* aStudy = NULL;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_Study) aStudy_impl = _local_impl->GetStudyByID(theStudyID);
+ if(aStudy_impl.IsNull()) return _PTR(Study)(aStudy);
+ aStudy = new SALOMEDS_Study(aStudy_impl);
+ }
+ else {
+ SALOMEDS::Study_var aStudy_impl = _corba_impl->GetStudyByID(theStudyID);
+ if(CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy);
+ aStudy = new SALOMEDS_Study(aStudy_impl);
+ }
+ return _PTR(Study)(aStudy);
+}
+
+bool SALOMEDS_StudyManager::CanCopy(const _PTR(SObject)& theSO)
+{
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
+ bool ret;
+
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_SObject) aSO_impl = aSO->GetLocalImpl();
+ SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
+ ret = _local_impl->CanCopy(aSO_impl, aDriver);
+ delete aDriver;
+ }
+ else {
+ ret = _corba_impl->CanCopy(aSO->GetCORBAImpl());
+ }
+
+ return ret;
+}
+
+bool SALOMEDS_StudyManager::Copy(const _PTR(SObject)& theSO)
+{
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
+ bool ret;
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_SObject) aSO_impl = aSO->GetLocalImpl();
+ SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
+ ret = _local_impl->Copy(aSO_impl, aDriver);
+ delete aDriver;
+ }
+ else {
+ ret = _corba_impl->Copy(aSO->GetCORBAImpl());
+ }
+ return ret;
+}
+
+bool SALOMEDS_StudyManager::CanPaste(const _PTR(SObject)& theSO)
+{
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
+ bool ret;
+
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_SObject) aSO_impl = aSO->GetLocalImpl();
+ SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
+ ret = _local_impl->CanPaste(aSO_impl, aDriver);
+ delete aDriver;
+ }
+ else {
+ ret = _corba_impl->CanPaste(aSO->GetCORBAImpl());
+ }
+
+ return ret;
+}
+
+_PTR(SObject) SALOMEDS_StudyManager::Paste(const _PTR(SObject)& theSO)
+{
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
+ SALOMEDSClient_SObject* aResult = NULL;
+
+ if(_isLocal) {
+ Handle(SALOMEDSImpl_SObject) aSO_impl = aSO->GetLocalImpl();
+ SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
+ Handle(SALOMEDSImpl_SObject) aNewSO = _local_impl->Paste(aSO_impl, aDriver);
+ delete aDriver;
+ if(aNewSO.IsNull()) return _PTR(SObject)(aResult);
+ aResult = new SALOMEDS_SObject(aNewSO);
+ }
+ else {
+ SALOMEDS::SObject_ptr aNewSO = _corba_impl->Paste(aSO->GetCORBAImpl());
+ if(CORBA::is_nil(aNewSO)) return _PTR(SObject)(aResult);
+ aResult = new SALOMEDS_SObject(aNewSO);
+ }
+
+ return _PTR(SObject)(aResult);
+}
+
+
+void SALOMEDS_StudyManager::init_orb()
+{
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
+ _orb = init(0 , 0 ) ;
+}
+
+SALOMEDS_Driver_i* GetDriver(const Handle(SALOMEDSImpl_SObject)& theObject, CORBA::ORB_ptr orb)
+{
+ SALOMEDS_Driver_i* driver = NULL;
+
+ Handle(SALOMEDSImpl_SComponent) aSCO = theObject->GetFatherComponent();
+ if(!aSCO.IsNull()) {
+ TCollection_AsciiString IOREngine = aSCO->GetIOR();
+ if(!IOREngine.IsEmpty()) {
+ CORBA::Object_var obj = orb->string_to_object(IOREngine.ToCString());
+ SALOMEDS::Driver_var Engine = SALOMEDS::Driver::_narrow(obj) ;
+ driver = new SALOMEDS_Driver_i(Engine, orb);
+ }
+ }
+
+ return driver;
+}
--- /dev/null
+// File : SALOMEDS_StudyManager.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef __SALOMEDS_STUDYMANAGER_H__
+#define __SALOMEDS_STUDYMANAGER_H__
+
+#include <vector>
+#include <string>
+
+#include "SALOMEDSClient.hxx"
+#include "SALOMEDSImpl_StudyManager.hxx"
+
+// IDL headers
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+
+class SALOMEDS_StudyManager: public SALOMEDSClient_StudyManager
+{
+private:
+ bool _isLocal;
+ Handle(SALOMEDSImpl_StudyManager) _local_impl;
+ SALOMEDS::StudyManager_var _corba_impl;
+ CORBA::ORB_var _orb;
+
+public:
+
+ SALOMEDS_StudyManager(SALOMEDS::StudyManager_ptr theManager);
+ SALOMEDS_StudyManager();
+ ~SALOMEDS_StudyManager();
+
+ virtual _PTR(Study) NewStudy(const std::string& study_name);
+ virtual _PTR(Study) Open(const std::string& theStudyUrl);
+ virtual void Close(const _PTR(Study)& theStudy);
+ virtual void Save(const _PTR(Study)& theStudy, bool theMultiFile);
+ virtual void SaveASCII(const _PTR(Study)& theStudy, bool theMultiFile);
+ virtual void SaveAs(const std::string& theUrl, const _PTR(Study)& theStudy, bool theMultiFile);
+ virtual void SaveAsASCII(const std::string& theUrl, const _PTR(Study)& theStudy, bool theMultiFile);
+ virtual std::vector<std::string> GetOpenStudies();
+ virtual _PTR(Study) GetStudyByName(const std::string& theStudyName) ;
+ virtual _PTR(Study) GetStudyByID(int theStudyID) ;
+ virtual bool CanCopy(const _PTR(SObject)& theSO);
+ virtual bool Copy(const _PTR(SObject)& theSO);
+ virtual bool CanPaste(const _PTR(SObject)& theSO);
+ virtual _PTR(SObject) Paste(const _PTR(SObject)& theSO);
+
+private:
+ void init_orb();
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_StudyManager_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
-
-#include <memory>
-#include <sstream>
-
-#include <OSD_Process.hxx>
-#include <Quantity_Date.hxx>
-
-#include <TDF_Label.hxx>
-#include <TDataStd_Name.hxx>
-#include <TDataStd_Comment.hxx>
-#include <TDataStd_Integer.hxx>
-#include <TDataStd_TreeNode.hxx>
-#include <TDataStd_UAttribute.hxx>
-#include <TDF_ChildIterator.hxx>
-#include <TDF_Tool.hxx>
-#include <TDF_Reference.hxx>
-#include <TDF_Data.hxx>
-#include <TDF_RelocationTable.hxx>
-#include <TDF_AttributeIterator.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TCollection_AsciiString.hxx>
-#include "SALOMEDS_StudyManager_i.hxx"
+#include "utilities.h"
#include "SALOME_LifeCycleCORBA.hxx"
-
+#include "SALOMEDS_StudyManager_i.hxx"
#include "SALOMEDS_Study_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
-#include "SALOMEDS_StudyBuilder_i.hxx"
-
-#include "SALOMEDS_IORAttribute.hxx"
-#include "SALOMEDS_PersRefAttribute.hxx"
-#include "SALOMEDS_TargetAttribute.hxx"
+#include "SALOMEDS_SComponent_i.hxx"
+#include "SALOMEDS_Driver_i.hxx"
+#include "SALOMEDS.hxx"
-#include "SALOMEDS_Tool.hxx"
-#include "HDFexplorer.hxx"
+#include "SALOMEDSImpl_Study.hxx"
+#include "SALOMEDSImpl_SObject.hxx"
+#include "SALOMEDSImpl_SComponent.hxx"
+#include "SALOMEDSImpl_AttributeIOR.hxx"
-// IDL headers
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+#include <TColStd_HArray1OfCharacter.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TCollection_AsciiString.hxx>
-#include "SALOME_GenericObj_i.hh"
#include "Utils_CorbaException.hxx"
-#include "Utils_ExceptHandlers.hxx"
-
-UNEXPECT_CATCH(SalomeException,SALOME::SALOME_Exception);
-UNEXPECT_CATCH(LockProtection, SALOMEDS::StudyBuilder::LockProtection);
-
-#define USE_CASE_LABEL_ID "0:2"
-#define AUTO_SAVE_GUID "128268A3-71C9-4036-89B1-F81BD6A4FCF2"
-#define AUTO_SAVE_TAG "0:8"
-#define AUTO_SAVE_TIME_OUT_IN_SECONDS 1200
-
-#include "utilities.h"
+#include <strstream>
+#include <map>
using namespace std;
-//===========================================================================
-namespace SALOMEDS{
-
- CORBA::Object_var
- GetObject(const TDF_Label& theLabel, CORBA::ORB_ptr theORB)
- {
- try {
- Handle(SALOMEDS_IORAttribute) anAttr;
- if(theLabel.FindAttribute(SALOMEDS_IORAttribute::GetID(),anAttr))
- return theORB->string_to_object(TCollection_AsciiString(anAttr->Get()).ToCString());
- }catch(...){
- }
- return CORBA::Object::_nil();
- }
+#ifdef WIN32
+#include <process.h>
+#else
+#include <sys/types.h>
+#include <unistd.h>
+#endif
+#include "OpUtil.hxx"
- PortableServer::ServantBase_var
- GetServant(CORBA::Object_ptr theObject, PortableServer::POA_ptr thePOA)
- {
- if(CORBA::is_nil(theObject))
- return NULL;
- try{
- return thePOA->reference_to_servant(theObject);
- }catch(...){
- return NULL;
- }
- }
-
-}
-
-//===========================================================================
-//Function : LoadAttributes
-//===========================================================================
-static
-void
-ReadAttributes(SALOMEDS_Study_i* theStudy,
- SALOMEDS::SObject_ptr aSO,
- HDFdataset* hdf_dataset)
-{
- hdf_dataset->OpenOnDisk();
-
- SALOMEDS::GenericAttribute_var anAttr;
-
- char* current_string = new char[hdf_dataset->GetSize()];
- hdf_dataset->ReadFromDisk(current_string);
-
- if (!strcmp(hdf_dataset->GetName(),"COMPONENTDATATYPE")) {
- anAttr = theStudy->GetBuilder()->FindOrCreateAttribute(aSO, "AttributeComment");
- } else if (!strcmp(hdf_dataset->GetName(),"Reference")) {
- theStudy->GetBuilder()->Addreference(aSO, theStudy->CreateObjectID(current_string));
- delete(current_string);
- hdf_dataset->CloseOnDisk();
- return;
- } else {
- MESSAGE("Read attribute "<<hdf_dataset->GetName())
- anAttr = theStudy->GetBuilder()->FindOrCreateAttribute(aSO, hdf_dataset->GetName());
- }
-
- if (!CORBA::is_nil(anAttr)) {
- anAttr->Restore(current_string);
- MESSAGE("Restoring attribute "<<hdf_dataset->GetName()<<" by string '"<<current_string<<"' done")
- } else {
- MESSAGE(hdf_dataset->GetName());
- MESSAGE("LoadAttributes: unknown types");
- }
- delete(current_string);
- hdf_dataset->CloseOnDisk();
-}
-
-//============================================================================
-//Function : Translate_IOR_to_persistentID
-//============================================================================
-static void Translate_IOR_to_persistentID(SALOMEDS_Study_i* theStudy,
- SALOMEDS_StudyBuilder_i* theBuilder,
- SALOMEDS::SObject_ptr theSObject,
- SALOMEDS::Driver_ptr theEngine,
- CORBA::Boolean theIsMultiFile,
- CORBA::Boolean theIsASCII)
-{
- MESSAGE("In Translate_IOR_to_persistentID");
- SALOMEDS_ChildIterator_i anIter = theStudy->GetChildIterator(theSObject);
- for(; anIter.More(); anIter.Next()){
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::SObject_var aSObject = anIter.Value();
- if(aSObject->FindAttribute(anAttr,"AttributeIOR")){
- SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- CORBA::String_var aString = anIOR->Value();
- CORBA::String_var aPersistentID =
- theEngine->IORToLocalPersistentID(aSObject,aString,theIsMultiFile,theIsASCII);
- anAttr = theBuilder->FindOrCreateAttribute(aSObject,"AttributePersistentRef");
- SALOMEDS::AttributePersistentRef_var aPersistentRef = SALOMEDS::AttributePersistentRef::_narrow(anAttr);
- aPersistentRef->SetValue(aPersistentID);
- aString = aSObject->GetID();
- }
- Translate_IOR_to_persistentID(theStudy,theBuilder,aSObject,theEngine,theIsMultiFile,theIsASCII);
- }
-}
+#include "SALOME_GenericObj_i.hh"
-//============================================================================
-//Function : BuildlTree
-//============================================================================
-static
-void
-BuildTree(SALOMEDS_Study_i* theStudy, HDFgroup* hdf_current_group)
-{
- hdf_current_group->OpenOnDisk();
-
- SALOMEDS::SObject_var aSO;
- char* Entry = hdf_current_group->GetName();
- if (strcmp(Entry,"STUDY_STRUCTURE") == 0) {
- MESSAGE("find the root of the document");
- aSO = theStudy->CreateObjectID("0:1");
- }
- else {
- aSO = theStudy->CreateObjectID(Entry);
- MESSAGE("BuildTree : Create a new label"<<Entry);
- }
- char name[HDF_NAME_MAX_LEN+1];
- Standard_Integer nbsons = hdf_current_group->nInternalObjects();
-
- for (Standard_Integer i=0; i<nbsons; i++) {
- hdf_current_group->InternalObjectIndentify(i,name);
- if (strncmp(name, "INTERNAL_COMPLEX",16) == 0) continue;
- hdf_object_type type = hdf_current_group->InternalObjectType(name);
+#include "Utils_ExceptHandlers.hxx"
- if (type == HDF_DATASET) {
- MESSAGE("--> Dataset: Internal Object Name : " << name);
- HDFdataset* new_dataset = new HDFdataset(name,hdf_current_group);
- ReadAttributes(theStudy,aSO,new_dataset);
- new_dataset = 0; // will be deleted by father destructor
+UNEXPECT_CATCH(SalomeException,SALOME::SALOME_Exception);
+UNEXPECT_CATCH(LockProtection, SALOMEDS::StudyBuilder::LockProtection);
- }
- else if (type == HDF_GROUP) {
- MESSAGE( "--> Group: Internal Object Name : " << name);
- HDFgroup* new_group = new HDFgroup(name,hdf_current_group);
- BuildTree(theStudy, new_group);
- new_group = 0; // will be deleted by father destructor
- }
- }
- hdf_current_group->CloseOnDisk();
-}
+static SALOMEDS_Driver_i* GetDriver(const Handle(SALOMEDSImpl_SObject)& theObject, CORBA::ORB_ptr orb);
+static std::map<int, PortableServer::POA_ptr> _mapOfPOA;
//============================================================================
/*! Function : SALOMEDS_StudyManager_i
* Purpose : SALOMEDS_StudyManager_i constructor
*/
//============================================================================
-SALOMEDS_StudyManager_i::SALOMEDS_StudyManager_i(CORBA::ORB_ptr theORB,
- PortableServer::POA_ptr thePOA):
- _orb(CORBA::ORB::_duplicate(theORB)),
- _poa(PortableServer::POA::_duplicate(thePOA)),
- _OCAFApp(new SALOMEDS_OCAFApplication()),
- _name_service(theORB)
+SALOMEDS_StudyManager_i::SALOMEDS_StudyManager_i(CORBA::ORB_ptr orb, PortableServer::POA_ptr thePOA)
{
+ _orb = CORBA::ORB::_duplicate(orb);
+ _poa = PortableServer::POA::_duplicate(thePOA);
+ _name_service = new SALOME_NamingService(_orb);
// Study directory creation in the naming service : to register all
// open studies in the session
- _name_service.Create_Directory("/Study");
- _IDcounter = 0;
+ _name_service->Create_Directory("/Study");
+ _impl = new SALOMEDSImpl_StudyManager;
+ _factory = new SALOMEDS_DriverFactory_i(_orb);
}
//============================================================================
SALOMEDS_StudyManager_i::~SALOMEDS_StudyManager_i()
{
// Destroy directory to register open studies
- _name_service.Destroy_Directory("/Study");
-}
-
-SALOMEDS_Study_i*
-SALOMEDS_StudyManager_i::DownCast(SALOMEDS::Study_ptr theStudy) const
-{
- if(!CORBA::is_nil(theStudy)){
- PortableServer::POA_var aPOA = GetPOA();
- PortableServer::ServantBase_var aServant = SALOMEDS::GetServant(theStudy,aPOA);
- if(aServant.in())
- return dynamic_cast<SALOMEDS_Study_i*>(aServant.in());
- }
- return NULL;
+ _name_service->Destroy_Directory("/Study");
+ delete _factory;
}
//============================================================================
* context name
*/
//============================================================================
-void SALOMEDS_StudyManager_i::register_name(char * theName) {
+void SALOMEDS_StudyManager_i::register_name(char * name)
+{
SALOMEDS::StudyManager_var aManager(_this());
- _name_service.Register(aManager.in(),theName);
+ _name_service->Register(aManager.in(), name);
}
* Purpose : Create a New Study of name study_name
*/
//============================================================================
-SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* theStudyName)
+SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* study_name)
{
- Handle(TDocStd_Document) aDocument;
- _OCAFApp->NewDocument("SALOME_STUDY",aDocument);
+ SALOMEDS::Locker lock;
+
+ Handle(SALOMEDSImpl_Study) aStudyImpl = _impl->NewStudy(TCollection_AsciiString((char*)study_name));
+ if(aStudyImpl.IsNull()) {
+ MESSAGE("NewStudy : Error : " << _impl->GetErrorCode());
+ return SALOMEDS::Study::_nil();
+ }
MESSAGE("NewStudy : Creating the CORBA servant holding it... ");
- SALOMEDS_Study_i* aStudyServant = new SALOMEDS_Study_i(this,aDocument,theStudyName);
- SALOMEDS::Study_var aStudy = aStudyServant->_this();
- //Study->StudyId( _OCAFApp->NbDocuments() );
- _IDcounter++;
- aStudyServant->StudyId( _IDcounter );
+ SALOMEDS_Study_i *Study_servant = new SALOMEDS_Study_i(aStudyImpl, _orb);
+ SALOMEDS::Study_var Study = SALOMEDS::Study::_narrow(Study_servant->_this());
// Register study in the naming service
// Path to acces the study
- if(!_name_service.Change_Directory("/Study")){
- MESSAGE( "Unable to access the study directory" );
- }else
- _name_service.Register(aStudy, theStudyName);
-
+ if(!_name_service->Change_Directory("/Study"))
+ MESSAGE( "Unable to access the study directory" )
+ else
+ _name_service->Register(Study, study_name);
+
// Assign the value of the IOR in the study->root
- CORBA::String_var anIOR = _orb->object_to_string(aStudy);
- SALOMEDS_IORAttribute::Set(aDocument->Main().Root(),
- const_cast<char*>(anIOR.in()),
- aStudyServant);
-
- // set Study properties
- SALOMEDS::AttributeStudyProperties_var aProp = aStudyServant->GetProperties();
- OSD_Process aProcess;
- Quantity_Date aDate = aProcess.SystemDate();
- aProp->SetCreationDate(CORBA::Long(aDate.Minute()),
- CORBA::Long(aDate.Hour()),
- CORBA::Long(aDate.Day()),
- CORBA::Long(aDate.Month()),
- CORBA::Long(aDate.Year()));
- aProp->SetCreationMode("from scratch");
- aProp->SetUserName(aProcess.UserName().ToCString());
-
- return aStudy._retn();
+ const char* IORStudy = _orb->object_to_string(Study);
+
+ aStudyImpl->SetTransientReference((char*)IORStudy);
+
+ _mapOfPOA[Study->StudyId()] = _poa;
+
+ return Study;
}
//============================================================================
* Purpose : Open a Study from it's persistent reference
*/
//============================================================================
-SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* theURL)
+SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* aUrl)
throw(SALOME::SALOME_Exception)
{
+ SALOMEDS::Locker lock;
+
Unexpect aCatch(SalomeException);
MESSAGE("Begin of SALOMEDS_StudyManager_i::Open");
- bool isASCII = false;
- std::ostringstream anURLStream;
- if (HDFascii::isASCII(theURL)) {
- isASCII = true;
- auto_ptr<char> aResultPath(HDFascii::ConvertFromASCIIToHDF(theURL));
- anURLStream<<aResultPath.get()<<"hdf_from_ascii.hdf";
- } else {
- anURLStream<<theURL;
- }
- std::string aHDFUrl = anURLStream.str();
-
- // open the HDFFile (all related hdf objects will be deleted )
- auto_ptr<HDFfile> hdf_file(new HDFfile(const_cast<char*>(aHDFUrl.c_str())));
+ Handle(SALOMEDSImpl_Study) aStudyImpl = _impl->Open(TCollection_AsciiString((char*)aUrl));
- try {
- hdf_file->OpenOnDisk(HDF_RDONLY);// mpv: was RDWR, but opened file can be write-protected too
- }catch(HDFexception){
- std::ostringstream aStream;
- aStream<<"Can't open file "<<theURL;
- std::string eStr = aStream.str();
- THROW_SALOME_CORBA_EXCEPTION(eStr.c_str(),SALOME::BAD_PARAM);
- }
MESSAGE("Open : Creating the CORBA servant holding it... ");
// Temporary aStudyUrl in place of study name
- Handle(TDocStd_Document) Doc;
- _OCAFApp->NewDocument("SALOME_STUDY",Doc);
-
- SALOMEDS_Study_i* aStudyServant = new SALOMEDS_Study_i(this,Doc,theURL);
- SALOMEDS::Study_var aStudy = aStudyServant->_this();
-
- // aStudy->StudyId( _OCAFApp->NbDocuments() );
- _IDcounter++;
- aStudy->StudyId( _IDcounter );
-
- // Assign the value of the URL in the study object
- aStudyServant->URL(theURL);
- SCRUTE(theURL);
+ SALOMEDS_Study_i * Study_servant = new SALOMEDS_Study_i(aStudyImpl, _orb);
+ SALOMEDS::Study_var Study = SALOMEDS::Study::_narrow(Study_servant->_this());
// Assign the value of the IOR in the study->root
- CORBA::String_var anIOR = _orb->object_to_string(aStudy);
- SALOMEDS_IORAttribute::Set(Doc->Main().Root(),
- const_cast<char*>(anIOR.in()),
- aStudyServant);
-
- SALOMEDS_PersRefAttribute::Set(Doc->Main(),const_cast<char*>(theURL));
-
- if (!hdf_file->ExistInternalObject("STUDY_STRUCTURE")) {
- MESSAGE("SALOMEDS_StudyManager::Open : the study is empty");
- return aStudy._retn();
- }
-
- //Create the Structure of the OCAF Document
- HDFgroup *hdf_group_study_structure = new HDFgroup("STUDY_STRUCTURE",hdf_file.get());
-
- Handle(TDF_Data) DF = Doc->GetData();
-
- try{
- BuildTree(aStudyServant,hdf_group_study_structure);
- }catch(HDFexception){
- std::ostringstream aStream;
- aStream<<"Can't open file "<<theURL;
- std::string eStr = aStream.str();
- THROW_SALOME_CORBA_EXCEPTION(eStr.c_str(),SALOME::BAD_PARAM);
- }
+ CORBA::String_var IORStudy = _orb->object_to_string(Study);
+ aStudyImpl->SetTransientReference((char*)IORStudy);
- hdf_file->CloseOnDisk();
-
// Register study in the naming service
// Path to acces the study
- if(!_name_service.Change_Directory("/Study")){
- MESSAGE( "Unable to access the study directory" );
- }else{
- CORBA::String_var aString(aStudyServant->Name());
- _name_service.Register(aStudy,aString.in());
- }
+ if(!_name_service->Change_Directory("/Study")) MESSAGE( "Unable to access the study directory" )
+ else _name_service->Register(Study, CORBA::string_dup(aStudyImpl->Name().ToCString()));
- if (isASCII) {
- SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
- aFilesToRemove->length(1);
- std::string aDir = SALOMEDS_Tool::GetDirFromPath(aHDFUrl);
- aFilesToRemove[0] = CORBA::string_dup(&aHDFUrl[strlen(aDir.c_str())]);
- SALOMEDS_Tool::RemoveTemporaryFiles(aDir,aFilesToRemove,true);
- }
-
- return aStudy._retn();
+ return Study;
}
* close action without saving
*/
//============================================================================
-void SALOMEDS_StudyManager_i::Close(SALOMEDS::Study_ptr aStudy)
+void SALOMEDS_StudyManager_i::Close(SALOMEDS::Study_ptr aStudy)
{
+ SALOMEDS::Locker lock;
+
if(aStudy->_is_nil()) return;
-
- aStudy->RemovePostponed(-1);
-
+
// Destroy study name in the naming service
- if(_name_service.Change_Directory("/Study")){
+ if(_name_service->Change_Directory("/Study")){
CORBA::String_var aString(aStudy->Name());
- _name_service.Destroy_Name(aString.in());
- }
+ _name_service->Destroy_Name(aString.in());
+ }
+ SALOMEDS::unlock();
aStudy->Close();
+ SALOMEDS::lock();
}
//============================================================================
* Purpose : Save a Study to it's persistent reference
*/
//============================================================================
-void SALOMEDS_StudyManager_i::Save(SALOMEDS::Study_ptr theStudy, CORBA::Boolean theMultiFile)
+void SALOMEDS_StudyManager_i::Save(SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile)
{
- CORBA::String_var anURL = theStudy->URL();
- if(strcmp(anURL.in(),"") == 0){
- MESSAGE( "No path specified to save the study. Nothing done");
- }else{
- _SaveAs(anURL,theStudy,theMultiFile,false);
+ SALOMEDS::Locker lock;
+
+ if(aStudy->_is_nil()) {
+ MESSAGE("Save error: Study is null");
+ return;
}
+
+ Handle(SALOMEDSImpl_Study) aStudyImpl = _impl->GetStudyByID(aStudy->StudyId());
+ _impl->Save(aStudyImpl, _factory, theMultiFile);
}
-void SALOMEDS_StudyManager_i::SaveASCII(SALOMEDS::Study_ptr theStudy, CORBA::Boolean theMultiFile)
+void SALOMEDS_StudyManager_i::SaveASCII(SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile)
{
- CORBA::String_var anURL = theStudy->URL();
- if(strcmp(anURL.in(),"") == 0){
- MESSAGE( "No path specified to save the study. Nothing done");
- }else{
- _SaveAs(anURL,theStudy,theMultiFile,true);
+ SALOMEDS::Locker lock;
+
+ if(aStudy->_is_nil()) {
+ MESSAGE("SaveASCII error: Study is null");
+ return;
}
+
+ Handle(SALOMEDSImpl_Study) aStudyImpl = _impl->GetStudyByID(aStudy->StudyId());
+ _impl->SaveASCII(aStudyImpl, _factory, theMultiFile);
}
//=============================================================================
* Purpose : Save a study to the persistent reference aUrl
*/
//============================================================================
-void SALOMEDS_StudyManager_i::SaveAs(const char* aUrl, SALOMEDS::Study_ptr theStudy, CORBA::Boolean theMultiFile)
+void SALOMEDS_StudyManager_i::SaveAs(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile)
{
- _SaveAs(aUrl,theStudy,theMultiFile, false);
+ SALOMEDS::Locker lock;
+ if(aStudy->_is_nil()) {
+ MESSAGE("SaveASCII error: Study is null");
+ return;
+ }
+
+ Handle(SALOMEDSImpl_Study) aStudyImpl = _impl->GetStudyByID(aStudy->StudyId());
+ _impl->SaveAs(TCollection_AsciiString((char*)aUrl), aStudyImpl, _factory, theMultiFile);
}
-void SALOMEDS_StudyManager_i::SaveAsASCII(const char* aUrl, SALOMEDS::Study_ptr theStudy, CORBA::Boolean theMultiFile)
+void SALOMEDS_StudyManager_i::SaveAsASCII(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile)
{
- _SaveAs(aUrl,theStudy,theMultiFile, true);
+ SALOMEDS::Locker lock;
+
+ if(aStudy->_is_nil()) {
+ MESSAGE("SaveASCII error: Study is null");
+ return;
+ }
+
+ Handle(SALOMEDSImpl_Study) aStudyImpl = _impl->GetStudyByID(aStudy->StudyId());
+ _impl->SaveAsASCII(TCollection_AsciiString((char*)aUrl), aStudyImpl, _factory, theMultiFile);
}
//============================================================================
//============================================================================
SALOMEDS::ListOfOpenStudies* SALOMEDS_StudyManager_i::GetOpenStudies()
{
- // MESSAGE("Begin of GetOpenStudies");
- SALOMEDS::ListOfOpenStudies_var aStudyList = new SALOMEDS::ListOfOpenStudies;
-
- if(!_name_service.Change_Directory("/Study")){
- MESSAGE("No active study in this session");
- }else{
- vector<string> aList = _name_service.list_directory();
- aStudyList->length(aList.size());
- for(unsigned int ind = 0; ind < aList.size(); ind++){
- aStudyList[ind] = CORBA::string_dup(aList[ind].c_str());
- SCRUTE(aStudyList[ind]) ;
- }
- }
+ SALOMEDS::Locker lock;
+
+ Handle(TColStd_HSequenceOfTransient) anOpened = _impl->GetOpenStudies();
+ int aLength = anOpened->Length();
- return aStudyList._retn();
+ SALOMEDS::ListOfOpenStudies_var _list_open_studies = new SALOMEDS::ListOfOpenStudies;
+ _list_open_studies->length(aLength);
+
+ if(!aLength)
+ {
+ MESSAGE("No active study in this session");
+ }
+ else
+ {
+ for (unsigned int ind=1; ind <= aLength; ind++)
+ {
+ Handle(SALOMEDSImpl_Study) aStudy = Handle(SALOMEDSImpl_Study)::DownCast(anOpened->Value(ind));
+ _list_open_studies[ind-1] = CORBA::string_dup(aStudy->Name().ToCString());
+ SCRUTE(_list_open_studies[ind-1]) ;
+ }
+ }
+ return _list_open_studies._retn();
}
//============================================================================
* Purpose : Get a study from its name
*/
//============================================================================
-SALOMEDS::Study_ptr
-SALOMEDS_StudyManager_i::GetStudyByName(const char* theStudyName)
+SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::GetStudyByName(const char* aStudyName)
{
- SALOMEDS::Study_var aStudy;
+ SALOMEDS::Locker lock;
+
+ Handle(SALOMEDSImpl_Study) aStudyImpl = _impl->GetStudyByName(TCollection_AsciiString((char*)aStudyName));
- // Go to study directory and look for aStudyName
- if(!_name_service.Change_Directory("/Study")){
- MESSAGE("No active study in this session");
- ASSERT(false); // Stop here...
- }
+ if(aStudyImpl.IsNull())
+ {
+ MESSAGE("No active study in this session");
+ ASSERT(false); // Stop here...
+ }
- if(_name_service.Find(theStudyName) > 0){
- // Study found
- CORBA::Object_ptr anObj = _name_service.Resolve(theStudyName) ;
- aStudy = SALOMEDS::Study::_narrow(anObj);
- MESSAGE("Study " << theStudyName << " found in the naming service");
- }else{
- MESSAGE("Study " << theStudyName << " not found in the naming service");
- }
- return aStudy._retn();
+ SALOMEDS_Study_i * Study_servant = new SALOMEDS_Study_i(aStudyImpl, _orb);
+ SALOMEDS::Study_var Study = SALOMEDS::Study::_narrow(Study_servant->_this());
+
+ return Study;
}
//============================================================================
* Purpose : Get a study from its ID
*/
//============================================================================
-SALOMEDS::Study_ptr
-SALOMEDS_StudyManager_i::GetStudyByID(CORBA::Short aStudyID)
+SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::GetStudyByID(CORBA::Short aStudyID)
{
- SALOMEDS::Study_var aStudy;
-
- if(!_name_service.Change_Directory("/Study")){
- MESSAGE("No active study in this session");
- }else{
- vector<string> aList = _name_service.list_directory();
- for(unsigned int ind = 0; ind < aList.size(); ind++){
- const char* aStudyName = aList[ind].c_str();
- MESSAGE( "GetStudyByID = " << aStudyName );
- if(_name_service.Find(aStudyName) > 0){
- CORBA::Object_ptr anObj = _name_service.Resolve(aStudyName) ;
- aStudy = SALOMEDS::Study::_narrow(anObj);
- MESSAGE( " aStudyID : " << aStudyID << "-" << aStudy->StudyId() );
- if(aStudyID == aStudy->StudyId()){
- MESSAGE("Study with studyID = " << aStudyID << " found in the naming service");
- return aStudy._retn();
- }
- }else{
- MESSAGE("Study " << aStudyName << " not found in the naming service");
- }
+ SALOMEDS::Locker lock;
+
+ Handle(SALOMEDSImpl_Study) aStudyImpl = _impl->GetStudyByID(aStudyID);
+
+ if(aStudyImpl.IsNull())
+ {
+ MESSAGE("No active study in this session");
+ ASSERT(false); // Stop here...
}
- }
- return aStudy._retn();
+ SALOMEDS_Study_i * Study_servant = new SALOMEDS_Study_i(aStudyImpl, _orb);
+ SALOMEDS::Study_var Study = SALOMEDS::Study::_narrow(Study_servant->_this());
+
+ return Study;
}
-//============================================================================
-/*! Function : SaveAttributes
- * Purpose : Save attributes for object
- */
-//============================================================================
-static void SaveAttributes(SALOMEDS::SObject_ptr SO, HDFgroup *hdf_group_sobject) {
- int a;
- hdf_size size[1];
- SALOMEDS::ListOfAttributes_var anAttrList = SO->GetAllAttributes();
- for(a = anAttrList->length() - 1; a >= 0; a--) {
- if (strcmp(anAttrList[a]->Type(), "AttributeIOR") == 0) continue; // never write AttributeIOR to file
- if (strcmp(anAttrList[a]->Type(), "AttributeExternalFileDef") == 0) continue; // never write ExternalFileDef to file
- if (strcmp(anAttrList[a]->Type(), "AttributeFileType") == 0) continue; // never write FileType to file
- CORBA::String_var aSaveStr(anAttrList[a]->Store());
- size[0] = (hdf_int32) strlen(aSaveStr.in()) + 1;
- HDFdataset *hdf_dataset = new HDFdataset(anAttrList[a]->Type(),hdf_group_sobject,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(aSaveStr);
- hdf_dataset->CloseOnDisk();
- //cout<<"********** Write Attribute "<<anAttrList[a]->Type()<<" : "<<aSaveStr<<" done"<<endl;
- hdf_dataset = 0; //will be deleted by hdf_sco_group destructor
- }
- // Reference attribute has no CORBA attribute representation, so, GetAllAttributes can not return this attribute
- SALOMEDS::SObject_var RefSO;
- if(SO->ReferencedObject(RefSO)) {
- CORBA::String_var attribute_reference(RefSO->GetID());
- size[0] = strlen(attribute_reference) + 1 ;
- HDFdataset *hdf_dataset = new HDFdataset("Reference",hdf_group_sobject,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(attribute_reference);
- hdf_dataset->CloseOnDisk();
- hdf_dataset = 0; // will be deleted by father hdf object destructor
- }
-}
-//=============================================================================
-/*! Function : _SaveProperties
- * Purpose : save the study properties in HDF file
- */
//============================================================================
-void SALOMEDS_StudyManager_i::_SaveProperties(SALOMEDS_Study_i* theStudy, HDFgroup *hdf_group)
-{
- // add modifications list (user and date of save)
- SALOMEDS::AttributeStudyProperties_ptr aProp = theStudy->GetProperties();
- int aLocked = aProp->IsLocked();
- if (aLocked)
- aProp->SetLocked(Standard_False);
- OSD_Process aProcess;
- Quantity_Date aDate = aProcess.SystemDate();
- aProp->SetModification(aProcess.UserName().ToCString(),
- CORBA::Long(aDate.Minute()),
- CORBA::Long(aDate.Hour()),
- CORBA::Long(aDate.Day()),
- CORBA::Long(aDate.Month()),
- CORBA::Long(aDate.Year()));
- if(aLocked)
- aProp->SetLocked(Standard_True);
-
- SALOMEDS::StringSeq_var aNames;
- SALOMEDS::LongSeq_var aMinutes, aHours, aDays, aMonths, aYears;
- aProp->GetModificationsList(aNames,aMinutes,aHours,aDays,aMonths,aYears,true);
-
- std::ostringstream aPropertyList;
- aPropertyList<<(strlen(aProp->GetCreationMode()) != 0? aProp->GetCreationMode()[0] : '0');
- aPropertyList<<(aProp->IsLocked()? 'l': 'u');
-
- int aLength = aNames->length();
- for(int anIndex = 0; anIndex < aLength; anIndex++) {
- aPropertyList<<std::setw(2)<<aMinutes[anIndex];
- aPropertyList<<std::setw(2)<<aHours[anIndex];
- aPropertyList<<std::setw(2)<<aDays[anIndex];
- aPropertyList<<std::setw(2)<<aMonths[anIndex];
- aPropertyList<<std::setw(4)<<aYears[anIndex];
- aPropertyList<<aNames[anIndex];
- aPropertyList<<char(0x1);
- }
- std::string aProperty = aPropertyList.str();
-
- hdf_size size[] = {aProperty.size() + 1};
- HDFdataset *hdf_dataset = new HDFdataset("AttributeStudyProperties",hdf_group,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(const_cast<char*>(aProperty.c_str()));
- MESSAGE("attribute StudyProperties " << aProperty << " wrote on file");
- hdf_dataset->CloseOnDisk();
- hdf_dataset = 0; //will be deleted by hdf_sco_group destructor
- aProp->SetModified(0);
-}
-
-//=============================================================================
-/*! Function : _SaveAs
- * Purpose : save the study in HDF file
+/*! Function : CanCopy
+ * Purpose :
*/
//============================================================================
-void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl,
- SALOMEDS::Study_ptr theStudy,
- CORBA::Boolean theMultiFile,
- CORBA::Boolean theASCII)
+CORBA::Boolean SALOMEDS_StudyManager_i::CanCopy(SALOMEDS::SObject_ptr theObject)
{
- // HDF File will be composed of differents part :
- // * For each ComponentDataType, all data created by the component
- // Informations in data group hdf_group_datacomponent
- // * Study Structure -> Exactly what is contained in OCAF document
- // Informations in data group hdf_group_study_structure
-
- if(SALOMEDS_Study_i* aStudy = DownCast(theStudy)){
- HDFfile *hdf_file=0;
- HDFgroup *hdf_group_study_structure =0;
- HDFgroup *hdf_sco_group =0;
- HDFgroup *hdf_sco_group2 =0;
-
- HDFgroup *hdf_group_datacomponent =0;
- HDFdataset *hdf_dataset =0;
- hdf_size size[1];
- hdf_int32 name_len = 0;
-
- int aLocked = aStudy->GetProperties()->IsLocked();
- if(aLocked)
- aStudy->GetProperties()->SetLocked(false);
+ SALOMEDS::Locker lock;
- SALOMEDS_StudyBuilder_i* SB= aStudy->GetBuilder();
- try{
- // mpv 15.12.2003: for saving components we have to load all data from all modules
- SALOMEDS_SComponentIterator_i aComponentIter = aStudy->GetComponentIterator();
- for(; aComponentIter.More(); aComponentIter.Next()){
- SALOMEDS::SComponent_var sco = aComponentIter.Value();
- // if there is an associated Engine call its method for saving
- CORBA::String_var IOREngine;
- try{
- if(!sco->ComponentIOR(IOREngine)){
- SALOMEDS::GenericAttribute_var aGeneric;
- SALOMEDS::AttributeName_var aName;
- if(sco->FindAttribute(aGeneric, "AttributeName"))
- aName = SALOMEDS::AttributeName::_narrow(aGeneric);
-
- if(!aName->_is_nil()){
- CORBA::String_var aCompType = aName->Value();
-
- CORBA::String_var aFactoryType;
- if(strcmp(aCompType, "SUPERV") == 0)
- aFactoryType = "SuperVisionContainer";
- else
- aFactoryType = "FactoryServer";
-
- Engines::Component_var aComp =
- SALOME_LifeCycleCORBA(&_name_service).FindOrLoad_Component(aFactoryType, aCompType);
-
- if(aComp->_is_nil()){
- Engines::Component_var aComp =
- SALOME_LifeCycleCORBA(&_name_service).FindOrLoad_Component("FactoryServerPy", aCompType);
- }
-
- if(!aComp->_is_nil()){
- SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aComp);
- if (!CORBA::is_nil(aDriver)) {
- SB->LoadWith(sco, aDriver);
- }
- }
- }
- }
- }catch(...){
- MESSAGE("Can not restore information to resave it");
- return;
- }
- }
-
- CORBA::String_var anOldName = aStudy->Name();
- aStudy->URL(aUrl);
-
- // To change for Save
- // Do not have to do a new file but just a Open??? Rewrite all informations after erasing evrything??
- hdf_file = new HDFfile((char *)aUrl);
- hdf_file->CreateOnDisk();
- MESSAGE("File " << aUrl << " created");
-
- //-----------------------------------------------------------------------
- // 1 - Create a groupe for each SComponent and Update the PersistanceRef
- //-----------------------------------------------------------------------
- hdf_group_datacomponent = new HDFgroup("DATACOMPONENT",hdf_file);
- hdf_group_datacomponent->CreateOnDisk();
-
- //SRN: Added 17 Nov, 2003
- SALOMEDS::SObject_var anAutoSaveSO = aStudy->FindObjectID(AUTO_SAVE_TAG);
- //SRN: End
-
- aComponentIter.Init();
- for(; aComponentIter.More(); aComponentIter.Next()){
- SALOMEDS::SComponent_var sco = aComponentIter.Value();
-
- CORBA::String_var scoid = sco->GetID();
- hdf_sco_group = new HDFgroup(scoid,hdf_group_datacomponent);
- hdf_sco_group->CreateOnDisk();
-
- CORBA::String_var componentDataType = sco->ComponentDataType();
- MESSAGE ( "Look for an engine for data type :"<< componentDataType);
-
- //SRN: Added 17 Nov 2003: If there is a specified attribute, the component peforms a special save
- if(!CORBA::is_nil(anAutoSaveSO) && SB->IsGUID(sco, AUTO_SAVE_GUID)){
- SALOMEDS::GenericAttribute_var aGeneric;
- SALOMEDS::AttributeTableOfString_var aTable;
- if(anAutoSaveSO->FindAttribute(aGeneric, "AttributeTableOfString")){
- aTable = SALOMEDS::AttributeTableOfString::_narrow(aGeneric);
- Standard_Integer nbRows = aTable->GetNbRows(), k, aTimeOut = 0;
- if(nbRows > 0 && aTable->GetNbColumns() > 1) {
- SALOMEDS::StringSeq_var aRow;
- for(k=1; k<=nbRows; k++){
- aRow = aTable->GetRow(k);
- if(strcmp(aRow[0], componentDataType) == 0){
- CORBA::String_var anEntry = CORBA::string_dup(aRow[1]);
- SALOMEDS::SObject_var aCompSpecificSO = aStudy->FindObjectID(anEntry);
- if(!CORBA::is_nil(aCompSpecificSO)) {
- SALOMEDS::AttributeInteger_var anInteger;
- if(aCompSpecificSO->FindAttribute(aGeneric, "AttributeInteger")) {
- anInteger = SALOMEDS::AttributeInteger::_narrow(aGeneric);
- anInteger->SetValue(-1);
- while(anInteger->Value() < 0) { sleep(2); if(++aTimeOut > AUTO_SAVE_TIME_OUT_IN_SECONDS) break; }
- } // if(aCompSpecificSO->FindAttribute(anInteger, "AttributeInteger"))
- } // if(!CORBA::is_nil(aCompSpecificSO))
- } // if (strcmp(aRow[0], componentDataType) == 0)
- } // for
-
- } // if(nbRows > 0 && aTable->GetNbColumns() > 1)
-
- } // if(anAutoSaveSO->FindAttribute(aTable, "AttributeTableOfString")
-
- } // if(SB->IsGUID(AUTO_SAVE_GUID)
-
- //SRN: End
-
- CORBA::String_var IOREngine;
- if(sco->ComponentIOR(IOREngine)){
- // we have found the associated engine to write the data
- MESSAGE ( "We have found an engine for data type :"<< componentDataType);
- CORBA::Object_var obj = _orb->string_to_object(IOREngine);
- SALOMEDS::Driver_var Engine = SALOMEDS::Driver::_narrow(obj) ;
-
- if(!CORBA::is_nil(Engine)){
- MESSAGE ( "Save the data of type:"<< componentDataType);
- MESSAGE("Engine :"<<Engine->ComponentDataType());
-
- SALOMEDS::TMPFile_var aStream;
-
- if(theASCII)
- aStream = Engine->SaveASCII(sco,SALOMEDS_Tool::GetDirFromPath(aUrl).c_str(),theMultiFile);
- else
- aStream = Engine->Save(sco,SALOMEDS_Tool::GetDirFromPath(aUrl).c_str(),theMultiFile);
-
- HDFdataset *hdf_dataset;
- hdf_size aHDFSize[1];
- if(aStream->length() > 0){ //The component saved some auxiliary files, then put them into HDF file
-
- aHDFSize[0] = aStream->length();
-
- HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group, HDF_STRING, aHDFSize, 1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk((unsigned char*) &aStream[0]); //Save the stream in the HDF file
- hdf_dataset->CloseOnDisk();
- }
- // store multifile state
- aHDFSize[0] = 2;
- hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk((void*)(theMultiFile?"M":"S")); // save: multi or single
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor
-
- // store ASCII state
- aHDFSize[0] = 2;
- hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk((void*)(theASCII?"A":"B")); // save: ASCII or BINARY
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor
-
- Translate_IOR_to_persistentID(aStudy,SB,sco,Engine,theMultiFile, theASCII);
- MESSAGE("After Translate_IOR_to_persistentID");
-
- // Creation of the persistance reference attribute
- }
- }
- hdf_sco_group->CloseOnDisk();
- hdf_sco_group=0; // will be deleted by hdf_group_datacomponent destructor
- }
- hdf_group_datacomponent->CloseOnDisk();
- hdf_group_datacomponent =0; // will be deleted by hdf_file destructor
-
-
- //-----------------------------------------------------------------------
- //3 - Write the Study Structure
- //-----------------------------------------------------------------------
- hdf_group_study_structure = new HDFgroup("STUDY_STRUCTURE",hdf_file);
- hdf_group_study_structure->CreateOnDisk();
-
- // save component attributes
- aComponentIter.Init();
- for(; aComponentIter.More(); aComponentIter.Next()){
- SALOMEDS::SComponent_var SC = aComponentIter.Value();
-
- CORBA::String_var scid = SC->GetID();
- hdf_sco_group2 = new HDFgroup(scid,hdf_group_study_structure);
- hdf_sco_group2->CreateOnDisk();
- SaveAttributes(SC, hdf_sco_group2);
- // ComponentDataType treatment
- CORBA::String_var component_name = SC->ComponentDataType();
- MESSAGE("Component data type " << component_name << " treated");
-
- name_len = (hdf_int32) strlen(component_name.in());
- size[0] = name_len +1 ;
- hdf_dataset = new HDFdataset("COMPONENTDATATYPE",hdf_sco_group2,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(const_cast<char*>(component_name.in()));
- MESSAGE("component name " << component_name << " wrote on file");
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- _SaveObject(aStudy, SC, hdf_sco_group2);
- hdf_sco_group2->CloseOnDisk();
- hdf_sco_group2=0; // will be deleted by hdf_group_study_structure destructor
- }
- //-----------------------------------------------------------------------
- //4 - Write the Study UseCases Structure
- //-----------------------------------------------------------------------
- SALOMEDS::SObject_var aSO = aStudy->FindObjectID(USE_CASE_LABEL_ID);
- if(!aSO->_is_nil()){
- HDFgroup *hdf_soo_group = new HDFgroup(USE_CASE_LABEL_ID,hdf_group_study_structure);
- hdf_soo_group->CreateOnDisk();
- SaveAttributes(aSO, hdf_soo_group);
- _SaveObject(aStudy, aSO, hdf_soo_group);
- MESSAGE("Use cases data structure writed");
- hdf_soo_group->CloseOnDisk();
- hdf_soo_group=0; // will be deleted by hdf_group_study_structure destructor
- }
-
- if (aLocked)
- aStudy->GetProperties()->SetLocked(true);
- //-----------------------------------------------------------------------
- //5 - Write the Study Properties
- //-----------------------------------------------------------------------
- name_len = (hdf_int32) strlen(aStudy->Name());
- size[0] = name_len +1 ;
- hdf_dataset = new HDFdataset("STUDY_NAME",hdf_group_study_structure,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- CORBA::String_var studid = aStudy->Name();
- hdf_dataset->WriteOnDisk(studid);
- MESSAGE("study name " << studid << " wrote on file");
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; // will be deleted by hdf_group_study_structure destructor
-
- _SaveProperties(aStudy, hdf_group_study_structure);
-
- hdf_group_study_structure->CloseOnDisk();
- hdf_file->CloseOnDisk();
-
- _name_service.Change_Directory("/Study");
- _name_service.Destroy_Name(anOldName);
- _name_service.Register(theStudy, aStudy->Name());
-
- aStudy->IsSaved(true);
- hdf_group_study_structure =0; // will be deleted by hdf_file destructor
- delete hdf_file; // recursively deletes all hdf objects...
- }catch(HDFexception){
- MESSAGE( "HDFexception ! " );
- }
- if(theASCII){ // save file in ASCII format
- HDFascii::ConvertFromHDFToASCII(aUrl, true);
- }
- }
+ SALOMEDS::Study_var aStudy = theObject->GetStudy();
+ Handle(SALOMEDSImpl_Study) aStudyImpl = _impl->GetStudyByID(aStudy->StudyId());
+ Handle(SALOMEDSImpl_SObject) anObject = aStudyImpl->GetSObject((char*)theObject->GetID());
+
+ SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
+ bool ret = _impl->CanCopy(anObject, aDriver);
+ delete aDriver;
+ return ret;
}
//============================================================================
-/*! Function : _SaveObject
+/*! Function : Copy
* Purpose :
*/
//============================================================================
-void SALOMEDS_StudyManager_i::_SaveObject(SALOMEDS_Study_i* theStudy,
- SALOMEDS::SObject_ptr theSObject,
- HDFgroup *hdf_group_datatype)
+CORBA::Boolean SALOMEDS_StudyManager_i::Copy(SALOMEDS::SObject_ptr theObject)
{
- // Write in group hdf_group_datatype all informations of SObject SC
- // Iterative function to parse all SObjects under a SComponent
- SALOMEDS::SObject_var RefSO;
- HDFgroup *hdf_group_sobject = 0;
-
- SALOMEDS_ChildIterator_i aChildIter = theStudy->GetChildIterator(theSObject);
- for(; aChildIter.More(); aChildIter.Next()){
- SALOMEDS::SObject_var aSObject = aChildIter.Value();
- SALOMEDS::ListOfAttributes_var anAllAttributes = aSObject->GetAllAttributes();
-
- // mpv: don't save empty labels
- if(anAllAttributes->length() == 0 && !aSObject->ReferencedObject(RefSO)){
- SALOMEDS_ChildIterator_i aSubChildIter = theStudy->GetChildIterator(theSObject);
- if(!aSubChildIter.More())
- continue;
-
- aSubChildIter.InitEx(true);
- bool anEmpty = true;
- for(; aSubChildIter.More() && anEmpty; aSubChildIter.Next()){
- SALOMEDS::SObject_var aSObj = aSubChildIter.Value();
- SALOMEDS::ListOfAttributes_var anAllAttr = aSObj->GetAllAttributes();
- if(anAllAttr->length() != 0 || aSObj->ReferencedObject(RefSO))
- anEmpty = false;
- }
- if(anEmpty)
- continue;
- }
+ SALOMEDS::Locker lock;
- CORBA::String_var scoid(aSObject->GetID());
- hdf_group_sobject = new HDFgroup(scoid,hdf_group_datatype);
- hdf_group_sobject->CreateOnDisk();
- SaveAttributes(aSObject, hdf_group_sobject);
- _SaveObject(theStudy,aSObject, hdf_group_sobject);
- hdf_group_sobject->CloseOnDisk();
- hdf_group_sobject =0; // will be deleted by father hdf object destructor
- }
+ SALOMEDS::Study_var aStudy = theObject->GetStudy();
+ Handle(SALOMEDSImpl_Study) aStudyImpl = _impl->GetStudyByID(aStudy->StudyId());
+ Handle(SALOMEDSImpl_SObject) anObject = aStudyImpl->GetSObject((char*)theObject->GetID());
+
+ SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
+ bool ret = _impl->Copy(anObject, aDriver);
+ delete aDriver;
+ return ret;
}
//============================================================================
-/*! Function : _SubstituteSlash
+/*! Function : CanPaste
* Purpose :
*/
//============================================================================
-
-std::string SALOMEDS_StudyManager_i::_SubstituteSlash(const char *theUrl)
+CORBA::Boolean SALOMEDS_StudyManager_i::CanPaste(SALOMEDS::SObject_ptr theObject)
{
- ASSERT(1==0);
- TCollection_ExtendedString aUrl(const_cast<char*>(theUrl));
- aUrl.ChangeAll(ToExtCharacter('/'),ToExtCharacter(':'));
- TCollection_AsciiString ch(aUrl);
- return ch.ToCString();
-}
-
-//============================================================================
-/*! Function : CanCopy
- * Purpose :
- */
-//============================================================================
-CORBA::Boolean SALOMEDS_StudyManager_i::CanCopy(SALOMEDS::SObject_ptr theObject) {
- SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent();
-
- if(aComponent->_is_nil())
- return false;
+ SALOMEDS::Locker lock;
- if(aComponent == theObject)
- return false;
+ SALOMEDS::Study_var aStudy = theObject->GetStudy();
+ Handle(SALOMEDSImpl_Study) aStudyImpl = _impl->GetStudyByID(aStudy->StudyId());
+ Handle(SALOMEDSImpl_SObject) anObject = aStudyImpl->GetSObject((char*)theObject->GetID());
- CORBA::String_var IOREngine;
- if(!aComponent->ComponentIOR(IOREngine))
- return false;
-
- CORBA::Object_var obj = _orb->string_to_object(IOREngine);
- SALOMEDS::Driver_var Engine = SALOMEDS::Driver::_narrow(obj) ;
- if (CORBA::is_nil(Engine))
- return false;
-
- return Engine->CanCopy(theObject);
+ SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
+ bool ret = _impl->CanPaste(anObject, aDriver);
+ delete aDriver;
+ return ret;
}
//============================================================================
-/*! Function : CopyLabel
- * Purpose :
+/*! Function : Paste
+ * Purpose :
*/
//============================================================================
-void SALOMEDS_StudyManager_i::CopyLabel(SALOMEDS_Study_i* theSourceStudy,
- const SALOMEDS::Driver_ptr theEngine,
- const Standard_Integer theSourceStartDepth,
- const TDF_Label& theSource,
- const TDF_Label& theDestinationMain)
+SALOMEDS::SObject_ptr SALOMEDS_StudyManager_i::Paste(SALOMEDS::SObject_ptr theObject)
+ throw(SALOMEDS::StudyBuilder::LockProtection)
{
- int a;
- TDF_Label aTargetLabel = theDestinationMain;
- TDF_Label aAuxTargetLabel = theDestinationMain.Father().FindChild(2);
- for(a = theSource.Depth() - theSourceStartDepth; a > 0 ; a--) {
- TDF_Label aSourceLabel = theSource;
- for(int aNbFather = 1; aNbFather < a; aNbFather++) aSourceLabel = aSourceLabel.Father();
- aTargetLabel = aTargetLabel.FindChild(aSourceLabel.Tag());
- aAuxTargetLabel = aAuxTargetLabel.FindChild(aSourceLabel.Tag());
- }
- // iterate attributes
- TDF_AttributeIterator anAttrIterator(theSource);
- Handle(TDF_RelocationTable) aRT = new TDF_RelocationTable();
- for(; anAttrIterator.More(); anAttrIterator.Next()) {
- Handle(TDF_Attribute) anAttr = anAttrIterator.Value();
- if (!Handle(TDataStd_TreeNode)::DownCast(anAttr).IsNull()) continue; // never copy tree node attribute
- if (!Handle(SALOMEDS_TargetAttribute)::DownCast(anAttr).IsNull()) continue; // and target attribute
-
- if (!Handle(TDF_Reference)::DownCast(anAttr).IsNull()) { // reference copied as Comment in auxiliary tree
- TDF_Label aReferenced = Handle(TDF_Reference)::DownCast(anAttr)->Get();
- TCollection_AsciiString anEntry;
- TDF_Tool::Entry(aReferenced, anEntry);
- // store the value of name attribute of referenced label
- Handle(TDataStd_Name) aNameAttribute;
- if (aReferenced.FindAttribute(TDataStd_Name::GetID(), aNameAttribute)) {
- anEntry += " ";
- anEntry += aNameAttribute->Get();
- }
- TDataStd_Comment::Set(aAuxTargetLabel, TCollection_ExtendedString(anEntry));
- continue;
- }
-
- if (!Handle(SALOMEDS_IORAttribute)::DownCast(anAttr).IsNull()) { // IOR => ID and TMPFile of Engine
- TCollection_AsciiString anEntry;
- TDF_Tool::Entry(theSource, anEntry);
- SALOMEDS::SObject_var aSO = theSourceStudy->FindObjectID(anEntry.ToCString());
- CORBA::Long anObjID;
- SALOMEDS::TMPFile_var aStream = theEngine->CopyFrom(aSO, anObjID);
- int aLen = aStream->length();
- TCollection_ExtendedString aResStr("");
- for(a = 0; a < aLen; a++) {
- aResStr += TCollection_ExtendedString(ToExtCharacter((Standard_Character)aStream[a]));
- }
- TDataStd_Integer::Set(aAuxTargetLabel, anObjID);
- TDataStd_Name::Set(aAuxTargetLabel, aResStr);
- continue;
- }
- Handle(TDF_Attribute) aNewAttribute = anAttr->NewEmpty();
- aTargetLabel.AddAttribute(aNewAttribute);
- anAttr->Paste(aNewAttribute, aRT);
-// aRT->SetRelocation(anAttr, aNewAttribute);
- }
-}
+ SALOMEDS::Locker lock;
-//============================================================================
-/*! Function : Copy
- * Purpose :
- */
-//============================================================================
-CORBA::Boolean SALOMEDS_StudyManager_i::Copy(SALOMEDS::SObject_ptr theObject) {
- // adoptation for alliances datamodel copy: without IOR attributes !!!
- // copy only SObjects and attributes without component help
- SALOMEDS::GenericAttribute_var anAttribute;
- bool aStructureOnly = !theObject->FindAttribute(anAttribute, "AttributeIOR");
-
- PortableServer::ServantBase_var aServant = GetServant(theObject,_poa);
- SALOMEDS_SObject_i* aSObject = dynamic_cast<SALOMEDS_SObject_i*>(aServant.in());
- if(aSObject == NULL)
- return false;
-
- SALOMEDS_Study_i* aStudy = aSObject->GetStudyServant();
- SALOMEDS::Driver_var anEngine;
- CORBA::String_var aString;
- if (!aStructureOnly) {
- SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent();
- if(!aComponent->ComponentIOR(aString))
- return false;
-
- CORBA::Object_var anObj = _orb->string_to_object(aString);
- anEngine = SALOMEDS::Driver::_narrow(anObj) ;
- }
+ Unexpect aCatch(LockProtection);
+ SALOMEDS::Study_var aStudy = theObject->GetStudy();
- // CAF document of current study usage
- Handle(TDocStd_Document) aDocument = aStudy->GetDocument();
- if(aDocument.IsNull())
- return false;
-
- // create new document for clipboard
- Handle(TDocStd_Document) aTargetDocument;
- _OCAFApp->NewDocument("SALOME_STUDY", aTargetDocument);
- // set component data type to the name attribute of root label
- if(!aStructureOnly){
- aString = anEngine->ComponentDataType();
- TDataStd_Comment::Set(aTargetDocument->Main().Root(),const_cast<char*>(aString.in()));
- }
- // set to the Root label integer attribute: study id
- TDataStd_Integer::Set(aTargetDocument->Main().Root(),aStudy->StudyId());
-
- // iterate all theObject's label children
- TDF_Label aStartLabel;
- aString = theObject->GetID();
- TDF_Tool::Label(aDocument->GetData(),const_cast<char*>(aString.in()),aStartLabel);
- Standard_Integer aSourceStartDepth = aStartLabel.Depth();
+ Handle(SALOMEDSImpl_Study) aStudyImpl = _impl->GetStudyByID(aStudy->StudyId());
+ Handle(SALOMEDSImpl_SObject) anObject = aStudyImpl->GetSObject((char*)theObject->GetID());
+ Handle(SALOMEDSImpl_SObject) aNewSO;
- // copy main source label
- CopyLabel(aStudy,anEngine,aSourceStartDepth,aStartLabel,aTargetDocument->Main());
-
- // copy all subchildren of the main source label (all levels)
- TDF_ChildIterator anIterator(aStartLabel,Standard_True);
- for(; anIterator.More(); anIterator.Next()){
- CopyLabel(aStudy,anEngine,aSourceStartDepth,anIterator.Value(),aTargetDocument->Main());
+ try {
+ SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
+ aNewSO = _impl->Paste(anObject, aDriver);
+ delete aDriver;
}
-
- // done: free old clipboard document and
- if (!_clipboard.IsNull()) {
-// Handle(TDocStd_Owner) anOwner;
-// if (_clipboard->Main().Root().FindAttribute(TDocStd_Owner::GetID(), anOwner)) {
-// Handle(TDocStd_Document) anEmptyDoc;
-// anOwner->SetDocument(anEmptyDoc);
-// }
- _OCAFApp->Close(_clipboard);
+ catch (...) {
+ throw SALOMEDS::StudyBuilder::LockProtection();
}
- _clipboard = aTargetDocument;
-
- return true;
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aNewSO, _orb);
+ return so._retn();
}
-//============================================================================
-/*! Function : CanPaste
- * Purpose :
- */
-//============================================================================
-CORBA::Boolean SALOMEDS_StudyManager_i::CanPaste(SALOMEDS::SObject_ptr theObject) {
- if (_clipboard.IsNull()) return false;
-
- Handle(TDataStd_Comment) aCompName;
- if (!_clipboard->Main().Root().FindAttribute(TDataStd_Comment::GetID(), aCompName)) return false;
- Handle(TDataStd_Integer) anObjID;
- if (!_clipboard->Main().Father().FindChild(2).FindAttribute(TDataStd_Integer::GetID(), anObjID))
- return false;
-
- SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent();
- if(aComponent->_is_nil())
- return false;
-
- CORBA::String_var IOREngine;
- if(!aComponent->ComponentIOR(IOREngine))
- return false;
-
- CORBA::Object_var obj = _orb->string_to_object(IOREngine);
- SALOMEDS::Driver_var Engine = SALOMEDS::Driver::_narrow(obj) ;
- if (CORBA::is_nil(Engine))
- return false;
- return Engine->CanPaste(TCollection_AsciiString(aCompName->Get()).ToCString(),anObjID->Get());
-}
-//============================================================================
-/*! Function : PasteLabel
- * Purpose :
- */
-//============================================================================
-TDF_Label SALOMEDS_StudyManager_i::PasteLabel(SALOMEDS_Study_i* theDestinationStudy,
- const SALOMEDS::Driver_ptr theEngine,
- const TDF_Label& theSource,
- const TDF_Label& theDestinationStart,
- const int theCopiedStudyID,
- const bool isFirstElement)
-{
- // get corresponding source, target and auxiliary labels
- TDF_Label aTargetLabel = theDestinationStart;
- TDF_Label aAuxSourceLabel = theSource.Root().FindChild(2);
- int a;
- if (!isFirstElement) {
- for(a = theSource.Depth() - 1; a > 0 ; a--) {
- TDF_Label aSourceLabel = theSource;
- for(int aNbFather = 1; aNbFather < a; aNbFather++)
- aSourceLabel = aSourceLabel.Father();
- aTargetLabel = aTargetLabel.FindChild(aSourceLabel.Tag());
- aAuxSourceLabel = aAuxSourceLabel.FindChild(aSourceLabel.Tag());
- }
- }
-
- // check auxiliary label for TMPFile => IOR
- Handle(TDataStd_Name) aNameAttribute;
- if (aAuxSourceLabel.FindAttribute(TDataStd_Name::GetID(), aNameAttribute)) {
- Handle(TDataStd_Integer) anObjID;
-
- aAuxSourceLabel.FindAttribute(TDataStd_Integer::GetID(), anObjID);
- Handle(TDataStd_Comment) aComponentName;
- theSource.Root().FindAttribute(TDataStd_Comment::GetID(), aComponentName);
- std::string aCompName = TCollection_AsciiString(aComponentName->Get()).ToCString();
- if (theEngine->CanPaste(aCompName.c_str(),anObjID->Get())) {
- SALOMEDS::TMPFile_var aTMPFil = new SALOMEDS::TMPFile();
- TCollection_ExtendedString aTMPStr = aNameAttribute->Get();
- int aLen = aTMPStr.Length();
- aTMPFil->length(aLen);
- for(a = 0; a < aLen; a++) {
- aTMPFil[a] = ToCharacter(aTMPStr.Value(a+1));
- }
- TCollection_AsciiString anEntry;
- TDF_Tool::Entry(aTargetLabel, anEntry);
- SALOMEDS::SObject_var aPastedSO = theDestinationStudy->FindObjectID(anEntry.ToCString());
- if(isFirstElement){
- SALOMEDS::SObject_var aDestSO =
- theEngine->PasteInto(aTMPFil.in(),
- anObjID->Get(),
- aPastedSO->GetFatherComponent());
- TDF_Tool::Label(theDestinationStart.Data(), aDestSO->GetID(), aTargetLabel);
- }else
- theEngine->PasteInto(aTMPFil.in(),anObjID->Get(),aPastedSO);
- }
- }
-
- // iterate attributes
- TDF_AttributeIterator anAttrIterator(theSource);
- Handle(TDF_RelocationTable) aRT = new TDF_RelocationTable();
- for(; anAttrIterator.More(); anAttrIterator.Next()) {
- Handle(TDF_Attribute) anAttr = anAttrIterator.Value();
- if (aTargetLabel.FindAttribute(anAttr->ID(), anAttr)) {
- aTargetLabel.ForgetAttribute(anAttr->ID());
- anAttr = anAttrIterator.Value();
- }
- Handle(TDF_Attribute) aNewAttribute = anAttr->NewEmpty();
- aTargetLabel.AddAttribute(aNewAttribute);
- anAttr->Paste(aNewAttribute, aRT);
-// aRT->SetRelocation(anAttr, aNewAttribute);
- }
- // check auxiliary label for Comment => reference or name attribute of the referenced object
- Handle(TDataStd_Comment) aCommentAttribute;
- if (aAuxSourceLabel.FindAttribute(TDataStd_Comment::GetID(), aCommentAttribute)) {
- std::string anEntry(TCollection_AsciiString(aCommentAttribute->Get()).ToCString());
- std::size_t aNameStart = anEntry.find(' ');
- std::string aName;
- if(aNameStart != std::string::npos){
- aName = anEntry.substr(aNameStart+1);
- anEntry = anEntry.substr(0,aNameStart);
- }
- if (theCopiedStudyID == theDestinationStudy->StudyId()) { // if copy to the same study, reanimate reference
- TDF_Label aRefLabel;
- TDF_Tool::Label(aTargetLabel.Data(),&anEntry[0],aRefLabel);
- TDF_Reference::Set(aTargetLabel, aRefLabel);
- SALOMEDS_TargetAttribute::Set(aRefLabel)->Append(aTargetLabel); // target attributes structure support
- } else {
- if(aNameStart != std::string::npos)
- TDataStd_Name::Set(aTargetLabel, &aName[0]);
- else
- TDataStd_Name::Set(aTargetLabel,
- TCollection_ExtendedString("Reference to:") + &anEntry[0]);
+SALOMEDS_Driver_i* GetDriver(const Handle(SALOMEDSImpl_SObject)& theObject, CORBA::ORB_ptr orb)
+{
+ SALOMEDS_Driver_i* driver = NULL;
+
+ Handle(SALOMEDSImpl_SComponent) aSCO = theObject->GetFatherComponent();
+ if(!aSCO.IsNull()) {
+ TCollection_AsciiString IOREngine = aSCO->GetIOR();
+ if(!IOREngine.IsEmpty()) {
+ CORBA::Object_var obj = orb->string_to_object(IOREngine.ToCString());
+ SALOMEDS::Driver_var Engine = SALOMEDS::Driver::_narrow(obj) ;
+ driver = new SALOMEDS_Driver_i(Engine, orb);
}
- }
+ }
- return aTargetLabel;
+ return driver;
}
-//============================================================================
-/*! Function : Paste
- * Purpose :
- */
-//============================================================================
-SALOMEDS::SObject_ptr SALOMEDS_StudyManager_i::Paste(SALOMEDS::SObject_ptr theObject)
- throw(SALOMEDS::StudyBuilder::LockProtection)
-{
- Unexpect aCatch(LockProtection);
-
- PortableServer::ServantBase_var aServant = GetServant(theObject,_poa);
- SALOMEDS_SObject_i* aSObject = dynamic_cast<SALOMEDS_SObject_i*>(aServant.in());
- if(aSObject == NULL)
- return false;
- SALOMEDS_Study_i* aStudy = aSObject->GetStudyServant();
+PortableServer::POA_ptr SALOMEDS_StudyManager_i::GetPOA(const SALOMEDS::Study_ptr theStudy) {
+ if (_mapOfPOA.find(theStudy->StudyId()) != _mapOfPOA.end()) return _mapOfPOA[theStudy->StudyId()];
+ return PortableServer::POA::_nil();
+}
- // if study is locked, then paste can't be done
- if (aStudy->GetProperties()->IsLocked())
- throw SALOMEDS::StudyBuilder::LockProtection();
+//===========================================================================
+// PRIVATE FUNCTIONS
+//===========================================================================
+long SALOMEDS_StudyManager_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
+{
+#ifdef WIN32
+ long pid = (long)_getpid();
+#else
+ long pid = (long)getpid();
+#endif
+ isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0;
+ SALOMEDSImpl_StudyManager* aManager = _impl.operator->();
+ return ((long)aManager);
+}
- // if there is no component name, then paste only SObjects and attributes: without component help
- Handle(TDataStd_Comment) aComponentName;
- bool aStructureOnly = !_clipboard->Main().Root().FindAttribute(TDataStd_Comment::GetID(), aComponentName);
-
- // get copied study ID
- Handle(TDataStd_Integer) aStudyIDAttribute;
- if (!_clipboard->Main().Root().FindAttribute(TDataStd_Integer::GetID(), aStudyIDAttribute))
- return SALOMEDS::SObject::_nil();
-
- // get component-engine
- SALOMEDS::SComponent_var aComponent;
- SALOMEDS::Driver_var anEngine;
- CORBA::String_var aString;
- if (!aStructureOnly) {
- aComponent = theObject->GetFatherComponent();
- if(!aComponent->ComponentIOR(aString))
- return SALOMEDS::SObject::_nil();
-
- CORBA::Object_var anObj = _orb->string_to_object(aString);
- anEngine = SALOMEDS::Driver::_narrow(anObj) ;
+//===========================================================================
+namespace SALOMEDS
+{
+/*
+ CORBA::Object_var
+ GetObject(const TDF_Label& theLabel, CORBA::ORB_ptr theORB)
+ {
+ try {
+ Handle(SALOMEDS_IORAttribute) anAttr;
+ if(theLabel.FindAttribute(SALOMEDS_IORAttribute::GetID(),anAttr))
+ return theORB->string_to_object(TCollection_AsciiString(anAttr->Get()).ToCString());
+ }catch(...){
+ }
+ return CORBA::Object::_nil();
}
+*/
- // CAF document of current study usage
- Handle(TDocStd_Document) aDocument = aStudy->GetDocument();
- if (aDocument.IsNull())
- return SALOMEDS::SObject::_nil();
-
- // fill root inserted SObject
- int aCStudyID = aStudyIDAttribute->Get();
- TDF_Label aLabel = aStructureOnly? aSObject->GetLabel(): aSObject->GetFatherComponentLabel();
- TDF_Label aStartLabel = PasteLabel(aStudy,anEngine,_clipboard->Main(),aLabel,aCStudyID,true);
-
- // paste all sublebels
- TDF_ChildIterator anIterator(_clipboard->Main(),Standard_True);
- for(; anIterator.More(); anIterator.Next()) {
- PasteLabel(aStudy,anEngine,anIterator.Value(),aStartLabel,aCStudyID,false);
+ PortableServer::ServantBase_var
+ GetServant(CORBA::Object_ptr theObject, PortableServer::POA_ptr thePOA)
+ {
+ if(CORBA::is_nil(theObject))
+ return NULL;
+ try{
+ return thePOA->reference_to_servant(theObject);
+ }catch(...){
+ return NULL;
+ }
}
- return SALOMEDS_SObject_i::NewRef(aStudy,aStartLabel)._retn();
}
+
+//===========================================================================
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_StudyManager_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#ifndef __SALOMEDS_STUDYMANAGER_I_H__
#define __SALOMEDS_STUDYMANAGER_I_H__
// std C++ headers
#include <iostream.h>
-#include <stdlib.h>
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS)
-// Cascade headers
-#include <TDocStd_Document.hxx>
-#include <TDF_Attribute.hxx>
-#include <TDataStd_Name.hxx>
-#include <TDF_Label.hxx>
-#include <TDocStd_Document.hxx>
-#include <Standard_NotImplemented.hxx>
-
-#include "SALOMEDS_OCAFApplication.hxx"
+// Naming Service header
#include "SALOME_NamingService.hxx"
-// HDF
-#include "HDFOI.hxx"
+#include <iostream.h>
+#include <stdlib.h>
-class SALOMEDS_Study_i;
+//Standard not implemented
+#include <Standard_NotImplemented.hxx>
+#include "SALOMEDS_Driver_i.hxx"
+#include "SALOMEDSImpl_StudyManager.hxx"
namespace SALOMEDS{
// To convert IOR from SALOMEDS_IORAttribute to CORBA::Object
- CORBA::Object_var
- GetObject(const TDF_Label&, CORBA::ORB_ptr);
-
- // To convert CORBA::Object to PortableServer::ServantBase
- PortableServer::ServantBase_var
- GetServant(CORBA::Object_ptr, PortableServer::POA_ptr);
-
-}
+ /* CORBA::Object_var GetObject(const TDF_Label&, CORBA::ORB_ptr); */
+ // To convert CORBA::Object to PortableServer::ServantBase
+ PortableServer::ServantBase_var GetServant(CORBA::Object_ptr, PortableServer::POA_ptr);
-class SALOMEDS_StudyManager_i:
- public virtual POA_SALOMEDS::StudyManager,
- public virtual PortableServer::RefCountServantBase
-{
- SALOMEDS_StudyManager_i(); // Not implemented
- void operator=(const SALOMEDS_StudyManager_i&); // Not implemented
+}
+class SALOMEDS_StudyManager_i: public POA_SALOMEDS::StudyManager,
+ public PortableServer::RefCountServantBase {
private:
- CORBA::ORB_var _orb;
- PortableServer::POA_var _poa;
- SALOME_NamingService _name_service;
- Handle (SALOMEDS_OCAFApplication) _OCAFApp;
- Handle(TDocStd_Document) _clipboard;
- int _IDcounter;
-
- // _SaveAs private function called by Save and SaveAs
- virtual void _SaveAs(const char* aUrl,
- SALOMEDS::Study_ptr aStudy,
- CORBA::Boolean theMultiFile,
- CORBA::Boolean theASCII);
- // _SaveObject private function called by _SaveAs
- void _SaveObject(SALOMEDS_Study_i* theStudy,
- SALOMEDS::SObject_ptr SC,
- HDFgroup *hdf_group_datatype);
- // _SubstituteSlash function called by Open and GetStudyByName
- virtual std::string _SubstituteSlash(const char *aUrl);
-
- void _SaveProperties(SALOMEDS_Study_i* theStudy, HDFgroup *hdf_group);
+
+ CORBA::ORB_ptr _orb;
+ PortableServer::POA_var _poa;
+ Handle(SALOMEDSImpl_StudyManager) _impl;
+ SALOME_NamingService* _name_service;
+ SALOMEDS_DriverFactory_i* _factory;
public:
+
//! standard constructor
- SALOMEDS_StudyManager_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA);
+ SALOMEDS_StudyManager_i(CORBA::ORB_ptr orb, PortableServer::POA_ptr thePOA);
//! standard destructor
virtual ~SALOMEDS_StudyManager_i();
- CORBA::ORB_var GetORB() const { return _orb; }
-
- PortableServer::POA_var GetPOA() const { return _poa; }
-
- SALOMEDS_Study_i* DownCast(SALOMEDS::Study_ptr theStudy) const;
-
//! method to Register study Manager in the naming service
/*!
\param char* arguments, the context to register the study manager in the NS
\return Study_ptr arguments
*/
virtual SALOMEDS::Study_ptr GetStudyByID(CORBA::Short aStudyID) ;
-
- void CopyLabel(SALOMEDS_Study_i* theSourceStudy,
- const SALOMEDS::Driver_ptr theEngine,
- const Standard_Integer theSourceStartDepth,
- const TDF_Label& theSource,
- const TDF_Label& theDestinationMain);
-
- TDF_Label PasteLabel(SALOMEDS_Study_i* theDestinationStudy,
- const SALOMEDS::Driver_ptr theEngine,
- const TDF_Label& theSource,
- const TDF_Label& theDestinationStart,
- const int theCopiedStudyID,
- const bool isFirstElement);
virtual CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
virtual CORBA::Boolean Copy(SALOMEDS::SObject_ptr theObject);
virtual CORBA::Boolean CanPaste(SALOMEDS::SObject_ptr theObject);
virtual SALOMEDS::SObject_ptr Paste(SALOMEDS::SObject_ptr theObject) throw(SALOMEDS::StudyBuilder::LockProtection);
+
+ virtual char* ConvertObjectToIOR(CORBA::Object_ptr theObject) {return _orb->object_to_string(theObject); }
+ virtual CORBA::Object_ptr ConvertIORToObject(const char* theIOR) { return _orb->string_to_object(theIOR); };
void ping(){};
+
+ virtual long GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal);
+
+ static PortableServer::POA_ptr GetPOA(const SALOMEDS::Study_ptr theStudy);
};
#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_Study_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
-
-#include <TDataStd_ChildNodeIterator.hxx>
-#include <TDocStd_Application.hxx>
-#include <TDocStd_Owner.hxx>
-#include <CDM_Document.hxx>
-#include <CDM_Application.hxx>
-#include <TDF_ChildIDIterator.hxx>
-
-#include <TColStd_SequenceOfExtendedString.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TCollection_AsciiString.hxx>
-
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-#include <TColStd_ListOfInteger.hxx>
+using namespace std;
+#include "utilities.h"
#include "SALOMEDS_Study_i.hxx"
-
-#include "SALOMEDS_StudyManager_i.hxx"
-#include "SALOMEDS_Callback_i.hxx"
-
-#include "SALOMEDS_SComponent_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
-
-#include "SALOMEDS_StudyBuilder_i.hxx"
+#include "SALOMEDS_UseCaseIterator_i.hxx"
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDS_AttributeStudyProperties_i.hxx"
#include "SALOMEDS_ChildIterator_i.hxx"
+#include "SALOMEDS_Driver_i.hxx"
+#include "SALOMEDS.hxx"
-#include "SALOMEDS_UseCaseBuilder_i.hxx"
-#include "SALOMEDS_SComponentIterator_i.hxx"
-
-#include "SALOME_GenericObj_i.hh"
-#include "SALOMEDS_LocalIDAttribute.hxx"
-#include "SALOMEDS_PersRefAttribute.hxx"
+#include "SALOMEDSImpl_SObject.hxx"
+#include "SALOMEDSImpl_SComponent.hxx"
+#include "SALOMEDSImpl_UseCaseBuilder.hxx"
+#include "SALOMEDSImpl_AttributeStudyProperties.hxx"
+#include "SALOMEDSImpl_ChildIterator.hxx"
-#include "SALOMEDS_StudyPropertiesAttribute.hxx"
-#include "SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx"
+#include <TColStd_SequenceOfExtendedString.hxx>
+#include <TColStd_HSequenceOfAsciiString.hxx>
+#include <TColStd_HSequenceOfTransient.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
-#include "utilities.h"
+#include <TDF_Label.hxx>
+#include <TDF_Attribute.hxx>
-#define DIRECTORYID 16661
-#define FILEID "FILE: "
-#define FILELOCALID 26662
+#ifdef WIN32
+#include <process.h>
+#else
+#include <sys/types.h>
+#include <unistd.h>
+#endif
-using namespace std;
+#include "OpUtil.hxx"
-bool operator<(const TDF_Label& theLeft, const TDF_Label& theRight)
-{
- TColStd_ListOfInteger aTagLeftList;
- TDF_Tool::TagList(theLeft,aTagLeftList);
- TColStd_ListIteratorOfListOfInteger anLeftIter(aTagLeftList);
-
- TColStd_ListOfInteger aTagRightList;
- TDF_Tool::TagList(theRight,aTagRightList);
- TColStd_ListIteratorOfListOfInteger anRightIter(aTagRightList);
-
- for(;;){
- Standard_Boolean aLeftMore = anLeftIter.More();
- Standard_Boolean aRightMore = anRightIter.More();
-
- if(!aLeftMore && !aRightMore)
- return Standard_False;
-
- if(!aLeftMore)
- return Standard_True;
-
- if(!aRightMore)
- return Standard_False;
-
- Standard_Integer aLeftTag = anLeftIter.Value();
- anLeftIter.Next();
-
- Standard_Integer aRightTag = anRightIter.Value();
- anRightIter.Next();
-
- if(aLeftTag == aRightTag)
- continue;
-
- return aLeftTag < aRightTag;
- }
-
- return Standard_False;
-}
-
-
//============================================================================
/*! Function : SALOMEDS_Study_i
* Purpose : SALOMEDS_Study_i constructor
*/
//============================================================================
-SALOMEDS_Study_i::SALOMEDS_Study_i(SALOMEDS_StudyManager_i* theStudyManager,
- const Handle(TDocStd_Document)& theDoc,
- const char* theStudyName):
- _StudyManager(theStudyManager),
- _doc(theDoc),
- _isSaved(false),
- _URL(NULL),
- _StudyId(-1),
- _autoFill(true),
- myNbUndos(0)
+SALOMEDS_Study_i::SALOMEDS_Study_i(const Handle(SALOMEDSImpl_Study) theImpl,
+ CORBA::ORB_ptr orb)
{
- _UseCaseBuilder = new SALOMEDS_UseCaseBuilder_i(this,_doc);
- SALOMEDS::UseCaseBuilder_var aUseCaseBuilder = _UseCaseBuilder->_this();
-
- _Builder = new SALOMEDS_StudyBuilder_i(this,_doc);
- SALOMEDS::StudyBuilder_var aStudyBuilder = _Builder->_this();
-
- SALOMEDS_Callback_i* aCallBackServant = new SALOMEDS_Callback_i(aUseCaseBuilder);
- _callbackOnAdd = aCallBackServant->_this();
- _callbackOnRemove = _callbackOnAdd;
+ _orb = CORBA::ORB::_duplicate(orb);
+ _impl = theImpl;
- _name = new char[strlen(theStudyName) +1];
- strcpy(_name,theStudyName);
- myNbPostponed.Append(0);
+ _builder = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb);
}
//============================================================================
//============================================================================
SALOMEDS_Study_i::~SALOMEDS_Study_i()
{
- delete [] _name ;
- delete [] _URL ;
}
-//============================================================================
-CORBA::ORB_var SALOMEDS_Study_i::GetORB() const
-{
- return _StudyManager->GetORB();
-}
-
-//============================================================================
-PortableServer::POA_var SALOMEDS_Study_i::GetPOA() const
-{
- return _StudyManager->GetPOA();
-}
-
-
-SALOMEDS_SObject_i*
-SALOMEDS_Study_i::DownCast(SALOMEDS::SObject_ptr theSObject) const
-{
- if(!CORBA::is_nil(theSObject)){
- PortableServer::POA_var aPOA = GetPOA();
- PortableServer::ServantBase_var aServant = SALOMEDS::GetServant(theSObject,aPOA);
- if(aServant.in())
- return dynamic_cast<SALOMEDS_SObject_i*>(aServant.in());
- }
- return NULL;
-}
-
-//============================================================================
-/*! Function : SetOnAddSObject
- * Purpose :
- */
-//============================================================================
-SALOMEDS::Callback_ptr SALOMEDS_Study_i::SetOnAddSObject(SALOMEDS::Callback_ptr theCallback)
-{
- SALOMEDS::Callback_var aRet = _callbackOnAdd;
- _callbackOnAdd = SALOMEDS::Callback::_duplicate(theCallback);
- return aRet._retn();
-}
-
-//============================================================================
-/*! Function : SetOnNewSObject
- * Purpose :
- */
-//============================================================================
-SALOMEDS::Callback_ptr SALOMEDS_Study_i::SetOnRemoveSObject(SALOMEDS::Callback_ptr theCallback)
-{
- SALOMEDS::Callback_var aRet = _callbackOnRemove;
- _callbackOnAdd = SALOMEDS::Callback::_duplicate(theCallback);
- return aRet._retn();
-}
-
-//============================================================================
-void SALOMEDS_Study_i::OnAddSObject(SALOMEDS::SObject_ptr theObject)
-{
- if(!CORBA::is_nil(_callbackOnAdd.in()))
- _callbackOnAdd->OnAddSObject(theObject);
-}
-
-//============================================================================
-void SALOMEDS_Study_i::OnRemoveSObject(SALOMEDS::SObject_ptr theObject)
-{
- if(!CORBA::is_nil(_callbackOnRemove.in()))
- _callbackOnRemove->OnRemoveSObject(theObject);
-}
-
-//============================================================================
-void SALOMEDS_Study_i::CheckLocked()
-{
- if(_doc->HasOpenCommand())
- return;
-
- Handle(SALOMEDS_StudyPropertiesAttribute) anAttr;
- if(_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(),anAttr))
- if(anAttr->IsLocked())
- throw SALOMEDS::StudyBuilder::LockProtection();
-}
-
-
-//============================================================================
-char* SALOMEDS_Study_i::ConvertObjectToIOR(CORBA::Object_ptr theObject)
-{
- return GetORB()->object_to_string(theObject);
-}
-
-
-//============================================================================
-CORBA::Object_ptr SALOMEDS_Study_i::ConvertIORToObject(const char* theIOR)
-{
- return GetORB()->string_to_object(theIOR);
-}
-
-
//============================================================================
/*! Function : GetPersistentReference
* Purpose : Get persistent reference of study (idem URL())
//============================================================================
char* SALOMEDS_Study_i::GetPersistentReference()
{
- return URL();
+ SALOMEDS::Locker lock;
+ return CORBA::string_dup(_impl->GetPersistentReference().ToCString());
}
//============================================================================
/*! Function : GetTransientReference
//============================================================================
char* SALOMEDS_Study_i::GetTransientReference()
{
- CORBA::String_var IOR;
-
- Handle(SALOMEDS_IORAttribute) Att;
- TDF_Label _lab = _doc->GetData()->Root();
- if (!_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(),Att)){
-
- TCollection_AsciiString ch(Att->Get());
- IOR = CORBA::string_dup(ch.ToCString());
- }
- else IOR = CORBA::string_dup(""); // NULL ?
-
- return CORBA::string_dup(IOR);
+ SALOMEDS::Locker lock;
+ return CORBA::string_dup(_impl->GetTransientReference().ToCString());
}
//============================================================================
//============================================================================
CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
{
- if (_doc.IsNull()) return true;
- return _doc->IsEmpty();
+ SALOMEDS::Locker lock;
+ return _impl->IsEmpty();
}
//============================================================================
* Purpose : Find a Component with ComponentDataType = aComponentName
*/
//============================================================================
-SALOMEDS::SComponent_ptr
-SALOMEDS_Study_i::FindComponent(const char* theComponentName)
+SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
{
- bool anIsFound = false;
- SALOMEDS::SComponent_var aSComponent;
- SALOMEDS_SComponentIterator_i aComponentIter(this,_doc);
- for(; aComponentIter.More() && !anIsFound; aComponentIter.Next()){
- SALOMEDS::SComponent_var aSComp = aComponentIter.Value();
- CORBA::String_var aName = aSComp->ComponentDataType();
- if(strcmp(theComponentName,aName.in()) == 0){
- aSComponent = aSComp;
- anIsFound = true;
- }
- }
- return aSComponent._retn();
+ SALOMEDS::Locker lock;
+
+ Handle(SALOMEDSImpl_SComponent) aCompImpl = _impl->FindComponent(TCollection_AsciiString((char*)aComponentName));
+ if(aCompImpl.IsNull()) return SALOMEDS::SComponent::_nil();
+
+ SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aCompImpl, _orb);
+ return sco._retn();
}
//============================================================================
//============================================================================
SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
{
- // Iterate on each components defined in the study
- // Get the component ID and compare with aComponentID
- bool _find = false;
- char *ID;
- SALOMEDS::SComponent_ptr compo;
-
- SALOMEDS_SComponentIterator_i itcomp(this,_doc);
- for (; itcomp.More(); itcomp.Next()) {
- SALOMEDS::SComponent_var SC = itcomp.Value();
- ID = SC->GetID();
- if(strcmp(aComponentID,ID)==0)
- {
- // ComponentID found
- _find = true;
- compo = SALOMEDS::SComponent::_narrow(SC);
- }
- }
- if(!_find)
- {
- compo = SALOMEDS::SComponent::_nil();
- }
- return compo;
+ SALOMEDS::Locker lock;
+
+ Handle(SALOMEDSImpl_SComponent) aCompImpl = _impl->FindComponentID(TCollection_AsciiString((char*)aComponentID));
+ if(aCompImpl.IsNull()) return SALOMEDS::SComponent::_nil();
+
+ SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aCompImpl, _orb);
+ return sco._retn();
}
//============================================================================
* Purpose : Find an Object with SALOMEDS::Name = anObjectName
*/
//============================================================================
-SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* theObjectName)
+SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
{
- // Iterate to all components defined in the study
- // After testing the component name, iterate in all objects defined under
- // components (function _FindObject)
- bool aIsFound = false;
- SALOMEDS::SObject_var aRefSO;
- SALOMEDS_SComponentIterator_i aComponentIter(this,_doc);
- for(; aComponentIter.More() && !aIsFound; aComponentIter.Next()){
- TDF_Label aLab = aComponentIter.GetValue();
- Handle(TDataStd_Name) anAttr;
- if(aLab.FindAttribute(TDataStd_Name::GetID(),anAttr)){
- TCollection_AsciiString aString(anAttr->Get());
- if(strcmp(aString.ToCString(),theObjectName) == 0){
- aRefSO = SALOMEDS_SComponent_i::NewRef(this,aLab)._retn();
- aIsFound = true;
- }
- }
- if(!aIsFound)
- aRefSO = _FindObject(aLab,theObjectName,aIsFound);
- }
+ SALOMEDS::Locker lock;
+
+ Handle(SALOMEDSImpl_SObject) aSO = _impl->FindObject(TCollection_AsciiString((char*)anObjectName));
+ if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
- return aRefSO._retn();
+ if(aSO->DynamicType() == STANDARD_TYPE(SALOMEDSImpl_SComponent)) {
+ Handle(SALOMEDSImpl_SComponent) aSCO = Handle(SALOMEDSImpl_SComponent)::DownCast(aSO);
+ SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aSCO, _orb);
+ return sco._retn();
+ }
+
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
+
+ return so._retn();
}
//============================================================================
//============================================================================
SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
{
- // Convert aSO->GetID in TDF_Label.
- TDF_Label Lab;
- TDF_Tool::Label(_doc->GetData(), (char*)anObjectID, Lab);
-
- if (Lab.IsNull())
- return SALOMEDS::SObject::_nil();
-
- return SALOMEDS_SObject_i::NewRef(this,Lab)._retn();
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_SObject) aSO = _impl->FindObjectID(TCollection_AsciiString((char*)anObjectID));
+ if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
+ return so._retn();
}
//============================================================================
//============================================================================
SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
{
- // Convert aSO->GetID in TDF_Label.
- TDF_Label Lab;
- TDF_Tool::Label(_doc->GetData(), (char*)anObjectID, Lab, Standard_True);
-
- if (Lab.IsNull())
- return SALOMEDS::SObject::_nil();
+ SALOMEDS::Locker lock;
+
+ Handle(SALOMEDSImpl_SObject) aSO = _impl->CreateObjectID((char*)anObjectID);
+ if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
- return SALOMEDS_SObject_i::NewRef(this,Lab)._retn();
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
+ return so._retn();
}
//============================================================================
* : with ComponentDataType = aComponentName
*/
//============================================================================
-SALOMEDS::Study::ListOfSObject*
-SALOMEDS_Study_i::FindObjectByName(const char* theObjectName,
- const char* theComponentName)
+SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
+ const char* aComponentName )
{
- SALOMEDS::Study::ListOfSObject_var aListOfSObj = new SALOMEDS::Study::ListOfSObject ;
- aListOfSObj->length(0);
+ SALOMEDS::Locker lock;
- SALOMEDS::SComponent_ptr aSComponent = FindComponent(theComponentName) ;
- if(aSComponent->_is_nil()){
- MESSAGE ("In FindObjectByName() : Component named " << theComponentName << " not found ");
- return aListOfSObj._retn();
+ Handle(TColStd_HSequenceOfTransient) aSeq = _impl->FindObjectByName(TCollection_AsciiString((char*)anObjectName),
+ TCollection_AsciiString((char*)aComponentName));
+ int aLength = aSeq->Length();
+ SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject ;
+ listSO->length(aLength);
+ for(int i = 1; i<=aLength; i++) {
+ Handle(SALOMEDSImpl_SObject) aSO = Handle(SALOMEDSImpl_SObject)::DownCast(aSeq->Value(i));
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
+ listSO[i-1] = so ;
}
-
- // Iterate on each object and subobject of the component
- // If objectName is found add it to the list of SObjects
- TDF_Label aLabel;
- CORBA::String_var anEntry = aSComponent->GetID();
- TDF_Tool::Label(_doc->GetData(),const_cast<char*>(anEntry.in()),aLabel);
-
- int aLength = 0 ;
- SALOMEDS::SObject_var aRefSO;
- TDF_ChildIterator aChildIter(aLabel,true);
- for(; aChildIter.More(); aChildIter.Next()){
- TDF_Label aLab = aChildIter.Value();
- Handle(TDataStd_Name) anAttr;
- if(aLab.FindAttribute(TDataStd_Name::GetID(),anAttr)){
- TCollection_AsciiString aString(anAttr->Get());
- if(strcmp(aString.ToCString(),theObjectName) == 0){
- aRefSO = SALOMEDS_SObject_i::NewRef(this,aLab)._retn();
- /* add to list */
- aLength++ ;
- aListOfSObj->length(aLength);
- aListOfSObj[aLength-1] = aRefSO;
- }
- }
- }
-
- return aListOfSObj._retn() ;
+ return listSO._retn() ;
}
-
-
//============================================================================
/*! Function : FindObjectIOR
* Purpose : Find an Object with IOR = anObjectIOR
*/
//============================================================================
-SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* theObjectIOR)
+SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
{
- // firstly searching in the datamap for optimization
- char* anIOR = const_cast<char*>(theObjectIOR);
- if(myIORLabels.IsBound(anIOR)){
- TDF_Label aLabel = myIORLabels.Find(anIOR);
- TSObjectHolder aSObjectHolder = SALOMEDS_SObject_i::New(this,aLabel);
- SALOMEDS_SObject_i* aSObjectPtr = aSObjectHolder.first;
- SALOMEDS::SObject_var aSObject = aSObjectHolder.second;
- // 11 oct 2002: forbidden attributes must be checked here
- SALOMEDS::GenericAttribute_var anAttr;
- if(!aSObjectPtr->FindAttribute(anAttr,"AttributeIOR")){
- myIORLabels.UnBind(anIOR);
- }else{
- return aSObject._retn();
- }
- }
+ SALOMEDS::Locker lock;
- // Iterate to all components defined in the study
- // After testing the component name, iterate in all objects defined under
- // components (function _FindObject)
- bool aIsFound = false;
- SALOMEDS::SObject_var aRefSO;
- SALOMEDS_SComponentIterator_i aComponentIter(this,_doc);
- for(; aComponentIter.More() && !aIsFound; aComponentIter.Next()){
- TDF_Label aLab = aComponentIter.GetValue();
- Handle(SALOMEDS_IORAttribute) anAttr;
- if(aLab.FindAttribute(SALOMEDS_IORAttribute::GetID(),anAttr)){
- TCollection_AsciiString aString(anAttr->Get());
- if(strcmp(aString.ToCString(),theObjectIOR) == 0){
- aRefSO = SALOMEDS_SComponent_i::NewRef(this,aLab);
- aIsFound = true;
- }
- }
- if(!aIsFound)
- aRefSO = _FindObjectIOR(aLab,theObjectIOR,aIsFound);
- }
+ Handle(SALOMEDSImpl_SObject) aSO = _impl->FindObjectIOR(TCollection_AsciiString((char*)anObjectIOR));
+ if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
- if(!aRefSO->_is_nil())
- MESSAGE("SALOMEDS_Study_i::FindObjectIOR: found label with old methods");
-
- return aRefSO._retn();
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
+ return so._retn();
}
//============================================================================
//============================================================================
SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
{
- TCollection_AsciiString aPath(CORBA::string_dup(thePath)), aToken;
- SALOMEDS::SObject_var aSO = SALOMEDS::SObject::_nil();
- int i = 1, aLength = aPath.Length();
- bool isRelative = false;
-
- if(aLength == 0) { //Empty path - return the current context
- return SALOMEDS_SObject_i::NewRef(this,_current)._retn();
- }
-
- if(aPath.Value(1) != '/') //Relative path
- isRelative = true;
-
- TDF_ChildIterator anIterator;
- TDF_Label aLabel;
- Handle(TDataStd_Name) anAttr;
-
- if(isRelative) {
- if(_current.IsNull()) throw SALOMEDS::Study::StudyInvalidContext();
- anIterator.Initialize(_current, Standard_False);
- }
- else {
- if(aPath.Length() == 1 && aPath.Value(1) == '/') { //Root
- return SALOMEDS_SObject_i::NewRef(this,_doc->Main())._retn();
- }
- anIterator.Initialize(_doc->Main(), Standard_False);
- }
-
- while(i <= aLength) {
+ SALOMEDS::Locker lock;
- aToken = aPath.Token("/", i);
- if(aToken.Length() == 0) break;
+ Handle(SALOMEDSImpl_SObject) aSO = _impl->FindObjectByPath(TCollection_AsciiString((char*)thePath));
+ if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
- for ( ; anIterator.More(); anIterator.Next() ) {
- aLabel = anIterator.Value();
- if(aLabel.FindAttribute(TDataStd_Name::GetID(), anAttr)) {
- if(anAttr->Get() == aToken) {
- aToken = aPath.Token("/", i+1); //Check if it was the last part of the path
- if(aToken.Length() == 0) { //The searched label is found (no part of the path is left)
- return SALOMEDS_SObject_i::NewRef(this,aLabel)._retn();
- }
-
- anIterator.Initialize(aLabel, Standard_False);
- break;
- }
- }
- }
-
- i++;
- }
-
- return aSO._retn();
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
+ return so._retn();
}
//============================================================================
//============================================================================
char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
{
+ SALOMEDS::Locker lock;
+
TCollection_AsciiString aPath("");
- if(CORBA::is_nil(theObject))
- return CORBA::string_dup(aPath.ToCString());
-
- SALOMEDS::SObject_var anObject = SALOMEDS::SObject::_narrow(theObject);
- if(anObject->_is_nil()) {
- CORBA::String_var anIOR = GetORB()->object_to_string(theObject);
- anObject = FindObjectIOR(anIOR);
- if(anObject->_is_nil())
- return CORBA::string_dup(aPath.ToCString());
- }
+ if(CORBA::is_nil(theObject)) return CORBA::string_dup(aPath.ToCString());
+ Handle(SALOMEDSImpl_SObject) aSO;
+ SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
- SALOMEDS::GenericAttribute_var anAttr;
- if(anObject->FindAttribute(anAttr, "AttributeName")) {
- SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
- if(anAttr->_is_nil())
- return CORBA::string_dup(aPath.ToCString());
- TCollection_AsciiString aValue(aName->Value());
- aValue.Prepend("/");
- aValue += aPath;
- aPath = aValue;
- SALOMEDS::SObject_ptr aFather = anObject->GetFather();
- if(!aFather->_is_nil()) {
- TDF_Label aLabel;
- Handle(TDataStd_Name) aNameAttrib;
- TDF_Tool::Label(_doc->GetData(), aFather->GetID(), aLabel);
- if(aLabel.FindAttribute(TDataStd_Name::GetID(), aNameAttrib)) {
- aValue = GetObjectPath(aFather);
- aPath = aValue + aPath;
- }
- }
+ if(!CORBA::is_nil(aSObj)) {
+ aSO = _impl->FindObjectID(aSObj->GetID());
}
-
+ else {
+ aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
+ }
+
+ if(aSO.IsNull()) return CORBA::string_dup(aPath.ToCString());
+
+ aPath = _impl->GetObjectPath(aSO);
return CORBA::string_dup(aPath.ToCString());
}
//============================================================================
void SALOMEDS_Study_i::SetContext(const char* thePath)
{
- if(thePath == NULL || strlen(thePath) == 0) throw SALOMEDS::Study::StudyInvalidDirectory();
- TCollection_AsciiString aPath(CORBA::string_dup(thePath)), aContext("");
- bool isInvalid = false;
- SALOMEDS::SObject_var aSO;
-
- if(aPath.Value(1) != '/') { //Relative path
- aContext = TCollection_AsciiString(GetContext());
- aContext += '/';
- aContext += aPath;
- }
- else
- aContext = aPath;
-
- try {
- aSO = FindObjectByPath(aContext.ToCString());
- }
- catch( ... ) {
- isInvalid = true;
- }
-
- if(isInvalid || aSO->_is_nil()) throw SALOMEDS::Study::StudyInvalidContext();
+ SALOMEDS::Locker lock;
- TDF_Label aLabel;
- TDF_Tool::Label(_doc->GetData(), aSO->GetID(), aLabel);
- if(aLabel.IsNull()) throw SALOMEDS::Study::StudyInvalidContext();
- else
- _current = aLabel; //Set the current context
-
+ _impl->SetContext(TCollection_AsciiString((char*)thePath));
+ if(_impl->IsError() && _impl->GetErrorCode() == "InvalidContext")
+ throw SALOMEDS::Study::StudyInvalidContext();
}
//============================================================================
//============================================================================
char* SALOMEDS_Study_i::GetContext()
{
- if(_current.IsNull())
- throw SALOMEDS::Study::StudyInvalidContext();
+ SALOMEDS::Locker lock;
- SALOMEDS::SObject_var aSObject = SALOMEDS_SObject_i::NewRef(this,_current);
- return GetObjectPath(aSObject);
+ if(!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
+ return CORBA::string_dup(_impl->GetContext().ToCString());
}
//============================================================================
* Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
*/
//============================================================================
-SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext) {
- TColStd_SequenceOfExtendedString aResultSeq;
+SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext)
+{
+ SALOMEDS::Locker lock;
+
SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
- TDF_Label aLabel;
- if (strlen(theContext) == 0) {
- if(_current.IsNull()) throw SALOMEDS::Study::StudyInvalidContext();
- aLabel = _current;
- } else {
- TDF_Label aTmp = _current;
- SetContext(theContext);
- aLabel = _current;
- _current = aTmp;
- }
- TDF_ChildIterator anIter(aLabel, Standard_False); // iterate all subchildren at all sublevels
- for(; anIter.More(); anIter.Next()) {
- TDF_Label aLabel = anIter.Value();
-// Handle(TDF_Attribute) anAttribute;
-// if (aLabel.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttribute) ||
-// aLabel.FindAttribute(SALOMEDS_LocalIDAttribute::GetID(), anAttribute)) {
- Handle(TDataStd_Name) aName;
- if (aLabel.FindAttribute(TDataStd_Name::GetID(), aName)) aResultSeq.Append(aName->Get());
-// }
- }
- // fill the result table
- int anIndex, aLength = aResultSeq.Length();
+ if (strlen(theContext) == 0 && !_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
+ Handle(TColStd_HSequenceOfAsciiString) aSeq = _impl->GetObjectNames(TCollection_AsciiString((char*)theContext));
+ int aLength = aSeq->Length();
aResult->length(aLength);
- for(anIndex = 0; anIndex < aLength; anIndex++) {
- aResult[anIndex] = CORBA::string_dup(TCollection_AsciiString(aResultSeq.Value(anIndex + 1)).ToCString());
+ for(int anIndex = 1; anIndex <= aLength; anIndex++) {
+ aResult[anIndex-1] = CORBA::string_dup(TCollection_AsciiString(aSeq->Value(anIndex)).ToCString());
}
return aResult._retn();
}
* Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
*/
//============================================================================
-SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext) {
- TColStd_SequenceOfExtendedString aResultSeq;
+SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext)
+{
+ SALOMEDS::Locker lock;
+
SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
- TDF_Label aLabel;
- if (strlen(theContext) == 0) {
- if(_current.IsNull()) throw SALOMEDS::Study::StudyInvalidContext();
- aLabel = _current;
- } else {
- TDF_Label aTmp = _current;
- SetContext(theContext);
- aLabel = _current;
- _current = aTmp;
- }
- TDF_ChildIterator anIter(aLabel, Standard_False); // iterate first-level children at all sublevels
- for(; anIter.More(); anIter.Next()) {
- TDF_Label aLabel = anIter.Value();
- Handle(SALOMEDS_LocalIDAttribute) anID;
- if (aLabel.FindAttribute(SALOMEDS_LocalIDAttribute::GetID(), anID)) {
- if (anID->Get() == DIRECTORYID) {
- Handle(TDataStd_Name) aName;
- if (aLabel.FindAttribute(TDataStd_Name::GetID(), aName)) {
- aResultSeq.Append(aName->Get());
- }
- }
- }
- }
- // fill the result table
- int anIndex, aLength = aResultSeq.Length();
+ if (strlen(theContext) == 0 && !_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
+ Handle(TColStd_HSequenceOfAsciiString) aSeq = _impl->GetDirectoryNames(TCollection_AsciiString((char*)theContext));
+ int aLength = aSeq->Length();
aResult->length(aLength);
- for(anIndex = 0; anIndex < aLength; anIndex++) {
- aResult[anIndex] = CORBA::string_dup(TCollection_AsciiString(aResultSeq.Value(anIndex + 1)).ToCString());
+ for(int anIndex = 1; anIndex <= aLength; anIndex++) {
+ aResult[anIndex-1] = CORBA::string_dup(TCollection_AsciiString(aSeq->Value(anIndex)).ToCString());
}
return aResult._retn();
}
* Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
*/
//============================================================================
-SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext) {
- TColStd_SequenceOfExtendedString aResultSeq;
+SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext)
+{
+ SALOMEDS::Locker lock;
+
SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
- TDF_Label aLabel;
- if (strlen(theContext) == 0) {
- if(_current.IsNull()) throw SALOMEDS::Study::StudyInvalidContext();
- aLabel = _current;
- } else {
- TDF_Label aTmp = _current;
- SetContext(theContext);
- aLabel = _current;
- _current = aTmp;
- }
- TDF_ChildIterator anIter(aLabel, Standard_False); // iterate all subchildren at all sublevels
- for(; anIter.More(); anIter.Next()) {
- TDF_Label aLabel = anIter.Value();
- Handle(SALOMEDS_LocalIDAttribute) anID;
- if (aLabel.FindAttribute(SALOMEDS_LocalIDAttribute::GetID(), anID)) {
- if (anID->Get() == FILELOCALID) {
- Handle(SALOMEDS_PersRefAttribute) aName;
- if(aLabel.FindAttribute(SALOMEDS_PersRefAttribute::GetID(), aName)) {
- TCollection_ExtendedString aFileName = aName->Get();
- if(aFileName.Length() > 0)
- aResultSeq.Append(aFileName.Split(strlen(FILEID)));
- }
- }
- }
-// }
- }
- // fill the result table
- int anIndex, aLength = aResultSeq.Length();
+ if (strlen(theContext) == 0 && !_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
+ Handle(TColStd_HSequenceOfAsciiString) aSeq = _impl->GetFileNames(TCollection_AsciiString((char*)theContext));
+ int aLength = aSeq->Length();
aResult->length(aLength);
- for(anIndex = 0; anIndex < aLength; anIndex++) {
- aResult[anIndex] = CORBA::string_dup(TCollection_AsciiString(aResultSeq.Value(anIndex + 1)).ToCString());
+ for(int anIndex = 1; anIndex <= aLength; anIndex++) {
+ aResult[anIndex-1] = CORBA::string_dup(TCollection_AsciiString(aSeq->Value(anIndex)).ToCString());
}
return aResult._retn();
}
* Purpose : method to get all components names
*/
//============================================================================
-SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext) {
- TColStd_SequenceOfExtendedString aResultSeq;
+SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext)
+{
+ SALOMEDS::Locker lock;
+
SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
- TDF_ChildIterator anIter(_doc->Main(), Standard_False); // iterate all subchildren at first level
- for(; anIter.More(); anIter.Next()) {
- TDF_Label aLabel = anIter.Value();
- Handle(TDataStd_Name) aName;
- if (aLabel.FindAttribute(TDataStd_Name::GetID(), aName)) aResultSeq.Append(aName->Get());
- }
- // fill the result table
- int anIndex, aLength = aResultSeq.Length();
+ if (strlen(theContext) == 0 && !_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
+ Handle(TColStd_HSequenceOfAsciiString) aSeq = _impl->GetComponentNames(TCollection_AsciiString((char*)theContext));
+ int aLength = aSeq->Length();
aResult->length(aLength);
- for(anIndex = 0; anIndex < aLength; anIndex++) {
- aResult[anIndex] = CORBA::string_dup(TCollection_AsciiString(aResultSeq.Value(anIndex + 1)).ToCString());
+ for(int anIndex = 1; anIndex <= aLength; anIndex++) {
+ aResult[anIndex-1] = CORBA::string_dup(TCollection_AsciiString(aSeq->Value(anIndex)).ToCString());
}
return aResult._retn();
}
* Purpose : Create a ChildIterator from an SObject
*/
//============================================================================
-SALOMEDS::ChildIterator_ptr
-SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSObject)
+SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
{
- SALOMEDS_ChildIterator_i* aServant =
- new SALOMEDS_ChildIterator_i(GetChildIterator(theSObject));
+ SALOMEDS::Locker lock;
- return aServant->_this();
-}
+ Handle(SALOMEDSImpl_SObject) aSO = _impl->GetSObject(theSO->GetID());
+ Handle(SALOMEDSImpl_ChildIterator) anItr = new SALOMEDSImpl_ChildIterator(aSO);
-SALOMEDS_ChildIterator_i
-SALOMEDS_Study_i::GetChildIterator(SALOMEDS::SObject_ptr theSObject)
-{
- TDF_Label aLab;
- TDF_Tool::Label(_doc->GetData(),theSObject->GetID(),aLab);
- return SALOMEDS_ChildIterator_i(this,aLab);
+ //Create iterator
+ SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
+ SALOMEDS::ChildIterator_var it = SALOMEDS::ChildIterator::_narrow(it_servant->_this());
+
+ return it;
}
+
//============================================================================
/*! Function : NewComponentIterator
* Purpose : Create a SComponentIterator
*/
//============================================================================
-SALOMEDS::SComponentIterator_ptr
-SALOMEDS_Study_i::NewComponentIterator()
-{
- SALOMEDS_SComponentIterator_i* aServant =
- new SALOMEDS_SComponentIterator_i(GetComponentIterator());
-
- return aServant->_this();
-}
-
-SALOMEDS_SComponentIterator_i
-SALOMEDS_Study_i::GetComponentIterator()
+SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
{
- return SALOMEDS_SComponentIterator_i(this,_doc);
+ SALOMEDS::Locker lock;
+ SALOMEDS_SComponentIterator_i* _it = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
+ _it->Init();
+ return _it->_this();
}
-//============================================================================
-/*! Function : GetUseCaseBuilder
- * Purpose : Returns a UseCase builder
- */
-//============================================================================
-SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
-{
- return _UseCaseBuilder->_this();
-}
//============================================================================
/*! Function : NewBuilder
* Purpose : Create a StudyBuilder
*/
//============================================================================
-SALOMEDS_StudyBuilder_i* SALOMEDS_Study_i::GetBuilder()
-{
- return _Builder;
-}
-
SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
{
- return GetBuilder()->_this();
+ SALOMEDS::Locker lock;
+ return _builder->_this();
}
//============================================================================
//============================================================================
char* SALOMEDS_Study_i::Name()
{
- return CORBA::string_dup(_name);
+ SALOMEDS::Locker lock;
+ return CORBA::string_dup(_impl->Name().ToCString());
}
//============================================================================
//============================================================================
void SALOMEDS_Study_i::Name(const char* name)
{
- _name = new char[strlen(name) +1];
- strcpy(_name,name);
+ SALOMEDS::Locker lock;
+ _impl->Name(TCollection_AsciiString((char*)name));
}
//============================================================================
//============================================================================
CORBA::Boolean SALOMEDS_Study_i::IsSaved()
{
- return _isSaved;
+ SALOMEDS::Locker lock;
+ return _impl->IsSaved();
}
//============================================================================
//============================================================================
void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
{
- _isSaved = save;
+ SALOMEDS::Locker lock;
+ _impl->IsSaved(save);
}
//============================================================================
//============================================================================
CORBA::Boolean SALOMEDS_Study_i::IsModified()
{
- // True if is modified and not saved
- if (_doc->IsModified())
- if (!_isSaved) return true;
- else return false;
- else return false;
+ SALOMEDS::Locker lock;
+ return _impl->IsModified();
}
//============================================================================
//============================================================================
char* SALOMEDS_Study_i::URL()
{
- if(!_URL) {
- _URL = new char[1];
- _URL[0] = (char)0;
- }
- return CORBA::string_dup(_URL);
+ SALOMEDS::Locker lock;
+ return CORBA::string_dup(_impl->URL().ToCString());
}
//============================================================================
//============================================================================
void SALOMEDS_Study_i::URL(const char* url)
{
- if (_URL) delete [] _URL;
- _URL = new char[strlen(url) +1];
- strcpy(_URL,url);
- SCRUTE(_URL);
-
- char *aName = _URL;
- char *adr = strtok(aName, "/");
- while (adr)
- {
- aName = adr;
- adr = strtok(NULL, "/");
- }
- strcpy(_URL,url);
- Name(aName);
+ SALOMEDS::Locker lock;
+ _impl->URL(TCollection_AsciiString((char*)url));
}
-//============================================================================
-/*! Function : _FindObject
- * Purpose : Find an Object with SALOMEDS::Name = anObjectName
- */
-//============================================================================
-SALOMEDS::SObject_ptr
-SALOMEDS_Study_i::_FindObject(TDF_Label theLabel,
- const char* theObjectName,
- bool& theIsFound)
+CORBA::Short SALOMEDS_Study_i::StudyId()
{
- theIsFound = false;
- // Iterate on each objects and subobjects of the component
- // If objectName find, stop the loop and get the object reference
- SALOMEDS::SObject_var aRefSO;
- TDF_ChildIterator aChildIter(theLabel,true);
- for(; aChildIter.More() && !theIsFound; aChildIter.Next()){
- TDF_Label aLab = aChildIter.Value();
- Handle(TDataStd_Name) anAttr;
- if(aLab.FindAttribute(TDataStd_Name::GetID(),anAttr)){
- TCollection_AsciiString aString(anAttr->Get());
- if(strcmp(aString.ToCString(),theObjectName) == 0){
- aRefSO = SALOMEDS_SObject_i::NewRef(this,aLab);
- theIsFound = true;
- }
- }
- }
- return aRefSO._retn();
+ SALOMEDS::Locker lock;
+ return _impl->StudyId();
}
-//============================================================================
-/*! Function : _FindObject
- * Purpose : Find an Object with SALOMEDS::IOR = anObjectIOR
- */
-//============================================================================
-SALOMEDS::SObject_ptr
-SALOMEDS_Study_i::_FindObjectIOR(TDF_Label theLabel,
- const char* theObjectIOR,
- bool& theIsFound)
-{
- // Iterate on each objects and subobjects of the component
- // If objectName find, stop the loop and get the object reference
- SALOMEDS::SObject_var aRefSO;
- TDF_ChildIterator aChildIter(theLabel,true);
- for(; aChildIter.More() && !theIsFound; aChildIter.Next()){
- TDF_Label aLab = aChildIter.Value();
- Handle(SALOMEDS_IORAttribute) anAttr;
- if(aLab.FindAttribute(SALOMEDS_IORAttribute::GetID(),anAttr)){
- TCollection_AsciiString aString(anAttr->Get());
- if(strcmp(aString.ToCString(),theObjectIOR) == 0){
- aRefSO = SALOMEDS_SObject_i::NewRef(this,aLab);
- theIsFound = true;
- }
- }
- }
- return aRefSO._retn();
+void SALOMEDS_Study_i::StudyId(CORBA::Short id)
+{
+ SALOMEDS::Locker lock;
+ _impl->StudyId(id);
}
-CORBA::Short SALOMEDS_Study_i::StudyId()
+void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR,const char* anEntry)
{
- return _StudyId;
+ SALOMEDS::Locker lock;
+ _impl->UpdateIORLabelMap(TCollection_AsciiString((char*)anIOR), TCollection_AsciiString((char*)anEntry));
}
-void SALOMEDS_Study_i::StudyId(CORBA::Short id)
+SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const TDF_Label theLabel, CORBA::ORB_ptr orb)
{
- _StudyId = id;
-}
+ SALOMEDS::Locker lock;
-void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR,const char* anEntry) {
- TDF_Label aLabel;
- CORBA::String_var anEn = CORBA::string_dup(anEntry);
- CORBA::String_var IOR = CORBA::string_dup(anIOR);
- TDF_Tool::Label(_doc->GetData(),anEn,aLabel, Standard_True);
- if (myIORLabels.IsBound(TCollection_ExtendedString(IOR))) myIORLabels.UnBind(TCollection_ExtendedString(IOR));
- myIORLabels.Bind(TCollection_ExtendedString(IOR), aLabel);
+ Handle(SALOMEDSImpl_AttributeIOR) Att;
+ if (theLabel.Root().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(),Att)){
+ char* IOR = CORBA::string_dup(TCollection_AsciiString(Att->Value()).ToCString());
+ CORBA::Object_var obj = orb->string_to_object(IOR);
+ SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ;
+ ASSERT(!CORBA::is_nil(aStudy));
+ return SALOMEDS::Study::_duplicate(aStudy);
+ } else {
+ MESSAGE("GetStudy: Problem to get study");
+ }
+ return SALOMEDS::Study::_nil();
}
-void SALOMEDS_Study_i::IORUpdated(const Handle(SALOMEDS_IORAttribute) theAttribute) {
- TCollection_AsciiString aString;
- TDF_Tool::Entry(theAttribute->Label(),aString);
- TCollection_AsciiString aValue(theAttribute->Get());
- UpdateIORLabelMap(aValue.ToCString(),aString.ToCString());
+void SALOMEDS_Study_i::IORUpdated(const Handle(SALOMEDSImpl_AttributeIOR) theAttribute)
+{
+ SALOMEDS::Locker lock;
+ SALOMEDSImpl_Study::IORUpdated(theAttribute);
}
-SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject) {
+SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
+{
+ SALOMEDS::Locker lock;
+
SALOMEDS::GenericAttribute_ptr aTarget;
if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
}
-SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties(){
- SALOMEDS::SObject_var aSObject = FindObjectID("0:1");
-
- SALOMEDS::GenericAttribute_var anAttr =
- GetBuilder()->FindOrCreateAttribute(aSObject,"AttributeStudyProperties");
-
- return SALOMEDS::AttributeStudyProperties::_narrow(anAttr);
+SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
+{
+ SALOMEDS::Locker lock;
+
+ Handle(SALOMEDSImpl_AttributeStudyProperties) anAttr = _impl->GetProperties();
+ SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
+ return SP->AttributeStudyProperties::_this();
}
-char* SALOMEDS_Study_i::GetLastModificationDate() {
- SALOMEDS::AttributeStudyProperties_var aProp = GetProperties();
- SALOMEDS::StringSeq_var aNames;
- SALOMEDS::LongSeq_var aMinutes, aHours, aDays, aMonths, aYears;
- aProp->GetModificationsList(aNames , aMinutes ,aHours, aDays, aMonths, aYears, true);
- int aLastIndex = aNames->length() - 1;
- char aResult[20];
- sprintf(aResult, "%2.2d/%2.2d/%4.4d %2.2d:%2.2d", (int)(aDays[aLastIndex]),(int)(aMonths[aLastIndex]),
- (int)(aYears[aLastIndex]), (int)(aHours[aLastIndex]), (int)(aMinutes[aLastIndex]));
- CORBA::String_var aResStr = CORBA::string_dup(aResult);
- return aResStr._retn();
+char* SALOMEDS_Study_i::GetLastModificationDate()
+{
+ SALOMEDS::Locker lock;
+ return CORBA::string_dup(_impl->GetLastModificationDate().ToCString());
}
-SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate() {
- SALOMEDS::AttributeStudyProperties_var aProp = GetProperties();
- SALOMEDS::StringSeq_var aNames;
- SALOMEDS::LongSeq_var aMinutes, aHours, aDays, aMonths, aYears;
- aProp->GetModificationsList(aNames , aMinutes ,aHours, aDays, aMonths, aYears, false);
-
- int anIndex, aLength = aNames->length();
+SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
+{
+ SALOMEDS::Locker lock;
+
+ Handle(TColStd_HSequenceOfAsciiString) aSeq = _impl->GetModificationsDate();
+ int aLength = aSeq->Length();
SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
aDates->length(aLength);
- for(anIndex = 0; anIndex < aLength; anIndex++) {
- char aDate[20];
- sprintf(aDate, "%2.2d/%2.2d/%4.4d %2.2d:%2.2d", (int)(aDays[anIndex]), (int)(aMonths[anIndex]),
- (int)(aYears[anIndex]), (int)(aHours[anIndex]), (int)(aMinutes[anIndex]));
- aDates[anIndex] = CORBA::string_dup(aDate);
+ for(int anIndex = 1; anIndex <= aLength; anIndex++) {
+ aDates[anIndex-1] = CORBA::string_dup(aSeq->Value(anIndex).ToCString());
}
return aDates._retn();
}
+//============================================================================
+/*! Function : GetUseCaseBuilder
+ * Purpose : Returns a UseCase builder
+ */
+//============================================================================
+SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
+{
+ SALOMEDS::Locker lock;
+ SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
+ return UCBuilder->_this();
+}
+
+
//============================================================================
/*! Function : Close
* Purpose :
//============================================================================
void SALOMEDS_Study_i::Close()
{
- SALOMEDS_SComponentIterator_i itcomponent(this,_doc);
+ SALOMEDS::Locker lock;
+
+ RemovePostponed(-1);
- const CORBA::ORB_var& anORB = GetORB();
- for (; itcomponent.More(); itcomponent.Next()) {
- SALOMEDS::SComponent_var sco = itcomponent.Value();
+ SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
+
+ for (; itcomponent->More(); itcomponent->Next()) {
+ SALOMEDS::SComponent_var sco = itcomponent->Value();
MESSAGE ( "Look for an engine for data type :"<< sco->ComponentDataType());
// if there is an associated Engine call its method for closing
if (sco->ComponentIOR(IOREngine)) {
// we have found the associated engine to write the data
MESSAGE ( "We have found an engine for data type :"<< sco->ComponentDataType());
- CORBA::Object_var obj = anORB->string_to_object(IOREngine);
+ CORBA::Object_var obj = _orb->string_to_object(IOREngine);
if (!CORBA::is_nil(obj)) {
SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
-
- if (!anEngine->_is_nil())
+
+ if (!anEngine->_is_nil()) {
+ SALOMEDS::unlock();
anEngine->Close(sco);
+ SALOMEDS::lock();
+ }
}
}
}
-
- Handle(TDocStd_Application) anApp = Handle(TDocStd_Application)::DownCast(_doc->Application());
-// Handle(TDocStd_Owner) anOwner;
-// if (_doc->Main().Root().FindAttribute(TDocStd_Owner::GetID(), anOwner)) {
-// Handle(TDocStd_Document) anEmptyDoc;
-// anOwner->SetDocument(anEmptyDoc);
-// }
- if(!anApp.IsNull()) anApp->Close(_doc);
- _doc.Nullify();
+ _impl->Close();
}
//============================================================================
* Purpose :
*/
//============================================================================
-void SALOMEDS_Study_i::AddPostponed(const char* theIOR) {
- if (!GetBuilder()->HasOpenCommand()) return;
- try {
- CORBA::Object_var obj = GetORB()->string_to_object(theIOR);
- if (!CORBA::is_nil(obj)) {
- SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj) ;
- if (!CORBA::is_nil(aGeneric)) {
- TCollection_AsciiString anIOR(const_cast<char*>(theIOR));
- anIOR.Prepend("d");
- myPostponedIORs.Append(anIOR); // add prefix: deleted
- myNbPostponed.SetValue(myNbPostponed.Length(), myNbPostponed.Last() + 1);
- }
- }
- } catch(...) {}
+void SALOMEDS_Study_i::AddPostponed(const char* theIOR)
+{
+ SALOMEDS::Locker lock;
+
+ CORBA::Object_var obj = _orb->string_to_object(theIOR);
+ if (!CORBA::is_nil(obj)) {
+ SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj) ;
+ if (!CORBA::is_nil(aGeneric)) _impl->AddPostponed((char*)theIOR);
+ }
}
-void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR) {
- if (!GetBuilder()->HasOpenCommand()) return;
- try {
- CORBA::Object_var obj = GetORB()->string_to_object(theIOR);
- if (!CORBA::is_nil(obj)) {
- SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj) ;
- if (!CORBA::is_nil(aGeneric)) {
- TCollection_AsciiString anIOR(const_cast<char*>(theIOR));
- anIOR.Prepend("c");
- myPostponedIORs.Append(anIOR); // add prefix: created
- myNbPostponed.SetValue(myNbPostponed.Length(), myNbPostponed.Last() + 1);
- }
- }
- } catch(...) {}
+void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR)
+{
+ SALOMEDS::Locker lock;
+
+ CORBA::Object_var obj = _orb->string_to_object(theIOR);
+ if (!CORBA::is_nil(obj)) {
+ SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj) ;
+ if (!CORBA::is_nil(aGeneric)) _impl->AddCreatedPostponed((char*)theIOR);
+ }
}
//============================================================================
* Purpose :
*/
//============================================================================
-void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long theUndoLimit) {
- int anIndex;
- int anOld;
-
- int aUndoLimit = theUndoLimit;
- if (theUndoLimit < 0) aUndoLimit = 0;
+void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long theUndoLimit)
+{
+ SALOMEDS::Locker lock;
- const CORBA::ORB_var& anORB = GetORB();
- if (myNbUndos > 0) { // remove undone
- anOld = 0;
- for(anIndex = 1; anIndex < myNbPostponed.Length() - myNbUndos; anIndex++)
- anOld += myNbPostponed(anIndex);
- int aNew = myPostponedIORs.Length() - myNbPostponed.Last();
-
- for(anIndex = anOld + 1; anIndex <= aNew; anIndex++) {
- TCollection_AsciiString anIOR = myPostponedIORs(anIndex);
- if (anIOR.Value(1) == 'c') {
- CORBA::Object_var obj = anORB->string_to_object(anIOR.Split(1).ToCString());
- SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
- if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
- }
+ Handle(TColStd_HSequenceOfAsciiString) aSeq = _impl->RemovePostponed(theUndoLimit);
+ int aLegth = aSeq->Length();
+ for(int i = 1; i <= aLegth; i++) {
+ TCollection_AsciiString anIOR = aSeq->Value(i);
+ if (anIOR.Value(1) == 'c') {
+ CORBA::Object_var obj = _orb->string_to_object(anIOR.Split(1).ToCString());
+ SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
+ if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
}
- if (anOld < aNew) myPostponedIORs.Remove(anOld + 1, aNew);
- if (myNbPostponed.Length() > 0) myNbPostponed.Remove(myNbPostponed.Length() - myNbUndos, myNbPostponed.Length() - 1);
-
- myNbUndos = 0;
- }
-
- if (myNbPostponed.Length() > aUndoLimit) { // remove objects, that can not be undone
- anOld = 0;
- for(anIndex = myNbPostponed.Length() - aUndoLimit; anIndex >= 1; anIndex--)
- anOld += myNbPostponed(anIndex);
- for(anIndex = 1; anIndex <= anOld; anIndex++) {
- TCollection_AsciiString anIOR = myPostponedIORs(anIndex);
- if (anIOR.Value(1) == 'd') {
- CORBA::Object_var obj = anORB->string_to_object(anIOR.Split(1).ToCString());
- SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
- if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
- }
+ else if (anIOR.Value(1) == 'd') {
+ CORBA::Object_var obj = _orb->string_to_object(anIOR.Split(1).ToCString());
+ SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
+ if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
}
- if (anOld > 0) myPostponedIORs.Remove(1, anOld);
- myNbPostponed.Remove(1, myNbPostponed.Length() - aUndoLimit);
- }
-
- if (theUndoLimit == -1) { // remove all IORs from the study on the study close
- TDF_ChildIDIterator anIter(_doc->GetData()->Root(), SALOMEDS_IORAttribute::GetID(), Standard_True);
- for(; anIter.More(); anIter.Next()) {
- Handle(SALOMEDS_IORAttribute) anAttr = Handle(SALOMEDS_IORAttribute)::DownCast(anIter.Value());
- CORBA::String_var anIOR = CORBA::string_dup(TCollection_AsciiString(anAttr->Get()).ToCString());
+ else {
try {
- CORBA::Object_var obj = anORB->string_to_object(anIOR);
+ CORBA::Object_var obj = _orb->string_to_object(anIOR.ToCString());
SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
} catch (...) {}
}
- } else myNbPostponed.Append(0);
+ }
}
//============================================================================
* Purpose :
*/
//============================================================================
-void SALOMEDS_Study_i::UndoPostponed(const CORBA::Long theWay) {
- myNbUndos += theWay;
- // remove current postponed
- if (myNbPostponed.Last() > 0)
- myPostponedIORs.Remove(myPostponedIORs.Length() - myNbPostponed.Last() + 1, myPostponedIORs.Length());
- myNbPostponed(myNbPostponed.Length()) = 0;
+void SALOMEDS_Study_i::UndoPostponed(const CORBA::Long theWay)
+{
+ SALOMEDS::Locker lock;
+
+ _impl->UndoPostponed(theWay);
+}
+
+
+//============================================================================
+/*! Function : DumpStudy
+ * Purpose :
+ */
+//============================================================================
+CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath, const char* theBaseName, CORBA::Boolean isPublished)
+{
+ SALOMEDS::Locker lock;
+
+ TCollection_AsciiString aPath((char*)thePath), aBaseName((char*)theBaseName);
+ SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
+ CORBA::Boolean ret = _impl->DumpStudy(aPath, aBaseName, isPublished, factory);
+ delete factory;
+ return ret;
+}
+
+//===========================================================================
+// PRIVATE FUNCTIONS
+//===========================================================================
+long SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
+{
+#ifdef WIN32
+ long pid = (long)_getpid();
+#else
+ long pid = (long)getpid();
+#endif
+ isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0;
+ SALOMEDSImpl_Study* local_impl = _impl.operator->();
+ return ((long)local_impl);
}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
// File : SALOMEDS_Study_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
-// $Header$
#ifndef __SALOMEDS_STUDY_I_H__
#define __SALOMEDS_STUDY_I_H__
// std C++ headers
-#include <map>
-#include <string>
+#include <iostream.h>
// IDL headers
#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOME_GenericObj)
#include CORBA_SERVER_HEADER(SALOMEDS)
-// Cascade headers
-#include <TDF_Tool.hxx>
-#include <TDF_Data.hxx>
-#include <TDF_Label.hxx>
-#include <TDocStd_Document.hxx>
-#include <TColStd_SequenceOfInteger.hxx>
-#include <TColStd_SequenceOfAsciiString.hxx>
+#include <stdio.h>
//SALOMEDS headers
-#include "SALOMEDS_DataMapStringLabel.hxx"
-#include "SALOMEDS_IORAttribute.hxx"
-
#include "SALOMEDS_SComponentIterator_i.hxx"
-#include "SALOMEDS_ChildIterator_i.hxx"
-
-class SALOMEDS_StudyManager_i;
-class SALOMEDS_UseCaseBuilder_i;
-class SALOMEDS_StudyBuilder_i;
-class SALOMEDS_SObject_i;
-
+#include "SALOMEDS_StudyBuilder_i.hxx"
+#include "SALOMEDS_SObject_i.hxx"
+#include "SALOMEDS_UseCaseBuilder_i.hxx"
-bool operator<(const TDF_Label& theLeft, const TDF_Label& theRight);
+#include "SALOMEDSImpl_Study.hxx"
+#include "SALOMEDSImpl_AttributeIOR.hxx"
-
-class SALOMEDS_Study_i: public virtual POA_SALOMEDS::Study,
- public virtual PortableServer::RefCountServantBase
+class SALOMEDS_Study_i: public POA_SALOMEDS::Study,
+ public PortableServer::RefCountServantBase
{
+private:
+ CORBA::ORB_ptr _orb;
+ Handle(SALOMEDSImpl_Study) _impl;
+ SALOMEDS_StudyBuilder_i* _builder;
+
public:
- typedef TDF_Label TSObjectID;
- typedef std::pair<SALOMEDS_SObject_i*,SALOMEDS::SObject_var> TSObjectHolder;
- typedef std::map<TSObjectID,TSObjectHolder> TSObjectMap;
- SALOMEDS_Study_i(SALOMEDS_StudyManager_i* theStudyManager,
- const Handle(TDocStd_Document)& theDoc,
- const char* theStudyName);
+ //! standard constructor
+ SALOMEDS_Study_i(const Handle(SALOMEDSImpl_Study), CORBA::ORB_ptr);
+ //! standard destructor
virtual ~SALOMEDS_Study_i();
-
- SALOMEDS_StudyManager_i* GetStudyManager(){ return _StudyManager; }
-
- Handle(TDocStd_Document) GetDocument(){ return _doc; }
-
- TSObjectMap& GetSObjectMap(){ return mySObjectMap;}
-
- CORBA::ORB_var GetORB() const;
-
- PortableServer::POA_var GetPOA() const;
-
- SALOMEDS_SObject_i* DownCast(SALOMEDS::SObject_ptr theSObject) const;
-
- SALOMEDS::Callback_ptr SetOnAddSObject(SALOMEDS::Callback_ptr theCallback);
-
- SALOMEDS::Callback_ptr SetOnRemoveSObject(SALOMEDS::Callback_ptr theCallback);
-
- void OnAddSObject(SALOMEDS::SObject_ptr theObject);
-
- void OnRemoveSObject(SALOMEDS::SObject_ptr theObject);
-
- void CheckLocked();
-
-
- virtual char* ConvertObjectToIOR(CORBA::Object_ptr theObject);
-
- virtual CORBA::Object_ptr ConvertIORToObject(const char* theIOR);
-
//! method to Get persistent reference of study (idem URL())
/*!
\sa URL()
\return ChildIterator_ptr arguments, the created ChildIterator
*/
virtual SALOMEDS::ChildIterator_ptr NewChildIterator(SALOMEDS::SObject_ptr aSO);
- SALOMEDS_ChildIterator_i GetChildIterator(SALOMEDS::SObject_ptr theSObject);
//! method to Create a SComponentIterator
/*!
\return SComponentIterator_ptr arguments, the created SComponentIterator
*/
virtual SALOMEDS::SComponentIterator_ptr NewComponentIterator();
- SALOMEDS_SComponentIterator_i GetComponentIterator();
//! method to Create a StudyBuilder
/*!
\return StudyBuilder_ptr arguments, the created StudyBuilder
*/
- SALOMEDS_StudyBuilder_i* GetBuilder();
virtual SALOMEDS::StudyBuilder_ptr NewBuilder();
//! method to get study name
virtual CORBA::Short StudyId();
virtual void StudyId(CORBA::Short id);
- void IORUpdated(const Handle(SALOMEDS_IORAttribute) theAttribute);
+ static SALOMEDS::Study_ptr GetStudy(const TDF_Label theLabel, CORBA::ORB_ptr orb);
+
+ static void IORUpdated(const Handle(SALOMEDSImpl_AttributeIOR) theAttribute);
virtual void UpdateIORLabelMap(const char* anIOR, const char* aLabel);
virtual SALOMEDS::ListOfDates* GetModificationsDate();
+ virtual char* ConvertObjectToIOR(CORBA::Object_ptr theObject) {return _orb->object_to_string(theObject); }
+ virtual CORBA::Object_ptr ConvertIORToObject(const char* theIOR) { return _orb->string_to_object(theIOR); };
+
virtual SALOMEDS::UseCaseBuilder_ptr GetUseCaseBuilder();
virtual void Close();
- void EnableUseCaseAutoFilling(CORBA::Boolean isEnabled) { _autoFill = isEnabled; }
+ void EnableUseCaseAutoFilling(CORBA::Boolean isEnabled) { _impl->EnableUseCaseAutoFilling(isEnabled); }
// postponed destroying of CORBA object functionality
virtual void AddPostponed(const char* theIOR);
// if theUndoLimit==0, removes all
virtual void UndoPostponed(const CORBA::Long theWay); // theWay = 1: resurrect objects,
// theWay = -1: get back to the list of postponed
-private:
- friend class SALOMEDS_StudyBuilder_i;
- friend class SALOMEDS_SObject_i;
-
- SALOMEDS_StudyManager_i* _StudyManager;
- TSObjectMap mySObjectMap;
+ virtual CORBA::Boolean DumpStudy(const char* thePath, const char* theBaseName, CORBA::Boolean isPublished);
- SALOMEDS_UseCaseBuilder_i* _UseCaseBuilder;
- SALOMEDS_StudyBuilder_i* _Builder;
- SALOMEDS::Callback_var _callbackOnAdd;
- SALOMEDS::Callback_var _callbackOnRemove;
-
- char* _name;
- Handle(TDocStd_Document) _doc; // OCAF Document
- CORBA::Boolean _isSaved; // True if the Study is saved
- char* _URL; //URL of the persistent reference of the study
- CORBA::Short _StudyId;
-
- SALOMEDS_DataMapStringLabel myIORLabels;
-
- // data structures for postponed destroying of CORBA object functionality
- TColStd_SequenceOfAsciiString myPostponedIORs; // ordered set of IORs
- TColStd_SequenceOfInteger myNbPostponed; // number of IOR in the each transaction
- int myNbUndos; // number of current Undos, made by user
-
- TDF_Label _current;
- bool _autoFill;
-
- SALOMEDS::SObject_ptr _FindObject(TDF_Label theLabel,
- const char* theObjectIOR,
- bool& theIsFound);
- SALOMEDS::SObject_ptr _FindObjectIOR(TDF_Label theLabel,
- const char* theObjectIOR,
- bool& theIsFound);
-
- SALOMEDS_Study_i(); // Not implemented
- void operator=(const SALOMEDS_Study_i&); // Not implemented
+ virtual Handle(SALOMEDSImpl_Study) GetImpl() { return _impl; }
+ virtual long GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal);
};
-
-
#endif
--- /dev/null
+// File : SALOMEDS_UseCaseBuilder.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+using namespace std;
+
+#include "SALOMEDS_UseCaseBuilder.hxx"
+
+#include "SALOMEDSImpl_SObject.hxx"
+#include "SALOMEDS_SObject.hxx"
+#include "SALOMEDSImpl_UseCaseIterator.hxx"
+#include "SALOMEDS_UseCaseIterator.hxx"
+#include <TCollection_AsciiString.hxx>
+#include <string>
+
+SALOMEDS_UseCaseBuilder::SALOMEDS_UseCaseBuilder(const Handle(SALOMEDSImpl_UseCaseBuilder)& theBuilder)
+{
+ _isLocal = true;
+ _local_impl = theBuilder;
+ _corba_impl = SALOMEDS::UseCaseBuilder::_nil();
+}
+
+SALOMEDS_UseCaseBuilder::SALOMEDS_UseCaseBuilder(SALOMEDS::UseCaseBuilder_ptr theBuilder)
+{
+ _isLocal = false;
+ _local_impl = NULL;
+ _corba_impl = SALOMEDS::UseCaseBuilder::_duplicate(theBuilder);
+}
+
+SALOMEDS_UseCaseBuilder::~SALOMEDS_UseCaseBuilder()
+{
+ if(!_isLocal) _corba_impl->Destroy();
+}
+
+bool SALOMEDS_UseCaseBuilder::Append(const _PTR(SObject)& theObject)
+{
+ bool ret;
+ SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
+ if(_isLocal) ret = _local_impl->Append(obj->GetLocalImpl());
+ else ret = _corba_impl->Append(obj->GetCORBAImpl());
+ return ret;
+}
+
+bool SALOMEDS_UseCaseBuilder::Remove(const _PTR(SObject)& theObject)
+{
+ bool ret;
+ SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
+ if(_isLocal) ret = _local_impl->Remove(obj->GetLocalImpl());
+ else ret = _corba_impl->Remove(obj->GetCORBAImpl());
+ return ret;
+}
+
+bool SALOMEDS_UseCaseBuilder::AppendTo(const _PTR(SObject)& theFather, _PTR(SObject) theObject)
+{
+ bool ret;
+ SALOMEDS_SObject* father = dynamic_cast<SALOMEDS_SObject*>(theFather.get());
+ SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
+ if(_isLocal) ret = _local_impl->AppendTo(father->GetLocalImpl(), obj->GetLocalImpl());
+ else ret = _corba_impl->AppendTo(father->GetCORBAImpl(), obj->GetCORBAImpl());
+ return ret;
+}
+
+bool SALOMEDS_UseCaseBuilder::InsertBefore(const _PTR(SObject)& theFirst, _PTR(SObject) theNext)
+{
+ bool ret;
+ SALOMEDS_SObject* first = dynamic_cast<SALOMEDS_SObject*>(theFirst.get());
+ SALOMEDS_SObject* next = dynamic_cast<SALOMEDS_SObject*>(theNext.get());
+ if(_isLocal) ret = _local_impl->InsertBefore(first->GetLocalImpl(), next->GetLocalImpl());
+ else ret = _corba_impl->InsertBefore(first->GetCORBAImpl(), next->GetCORBAImpl());
+ return ret;
+}
+
+bool SALOMEDS_UseCaseBuilder::SetCurrentObject(const _PTR(SObject)& theObject)
+{
+ bool ret;
+ SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
+ if(_isLocal) ret = _local_impl->SetCurrentObject(obj->GetLocalImpl());
+ else ret = _corba_impl->SetCurrentObject(obj->GetCORBAImpl());
+ return ret;
+}
+
+bool SALOMEDS_UseCaseBuilder::SetRootCurrent()
+{
+ bool ret;
+ if(_isLocal) ret = _local_impl->SetRootCurrent();
+ else ret = _corba_impl->SetRootCurrent();
+ return ret;
+}
+
+bool SALOMEDS_UseCaseBuilder::HasChildren(const _PTR(SObject)& theObject)
+{
+ bool ret;
+ SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
+ if(_isLocal) ret = _local_impl->HasChildren(obj->GetLocalImpl());
+ else ret = _corba_impl->HasChildren(obj->GetCORBAImpl());
+ return ret;
+}
+
+bool SALOMEDS_UseCaseBuilder::IsUseCase(const _PTR(SObject)& theObject)
+{
+ bool ret;
+ SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
+ if(_isLocal) ret = _local_impl->IsUseCase(obj->GetLocalImpl());
+ else ret = _corba_impl->IsUseCase(obj->GetCORBAImpl());
+ return ret;
+}
+
+bool SALOMEDS_UseCaseBuilder::SetName(const std::string& theName)
+{
+ bool ret;
+ if(_isLocal) ret = _local_impl->SetName((char*)theName.c_str());
+ else ret = _corba_impl->SetName((char*)theName.c_str());
+ return ret;
+}
+
+_PTR(SObject) SALOMEDS_UseCaseBuilder::GetCurrentObject()
+{
+ SALOMEDS_SObject* obj = NULL;
+ if(_isLocal) obj = new SALOMEDS_SObject(_local_impl->GetCurrentObject());
+ else obj = new SALOMEDS_SObject(_corba_impl->GetCurrentObject());
+ return _PTR(SObject)(obj);
+}
+
+std::string SALOMEDS_UseCaseBuilder::GetName()
+{
+ std::string aName;
+ if(_isLocal) aName = _local_impl->GetName().ToCString();
+ else aName = _corba_impl->GetName();
+ return aName;
+}
+
+_PTR(SObject) SALOMEDS_UseCaseBuilder::AddUseCase(const std::string& theName)
+{
+ SALOMEDS_SObject* obj = NULL;
+ if(_isLocal) obj = new SALOMEDS_SObject(_local_impl->AddUseCase((char*)theName.c_str()));
+ else obj = new SALOMEDS_SObject(_corba_impl->AddUseCase((char*)theName.c_str()));
+ return _PTR(SObject)(obj);
+}
+
+_PTR(UseCaseIterator) SALOMEDS_UseCaseBuilder::GetUseCaseIterator(const _PTR(SObject)& theObject)
+{
+ SALOMEDS_UseCaseIterator* it = NULL;
+ SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
+ if(_isLocal) it = new SALOMEDS_UseCaseIterator(_local_impl->GetUseCaseIterator(obj->GetLocalImpl()));
+ else it = new SALOMEDS_UseCaseIterator(_corba_impl->GetUseCaseIterator(obj->GetCORBAImpl()));
+ return _PTR(UseCaseIterator)(it);
+}
--- /dev/null
+// File : SALOMEDS_UseCaseBuilder.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef __SALOMEDS_USECaseBuilder_H__
+#define __SALOMEDS_USECaseBuilder_H__
+
+#include "SALOMEDSClient.hxx"
+#include "SALOMEDSImpl_UseCaseBuilder.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+
+class SALOMEDS_UseCaseBuilder: public SALOMEDSClient_UseCaseBuilder
+{
+
+private:
+ bool _isLocal;
+ Handle(SALOMEDSImpl_UseCaseBuilder) _local_impl;
+ SALOMEDS::UseCaseBuilder_var _corba_impl;
+
+public:
+
+ SALOMEDS_UseCaseBuilder(const Handle(SALOMEDSImpl_UseCaseBuilder)& theBuilder);
+ SALOMEDS_UseCaseBuilder(SALOMEDS::UseCaseBuilder_ptr theBuilder);
+ ~SALOMEDS_UseCaseBuilder();
+
+ virtual bool Append(const _PTR(SObject)& theObject);
+ virtual bool Remove(const _PTR(SObject)& theObject);
+ virtual bool AppendTo(const _PTR(SObject)& theFather, _PTR(SObject) theObject);
+ virtual bool InsertBefore(const _PTR(SObject)& theFirst, _PTR(SObject) theNext);
+ virtual bool SetCurrentObject(const _PTR(SObject)& theObject);
+ virtual bool SetRootCurrent();
+ virtual bool HasChildren(const _PTR(SObject)& theObject);
+ virtual bool IsUseCase(const _PTR(SObject)& theObject);
+ virtual bool SetName(const std::string& theName);
+ virtual _PTR(SObject) GetCurrentObject();
+ virtual std::string GetName();
+ virtual _PTR(SObject) AddUseCase(const std::string& theName);
+ virtual _PTR(UseCaseIterator) GetUseCaseIterator(const _PTR(SObject)& anObject);
+
+};
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
// File : SALOMEDS_UseCaseBuilder_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
+using namespace std;
#include "SALOMEDS_UseCaseBuilder_i.hxx"
-#include "SALOMEDS_Study_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
#include "SALOMEDS_UseCaseIterator_i.hxx"
-
-#include <TDF_Label.hxx>
-#include <TDF_Tool.hxx>
-#include <TDF_Data.hxx>
-#include <TDF_Reference.hxx>
-#include <TDF_AttributeList.hxx>
-#include <TDF_ListIteratorOfAttributeList.hxx>
-#include <TDataStd_ChildNodeIterator.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TDF_ChildIterator.hxx>
-
-#include <TDataStd_Integer.hxx>
-#include <TDataStd_Name.hxx>
-#include <Standard_GUID.hxx>
-
-#define USE_CASE_LABEL_TAG 2
-#define USE_CASE_GUID "AA43BB12-D9CD-11d6-945D-0050DA506788"
+#include "SALOMEDS_SObject_i.hxx"
+#include "SALOMEDS.hxx"
#include "utilities.h"
-using namespace std;
-
//============================================================================
/*! Function : constructor
* Purpose :
*/
//============================================================================
-SALOMEDS_UseCaseBuilder_i::SALOMEDS_UseCaseBuilder_i(SALOMEDS_Study_i* theStudy,
- const Handle(TDocStd_Document)& theDocument):
- _doc(theDocument),
- _study(theStudy)
+SALOMEDS_UseCaseBuilder_i::SALOMEDS_UseCaseBuilder_i(const Handle(SALOMEDSImpl_UseCaseBuilder)& theImpl,
+ CORBA::ORB_ptr orb)
{
- if(_doc.IsNull()) return;
-
- TDF_Label aLabel = _doc->Main().Root().FindChild(USE_CASE_LABEL_TAG); //Iterate all use cases
- if(!aLabel.FindAttribute(Standard_GUID(USE_CASE_GUID), _root)) {
- _root = TDataStd_TreeNode::Set(aLabel, Standard_GUID(USE_CASE_GUID));
- }
-
- Handle(TDF_Reference) aRef;
- if(!_root->FindAttribute(TDF_Reference::GetID(), aRef)) {
- aRef = TDF_Reference::Set(_root->Label(), _root->Label());
- }
-
- Handle(TDataStd_Name) aNameAttr;
- if(!aLabel.FindAttribute(TDataStd_Name::GetID(), aNameAttr)) {
- aNameAttr = TDataStd_Name::Set(aLabel, "Use cases");
- }
-
+ _orb = CORBA::ORB::_duplicate(orb);
+ _impl = theImpl;
}
//============================================================================
}
-//============================================================================
-CORBA::ORB_var SALOMEDS_UseCaseBuilder_i::GetORB() const
-{
- return _study->GetORB();
-}
-
-
-//============================================================================
-PortableServer::POA_var SALOMEDS_UseCaseBuilder_i::GetPOA() const
-{
- return _study->GetPOA();
-}
-
-
-//============================================================================
//============================================================================
/*! Function : Append
* Purpose :
//============================================================================
CORBA::Boolean SALOMEDS_UseCaseBuilder_i::Append(SALOMEDS::SObject_ptr theObject)
{
- if(_root.IsNull() || theObject->_is_nil()) return 0;
-
- TDF_Label aLabel;
-
- TDF_Tool::Label(_root->Label().Data(), theObject->GetID(), aLabel);
- if(aLabel.IsNull()) return 0;
-
- Handle(TDataStd_TreeNode) aNode, aCurrentNode;
- aNode = TDataStd_TreeNode::Set(aLabel, _root->ID());
- aNode->Remove();
-
- Handle(TDF_Reference) aRef;
- if(!_root->FindAttribute(TDF_Reference::GetID(), aRef)) {
- aRef = TDF_Reference::Set(_root->Label(), _root->Label());
- }
- TDF_Label aCurrent = aRef->Get();
-
- if(aCurrent.IsNull() || !aCurrent.FindAttribute(_root->ID(), aCurrentNode))
- aCurrentNode = _root;
-
- return aCurrentNode->Append(aNode);
+ SALOMEDS::Locker lock;
+ if(_impl.IsNull() || theObject->_is_nil()) return 0;
+ return _impl->Append(_impl->GetSObject(theObject->GetID()));
}
//============================================================================
//============================================================================
CORBA::Boolean SALOMEDS_UseCaseBuilder_i::Remove(SALOMEDS::SObject_ptr theObject)
{
- if(_root.IsNull() || theObject->_is_nil()) return 0;
-
- TDF_Label aLabel;
- TDF_Tool::Label(_root->Label().Data(), theObject->GetID(), aLabel);
- if(aLabel.IsNull()) return 0;
-
- Handle(TDataStd_TreeNode) aNode;
- if(!aLabel.FindAttribute(_root->ID(), aNode)) return 0;
-
- aNode->Remove();
-
- TDF_AttributeList aList;
- aList.Append(aNode);
-
- Handle(TDF_Reference) aRef;
- if(!_root->FindAttribute(TDF_Reference::GetID(), aRef)) {
- aRef = TDF_Reference::Set(_root->Label(), _root->Label());
- }
- TDF_Label aCurrent = aRef->Get();
-
- TDataStd_ChildNodeIterator aChildItr(aNode, Standard_True);
- for(; aChildItr.More(); aChildItr.Next())
- aList.Append(aChildItr.Value());
-
- TDF_ListIteratorOfAttributeList anIterator(aList);
- for(; anIterator.More(); anIterator.Next()) {
- if(anIterator.Value()->Label() == aCurrent) { //The current node is removed
- aRef->Set(_root->Label()); //Reset the current node to the root
- }
- anIterator.Value()->Label().ForgetAttribute(_root->ID());
- }
-
- return 1;
+ SALOMEDS::Locker lock;
+ if(_impl.IsNull() || theObject->_is_nil()) return 0;
+ return _impl->Remove(_impl->GetSObject(theObject->GetID()));
}
CORBA::Boolean SALOMEDS_UseCaseBuilder_i::AppendTo(SALOMEDS::SObject_ptr theFather,
SALOMEDS::SObject_ptr theObject)
{
- if(_root.IsNull() || theFather->_is_nil() || theObject->_is_nil()) return 0;
-
- TDF_Label aFatherLabel, aLabel;
- Handle(TDataStd_TreeNode) aFather, aNode;
-
- TDF_Tool::Label(_root->Label().Data(), theFather->GetID(), aFatherLabel);
- if(aFatherLabel.IsNull()) return 0;
- if(!aFatherLabel.FindAttribute(_root->ID(), aFather)) return 0;
-
- TDF_Tool::Label(_root->Label().Data(), theObject->GetID(), aLabel);
- if(aLabel.IsNull()) return 0;
- if(!aLabel.FindAttribute(_root->ID(), aNode)) {
- aNode = TDataStd_TreeNode::Set(aLabel, _root->ID());
- }
- else
- aNode->Remove();
-
- return aFather->Append(aNode);
+ SALOMEDS::Locker lock;
+ if(_impl.IsNull() || theFather->_is_nil() || theObject->_is_nil()) return 0;
+ return _impl->AppendTo(_impl->GetSObject(theFather->GetID()), _impl->GetSObject(theObject->GetID()));
}
//============================================================================
CORBA::Boolean SALOMEDS_UseCaseBuilder_i::InsertBefore(SALOMEDS::SObject_ptr theFirst,
SALOMEDS::SObject_ptr theNext)
{
- if(_root.IsNull() || theFirst->_is_nil() || theNext->_is_nil()) return 0;
-
- TDF_Label aFirstLabel, aLabel;
- Handle(TDataStd_TreeNode) aFirstNode, aNode;
-
- TDF_Tool::Label(_root->Label().Data(), theFirst->GetID(), aFirstLabel);
- if(aFirstLabel.IsNull()) return 0;
- if(aFirstLabel.FindAttribute(_root->ID(), aFirstNode)) {
- aFirstNode->Remove();
- aFirstLabel.ForgetAttribute(aFirstNode->ID());
- }
-
- aFirstNode = TDataStd_TreeNode::Set(aFirstLabel, _root->ID());
-
-
- TDF_Tool::Label(_root->Label().Data(), theNext->GetID(), aLabel);
- if(aLabel.IsNull()) return 0;
- if(!aLabel.FindAttribute(_root->ID(), aNode)) return 0;
-
- return aNode->InsertBefore(aFirstNode);
+ SALOMEDS::Locker lock;
+ if(_impl.IsNull() || theFirst->_is_nil() || theNext->_is_nil()) return 0;
+ return _impl->AppendTo(_impl->GetSObject(theFirst->GetID()), _impl->GetSObject(theNext->GetID()));
}
//============================================================================
CORBA::Boolean SALOMEDS_UseCaseBuilder_i::SetCurrentObject(SALOMEDS::SObject_ptr theObject)
{
- if(_root.IsNull() || theObject->_is_nil()) return 0;
-
- TDF_Label aLabel;
- Handle(TDataStd_TreeNode) aNode;
- TDF_Tool::Label(_root->Label().Data(), theObject->GetID(), aLabel);
- if(aLabel.IsNull()) return 0;
- if(!aLabel.FindAttribute(_root->ID(), aNode)) return 0;
-
-
- Handle(TDF_Reference) aRef;
- if(!_root->FindAttribute(TDF_Reference::GetID(), aRef)) {
- aRef = TDF_Reference::Set(_root->Label(), aNode->Label());
- }
-
- aRef->Set(aNode->Label());
-
- return 1;
+ SALOMEDS::Locker lock;
+ if(_impl.IsNull() || theObject->_is_nil()) return 0;
+ return _impl->SetCurrentObject(_impl->GetSObject(theObject->GetID()));
}
//============================================================================
//============================================================================
CORBA::Boolean SALOMEDS_UseCaseBuilder_i::SetRootCurrent()
{
- if(_root.IsNull()) return 0;
-
- Handle(TDF_Reference) aRef;
- if(!_root->FindAttribute(TDF_Reference::GetID(), aRef))
- aRef = TDF_Reference::Set(_root->Label(), _root->Label());
-
- aRef->Set(_root->Label());
- return 1;
+ SALOMEDS::Locker lock;
+ if(_impl.IsNull()) return 0;
+ return _impl->SetRootCurrent();
}
//============================================================================
//============================================================================
CORBA::Boolean SALOMEDS_UseCaseBuilder_i::HasChildren(SALOMEDS::SObject_ptr theObject)
{
- if(_root.IsNull()) return 0;
-
- TDF_Label aLabel;
- if (theObject->_is_nil()) aLabel = _root->Label();
- else TDF_Tool::Label(_root->Label().Data(), theObject->GetID(), aLabel);
- if(aLabel.IsNull()) return 0;
-
- Handle(TDataStd_TreeNode) aNode;
- if(!aLabel.FindAttribute(_root->ID(), aNode)) return 0;
-
- return !(aNode->First().IsNull());
+ SALOMEDS::Locker lock;
+ if(_impl.IsNull()) return 0;
+ return _impl->HasChildren(_impl->GetSObject(theObject->GetID()));
}
//============================================================================
* Purpose :
*/
//============================================================================
-CORBA::Boolean SALOMEDS_UseCaseBuilder_i::SetName(const char* theName) {
- if(_root.IsNull()) return 0;
-
- Handle(TDataStd_Name) aNameAttrib;
- TCollection_ExtendedString aName(const_cast<char*>(theName));
-
- if (!_root->FindAttribute(TDataStd_Name::GetID(), aNameAttrib))
- aNameAttrib = TDataStd_Name::Set(_root->Label(), aName);
- else
- aNameAttrib->Set(aName);
-
- return 1;
+CORBA::Boolean SALOMEDS_UseCaseBuilder_i::SetName(const char* theName)
+{
+ SALOMEDS::Locker lock;
+ if(_impl.IsNull()) return 0;
+ return _impl->SetName((char*)theName);
}
//============================================================================
SALOMEDS::SObject_ptr SALOMEDS_UseCaseBuilder_i::GetCurrentObject()
{
- if(_root.IsNull()) return NULL;
-
- Handle(TDF_Reference) aRef;
- if(!_root->FindAttribute(TDF_Reference::GetID(), aRef)) {
- aRef = TDF_Reference::Set(_root->Label(), _root->Label());
- }
- TDF_Label aCurrent = aRef->Get();
- if(aCurrent.IsNull()) return NULL;
-
- return SALOMEDS_SObject_i::NewRef(_study,aCurrent)._retn();
+ SALOMEDS::Locker lock;
+
+ if(_impl.IsNull()) return NULL;
+ Handle(SALOMEDSImpl_SObject) aSO = _impl->GetCurrentObject();
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
+ return so._retn();
}
//============================================================================
* Purpose :
*/
//============================================================================
-char* SALOMEDS_UseCaseBuilder_i::GetName() {
- CORBA::String_var aString;
- if(_root.IsNull()) return aString._retn();
-
- Handle(TDataStd_Name) aName;
- if (!_root->FindAttribute(TDataStd_Name::GetID(), aName)) return aString._retn();
- aString = CORBA::string_dup(TCollection_AsciiString(aName->Get()).ToCString());
- return aString._retn();
+char* SALOMEDS_UseCaseBuilder_i::GetName()
+{
+ SALOMEDS::Locker lock;
+ return CORBA::string_dup(_impl->GetName().ToCString());
}
//============================================================================
//============================================================================
CORBA::Boolean SALOMEDS_UseCaseBuilder_i::IsUseCase(SALOMEDS::SObject_ptr theObject)
{
- if(theObject->_is_nil()) return false;
- TDF_Label aFather, aLabel;
- TDF_Tool::Label(_doc->GetData(), theObject->GetID(), aLabel);
- aFather = _doc->Main().Root().FindChild(USE_CASE_LABEL_TAG);
- if(aLabel.Father() == aFather) return true;
- return false;
+ SALOMEDS::Locker lock;
+
+ if(_impl.IsNull() || theObject->_is_nil()) return false;
+ return _impl->IsUseCase(_impl->GetSObject(theObject->GetID()));
}
//============================================================================
//============================================================================
SALOMEDS::SObject_ptr SALOMEDS_UseCaseBuilder_i::AddUseCase(const char* theName)
{
- Standard_GUID aBasicGUID(USE_CASE_GUID);
-
- //Create a use cases structure if it not exists
-
- Handle(TDataStd_TreeNode) aFatherNode, aNode;
- Handle(TDataStd_Integer) anInteger;
- Handle(TDF_Reference) aRef;
-
- TDF_Label aLabel = _doc->Main().Root().FindChild(USE_CASE_LABEL_TAG);
-
- if(!_root->FindAttribute(TDF_Reference::GetID(), aRef)) {
- aRef = TDF_Reference::Set(aLabel, aLabel);
- }
-
- if(!aRef->Get().FindAttribute(aBasicGUID, aFatherNode)) {
- aFatherNode = TDataStd_TreeNode::Set(aRef->Get());
- }
-
- if(!_root->FindAttribute(TDataStd_Integer::GetID(), anInteger)) {
- anInteger = TDataStd_Integer::Set(aLabel, 0);
- }
-
- //Create a new use case
- anInteger->Set(anInteger->Get()+1);
- TDF_Label aChild = aLabel.FindChild(anInteger->Get());
- aNode = TDataStd_TreeNode::Set(aChild, aBasicGUID);
- aFatherNode->Append(aNode);
- TDataStd_Name::Set(aChild, TCollection_ExtendedString(const_cast<char*>(theName)));
-
- return SALOMEDS_SObject_i::NewRef(_study,aChild)._retn();
+ SALOMEDS::Locker lock;
+
+ if(_impl.IsNull()) return SALOMEDS::SObject::_nil();
+ Handle(SALOMEDSImpl_SObject) aSO = _impl->AddUseCase((char*)theName);
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
+ return so._retn();
}
//============================================================================
* Purpose : Creates a new UseCase iterator, if anObject is null all use cases are iterated
*/
//============================================================================
-SALOMEDS::UseCaseIterator_ptr SALOMEDS_UseCaseBuilder_i::GetUseCaseIterator(SALOMEDS::SObject_ptr anObject)
+SALOMEDS::UseCaseIterator_ptr SALOMEDS_UseCaseBuilder_i::GetUseCaseIterator(SALOMEDS::SObject_ptr theObject)
{
- TDF_Label aLabel;
-
- if(!anObject->_is_nil()) {
- TDF_Tool::Label(_doc->GetData(), anObject->GetID(), aLabel); //Iterate only sub tree in the use case
- }
- else {
- aLabel = _doc->Main().Root().FindChild(USE_CASE_LABEL_TAG); //Iterate all use cases
- }
-
- SALOMEDS_UseCaseIterator_i* aServant = new SALOMEDS_UseCaseIterator_i(_study,aLabel,USE_CASE_GUID,Standard_False);
- return aServant->_this();
+ SALOMEDS::Locker lock;
+
+ if(_impl.IsNull()) return SALOMEDS::UseCaseIterator::_nil();
+ Handle(SALOMEDSImpl_UseCaseIterator) anItr = _impl->GetUseCaseIterator(_impl->GetSObject(theObject->GetID()));
+ SALOMEDS_UseCaseIterator_i* aServant = new SALOMEDS_UseCaseIterator_i(anItr, _orb);
+ SALOMEDS::UseCaseIterator_var anIterator = SALOMEDS::UseCaseIterator::_narrow(aServant->_this());
+ return anIterator._retn();
}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
// File : SALOMEDS_UseCaseBuilder_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
#ifndef __SALOMEDS_USECaseBuilder_I_H__
#define __SALOMEDS_USECaseBuilder_I_H__
+// std C++ headers
+#include <iostream.h>
+
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS)
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+#include <SALOME_GenericObj_i.hh>
// Cascade headers
-#include <TDataStd_TreeNode.hxx>
-#include <TDocStd_Document.hxx>
+#include <Standard_GUID.hxx>
+#include <stdio.h>
-class SALOMEDS_Study_i;
+#include "SALOMEDSImpl_UseCaseIterator.hxx"
+#include "SALOMEDSImpl_UseCaseBuilder.hxx"
-class SALOMEDS_UseCaseBuilder_i: public POA_SALOMEDS::UseCaseBuilder,
- public PortableServer::RefCountServantBase
+class SALOMEDS_UseCaseBuilder_i: public virtual POA_SALOMEDS::UseCaseBuilder,
+ public virtual PortableServer::RefCountServantBase,
+ public virtual SALOME::GenericObj_i
{
- SALOMEDS_UseCaseBuilder_i(); // Not implemented
- void operator=(const SALOMEDS_UseCaseBuilder_i&); // Not implemented
-
private:
- Handle(TDataStd_TreeNode) _root;
- Handle(TDocStd_Document) _doc;
- SALOMEDS_Study_i* _study;
+
+ CORBA::ORB_ptr _orb;
+ Handle(SALOMEDSImpl_UseCaseBuilder) _impl;
public:
- SALOMEDS_UseCaseBuilder_i(SALOMEDS_Study_i* theStudy,
- const Handle(TDocStd_Document)& theDocument);
+
+ //! standard constructor
+ SALOMEDS_UseCaseBuilder_i(const Handle(SALOMEDSImpl_UseCaseBuilder)& theDocument,
+ CORBA::ORB_ptr);
+ //! standard destructor
~SALOMEDS_UseCaseBuilder_i();
- CORBA::ORB_var GetORB() const;
- PortableServer::POA_var GetPOA() const;
-
virtual CORBA::Boolean Append(SALOMEDS::SObject_ptr theObject);
virtual CORBA::Boolean Remove(SALOMEDS::SObject_ptr theObject);
--- /dev/null
+// File : SALOMEDS_UseCaseIterator.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+using namespace std;
+
+#include "SALOMEDS_UseCaseIterator.hxx"
+#include "SALOMEDS_SObject.hxx"
+
+SALOMEDS_UseCaseIterator::SALOMEDS_UseCaseIterator(const Handle(SALOMEDSImpl_UseCaseIterator)& theIterator)
+{
+ _isLocal = true;
+ _local_impl = theIterator;
+ _corba_impl = SALOMEDS::UseCaseIterator::_nil();
+}
+
+SALOMEDS_UseCaseIterator::SALOMEDS_UseCaseIterator(SALOMEDS::UseCaseIterator_ptr theIterator)
+{
+ _isLocal = false;
+ _local_impl = NULL;
+ _corba_impl = SALOMEDS::UseCaseIterator::_duplicate(theIterator);
+}
+
+SALOMEDS_UseCaseIterator::~SALOMEDS_UseCaseIterator()
+{
+ if(!_isLocal) _corba_impl->Destroy();
+}
+
+void SALOMEDS_UseCaseIterator::Init(bool theAllLevels)
+{
+ if(_isLocal) _local_impl->Init(theAllLevels);
+ else _corba_impl->Init(theAllLevels);
+}
+
+bool SALOMEDS_UseCaseIterator::More()
+{
+ bool ret;
+ if(_isLocal) ret = _local_impl->More();
+ else ret = _corba_impl->More();
+ return ret;
+}
+
+void SALOMEDS_UseCaseIterator::Next()
+{
+ if(_isLocal) _local_impl->Next();
+ else _corba_impl->Next();
+}
+
+_PTR(SObject) SALOMEDS_UseCaseIterator::Value()
+{
+ SALOMEDS_SObject* aSO;
+ if(_isLocal) aSO = new SALOMEDS_SObject(_local_impl->Value());
+ else aSO = new SALOMEDS_SObject(_corba_impl->Value());
+ return _PTR(SObject)(aSO);
+}
--- /dev/null
+// File : SALOMEDS_UseCaseIterator.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef __SALOMEDS_USECASEITERATOR_H__
+#define __SALOMEDS_USECASEITERATOR_H__
+
+#include "SALOMEDSClient_UseCaseIterator.hxx"
+#include "SALOMEDSClient_SObject.hxx"
+#include "SALOMEDSImpl_UseCaseIterator.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+
+class SALOMEDS_UseCaseIterator: public SALOMEDSClient_UseCaseIterator
+{
+private:
+ bool _isLocal;
+ Handle(SALOMEDSImpl_UseCaseIterator) _local_impl;
+ SALOMEDS::UseCaseIterator_var _corba_impl;
+
+public:
+
+ SALOMEDS_UseCaseIterator(const Handle(SALOMEDSImpl_UseCaseIterator)& theIterator);
+ SALOMEDS_UseCaseIterator(SALOMEDS::UseCaseIterator_ptr theIterator);
+ ~SALOMEDS_UseCaseIterator();
+
+ virtual void Init(bool theAllLevels);
+ virtual bool More();
+ virtual void Next();
+ virtual _PTR(SObject) Value();
+};
+
+#endif
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
// File : SALOMEDS_UseCaseIterator_i.cxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
using namespace std;
#include "SALOMEDS_UseCaseIterator_i.hxx"
#include "SALOMEDS_SObject_i.hxx"
-#include "utilities.h"
-
+#include "SALOMEDS.hxx"
+#include "SALOMEDSImpl_SObject.hxx"
+#include "utilities.h"
//============================================================================
/*! Function : constructor
* Purpose :
*/
//============================================================================
-SALOMEDS_UseCaseIterator_i::SALOMEDS_UseCaseIterator_i(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel,
- const Standard_GUID& theGUID,
- const Standard_Boolean theIsAllLevels):
- _guid(theGUID),
- _levels(theIsAllLevels),
- _study(theStudy)
+SALOMEDS_UseCaseIterator_i::SALOMEDS_UseCaseIterator_i(const Handle(SALOMEDSImpl_UseCaseIterator)& theImpl,
+ CORBA::ORB_ptr orb)
{
- if(theLabel.FindAttribute(_guid, _node)) {
- _it.Initialize (_node, _levels);
- }
+ _orb = CORBA::ORB::_duplicate(orb);
+ _impl = theImpl;
}
//============================================================================
//============================================================================
void SALOMEDS_UseCaseIterator_i::Init(CORBA::Boolean allLevels)
{
- _it.Initialize (_node, allLevels);
+ SALOMEDS::Locker lock;
+ _impl->Init(allLevels);
}
//============================================================================
//============================================================================
CORBA::Boolean SALOMEDS_UseCaseIterator_i::More()
{
- return _it.More();
+ SALOMEDS::Locker lock;
+ return _impl->More();
}
- //============================================================================
+//============================================================================
/*! Function : Next
*
*/
//============================================================================
void SALOMEDS_UseCaseIterator_i::Next()
{
- _it.Next();
+ SALOMEDS::Locker lock;
+ _impl->Next();
}
* Purpose :
*/
//============================================================================
-
SALOMEDS::SObject_ptr SALOMEDS_UseCaseIterator_i::Value()
{
- TDF_Label L = _it.Value()->Label();
- return SALOMEDS_SObject_i::NewRef(_study,L)._retn();
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_SObject) aSO = _impl->Value();
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
+ return so._retn();
}
-// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
// File : SALOMEDS_UseCaseIterator_i.hxx
-// Author : Yves FRICAUD
+// Author : Sergey RUIN
// Module : SALOME
#ifndef __SALOMEDS_USECASEITERATOR_I_H__
#define __SALOMEDS_USECASEITERATOR_I_H__
+// std C++ headers
+#include <iostream.h>
+
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS)
+#include <SALOME_GenericObj_i.hh>
-// Cascade headers
-#include <TDataStd_ChildNodeIterator.hxx>
-#include <TDataStd_TreeNode.hxx>
-#include <Standard_GUID.hxx>
-
-class SALOMEDS_Study_i;
+#include "SALOMEDSImpl_UseCaseIterator.hxx"
-class SALOMEDS_UseCaseIterator_i: public POA_SALOMEDS::UseCaseIterator,
- public PortableServer::RefCountServantBase
+class SALOMEDS_UseCaseIterator_i: public virtual POA_SALOMEDS::UseCaseIterator,
+ public virtual PortableServer::RefCountServantBase,
+ public virtual SALOME::GenericObj_i
{
- SALOMEDS_UseCaseIterator_i(); // Not implemented
- void operator=(const SALOMEDS_UseCaseIterator_i&); // Not implemented
-
private:
- Standard_GUID _guid;
- Standard_Boolean _levels;
- Handle(TDataStd_TreeNode) _node;
- TDataStd_ChildNodeIterator _it;
- SALOMEDS_Study_i* _study;
+ CORBA::ORB_ptr _orb;
+ Handle(SALOMEDSImpl_UseCaseIterator) _impl;
public:
+
//! standard constructor
- SALOMEDS_UseCaseIterator_i(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel,
- const Standard_GUID& theGUID,
- const Standard_Boolean theIsAllLevels);
+ SALOMEDS_UseCaseIterator_i(const Handle(SALOMEDSImpl_UseCaseIterator)& theImpl,
+ CORBA::ORB_ptr);
//! standard destructor
~SALOMEDS_UseCaseIterator_i();
virtual void Next();
virtual SALOMEDS::SObject_ptr Value();
};
-
-
#endif
--- /dev/null
+// SALOME Utils : general SALOME's definitions and tools
+//
+// Copyright (C) 2003 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 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
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+// File: Utils_Mutex.cxx
+// Author: Sergey ANIKIN
+// Module : SALOME
+// $Header$
+
+
+#include <Utils_Mutex.hxx>
+
+Utils_Mutex::Utils_Mutex()
+: myCount( 0 )
+{
+ pthread_mutex_init( &myMutex, 0 );
+ pthread_mutex_init( &myHelperMutex, 0 );
+}
+
+Utils_Mutex::~Utils_Mutex()
+{
+ pthread_mutex_destroy( &myHelperMutex );
+ pthread_mutex_destroy( &myMutex );
+}
+
+void Utils_Mutex::lock()
+{
+ pthread_mutex_lock( &myHelperMutex );
+
+ if ( myCount > 0 && myThread == pthread_self() ) {
+ myCount++;
+ }
+ else {
+ pthread_mutex_unlock( &myHelperMutex );
+ pthread_mutex_lock( &myMutex );
+ pthread_mutex_lock( &myHelperMutex );
+ myCount = 1;
+ myThread = pthread_self();
+ }
+
+ pthread_mutex_unlock( &myHelperMutex );
+}
+
+void Utils_Mutex::unlock()
+{
+ pthread_mutex_lock( &myHelperMutex );
+
+ if ( myThread == pthread_self() ) {
+ if ( myCount && (--myCount) < 1 ) {
+ myCount = 0;
+ pthread_mutex_unlock( &myMutex );
+ }
+ }
+
+ pthread_mutex_unlock( &myHelperMutex );
+}
+
+Utils_Locker::Utils_Locker( Utils_Mutex* mutex )
+: myMutex( mutex )
+{
+ if ( myMutex ) myMutex->lock();
+}
+
+Utils_Locker::~Utils_Locker()
+{
+ if ( myMutex ) myMutex->unlock();
+}
--- /dev/null
+// SALOME Utils : general SALOME's definitions and tools
+//
+// Copyright (C) 2003 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 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
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+// File: Utils_Mutex.hxx
+// Author: Sergey ANIKIN
+// Module : SALOME
+// $Header$
+
+
+#ifndef Utils_Mutex_HeaderFile
+#define Utils_Mutex_HeaderFile
+
+#include <pthread.h>
+
+class Utils_Mutex
+{
+public:
+ Utils_Mutex();
+ ~Utils_Mutex();
+
+ void lock();
+ void unlock();
+
+private:
+ pthread_mutex_t myMutex;
+ pthread_mutex_t myHelperMutex;
+ pthread_t myThread;
+ int myCount;
+};
+
+class Utils_Locker
+{
+public:
+ Utils_Locker( Utils_Mutex* );
+ virtual ~Utils_Locker();
+
+private:
+ Utils_Mutex* myMutex;
+};
+
+#endif