| 2218 |
sbetterm |
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%42030C2C00B8.cm preserve=no
|
|
|
7 |
//## end module%42030C2C00B8.cm
|
|
|
8 |
|
|
|
9 |
//## begin module%42030C2C00B8.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%42030C2C00B8.cp
|
|
|
19 |
|
|
|
20 |
//## Module: TestScenario%42030C2C00B8; Pseudo Package body
|
|
|
21 |
//## Subsystem: MASS::Dev::Tools::TxnTestManager::src%41F5A79001E4
|
|
|
22 |
//## Source file: Z:\MASS_Dev\Tools\TxnTestManager\src\TestScenario.cpp
|
|
|
23 |
|
|
|
24 |
//## begin module%42030C2C00B8.additionalIncludes preserve=no
|
|
|
25 |
//## end module%42030C2C00B8.additionalIncludes
|
|
|
26 |
|
|
|
27 |
//## begin module%42030C2C00B8.includes preserve=yes
|
|
|
28 |
#pragma warn -com
|
|
|
29 |
#include <LoggingMacros.h>
|
|
|
30 |
#pragma warn +com
|
|
|
31 |
//## end module%42030C2C00B8.includes
|
|
|
32 |
|
|
|
33 |
// TransactionSpecification
|
|
|
34 |
#include "TransactionSpecification.h"
|
|
|
35 |
// EvaluationContext
|
|
|
36 |
#include "EvaluationContext.h"
|
|
|
37 |
// TransactionStream
|
|
|
38 |
#include "TransactionStream.h"
|
|
|
39 |
// Iteration
|
|
|
40 |
#include "Iteration.h"
|
|
|
41 |
// TestScenario
|
|
|
42 |
#include "TestScenario.h"
|
|
|
43 |
//## begin module%42030C2C00B8.additionalDeclarations preserve=yes
|
|
|
44 |
#include <locale>
|
|
|
45 |
//## end module%42030C2C00B8.additionalDeclarations
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
// Class TestScenario
|
|
|
49 |
|
|
|
50 |
//## Operation: TestScenario%4203231D030E
|
|
|
51 |
TestScenario::TestScenario (const int &scenario, Iteration& iteration)
|
|
|
52 |
//## begin TestScenario::TestScenario%4203231D030E.hasinit preserve=no
|
|
|
53 |
: m_batchSize(0),
|
|
|
54 |
m_repeatCount(0),
|
|
|
55 |
m_iteration(&iteration)
|
|
|
56 |
//## end TestScenario::TestScenario%4203231D030E.hasinit
|
|
|
57 |
//## begin TestScenario::TestScenario%4203231D030E.initialization preserve=yes
|
|
|
58 |
|
|
|
59 |
, m_scenario( scenario )
|
|
|
60 |
|
|
|
61 |
//## end TestScenario::TestScenario%4203231D030E.initialization
|
|
|
62 |
{
|
|
|
63 |
//## begin TestScenario::TestScenario%4203231D030E.body preserve=yes
|
|
|
64 |
//## end TestScenario::TestScenario%4203231D030E.body
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
TestScenario::~TestScenario()
|
|
|
69 |
{
|
|
|
70 |
//## begin TestScenario::~TestScenario%42030C2C00B8_dest.body preserve=yes
|
|
|
71 |
|
|
|
72 |
for ( std::map< int, TransactionSpecification * >::iterator
|
|
|
73 |
where = m_transaction.begin();
|
|
|
74 |
where != m_transaction.end();
|
|
|
75 |
++where )
|
|
|
76 |
{
|
|
|
77 |
delete where->second;
|
|
|
78 |
where->second = 0;
|
|
|
79 |
}
|
|
|
80 |
m_iteration = 0; // We don't own this object.
|
|
|
81 |
|
|
|
82 |
//## end TestScenario::~TestScenario%42030C2C00B8_dest.body
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
//## Other Operations (implementation)
|
|
|
88 |
//## Operation: buildBatchName%4208537A00B6
|
|
|
89 |
std::string & TestScenario::buildBatchName (std::string &batchName, const std::string &scenarioName)
|
|
|
90 |
{
|
|
|
91 |
//## begin TestScenario::buildBatchName%4208537A00B6.body preserve=yes
|
|
|
92 |
|
|
|
93 |
batchName.erase();
|
|
|
94 |
batchName.reserve( scenarioName.length() );
|
|
|
95 |
|
|
|
96 |
for ( std::string::size_type index = 0; index < scenarioName.length(); ++index )
|
|
|
97 |
{
|
|
|
98 |
if ( std::isalnum( scenarioName[ index ] ) )
|
|
|
99 |
{
|
|
|
100 |
batchName += scenarioName[ index ];
|
|
|
101 |
}
|
|
|
102 |
else
|
|
|
103 |
{
|
|
|
104 |
batchName += '_';
|
|
|
105 |
}
|
|
|
106 |
}
|
|
|
107 |
|
|
|
108 |
return ( batchName );
|
|
|
109 |
|
|
|
110 |
//## end TestScenario::buildBatchName%4208537A00B6.body
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
//## Operation: generate%420455D80390
|
|
|
114 |
const bool TestScenario::generate (TransactionStream& stream, const bool &generateHeaders, EvaluationContext& evaluationContext)
|
|
|
115 |
{
|
|
|
116 |
//## begin TestScenario::generate%420455D80390.body preserve=yes
|
|
|
117 |
|
|
|
118 |
bool generated = true;
|
|
|
119 |
if ( m_repeatCount )
|
|
|
120 |
{
|
|
|
121 |
std::string batchName;
|
|
|
122 |
stream.newBatch(
|
|
|
123 |
m_batchSize,
|
|
|
124 |
buildBatchName( batchName, m_scenarioName ) );
|
| 2222 |
sbetterm |
125 |
for ( unsigned repeat = 1; repeat <= m_repeatCount && generated; ++repeat )
|
| 2218 |
sbetterm |
126 |
{
|
| 2222 |
sbetterm |
127 |
evaluationContext.setScenarioIndex( repeat );
|
|
|
128 |
|
| 2218 |
sbetterm |
129 |
for ( std::vector< TransactionSpecification * >::iterator
|
|
|
130 |
where = m_orderedTransactionCollection.begin();
|
|
|
131 |
where != m_orderedTransactionCollection.end();
|
|
|
132 |
++where )
|
|
|
133 |
{
|
|
|
134 |
if ( !(*where)->generate(
|
|
|
135 |
stream,
|
|
|
136 |
generateHeaders,
|
|
|
137 |
evaluationContext ) )
|
|
|
138 |
{
|
|
|
139 |
generated = false;
|
|
|
140 |
break;
|
|
|
141 |
}
|
|
|
142 |
}
|
|
|
143 |
}
|
|
|
144 |
}
|
|
|
145 |
return ( generated );
|
|
|
146 |
|
|
|
147 |
//## end TestScenario::generate%420455D80390.body
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
//## Operation: getBatchSize%42042C5E0029
|
|
|
151 |
const unsigned & TestScenario::getBatchSize () const
|
|
|
152 |
{
|
|
|
153 |
//## begin TestScenario::getBatchSize%42042C5E0029.body preserve=yes
|
|
|
154 |
|
|
|
155 |
return ( m_batchSize );
|
|
|
156 |
|
|
|
157 |
//## end TestScenario::getBatchSize%42042C5E0029.body
|
|
|
158 |
}
|
|
|
159 |
|
|
|
160 |
//## Operation: getIteration%420460EA003C
|
|
|
161 |
const Iteration& TestScenario::getIteration () const
|
|
|
162 |
{
|
|
|
163 |
//## begin TestScenario::getIteration%420460EA003C.body preserve=yes
|
|
|
164 |
|
|
|
165 |
return ( *m_iteration );
|
|
|
166 |
|
|
|
167 |
//## end TestScenario::getIteration%420460EA003C.body
|
|
|
168 |
}
|
|
|
169 |
|
|
|
170 |
//## Operation: getRepeatCount%42042C5D02F8
|
|
|
171 |
const unsigned & TestScenario::getRepeatCount () const
|
|
|
172 |
{
|
|
|
173 |
//## begin TestScenario::getRepeatCount%42042C5D02F8.body preserve=yes
|
|
|
174 |
|
|
|
175 |
return ( m_repeatCount );
|
|
|
176 |
|
|
|
177 |
//## end TestScenario::getRepeatCount%42042C5D02F8.body
|
|
|
178 |
}
|
|
|
179 |
|
|
|
180 |
//## Operation: getScenarioName%42084D3A0270
|
|
|
181 |
const std::string & TestScenario::getScenarioName () const
|
|
|
182 |
{
|
|
|
183 |
//## begin TestScenario::getScenarioName%42084D3A0270.body preserve=yes
|
|
|
184 |
|
|
|
185 |
return ( m_scenarioName );
|
|
|
186 |
|
|
|
187 |
//## end TestScenario::getScenarioName%42084D3A0270.body
|
|
|
188 |
}
|
|
|
189 |
|
|
|
190 |
//## Operation: getScenarioNumber%4203252300A6
|
|
|
191 |
const int & TestScenario::getScenarioNumber () const
|
|
|
192 |
{
|
|
|
193 |
//## begin TestScenario::getScenarioNumber%4203252300A6.body preserve=yes
|
|
|
194 |
|
|
|
195 |
return ( m_scenario );
|
|
|
196 |
|
|
|
197 |
//## end TestScenario::getScenarioNumber%4203252300A6.body
|
|
|
198 |
}
|
|
|
199 |
|
|
|
200 |
//## Operation: getTransactionCount%420890BF03BE
|
|
|
201 |
const unsigned TestScenario::getTransactionCount () const
|
|
|
202 |
{
|
|
|
203 |
//## begin TestScenario::getTransactionCount%420890BF03BE.body preserve=yes
|
|
|
204 |
|
|
|
205 |
return ( m_transaction.size() * m_repeatCount );
|
|
|
206 |
|
|
|
207 |
//## end TestScenario::getTransactionCount%420890BF03BE.body
|
|
|
208 |
}
|
|
|
209 |
|
|
|
210 |
//## Operation: getTransactionSpecification%420328E00043
|
|
|
211 |
TransactionSpecification& TestScenario::getTransactionSpecification (const int &transaction, const std::string &payloadStructureName)
|
|
|
212 |
{
|
|
|
213 |
//## begin TestScenario::getTransactionSpecification%420328E00043.body preserve=yes
|
|
|
214 |
|
|
|
215 |
std::map< int, TransactionSpecification * >::const_iterator
|
|
|
216 |
instance = m_transaction.find( transaction );
|
|
|
217 |
|
|
|
218 |
if ( instance != m_transaction.end() )
|
|
|
219 |
{
|
|
|
220 |
return ( *instance->second );
|
|
|
221 |
}
|
|
|
222 |
else
|
|
|
223 |
{
|
|
|
224 |
TransactionSpecification * object = 0;
|
|
|
225 |
|
|
|
226 |
try
|
|
|
227 |
{
|
|
|
228 |
object = new TransactionSpecification( transaction, payloadStructureName, *this );
|
|
|
229 |
|
|
|
230 |
m_orderedTransactionCollection.push_back( object );
|
|
|
231 |
if ( m_transaction.insert(
|
|
|
232 |
std::map< int, TransactionSpecification * >::value_type(
|
|
|
233 |
transaction,
|
|
|
234 |
object ) ).second )
|
|
|
235 |
{
|
|
|
236 |
return ( *object );
|
|
|
237 |
}
|
|
|
238 |
else
|
|
|
239 |
{
|
|
|
240 |
MTHROW( std::runtime_error, \
|
|
|
241 |
"Cannot add transaction \"" \
|
|
|
242 |
<< transaction \
|
|
|
243 |
<< "\" to scenario " \
|
|
|
244 |
<< m_scenario \
|
|
|
245 |
<< '.' );
|
|
|
246 |
}
|
|
|
247 |
}
|
|
|
248 |
catch ( ... )
|
|
|
249 |
{
|
|
|
250 |
delete object;
|
|
|
251 |
object = 0;
|
|
|
252 |
|
|
|
253 |
throw;
|
|
|
254 |
}
|
|
|
255 |
}
|
|
|
256 |
|
|
|
257 |
//## end TestScenario::getTransactionSpecification%420328E00043.body
|
|
|
258 |
}
|
|
|
259 |
|
|
|
260 |
//## Operation: setBatchSize%42042CF100D5
|
|
|
261 |
const unsigned & TestScenario::setBatchSize (const unsigned &value)
|
|
|
262 |
{
|
|
|
263 |
//## begin TestScenario::setBatchSize%42042CF100D5.body preserve=yes
|
|
|
264 |
|
|
|
265 |
return ( m_batchSize = value );
|
|
|
266 |
|
|
|
267 |
//## end TestScenario::setBatchSize%42042CF100D5.body
|
|
|
268 |
}
|
|
|
269 |
|
|
|
270 |
//## Operation: setRepeatCount%42042CF100E5
|
|
|
271 |
const unsigned & TestScenario::setRepeatCount (const unsigned &value)
|
|
|
272 |
{
|
|
|
273 |
//## begin TestScenario::setRepeatCount%42042CF100E5.body preserve=yes
|
|
|
274 |
|
|
|
275 |
return ( m_repeatCount = value );
|
|
|
276 |
|
|
|
277 |
//## end TestScenario::setRepeatCount%42042CF100E5.body
|
|
|
278 |
}
|
|
|
279 |
|
|
|
280 |
//## Operation: setScenarioName%42084D300222
|
|
|
281 |
std::string & TestScenario::setScenarioName (const std::string &value)
|
|
|
282 |
{
|
|
|
283 |
//## begin TestScenario::setScenarioName%42084D300222.body preserve=yes
|
|
|
284 |
|
|
|
285 |
return ( m_scenarioName = value );
|
|
|
286 |
|
|
|
287 |
//## end TestScenario::setScenarioName%42084D300222.body
|
|
|
288 |
}
|
|
|
289 |
|
|
|
290 |
// Additional Declarations
|
|
|
291 |
//## begin TestScenario%42030C2C00B8.declarations preserve=yes
|
|
|
292 |
//## end TestScenario%42030C2C00B8.declarations
|
|
|
293 |
|
|
|
294 |
//## begin module%42030C2C00B8.epilog preserve=yes
|
|
|
295 |
//## end module%42030C2C00B8.epilog
|