Back to index

salome-geom  6.5.0
GEOM_Client.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 //  File   : GEOM_Client.hxx
00023 //  Author : Yves FRICAUD
00024 //  Module : GEOM
00025 
00026 #ifndef _GEOM_Client_HeaderFile
00027 #define _GEOM_Client_HeaderFile
00028 
00029 #include <SALOMEconfig.h>
00030 #include CORBA_SERVER_HEADER(GEOM_Gen)
00031 
00032 #ifdef HAVE_FINITE
00033 #undef HAVE_FINITE // E.A. fix a warning about redefinition of HAVE_FINITE in re-inclusion of Standard_values.h
00034 #endif
00035 #ifndef _TColStd_SequenceOfAsciiString_HeaderFile
00036 #include <TColStd_SequenceOfAsciiString.hxx>
00037 #endif
00038 #ifndef _TopTools_SequenceOfShape_HeaderFile
00039 #include <TopTools_SequenceOfShape.hxx>
00040 #endif
00041 #ifndef _Standard_Integer_HeaderFile
00042 #include <Standard_Integer.hxx>
00043 #endif
00044 
00045 class TCollection_AsciiString;
00046 class TopoDS_Shape;
00047 
00048 #ifndef _Standard_HeaderFile
00049 #include <Standard.hxx>
00050 #endif
00051 #ifndef _Standard_Macro_HeaderFile
00052 #include <Standard_Macro.hxx>
00053 #endif
00054 
00055 #ifdef WNT
00056  #if defined GEOMCLIENT_EXPORTS || defined GEOMClient_EXPORTS
00057   #if defined WIN32
00058    #define GEOMCLIENT_EXPORT __declspec( dllexport )
00059   #else
00060    #define GEOMCLIENT_EXPORT
00061   #endif
00062  #else
00063   #if defined WIN32
00064    #define GEOMCLIENT_EXPORT __declspec( dllimport )
00065   #else
00066    #define GEOMCLIENT_EXPORT
00067   #endif
00068  #endif
00069 #else
00070  #define GEOMCLIENT_EXPORT
00071 #endif
00072 
00073 #include <TCollection_AsciiString.hxx>
00074 #include <TopoDS_Shape.hxx>
00075 #include <map>
00076 #include <vector>
00077 
00078 /*
00079  * if define SINGLE_CLIENT is not commented, the method get_client always returns the same GEOM_Client object (singleton object)
00080  * and the SHAPE_READER macro can be used to define an object that is always this singleton object
00081  * if define SINGLE_CLIENT is commented, we get the old way to define the GEOM_Client objects : get_client returns a new object
00082  * and the SHAPE_READER macro defines also a new object
00083  */
00084 #define SINGLE_CLIENT
00085 
00086 //=====================================================================
00087 // GEOM_Client : class definition
00088 //=====================================================================
00089 class GEOMCLIENT_EXPORT GEOM_Client  {
00090 
00091  public:
00092 
00093   inline void* operator new(size_t,void* anAddress)
00094   {
00095     return anAddress;
00096   }
00097   inline void* operator new(size_t size)
00098   {
00099     return Standard::Allocate(size);
00100   }
00101   inline void  operator delete(void *anAddress)
00102   {
00103     if (anAddress) Standard::Free((Standard_Address&)anAddress);
00104   }
00105   // Methods PUBLIC
00106   //
00107   //Standard_EXPORT
00108   GEOM_Client();
00109   //Standard_EXPORT
00110   GEOM_Client(Engines::Container_ptr client);
00111   //Standard_EXPORT
00112   GEOM_Client(const GEOM_Client& client);
00113   //Standard_EXPORT
00114   Standard_Boolean Find( const TCollection_AsciiString& IOR, TopoDS_Shape& S ) ;
00115   //Standard_EXPORT
00116   Standard_Boolean Find( const TopoDS_Shape& S, TCollection_AsciiString& IOR ) ;
00117   //Standard_EXPORT
00118   void Bind( const TCollection_AsciiString& IOR, const TopoDS_Shape& S ) ;
00119   //Standard_EXPORT
00120   TopoDS_Shape GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape );
00121   //Standard_EXPORT
00122   void RemoveShapeFromBuffer( const TCollection_AsciiString& IOR ) ;
00123   //Standard_EXPORT
00124   void ClearClientBuffer() ;
00125   //Standard_EXPORT
00126   unsigned int BufferLength() ;
00127   TopoDS_Shape Load( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape);
00128 #ifdef SINGLE_CLIENT
00129   static GEOM_Client& get_client();
00130 #else
00131   static GEOM_Client get_client();
00132 #endif
00133 
00134  private:
00135   // Fields PRIVATE
00136   //
00137   std::map< TCollection_AsciiString , std::vector<TopoDS_Shape> > _mySubShapes;
00138   std::map< TCollection_AsciiString , TopoDS_Shape > myShapesMap;
00139   long  pid_client;
00140 };
00141 
00142 #ifdef SINGLE_CLIENT
00143 #define SHAPE_READER(obj) GEOM_Client& obj=GEOM_Client::get_client()
00144 #else
00145 #define SHAPE_READER(obj) GEOM_Client obj
00146 #endif
00147 
00148 #endif