summaryrefslogtreecommitdiff
path: root/src/Dynamic/Dynamic_DynamicClass.cxx
blob: 613d14befa8f335a716730af0fe17c2ba83455fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// File:	Dynamic_DynamicClass.cxx
// Created:	Fri Jan 22 11:45:20 1993
// Author:	Gilles DEBARBOUILLE
//		<gde@bravox>


#include <Dynamic_DynamicClass.ixx>
#include <Dynamic_DynamicInstance.hxx>
#include <Dynamic_Parameter.hxx>
#include <Dynamic_CompiledMethod.hxx>
#include <Dynamic_InterpretedMethod.hxx>
#include <Dynamic_SequenceOfMethods.hxx>
#include <TCollection_AsciiString.hxx>


//=======================================================================
//function : Dynamic_DynamicClass
//purpose  : 
//=======================================================================

Dynamic_DynamicClass::Dynamic_DynamicClass(const Standard_CString aname)
{
  thename = new TCollection_HAsciiString(aname);
  thesequenceofmethods = new Dynamic_SequenceOfMethods();
}

//=======================================================================
//function : Parameter
//purpose  : 
//=======================================================================

void Dynamic_DynamicClass::Parameter(const Handle(Dynamic_Parameter)& aparameter)
{
  Handle(Dynamic_ParameterNode) parameternode = new Dynamic_ParameterNode(aparameter);
  parameternode->Next(thefirstparameternode);
  thefirstparameternode = parameternode;
}

//=======================================================================
//function : CompiledMethod
//purpose  : 
//=======================================================================

void Dynamic_DynamicClass::CompiledMethod(const Standard_CString amethod,
					  const Standard_CString anaddress)
{
  TCollection_AsciiString string = thename->String();
  string = string + "_" + amethod;
  Handle(Dynamic_CompiledMethod) method = new Dynamic_CompiledMethod(string.ToCString(),anaddress);
  thesequenceofmethods->Append(method);
}

//=======================================================================
//function : InterpretedMethod
//purpose  : 
//=======================================================================

void Dynamic_DynamicClass::InterpretedMethod(const Standard_CString amethod,
					     const Standard_CString afile)
{
  TCollection_AsciiString string = thename->String();
  string = string + "_" + amethod;
  Handle(Dynamic_InterpretedMethod) method =
    new Dynamic_InterpretedMethod(string.ToCString(),afile); 
  thesequenceofmethods->Append(method);
}

//=======================================================================
//function : Method
//purpose  : 
//=======================================================================

Handle(Dynamic_Method) Dynamic_DynamicClass::Method(const Standard_CString amethod) const
{
  Standard_Integer index;
  TCollection_AsciiString methodname(amethod);
  Handle(Dynamic_Method) method;
  Handle(Dynamic_Method) nullmethod;
  Handle(Dynamic_SequenceOfMethods) sequenceofmethods = thesequenceofmethods;

  if(methodname.Search("_") == -1)
    {
      methodname = thename->String();
      methodname = methodname + "_" + amethod;
    }

  for(index=1;index<=thesequenceofmethods->Length();index++)
    {
      method = thesequenceofmethods->Value(index);
      if(method->Type() == methodname) return method;
    }
  return nullmethod;
}

//=======================================================================
//function : Instance
//purpose  : 
//=======================================================================

Handle(Dynamic_DynamicInstance) Dynamic_DynamicClass::Instance() const
{
  Handle(Dynamic_DynamicInstance) instance = new Dynamic_DynamicInstance();
  Handle(Dynamic_DynamicClass) me(this);

  Handle(Dynamic_ParameterNode) parameternode;

  parameternode = thefirstparameternode;

  while(!parameternode.IsNull())
    {
      instance->Parameter(parameternode->Object());
      parameternode = parameternode->Next();
    }

  instance->Class(me);

  return instance;
}

//=======================================================================
//function : Dump
//purpose  : 
//=======================================================================

//void Dynamic_DynamicClass::Dump(Standard_OStream& astream) const
void Dynamic_DynamicClass::Dump(Standard_OStream& ) const
{}