Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
GEOM_Client.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File : GEOM_Client.hxx
23 // Author : Yves FRICAUD
24 // Module : GEOM
25 
26 #ifndef _GEOM_Client_HeaderFile
27 #define _GEOM_Client_HeaderFile
28 
29 #include <SALOMEconfig.h>
30 #include CORBA_SERVER_HEADER(GEOM_Gen)
31 
32 #ifdef HAVE_FINITE
33 #undef HAVE_FINITE // E.A. fix a warning about redefinition of HAVE_FINITE in re-inclusion of Standard_values.h
34 #endif
35 #ifndef _TColStd_SequenceOfAsciiString_HeaderFile
36 #include <TColStd_SequenceOfAsciiString.hxx>
37 #endif
38 #ifndef _TopTools_SequenceOfShape_HeaderFile
39 #include <TopTools_SequenceOfShape.hxx>
40 #endif
41 #ifndef _Standard_Integer_HeaderFile
42 #include <Standard_Integer.hxx>
43 #endif
44 
45 class TCollection_AsciiString;
46 class TopoDS_Shape;
47 
48 #ifndef _Standard_HeaderFile
49 #include <Standard.hxx>
50 #endif
51 #ifndef _Standard_Macro_HeaderFile
52 #include <Standard_Macro.hxx>
53 #endif
54 
55 #ifdef WIN32
56  #if defined GEOMCLIENT_EXPORTS || defined GEOMClient_EXPORTS
57  #define GEOMCLIENT_EXPORT __declspec( dllexport )
58  #else
59  #define GEOMCLIENT_EXPORT __declspec( dllimport )
60  #endif
61 #else
62  #define GEOMCLIENT_EXPORT
63 #endif
64 
65 #include <TCollection_AsciiString.hxx>
66 #include <TopoDS_Shape.hxx>
67 #include <map>
68 #include <vector>
69 
70 /*
71  * if define SINGLE_CLIENT is not commented, the method get_client always returns the same GEOM_Client object (singleton object)
72  * and the SHAPE_READER macro can be used to define an object that is always this singleton object
73  * if define SINGLE_CLIENT is commented, we get the old way to define the GEOM_Client objects : get_client returns a new object
74  * and the SHAPE_READER macro defines also a new object
75  */
76 #define SINGLE_CLIENT
77 
78 //=====================================================================
79 // GEOM_Client : class definition
80 //=====================================================================
82 
83  public:
84 
85  inline void* operator new(size_t,void* anAddress)
86  {
87  return anAddress;
88  }
89  inline void* operator new(size_t size)
90  {
91  return Standard::Allocate(size);
92  }
93  inline void operator delete(void *anAddress)
94  {
95  if (anAddress) Standard::Free((Standard_Address&)anAddress);
96  }
97  // Methods PUBLIC
98  //
99  //Standard_EXPORT
100  GEOM_Client();
101  //Standard_EXPORT
102  GEOM_Client(Engines::Container_ptr client);
103  //Standard_EXPORT
104  GEOM_Client(const GEOM_Client& client);
105  //Standard_EXPORT
106  Standard_Boolean Find( const TCollection_AsciiString& IOR, TopoDS_Shape& S ) ;
107  //Standard_EXPORT
108  Standard_Boolean Find( const TopoDS_Shape& S, TCollection_AsciiString& IOR ) ;
109  //Standard_EXPORT
110  void Bind( const TCollection_AsciiString& IOR, const TopoDS_Shape& S ) ;
111  //Standard_EXPORT
112  TopoDS_Shape GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape );
113  //Standard_EXPORT
114  void RemoveShapeFromBuffer( const TCollection_AsciiString& IOR ) ;
115  //Standard_EXPORT
116  void ClearClientBuffer() ;
117  //Standard_EXPORT
118  unsigned int BufferLength() ;
119  TopoDS_Shape Load( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape);
120 #ifdef SINGLE_CLIENT
121  static GEOM_Client& get_client();
122 #else
123  static GEOM_Client get_client();
124 #endif
125 
126  private:
127  // Fields PRIVATE
128  //
129  std::map< TCollection_AsciiString , std::vector<TopoDS_Shape> > _mySubShapes;
130  std::map< TCollection_AsciiString , TopoDS_Shape > myShapesMap;
132 };
133 
134 #ifdef SINGLE_CLIENT
135 #define SHAPE_READER(obj) GEOM_Client& obj=GEOM_Client::get_client()
136 #else
137 #define SHAPE_READER(obj) GEOM_Client obj
138 #endif
139 
140 #endif