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.
18 #include <Standard_GUID.hxx>
19 #include <Standard_Type.hxx>
20 #include <TDataXtd_Axis.hxx>
21 #include <TDataXtd_Constraint.hxx>
22 #include <TDataXtd_Geometry.hxx>
23 #include <TDataXtd_Plane.hxx>
24 #include <TDataXtd_Point.hxx>
25 #include <TNaming_NamedShape.hxx>
26 #include <TPrsStd_AxisDriver.hxx>
27 #include <TPrsStd_ConstraintDriver.hxx>
28 #include <TPrsStd_DataMapOfGUIDDriver.hxx>
29 #include <TPrsStd_Driver.hxx>
30 #include <TPrsStd_DriverTable.hxx>
31 #include <TPrsStd_GeometryDriver.hxx>
32 #include <TPrsStd_NamedShapeDriver.hxx>
33 #include <TPrsStd_PlaneDriver.hxx>
34 #include <TPrsStd_PointDriver.hxx>
36 IMPLEMENT_STANDARD_RTTIEXT(TPrsStd_DriverTable,MMgt_TShared)
38 static Handle(TPrsStd_DriverTable) drivertable;
40 //=======================================================================
43 //=======================================================================
45 Handle(TPrsStd_DriverTable) TPrsStd_DriverTable::Get()
47 if ( drivertable.IsNull() )
49 drivertable = new TPrsStd_DriverTable;
51 cout << "The new TPrsStd_DriverTable was created" << endl;
57 //=======================================================================
58 //function : TPrsStd_DriverTable
60 //=======================================================================
62 TPrsStd_DriverTable::TPrsStd_DriverTable()
64 InitStandardDrivers();
67 //=======================================================================
68 //function : InitStandardDrivers
69 //purpose : Adds standard drivers to the DriverTable
70 //=======================================================================
72 void TPrsStd_DriverTable::InitStandardDrivers()
74 if (myDrivers.Extent() > 0) return;
76 Handle(TPrsStd_AxisDriver) axisdrv = new TPrsStd_AxisDriver;
77 Handle(TPrsStd_ConstraintDriver) cnstrdrv = new TPrsStd_ConstraintDriver;
78 Handle(TPrsStd_GeometryDriver) geomdrv = new TPrsStd_GeometryDriver ;
79 Handle(TPrsStd_NamedShapeDriver) nshapedrv = new TPrsStd_NamedShapeDriver;
80 Handle(TPrsStd_PlaneDriver) planedrv = new TPrsStd_PlaneDriver;
81 Handle(TPrsStd_PointDriver) pointdrv = new TPrsStd_PointDriver;
83 myDrivers.Bind(TDataXtd_Axis::GetID(), axisdrv);
84 myDrivers.Bind(TDataXtd_Constraint::GetID(), cnstrdrv);
85 myDrivers.Bind(TDataXtd_Geometry::GetID(), geomdrv);
86 myDrivers.Bind(TNaming_NamedShape::GetID(), nshapedrv);
87 myDrivers.Bind(TDataXtd_Plane::GetID(), planedrv);
88 myDrivers.Bind(TDataXtd_Point::GetID(), pointdrv);
91 //=======================================================================
92 //function : AddDriver
93 //purpose : Adds a driver to the DriverTable
94 //=======================================================================
96 Standard_Boolean TPrsStd_DriverTable::AddDriver(const Standard_GUID& guid,
97 const Handle(TPrsStd_Driver)& driver)
99 return myDrivers.Bind(guid,driver);
102 //=======================================================================
103 //function : FindDriver
104 //purpose : Returns the driver if find
105 //=======================================================================
107 Standard_Boolean TPrsStd_DriverTable::FindDriver(const Standard_GUID& guid,
108 Handle(TPrsStd_Driver)& driver) const
110 if (myDrivers.IsBound(guid))
112 driver = myDrivers.Find(guid);
113 return Standard_True;
115 return Standard_False;
118 //=======================================================================
119 //function : RemoveDriver
120 //purpose : Removes a driver from the DriverTable
121 //=======================================================================
123 Standard_Boolean TPrsStd_DriverTable::RemoveDriver(const Standard_GUID& guid)
125 return myDrivers.UnBind(guid);
128 //=======================================================================
130 //purpose : Removes all drivers
131 //=======================================================================
133 void TPrsStd_DriverTable::Clear()