0024624: Lost word in license statement in source 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-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <TPrsStd_DriverTable.ixx>
18
19 #include <TPrsStd_DataMapOfGUIDDriver.hxx>
20
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>
28
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>
35
36
37 static Handle(TPrsStd_DriverTable) drivertable;
38
39 //=======================================================================
40 //function : Get
41 //purpose  : 
42 //=======================================================================
43
44 Handle(TPrsStd_DriverTable) TPrsStd_DriverTable::Get()
45 {
46   if ( drivertable.IsNull() )
47   {
48     drivertable = new TPrsStd_DriverTable;
49 #ifdef DEB
50     cout << "The new TPrsStd_DriverTable was created" << endl;
51 #endif
52   }
53   return drivertable;
54 }
55
56 //=======================================================================
57 //function : TPrsStd_DriverTable
58 //purpose  : 
59 //=======================================================================
60
61 TPrsStd_DriverTable::TPrsStd_DriverTable()
62 {
63   InitStandardDrivers();
64 }
65
66 //=======================================================================
67 //function : InitStandardDrivers
68 //purpose  : Adds standard drivers to the DriverTable
69 //=======================================================================
70
71 void TPrsStd_DriverTable::InitStandardDrivers() 
72 {
73   if (myDrivers.Extent() > 0) return;
74
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;
81
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);
88 }
89
90 //=======================================================================
91 //function : AddDriver
92 //purpose  : Adds a driver to the DriverTable
93 //=======================================================================
94
95 Standard_Boolean TPrsStd_DriverTable::AddDriver(const Standard_GUID&  guid,
96                                                 const Handle(TPrsStd_Driver)& driver)
97 {
98   return myDrivers.Bind(guid,driver);
99 }
100
101 //=======================================================================
102 //function : FindDriver
103 //purpose  : Returns the driver if find
104 //=======================================================================
105
106 Standard_Boolean TPrsStd_DriverTable::FindDriver(const Standard_GUID& guid,
107                                                  Handle(TPrsStd_Driver)& driver) const
108 {
109   if (myDrivers.IsBound(guid))
110   {
111     driver = myDrivers.Find(guid);
112     return Standard_True;
113   }
114   return Standard_False;
115 }
116
117 //=======================================================================
118 //function : RemoveDriver
119 //purpose  : Removes a driver from the DriverTable
120 //=======================================================================
121
122 Standard_Boolean TPrsStd_DriverTable::RemoveDriver(const Standard_GUID& guid)
123 {
124   return myDrivers.UnBind(guid);
125 }
126
127 //=======================================================================
128 //function : Clear
129 //purpose  : Removes all drivers
130 //=======================================================================
131
132 void TPrsStd_DriverTable::Clear()
133 {
134   myDrivers.Clear();
135 }