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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
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>
26 //=======================================================================
27 //function : Dynamic_DynamicClass
29 //=======================================================================
31 Dynamic_DynamicClass::Dynamic_DynamicClass(const Standard_CString aname)
33 thename = new TCollection_HAsciiString(aname);
34 thesequenceofmethods = new Dynamic_SequenceOfMethods();
37 //=======================================================================
38 //function : Parameter
40 //=======================================================================
42 void Dynamic_DynamicClass::Parameter(const Handle(Dynamic_Parameter)& aparameter)
44 Handle(Dynamic_ParameterNode) parameternode = new Dynamic_ParameterNode(aparameter);
45 parameternode->Next(thefirstparameternode);
46 thefirstparameternode = parameternode;
49 //=======================================================================
50 //function : CompiledMethod
52 //=======================================================================
54 void Dynamic_DynamicClass::CompiledMethod(const Standard_CString amethod,
55 const Standard_CString anaddress)
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);
63 //=======================================================================
64 //function : InterpretedMethod
66 //=======================================================================
68 void Dynamic_DynamicClass::InterpretedMethod(const Standard_CString amethod,
69 const Standard_CString afile)
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);
78 //=======================================================================
81 //=======================================================================
83 Handle(Dynamic_Method) Dynamic_DynamicClass::Method(const Standard_CString amethod) const
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;
91 if(methodname.Search("_") == -1)
93 methodname = thename->String();
94 methodname = methodname + "_" + amethod;
97 for(index=1;index<=thesequenceofmethods->Length();index++)
99 method = thesequenceofmethods->Value(index);
100 if(method->Type() == methodname) return method;
105 //=======================================================================
106 //function : Instance
108 //=======================================================================
110 Handle(Dynamic_DynamicInstance) Dynamic_DynamicClass::Instance() const
112 Handle(Dynamic_DynamicInstance) instance = new Dynamic_DynamicInstance();
113 Handle(Dynamic_DynamicClass) me(this);
115 Handle(Dynamic_ParameterNode) parameternode;
117 parameternode = thefirstparameternode;
119 while(!parameternode.IsNull())
121 instance->Parameter(parameternode->Object());
122 parameternode = parameternode->Next();
130 //=======================================================================
133 //=======================================================================
135 //void Dynamic_DynamicClass::Dump(Standard_OStream& astream) const
136 void Dynamic_DynamicClass::Dump(Standard_OStream& ) const