b311480e |
1 | // Created on: 1999-06-11 |
2 | // Created by: Sergey RUIN |
3 | // Copyright (c) 1999-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
7fd59977 |
17 | |
42cf5bc1 |
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> |
7fd59977 |
26 | #include <TPrsStd_AxisDriver.hxx> |
27 | #include <TPrsStd_ConstraintDriver.hxx> |
42cf5bc1 |
28 | #include <TPrsStd_DataMapOfGUIDDriver.hxx> |
29 | #include <TPrsStd_Driver.hxx> |
30 | #include <TPrsStd_DriverTable.hxx> |
7fd59977 |
31 | #include <TPrsStd_GeometryDriver.hxx> |
32 | #include <TPrsStd_NamedShapeDriver.hxx> |
33 | #include <TPrsStd_PlaneDriver.hxx> |
34 | #include <TPrsStd_PointDriver.hxx> |
35 | |
25e59720 |
36 | IMPLEMENT_STANDARD_RTTIEXT(TPrsStd_DriverTable,Standard_Transient) |
92efcf78 |
37 | |
7fd59977 |
38 | static Handle(TPrsStd_DriverTable) drivertable; |
39 | |
40 | //======================================================================= |
41 | //function : Get |
42 | //purpose : |
43 | //======================================================================= |
44 | |
45 | Handle(TPrsStd_DriverTable) TPrsStd_DriverTable::Get() |
46 | { |
47 | if ( drivertable.IsNull() ) |
48 | { |
49 | drivertable = new TPrsStd_DriverTable; |
ef779ae0 |
50 | // it must be never destroyed, even this library is unloaded |
51 | new Handle(TPrsStd_DriverTable)(drivertable); |
0797d9d3 |
52 | #ifdef OCCT_DEBUG |
04232180 |
53 | std::cout << "The new TPrsStd_DriverTable was created" << std::endl; |
7fd59977 |
54 | #endif |
55 | } |
56 | return drivertable; |
57 | } |
58 | |
59 | //======================================================================= |
60 | //function : TPrsStd_DriverTable |
61 | //purpose : |
62 | //======================================================================= |
63 | |
64 | TPrsStd_DriverTable::TPrsStd_DriverTable() |
65 | { |
66 | InitStandardDrivers(); |
67 | } |
68 | |
69 | //======================================================================= |
70 | //function : InitStandardDrivers |
71 | //purpose : Adds standard drivers to the DriverTable |
72 | //======================================================================= |
73 | |
74 | void TPrsStd_DriverTable::InitStandardDrivers() |
75 | { |
76 | if (myDrivers.Extent() > 0) return; |
77 | |
78 | Handle(TPrsStd_AxisDriver) axisdrv = new TPrsStd_AxisDriver; |
79 | Handle(TPrsStd_ConstraintDriver) cnstrdrv = new TPrsStd_ConstraintDriver; |
80 | Handle(TPrsStd_GeometryDriver) geomdrv = new TPrsStd_GeometryDriver ; |
81 | Handle(TPrsStd_NamedShapeDriver) nshapedrv = new TPrsStd_NamedShapeDriver; |
82 | Handle(TPrsStd_PlaneDriver) planedrv = new TPrsStd_PlaneDriver; |
83 | Handle(TPrsStd_PointDriver) pointdrv = new TPrsStd_PointDriver; |
84 | |
85 | myDrivers.Bind(TDataXtd_Axis::GetID(), axisdrv); |
86 | myDrivers.Bind(TDataXtd_Constraint::GetID(), cnstrdrv); |
87 | myDrivers.Bind(TDataXtd_Geometry::GetID(), geomdrv); |
88 | myDrivers.Bind(TNaming_NamedShape::GetID(), nshapedrv); |
89 | myDrivers.Bind(TDataXtd_Plane::GetID(), planedrv); |
90 | myDrivers.Bind(TDataXtd_Point::GetID(), pointdrv); |
91 | } |
92 | |
93 | //======================================================================= |
94 | //function : AddDriver |
95 | //purpose : Adds a driver to the DriverTable |
96 | //======================================================================= |
97 | |
98 | Standard_Boolean TPrsStd_DriverTable::AddDriver(const Standard_GUID& guid, |
99 | const Handle(TPrsStd_Driver)& driver) |
100 | { |
101 | return myDrivers.Bind(guid,driver); |
102 | } |
103 | |
104 | //======================================================================= |
105 | //function : FindDriver |
106 | //purpose : Returns the driver if find |
107 | //======================================================================= |
108 | |
109 | Standard_Boolean TPrsStd_DriverTable::FindDriver(const Standard_GUID& guid, |
110 | Handle(TPrsStd_Driver)& driver) const |
111 | { |
112 | if (myDrivers.IsBound(guid)) |
113 | { |
114 | driver = myDrivers.Find(guid); |
115 | return Standard_True; |
116 | } |
117 | return Standard_False; |
118 | } |
119 | |
120 | //======================================================================= |
121 | //function : RemoveDriver |
122 | //purpose : Removes a driver from the DriverTable |
123 | //======================================================================= |
124 | |
125 | Standard_Boolean TPrsStd_DriverTable::RemoveDriver(const Standard_GUID& guid) |
126 | { |
127 | return myDrivers.UnBind(guid); |
128 | } |
129 | |
130 | //======================================================================= |
131 | //function : Clear |
132 | //purpose : Removes all drivers |
133 | //======================================================================= |
134 | |
135 | void TPrsStd_DriverTable::Clear() |
136 | { |
137 | myDrivers.Clear(); |
138 | } |