1 // Created on: 1999-06-11
2 // Created by: Sergey RUIN
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <TPrsStd_DriverTable.ixx>
19 #include <TPrsStd_DataMapOfGUIDDriver.hxx>
21 #include <TPrsStd_Driver.hxx>
22 #include <TPrsStd_AxisDriver.hxx>
23 #include <TPrsStd_ConstraintDriver.hxx>
24 #include <TPrsStd_GeometryDriver.hxx>
25 #include <TPrsStd_NamedShapeDriver.hxx>
26 #include <TPrsStd_PlaneDriver.hxx>
27 #include <TPrsStd_PointDriver.hxx>
29 #include <TDataXtd_Axis.hxx>
30 #include <TDataXtd_Constraint.hxx>
31 #include <TDataXtd_Geometry.hxx>
32 #include <TNaming_NamedShape.hxx>
33 #include <TDataXtd_Plane.hxx>
34 #include <TDataXtd_Point.hxx>
37 static Handle(TPrsStd_DriverTable) drivertable;
39 //=======================================================================
42 //=======================================================================
44 Handle(TPrsStd_DriverTable) TPrsStd_DriverTable::Get()
46 if ( drivertable.IsNull() )
48 drivertable = new TPrsStd_DriverTable;
50 cout << "The new TPrsStd_DriverTable was created" << endl;
56 //=======================================================================
57 //function : TPrsStd_DriverTable
59 //=======================================================================
61 TPrsStd_DriverTable::TPrsStd_DriverTable()
63 InitStandardDrivers();
66 //=======================================================================
67 //function : InitStandardDrivers
68 //purpose : Adds standard drivers to the DriverTable
69 //=======================================================================
71 void TPrsStd_DriverTable::InitStandardDrivers()
73 if (myDrivers.Extent() > 0) return;
75 Handle(TPrsStd_AxisDriver) axisdrv = new TPrsStd_AxisDriver;
76 Handle(TPrsStd_ConstraintDriver) cnstrdrv = new TPrsStd_ConstraintDriver;
77 Handle(TPrsStd_GeometryDriver) geomdrv = new TPrsStd_GeometryDriver ;
78 Handle(TPrsStd_NamedShapeDriver) nshapedrv = new TPrsStd_NamedShapeDriver;
79 Handle(TPrsStd_PlaneDriver) planedrv = new TPrsStd_PlaneDriver;
80 Handle(TPrsStd_PointDriver) pointdrv = new TPrsStd_PointDriver;
82 myDrivers.Bind(TDataXtd_Axis::GetID(), axisdrv);
83 myDrivers.Bind(TDataXtd_Constraint::GetID(), cnstrdrv);
84 myDrivers.Bind(TDataXtd_Geometry::GetID(), geomdrv);
85 myDrivers.Bind(TNaming_NamedShape::GetID(), nshapedrv);
86 myDrivers.Bind(TDataXtd_Plane::GetID(), planedrv);
87 myDrivers.Bind(TDataXtd_Point::GetID(), pointdrv);
90 //=======================================================================
91 //function : AddDriver
92 //purpose : Adds a driver to the DriverTable
93 //=======================================================================
95 Standard_Boolean TPrsStd_DriverTable::AddDriver(const Standard_GUID& guid,
96 const Handle(TPrsStd_Driver)& driver)
98 return myDrivers.Bind(guid,driver);
101 //=======================================================================
102 //function : FindDriver
103 //purpose : Returns the driver if find
104 //=======================================================================
106 Standard_Boolean TPrsStd_DriverTable::FindDriver(const Standard_GUID& guid,
107 Handle(TPrsStd_Driver)& driver) const
109 if (myDrivers.IsBound(guid))
111 driver = myDrivers.Find(guid);
112 return Standard_True;
114 return Standard_False;
117 //=======================================================================
118 //function : RemoveDriver
119 //purpose : Removes a driver from the DriverTable
120 //=======================================================================
122 Standard_Boolean TPrsStd_DriverTable::RemoveDriver(const Standard_GUID& guid)
124 return myDrivers.UnBind(guid);
127 //=======================================================================
129 //purpose : Removes all drivers
130 //=======================================================================
132 void TPrsStd_DriverTable::Clear()