geom/src/GEOMClient/GEOM_Client.hxx

141 lines
4.3 KiB
C++
Raw Normal View History

2014-02-18 12:44:41 +06:00
// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
// 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
2014-02-18 12:44:41 +06:00
// version 2.1 of the License, or (at your option) any later version.
2003-07-09 20:33:44 +06:00
//
2012-08-09 13:58:02 +06:00
// 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.
2003-07-09 20:33:44 +06:00
//
2012-08-09 13:58:02 +06:00
// 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
2003-07-09 20:33:44 +06:00
//
2012-08-09 13:58:02 +06:00
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
2003-07-09 20:33:44 +06:00
//
// File : GEOM_Client.hxx
// Author : Yves FRICAUD
// Module : GEOM
2012-08-09 13:58:02 +06:00
2003-05-12 21:09:12 +06:00
#ifndef _GEOM_Client_HeaderFile
#define _GEOM_Client_HeaderFile
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Gen)
2012-08-09 13:58:02 +06:00
#ifdef HAVE_FINITE
#undef HAVE_FINITE // E.A. fix a warning about redefinition of HAVE_FINITE in re-inclusion of Standard_values.h
#endif
2003-05-12 21:09:12 +06:00
#ifndef _TColStd_SequenceOfAsciiString_HeaderFile
#include <TColStd_SequenceOfAsciiString.hxx>
#endif
#ifndef _TopTools_SequenceOfShape_HeaderFile
#include <TopTools_SequenceOfShape.hxx>
#endif
#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#endif
2012-08-09 13:58:02 +06:00
2003-05-12 21:09:12 +06:00
class TCollection_AsciiString;
class TopoDS_Shape;
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
#ifdef WIN32
#if defined GEOMCLIENT_EXPORTS || defined GEOMClient_EXPORTS
#define GEOMCLIENT_EXPORT __declspec( dllexport )
#else
#define GEOMCLIENT_EXPORT __declspec( dllimport )
#endif
2005-08-19 17:51:38 +06:00
#else
#define GEOMCLIENT_EXPORT
2005-08-19 17:51:38 +06:00
#endif
2003-05-12 21:09:12 +06:00
2012-08-09 13:58:02 +06:00
#include <TCollection_AsciiString.hxx>
#include <TopoDS_Shape.hxx>
#include <map>
#include <vector>
/*
* if define SINGLE_CLIENT is not commented, the method get_client always returns the same GEOM_Client object (singleton object)
* and the SHAPE_READER macro can be used to define an object that is always this singleton object
* if define SINGLE_CLIENT is commented, we get the old way to define the GEOM_Client objects : get_client returns a new object
* and the SHAPE_READER macro defines also a new object
*/
#define SINGLE_CLIENT
2003-05-12 21:09:12 +06:00
//=====================================================================
// GEOM_Client : class definition
//=====================================================================
class GEOMCLIENT_EXPORT GEOM_Client {
2003-05-12 21:09:12 +06:00
2012-08-09 13:58:02 +06:00
public:
inline void* operator new(size_t,void* anAddress)
2003-05-12 21:09:12 +06:00
{
return anAddress;
}
2012-08-09 13:58:02 +06:00
inline void* operator new(size_t size)
{
return Standard::Allocate(size);
2003-05-12 21:09:12 +06:00
}
2012-08-09 13:58:02 +06:00
inline void operator delete(void *anAddress)
{
if (anAddress) Standard::Free((Standard_Address&)anAddress);
2003-05-12 21:09:12 +06:00
}
// Methods PUBLIC
2012-08-09 13:58:02 +06:00
//
//Standard_EXPORT
2005-08-19 17:51:38 +06:00
GEOM_Client();
2012-08-09 13:58:02 +06:00
//Standard_EXPORT
2005-08-19 17:51:38 +06:00
GEOM_Client(Engines::Container_ptr client);
2012-08-09 13:58:02 +06:00
//Standard_EXPORT
GEOM_Client(const GEOM_Client& client);
//Standard_EXPORT
Standard_Boolean Find( const TCollection_AsciiString& IOR, TopoDS_Shape& S ) ;
//Standard_EXPORT
Standard_Boolean Find( const TopoDS_Shape& S, TCollection_AsciiString& IOR ) ;
//Standard_EXPORT
2005-08-19 17:51:38 +06:00
void Bind( const TCollection_AsciiString& IOR, const TopoDS_Shape& S ) ;
2012-08-09 13:58:02 +06:00
//Standard_EXPORT
2005-08-19 17:51:38 +06:00
TopoDS_Shape GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape );
2012-08-09 13:58:02 +06:00
//Standard_EXPORT
2005-08-19 17:51:38 +06:00
void RemoveShapeFromBuffer( const TCollection_AsciiString& IOR ) ;
2012-08-09 13:58:02 +06:00
//Standard_EXPORT
2005-08-19 17:51:38 +06:00
void ClearClientBuffer() ;
2012-08-09 13:58:02 +06:00
//Standard_EXPORT
2005-08-19 17:51:38 +06:00
unsigned int BufferLength() ;
2004-12-01 15:39:14 +05:00
TopoDS_Shape Load( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape);
2012-08-09 13:58:02 +06:00
#ifdef SINGLE_CLIENT
static GEOM_Client& get_client();
#else
static GEOM_Client get_client();
#endif
2003-05-12 21:09:12 +06:00
2012-08-09 13:58:02 +06:00
private:
2003-05-12 21:09:12 +06:00
// Fields PRIVATE
//
2012-08-09 13:58:02 +06:00
std::map< TCollection_AsciiString , std::vector<TopoDS_Shape> > _mySubShapes;
std::map< TCollection_AsciiString , TopoDS_Shape > myShapesMap;
2004-03-26 20:09:49 +05:00
long pid_client;
2003-05-12 21:09:12 +06:00
};
2012-08-09 13:58:02 +06:00
#ifdef SINGLE_CLIENT
#define SHAPE_READER(obj) GEOM_Client& obj=GEOM_Client::get_client()
#else
#define SHAPE_READER(obj) GEOM_Client obj
#endif
2003-05-12 21:09:12 +06:00
#endif