0024509: Suspect unused variable in TPrsStd_ConstraintTools.cxx
[occt.git] / src / Dynamic / Dynamic_DynamicClass.cxx
1 // Created on: 1993-01-22
2 // Created by: Gilles DEBARBOUILLE
3 // Copyright (c) 1993-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 <Dynamic_DynamicClass.ixx>
18 #include <Dynamic_DynamicInstance.hxx>
19 #include <Dynamic_Parameter.hxx>
20 #include <Dynamic_CompiledMethod.hxx>
21 #include <Dynamic_InterpretedMethod.hxx>
22 #include <Dynamic_SequenceOfMethods.hxx>
23 #include <TCollection_AsciiString.hxx>
24
25
26 //=======================================================================
27 //function : Dynamic_DynamicClass
28 //purpose  : 
29 //=======================================================================
30
31 Dynamic_DynamicClass::Dynamic_DynamicClass(const Standard_CString aname)
32 {
33   thename = new TCollection_HAsciiString(aname);
34   thesequenceofmethods = new Dynamic_SequenceOfMethods();
35 }
36
37 //=======================================================================
38 //function : Parameter
39 //purpose  : 
40 //=======================================================================
41
42 void Dynamic_DynamicClass::Parameter(const Handle(Dynamic_Parameter)& aparameter)
43 {
44   Handle(Dynamic_ParameterNode) parameternode = new Dynamic_ParameterNode(aparameter);
45   parameternode->Next(thefirstparameternode);
46   thefirstparameternode = parameternode;
47 }
48
49 //=======================================================================
50 //function : CompiledMethod
51 //purpose  : 
52 //=======================================================================
53
54 void Dynamic_DynamicClass::CompiledMethod(const Standard_CString amethod,
55                                           const Standard_CString anaddress)
56 {
57   TCollection_AsciiString string = thename->String();
58   string = string + "_" + amethod;
59   Handle(Dynamic_CompiledMethod) method = new Dynamic_CompiledMethod(string.ToCString(),anaddress);
60   thesequenceofmethods->Append(method);
61 }
62
63 //=======================================================================
64 //function : InterpretedMethod
65 //purpose  : 
66 //=======================================================================
67
68 void Dynamic_DynamicClass::InterpretedMethod(const Standard_CString amethod,
69                                              const Standard_CString afile)
70 {
71   TCollection_AsciiString string = thename->String();
72   string = string + "_" + amethod;
73   Handle(Dynamic_InterpretedMethod) method =
74     new Dynamic_InterpretedMethod(string.ToCString(),afile); 
75   thesequenceofmethods->Append(method);
76 }
77
78 //=======================================================================
79 //function : Method
80 //purpose  : 
81 //=======================================================================
82
83 Handle(Dynamic_Method) Dynamic_DynamicClass::Method(const Standard_CString amethod) const
84 {
85   Standard_Integer index;
86   TCollection_AsciiString methodname(amethod);
87   Handle(Dynamic_Method) method;
88   Handle(Dynamic_Method) nullmethod;
89   Handle(Dynamic_SequenceOfMethods) sequenceofmethods = thesequenceofmethods;
90
91   if(methodname.Search("_") == -1)
92     {
93       methodname = thename->String();
94       methodname = methodname + "_" + amethod;
95     }
96
97   for(index=1;index<=thesequenceofmethods->Length();index++)
98     {
99       method = thesequenceofmethods->Value(index);
100       if(method->Type() == methodname) return method;
101     }
102   return nullmethod;
103 }
104
105 //=======================================================================
106 //function : Instance
107 //purpose  : 
108 //=======================================================================
109
110 Handle(Dynamic_DynamicInstance) Dynamic_DynamicClass::Instance() const
111 {
112   Handle(Dynamic_DynamicInstance) instance = new Dynamic_DynamicInstance();
113   Handle(Dynamic_DynamicClass) me(this);
114
115   Handle(Dynamic_ParameterNode) parameternode;
116
117   parameternode = thefirstparameternode;
118
119   while(!parameternode.IsNull())
120     {
121       instance->Parameter(parameternode->Object());
122       parameternode = parameternode->Next();
123     }
124
125   instance->Class(me);
126
127   return instance;
128 }
129
130 //=======================================================================
131 //function : Dump
132 //purpose  : 
133 //=======================================================================
134
135 //void Dynamic_DynamicClass::Dump(Standard_OStream& astream) const
136 void Dynamic_DynamicClass::Dump(Standard_OStream& ) const
137 {}