7fd59977 |
1 | // File: TPrsStd_DriverTable.cxx |
2 | // Created: Fri Jun 11 17:58:49 1999 |
3 | // Author: Sergey RUIN |
4 | // <srn@popox.nnov.matra-dtv.fr> |
5 | |
6 | |
7 | #include <TPrsStd_DriverTable.ixx> |
8 | |
9 | #include <TPrsStd_DataMapOfGUIDDriver.hxx> |
10 | |
11 | #include <TPrsStd_Driver.hxx> |
12 | #include <TPrsStd_AxisDriver.hxx> |
13 | #include <TPrsStd_ConstraintDriver.hxx> |
14 | #include <TPrsStd_GeometryDriver.hxx> |
15 | #include <TPrsStd_NamedShapeDriver.hxx> |
16 | #include <TPrsStd_PlaneDriver.hxx> |
17 | #include <TPrsStd_PointDriver.hxx> |
18 | |
19 | #include <TDataXtd_Axis.hxx> |
20 | #include <TDataXtd_Constraint.hxx> |
21 | #include <TDataXtd_Geometry.hxx> |
22 | #include <TNaming_NamedShape.hxx> |
23 | #include <TDataXtd_Plane.hxx> |
24 | #include <TDataXtd_Point.hxx> |
25 | |
26 | |
27 | static Handle(TPrsStd_DriverTable) drivertable; |
28 | |
29 | //======================================================================= |
30 | //function : Get |
31 | //purpose : |
32 | //======================================================================= |
33 | |
34 | Handle(TPrsStd_DriverTable) TPrsStd_DriverTable::Get() |
35 | { |
36 | if ( drivertable.IsNull() ) |
37 | { |
38 | drivertable = new TPrsStd_DriverTable; |
39 | #ifdef DEB |
40 | cout << "The new TPrsStd_DriverTable was created" << endl; |
41 | #endif |
42 | } |
43 | return drivertable; |
44 | } |
45 | |
46 | //======================================================================= |
47 | //function : TPrsStd_DriverTable |
48 | //purpose : |
49 | //======================================================================= |
50 | |
51 | TPrsStd_DriverTable::TPrsStd_DriverTable() |
52 | { |
53 | InitStandardDrivers(); |
54 | } |
55 | |
56 | //======================================================================= |
57 | //function : InitStandardDrivers |
58 | //purpose : Adds standard drivers to the DriverTable |
59 | //======================================================================= |
60 | |
61 | void TPrsStd_DriverTable::InitStandardDrivers() |
62 | { |
63 | if (myDrivers.Extent() > 0) return; |
64 | |
65 | Handle(TPrsStd_AxisDriver) axisdrv = new TPrsStd_AxisDriver; |
66 | Handle(TPrsStd_ConstraintDriver) cnstrdrv = new TPrsStd_ConstraintDriver; |
67 | Handle(TPrsStd_GeometryDriver) geomdrv = new TPrsStd_GeometryDriver ; |
68 | Handle(TPrsStd_NamedShapeDriver) nshapedrv = new TPrsStd_NamedShapeDriver; |
69 | Handle(TPrsStd_PlaneDriver) planedrv = new TPrsStd_PlaneDriver; |
70 | Handle(TPrsStd_PointDriver) pointdrv = new TPrsStd_PointDriver; |
71 | |
72 | myDrivers.Bind(TDataXtd_Axis::GetID(), axisdrv); |
73 | myDrivers.Bind(TDataXtd_Constraint::GetID(), cnstrdrv); |
74 | myDrivers.Bind(TDataXtd_Geometry::GetID(), geomdrv); |
75 | myDrivers.Bind(TNaming_NamedShape::GetID(), nshapedrv); |
76 | myDrivers.Bind(TDataXtd_Plane::GetID(), planedrv); |
77 | myDrivers.Bind(TDataXtd_Point::GetID(), pointdrv); |
78 | } |
79 | |
80 | //======================================================================= |
81 | //function : AddDriver |
82 | //purpose : Adds a driver to the DriverTable |
83 | //======================================================================= |
84 | |
85 | Standard_Boolean TPrsStd_DriverTable::AddDriver(const Standard_GUID& guid, |
86 | const Handle(TPrsStd_Driver)& driver) |
87 | { |
88 | return myDrivers.Bind(guid,driver); |
89 | } |
90 | |
91 | //======================================================================= |
92 | //function : FindDriver |
93 | //purpose : Returns the driver if find |
94 | //======================================================================= |
95 | |
96 | Standard_Boolean TPrsStd_DriverTable::FindDriver(const Standard_GUID& guid, |
97 | Handle(TPrsStd_Driver)& driver) const |
98 | { |
99 | if (myDrivers.IsBound(guid)) |
100 | { |
101 | driver = myDrivers.Find(guid); |
102 | return Standard_True; |
103 | } |
104 | return Standard_False; |
105 | } |
106 | |
107 | //======================================================================= |
108 | //function : RemoveDriver |
109 | //purpose : Removes a driver from the DriverTable |
110 | //======================================================================= |
111 | |
112 | Standard_Boolean TPrsStd_DriverTable::RemoveDriver(const Standard_GUID& guid) |
113 | { |
114 | return myDrivers.UnBind(guid); |
115 | } |
116 | |
117 | //======================================================================= |
118 | //function : Clear |
119 | //purpose : Removes all drivers |
120 | //======================================================================= |
121 | |
122 | void TPrsStd_DriverTable::Clear() |
123 | { |
124 | myDrivers.Clear(); |
125 | } |