| 2263 |
kivins |
1 |
//## begin module%1.7%.codegen_version preserve=yes
|
|
|
2 |
// Read the documentation to learn more about C++ code generator
|
|
|
3 |
// versioning.
|
|
|
4 |
//## end module%1.7%.codegen_version
|
|
|
5 |
|
|
|
6 |
//## begin module%4209C5FB02C3.cm preserve=no
|
|
|
7 |
//## end module%4209C5FB02C3.cm
|
|
|
8 |
|
|
|
9 |
//## begin module%4209C5FB02C3.cp preserve=no
|
|
|
10 |
// C O P Y R I G H T N O T I C E
|
|
|
11 |
// This material is confidential to ERG and may not be disclosed in whole
|
|
|
12 |
// or in part to any third party nor used in any manner whatsoever other
|
|
|
13 |
// than for the purposes expressly consented to by ERG in writing.
|
|
|
14 |
//
|
|
|
15 |
// This material is also copyright and may not be reproduced, stored in a
|
|
|
16 |
// retrieval system or transmitted in any form or by any means in whole or
|
|
|
17 |
// in part without the express written consent of ERG.
|
|
|
18 |
//## end module%4209C5FB02C3.cp
|
|
|
19 |
|
|
|
20 |
//## Module: DefinedVariableTable%4209C5FB02C3; Pseudo Package body
|
|
|
21 |
//## Subsystem: MASS::Dev::Tools::TxnTestManager::src%41F5A79001E4
|
|
|
22 |
//## Source file: Z:\MASS_Dev\Tools\TxnTestManager\src\DefinedVariableTable.cpp
|
|
|
23 |
|
|
|
24 |
//## begin module%4209C5FB02C3.additionalIncludes preserve=no
|
|
|
25 |
//## end module%4209C5FB02C3.additionalIncludes
|
|
|
26 |
|
|
|
27 |
//## begin module%4209C5FB02C3.includes preserve=yes
|
|
|
28 |
#pragma warn -com
|
|
|
29 |
#include <LoggingMacros.h>
|
|
|
30 |
#pragma warn +com
|
|
|
31 |
//## end module%4209C5FB02C3.includes
|
|
|
32 |
|
|
|
33 |
// TestScenario
|
|
|
34 |
#include "TestScenario.h"
|
|
|
35 |
// TransactionSpecification
|
|
|
36 |
#include "TransactionSpecification.h"
|
|
|
37 |
// EvaluationContext
|
|
|
38 |
#include "EvaluationContext.h"
|
|
|
39 |
// DefinedVariable
|
|
|
40 |
#include "DefinedVariable.h"
|
|
|
41 |
// DefinedVariableTable
|
|
|
42 |
#include "DefinedVariableTable.h"
|
|
|
43 |
//## begin module%4209C5FB02C3.additionalDeclarations preserve=yes
|
|
|
44 |
//## end module%4209C5FB02C3.additionalDeclarations
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
// Class DefinedVariableTable
|
|
|
48 |
|
|
|
49 |
DefinedVariableTable::DefinedVariableTable()
|
|
|
50 |
//## begin DefinedVariableTable::DefinedVariableTable%4209C5FB02C3_const.initialization preserve=yes
|
|
|
51 |
//## end DefinedVariableTable::DefinedVariableTable%4209C5FB02C3_const.initialization
|
|
|
52 |
{
|
|
|
53 |
//## begin DefinedVariableTable::DefinedVariableTable%4209C5FB02C3_const.body preserve=yes
|
|
|
54 |
//## end DefinedVariableTable::DefinedVariableTable%4209C5FB02C3_const.body
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
DefinedVariableTable::~DefinedVariableTable()
|
|
|
59 |
{
|
|
|
60 |
//## begin DefinedVariableTable::~DefinedVariableTable%4209C5FB02C3_dest.body preserve=yes
|
|
|
61 |
|
|
|
62 |
clear();
|
|
|
63 |
|
|
|
64 |
//## end DefinedVariableTable::~DefinedVariableTable%4209C5FB02C3_dest.body
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
//## Other Operations (implementation)
|
|
|
70 |
//## Operation: clear%4209C916032F
|
|
|
71 |
void DefinedVariableTable::clear ()
|
|
|
72 |
{
|
|
|
73 |
//## begin DefinedVariableTable::clear%4209C916032F.body preserve=yes
|
|
|
74 |
|
|
|
75 |
for ( std::map< std::string, DefinedVariable * >::iterator
|
|
|
76 |
where = m_variable.begin();
|
|
|
77 |
where != m_variable.end();
|
|
|
78 |
++where )
|
|
|
79 |
{
|
|
|
80 |
delete where->second;
|
|
|
81 |
where->second = 0;
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
//## end DefinedVariableTable::clear%4209C916032F.body
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
//## Operation: defineVariable%425B4483019F
|
|
|
88 |
DefinedVariable& DefinedVariableTable::defineVariable (const std::string &variableName)
|
|
|
89 |
{
|
|
|
90 |
//## begin DefinedVariableTable::defineVariable%425B4483019F.body preserve=yes
|
|
|
91 |
|
|
|
92 |
std::map< std::string, DefinedVariable * >::const_iterator
|
|
|
93 |
instance = m_variable.find( variableName );
|
|
|
94 |
|
|
|
95 |
if ( instance != m_variable.end() )
|
|
|
96 |
{
|
|
|
97 |
return ( *instance->second );
|
|
|
98 |
}
|
|
|
99 |
else
|
|
|
100 |
{
|
|
|
101 |
DefinedVariable * object = 0;
|
|
|
102 |
|
|
|
103 |
try
|
|
|
104 |
{
|
|
|
105 |
object = new DefinedVariable( variableName );
|
|
|
106 |
|
|
|
107 |
if ( m_variable.insert(
|
|
|
108 |
std::map< std::string, DefinedVariable * >::value_type(
|
|
|
109 |
variableName,
|
|
|
110 |
object ) ).second )
|
|
|
111 |
{
|
|
|
112 |
return ( *object );
|
|
|
113 |
}
|
|
|
114 |
else
|
|
|
115 |
{
|
|
|
116 |
MTHROW( std::runtime_error, \
|
|
|
117 |
"Cannot add variable \"" \
|
|
|
118 |
<< variableName \
|
|
|
119 |
<< "\" to defined variable table." );
|
|
|
120 |
}
|
|
|
121 |
}
|
|
|
122 |
catch ( ... )
|
|
|
123 |
{
|
|
|
124 |
delete object;
|
|
|
125 |
object = 0;
|
|
|
126 |
|
|
|
127 |
throw;
|
|
|
128 |
}
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
//## end DefinedVariableTable::defineVariable%425B4483019F.body
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
//## Operation: defineVariable%425B461402A1
|
|
|
135 |
DefinedVariable& DefinedVariableTable::defineVariable (const std::string &variableName, TestScenario &testScenario)
|
|
|
136 |
{
|
|
|
137 |
//## begin DefinedVariableTable::defineVariable%425B461402A1.body preserve=yes
|
|
|
138 |
|
|
|
139 |
const int testScenarioNumber = testScenario.getScenarioNumber();
|
|
|
140 |
std::map< int, TestScenario * >::const_iterator
|
|
|
141 |
instance = m_scenario.find( testScenarioNumber );
|
|
|
142 |
|
|
|
143 |
if ( instance != m_scenario.end() )
|
|
|
144 |
{
|
|
|
145 |
return ( testScenario.defineVariable( variableName ) );
|
|
|
146 |
}
|
|
|
147 |
else
|
|
|
148 |
{
|
|
|
149 |
if ( m_scenario.insert(
|
|
|
150 |
std::map< int, TestScenario * >::value_type(
|
|
|
151 |
testScenarioNumber,
|
|
|
152 |
&testScenario ) ).second )
|
|
|
153 |
{
|
|
|
154 |
return ( testScenario.defineVariable( variableName ) );
|
|
|
155 |
}
|
|
|
156 |
else
|
|
|
157 |
{
|
|
|
158 |
MTHROW( std::runtime_error, \
|
|
|
159 |
"Cannot add test scenario \"" \
|
|
|
160 |
<< testScenarioNumber \
|
|
|
161 |
<< "\" to defined variable table." );
|
|
|
162 |
}
|
|
|
163 |
}
|
|
|
164 |
|
|
|
165 |
//## end DefinedVariableTable::defineVariable%425B461402A1.body
|
|
|
166 |
}
|
|
|
167 |
|
|
|
168 |
//## Operation: getVariable%4209C7770264
|
|
|
169 |
DefinedVariable& DefinedVariableTable::getVariable (const std::string &variableName, EvaluationContext& context)
|
|
|
170 |
{
|
|
|
171 |
//## begin DefinedVariableTable::getVariable%4209C7770264.body preserve=yes
|
|
|
172 |
|
|
|
173 |
std::map< int, TestScenario * >::const_iterator
|
|
|
174 |
scenario = m_scenario.find(
|
|
|
175 |
context.getTransaction().getScenario().getScenarioNumber() );
|
|
|
176 |
|
|
|
177 |
if ( scenario != m_scenario.end() &&
|
|
|
178 |
scenario->second->isVariable( variableName ) )
|
|
|
179 |
{
|
|
|
180 |
return ( scenario->second->getVariable( variableName ) );
|
|
|
181 |
}
|
|
|
182 |
|
|
|
183 |
std::map< std::string, DefinedVariable * >::const_iterator
|
|
|
184 |
instance = m_variable.find( variableName );
|
|
|
185 |
|
|
|
186 |
if ( instance != m_variable.end() )
|
|
|
187 |
{
|
|
|
188 |
return ( *instance->second );
|
|
|
189 |
}
|
|
|
190 |
|
|
|
191 |
MTHROW( std::runtime_error, \
|
|
|
192 |
"Variable \"" \
|
|
|
193 |
<< variableName \
|
|
|
194 |
<< "\" is not defined." );
|
|
|
195 |
|
|
|
196 |
//## end DefinedVariableTable::getVariable%4209C7770264.body
|
|
|
197 |
}
|
|
|
198 |
|
|
|
199 |
//## Operation: isVariable%420ACFBB01CE
|
|
|
200 |
const bool DefinedVariableTable::isVariable (const std::string &symbol, EvaluationContext& context) const
|
|
|
201 |
{
|
|
|
202 |
//## begin DefinedVariableTable::isVariable%420ACFBB01CE.body preserve=yes
|
|
|
203 |
|
|
|
204 |
std::map< int, TestScenario * >::const_iterator
|
|
|
205 |
instance = m_scenario.find(
|
|
|
206 |
context.getTransaction().getScenario().getScenarioNumber() );
|
|
|
207 |
|
|
|
208 |
if ( instance != m_scenario.end() &&
|
|
|
209 |
instance->second->isVariable( symbol ) )
|
|
|
210 |
{
|
|
|
211 |
return ( true );
|
|
|
212 |
}
|
|
|
213 |
|
|
|
214 |
return ( m_variable.find( symbol ) != m_variable.end() );
|
|
|
215 |
|
|
|
216 |
//## end DefinedVariableTable::isVariable%420ACFBB01CE.body
|
|
|
217 |
}
|
|
|
218 |
|
|
|
219 |
// Additional Declarations
|
|
|
220 |
//## begin DefinedVariableTable%4209C5FB02C3.declarations preserve=yes
|
|
|
221 |
//## end DefinedVariableTable%4209C5FB02C3.declarations
|
|
|
222 |
|
|
|
223 |
//## begin module%4209C5FB02C3.epilog preserve=yes
|
|
|
224 |
//## end module%4209C5FB02C3.epilog
|