0023024: Update headers of OCCT files
[occt.git] / src / TPrsStd / TPrsStd_DriverTable.cxx
1 // Created on: 1999-06-11
2 // Created by: Sergey RUIN
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22
23 #include <TPrsStd_DriverTable.ixx>
24
25 #include <TPrsStd_DataMapOfGUIDDriver.hxx>
26
27 #include <TPrsStd_Driver.hxx>
28 #include <TPrsStd_AxisDriver.hxx>
29 #include <TPrsStd_ConstraintDriver.hxx>
30 #include <TPrsStd_GeometryDriver.hxx>
31 #include <TPrsStd_NamedShapeDriver.hxx>
32 #include <TPrsStd_PlaneDriver.hxx>
33 #include <TPrsStd_PointDriver.hxx>
34
35 #include <TDataXtd_Axis.hxx>
36 #include <TDataXtd_Constraint.hxx>
37 #include <TDataXtd_Geometry.hxx>
38 #include <TNaming_NamedShape.hxx>
39 #include <TDataXtd_Plane.hxx>
40 #include <TDataXtd_Point.hxx>
41
42
43 static Handle(TPrsStd_DriverTable) drivertable;
44
45 //=======================================================================
46 //function : Get
47 //purpose  : 
48 //=======================================================================
49
50 Handle(TPrsStd_DriverTable) TPrsStd_DriverTable::Get()
51 {
52   if ( drivertable.IsNull() )
53   {
54     drivertable = new TPrsStd_DriverTable;
55 #ifdef DEB
56     cout << "The new TPrsStd_DriverTable was created" << endl;
57 #endif
58   }
59   return drivertable;
60 }
61
62 //=======================================================================
63 //function : TPrsStd_DriverTable
64 //purpose  : 
65 //=======================================================================
66
67 TPrsStd_DriverTable::TPrsStd_DriverTable()
68 {
69   InitStandardDrivers();
70 }
71
72 //=======================================================================
73 //function : InitStandardDrivers
74 //purpose  : Adds standard drivers to the DriverTable
75 //=======================================================================
76
77 void TPrsStd_DriverTable::InitStandardDrivers() 
78 {
79   if (myDrivers.Extent() > 0) return;
80
81   Handle(TPrsStd_AxisDriver) axisdrv = new TPrsStd_AxisDriver;
82   Handle(TPrsStd_ConstraintDriver) cnstrdrv = new TPrsStd_ConstraintDriver;
83   Handle(TPrsStd_GeometryDriver) geomdrv = new TPrsStd_GeometryDriver ;
84   Handle(TPrsStd_NamedShapeDriver) nshapedrv = new TPrsStd_NamedShapeDriver;
85   Handle(TPrsStd_PlaneDriver) planedrv = new TPrsStd_PlaneDriver;
86   Handle(TPrsStd_PointDriver) pointdrv = new TPrsStd_PointDriver;
87
88   myDrivers.Bind(TDataXtd_Axis::GetID(), axisdrv);
89   myDrivers.Bind(TDataXtd_Constraint::GetID(), cnstrdrv);
90   myDrivers.Bind(TDataXtd_Geometry::GetID(), geomdrv);
91   myDrivers.Bind(TNaming_NamedShape::GetID(), nshapedrv);
92   myDrivers.Bind(TDataXtd_Plane::GetID(), planedrv);
93   myDrivers.Bind(TDataXtd_Point::GetID(), pointdrv);
94 }
95
96 //=======================================================================
97 //function : AddDriver
98 //purpose  : Adds a driver to the DriverTable
99 //=======================================================================
100
101 Standard_Boolean TPrsStd_DriverTable::AddDriver(const Standard_GUID&  guid,
102                                                 const Handle(TPrsStd_Driver)& driver)
103 {
104   return myDrivers.Bind(guid,driver);
105 }
106
107 //=======================================================================
108 //function : FindDriver
109 //purpose  : Returns the driver if find
110 //=======================================================================
111
112 Standard_Boolean TPrsStd_DriverTable::FindDriver(const Standard_GUID& guid,
113                                                  Handle(TPrsStd_Driver)& driver) const
114 {
115   if (myDrivers.IsBound(guid))
116   {
117     driver = myDrivers.Find(guid);
118     return Standard_True;
119   }
120   return Standard_False;
121 }
122
123 //=======================================================================
124 //function : RemoveDriver
125 //purpose  : Removes a driver from the DriverTable
126 //=======================================================================
127
128 Standard_Boolean TPrsStd_DriverTable::RemoveDriver(const Standard_GUID& guid)
129 {
130   return myDrivers.UnBind(guid);
131 }
132
133 //=======================================================================
134 //function : Clear
135 //purpose  : Removes all drivers
136 //=======================================================================
137
138 void TPrsStd_DriverTable::Clear()
139 {
140   myDrivers.Clear();
141 }