Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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%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
// Iteration
34
#include "Iteration.h"
35
// TestScenario
36
#include "TestScenario.h"
37
// TransactionSpecification
38
#include "TransactionSpecification.h"
39
// EvaluationContext
40
#include "EvaluationContext.h"
41
// TransactionStream
42
#include "TransactionStream.h"
43
// DefinedVariable
44
#include "DefinedVariable.h"
45
//## begin module%42030C2C00B8.additionalDeclarations preserve=yes
46
#include <locale>
47
//## end module%42030C2C00B8.additionalDeclarations
48
 
49
 
50
// Class TestScenario 
51
 
52
//## Operation: TestScenario%4203231D030E
53
TestScenario::TestScenario (const int &scenario, Iteration& iteration)
54
  //## begin TestScenario::TestScenario%4203231D030E.hasinit preserve=no
55
      : m_batchSize(0),
56
        m_repeatCount(0),
57
        m_iteration(&iteration)
58
  //## end TestScenario::TestScenario%4203231D030E.hasinit
59
  //## begin TestScenario::TestScenario%4203231D030E.initialization preserve=yes
60
 
61
,	m_scenario( scenario )
62
 
63
  //## end TestScenario::TestScenario%4203231D030E.initialization
64
{
65
  //## begin TestScenario::TestScenario%4203231D030E.body preserve=yes
66
  //## end TestScenario::TestScenario%4203231D030E.body
67
}
68
 
69
 
70
TestScenario::~TestScenario()
71
{
72
  //## begin TestScenario::~TestScenario%42030C2C00B8_dest.body preserve=yes
73
 
74
	for ( std::map< int, TransactionSpecification * >::iterator
75
			where = m_transaction.begin();
76
		  where != m_transaction.end();
77
		  ++where )
78
	{
79
		delete where->second;
80
		where->second = 0;
81
	}
82
	m_iteration = 0;	// We don't own this object.
83
 
84
  //## end TestScenario::~TestScenario%42030C2C00B8_dest.body
85
}
86
 
87
 
88
 
89
//## Other Operations (implementation)
90
//## Operation: buildBatchName%4208537A00B6
91
std::string & TestScenario::buildBatchName (std::string &batchName, const std::string &scenarioName)
92
{
93
  //## begin TestScenario::buildBatchName%4208537A00B6.body preserve=yes
94
 
95
	batchName.erase();
96
	batchName.reserve( scenarioName.length() );
97
 
98
	for ( std::string::size_type index = 0; index < scenarioName.length(); ++index )
99
	{
100
		if ( std::isalnum( scenarioName[ index ] ) )
101
		{
102
			batchName += scenarioName[ index ];
103
		}
104
		else
105
		{
106
			batchName += '_';
107
		}
108
	}
109
 
110
	return ( batchName );
111
 
112
  //## end TestScenario::buildBatchName%4208537A00B6.body
113
}
114
 
115
//## Operation: defineVariable%425B47DD004F
116
DefinedVariable& TestScenario::defineVariable (const std::string &variableName)
117
{
118
  //## begin TestScenario::defineVariable%425B47DD004F.body preserve=yes
119
 
120
	std::map< std::string, DefinedVariable * >::const_iterator
121
		instance = m_variable.find( variableName );
122
 
123
	if ( instance != m_variable.end() )
124
	{
125
		return ( *instance->second );
126
	}
127
	else
128
	{
129
		DefinedVariable * object = 0;
130
 
131
		try
132
		{
133
			object = new DefinedVariable( variableName );
134
 
135
			if ( m_variable.insert(
136
					std::map< std::string, DefinedVariable * >::value_type(
137
						variableName,
138
						object ) ).second )
139
			{
140
				return ( *object );
141
			}
142
			else
143
			{
144
				MTHROW( std::runtime_error, \
145
					"Cannot add variable \"" \
146
					<< variableName \
147
					<< "\" to defined variable table." );
148
			}
149
		}
150
		catch ( ... )
151
		{
152
			delete object;
153
			object = 0;
154
 
155
			throw;
156
		}
157
	}
158
 
159
  //## end TestScenario::defineVariable%425B47DD004F.body
160
}
161
 
162
//## Operation: generate%420455D80390
163
const bool TestScenario::generate (TransactionStream& stream, const bool &generateHeaders, EvaluationContext& evaluationContext)
164
{
165
  //## begin TestScenario::generate%420455D80390.body preserve=yes
166
 
167
	bool generated = true;
168
	if ( m_repeatCount )
169
	{
170
    /* batch name now associated with tets case not test step		
171
    std::string batchName;
172
		stream.newBatch(
173
			m_batchSize,
174
			buildBatchName( batchName, m_scenarioName ) );
175
    */
176
 
177
		for ( unsigned repeat = 1; repeat <= m_repeatCount && generated; ++repeat )
178
		{
179
			evaluationContext.setScenarioIndex( repeat );
180
 
181
			for ( std::vector< TransactionSpecification * >::iterator
182
					where = m_orderedTransactionCollection.begin();
183
				  where != m_orderedTransactionCollection.end();
184
				  ++where )
185
			{
186
				if ( !(*where)->generate(
187
							stream,
188
							generateHeaders,
189
							evaluationContext ) )
190
				{
191
					generated = false;
192
					break;
193
				}
194
			}
195
		}
196
	}
197
	return ( generated );
198
 
199
  //## end TestScenario::generate%420455D80390.body
200
}
201
 
202
//## Operation: getBatchSize%42042C5E0029
203
const unsigned & TestScenario::getBatchSize () const
204
{
205
  //## begin TestScenario::getBatchSize%42042C5E0029.body preserve=yes
206
 
207
	return ( m_batchSize );
208
 
209
  //## end TestScenario::getBatchSize%42042C5E0029.body
210
}
211
 
212
//## Operation: getIteration%420460EA003C
213
const Iteration & TestScenario::getIteration () const
214
{
215
  //## begin TestScenario::getIteration%420460EA003C.body preserve=yes
216
 
217
	return ( *m_iteration );  
218
 
219
  //## end TestScenario::getIteration%420460EA003C.body
220
}
221
 
222
//## Operation: getRepeatCount%42042C5D02F8
223
const unsigned & TestScenario::getRepeatCount () const
224
{
225
  //## begin TestScenario::getRepeatCount%42042C5D02F8.body preserve=yes
226
 
227
	return ( m_repeatCount );
228
 
229
  //## end TestScenario::getRepeatCount%42042C5D02F8.body
230
}
231
 
232
//## Operation: getScenarioName%42084D3A0270
233
const std::string & TestScenario::getScenarioName () const
234
{
235
  //## begin TestScenario::getScenarioName%42084D3A0270.body preserve=yes
236
 
237
	return ( m_scenarioName );
238
 
239
  //## end TestScenario::getScenarioName%42084D3A0270.body
240
}
241
 
242
//## Operation: getScenarioNumber%4203252300A6
243
const int & TestScenario::getScenarioNumber () const
244
{
245
  //## begin TestScenario::getScenarioNumber%4203252300A6.body preserve=yes
246
 
247
	return ( m_scenario );
248
 
249
  //## end TestScenario::getScenarioNumber%4203252300A6.body
250
}
251
 
252
//## Operation: getTransactionCount%420890BF03BE
253
const unsigned TestScenario::getTransactionCount () const
254
{
255
  //## begin TestScenario::getTransactionCount%420890BF03BE.body preserve=yes
256
 
257
	return ( m_transaction.size() * m_repeatCount );
258
 
259
  //## end TestScenario::getTransactionCount%420890BF03BE.body
260
}
261
 
262
//## Operation: getTransactionSpecification%420328E00043
263
TransactionSpecification& TestScenario::getTransactionSpecification (const int &transaction, const std::string &payloadStructureName)
264
{
265
  //## begin TestScenario::getTransactionSpecification%420328E00043.body preserve=yes
266
 
267
	std::map< int, TransactionSpecification * >::const_iterator
268
		instance = m_transaction.find( transaction );
269
 
270
	if ( instance != m_transaction.end() )
271
	{
272
		return ( *instance->second );
273
	}
274
	else
275
	{
276
		TransactionSpecification * object = 0;
277
 
278
		try
279
		{
280
			object = new TransactionSpecification( transaction, payloadStructureName, *this );
281
 
282
			m_orderedTransactionCollection.push_back( object );
283
			if ( m_transaction.insert(
284
					std::map< int, TransactionSpecification * >::value_type(
285
						transaction,
286
						object ) ).second )
287
			{
288
				return ( *object );
289
			}
290
			else
291
			{
292
				MTHROW( std::runtime_error, \
293
					"Cannot add transaction \"" \
294
					<< transaction \
295
					<< "\" to scenario " \
296
					<< m_scenario \
297
					<< '.' );
298
			}
299
		}
300
		catch ( ... )
301
		{
302
			delete object;
303
			object = 0;
304
 
305
			throw;
306
		}
307
	}
308
 
309
  //## end TestScenario::getTransactionSpecification%420328E00043.body
310
}
311
 
312
//## Operation: getVariable%425B47F50012
313
DefinedVariable& TestScenario::getVariable (const std::string &variableName)
314
{
315
  //## begin TestScenario::getVariable%425B47F50012.body preserve=yes
316
 
317
	std::map< std::string, DefinedVariable * >::const_iterator
318
		instance = m_variable.find( variableName );
319
 
320
	if ( instance != m_variable.end() )
321
	{
322
		return ( *instance->second );
323
	}
324
 
325
	MTHROW( std::runtime_error, \
326
		"Variable \"" \
327
		<< variableName \
328
		<< "\" is not defined." );
329
 
330
  //## end TestScenario::getVariable%425B47F50012.body
331
}
332
 
333
//## Operation: isVariable%425B4B6A01C1
334
const bool TestScenario::isVariable (const std::string &symbol) const
335
{
336
  //## begin TestScenario::isVariable%425B4B6A01C1.body preserve=yes
337
 
338
	return ( m_variable.find( symbol ) != m_variable.end() );
339
 
340
  //## end TestScenario::isVariable%425B4B6A01C1.body
341
}
342
 
343
//## Operation: setBatchSize%42042CF100D5
344
const unsigned & TestScenario::setBatchSize (const unsigned &value)
345
{
346
  //## begin TestScenario::setBatchSize%42042CF100D5.body preserve=yes
347
 
348
	return ( m_batchSize = value );
349
 
350
  //## end TestScenario::setBatchSize%42042CF100D5.body
351
}
352
 
353
//## Operation: setRepeatCount%42042CF100E5
354
const unsigned & TestScenario::setRepeatCount (const unsigned &value)
355
{
356
  //## begin TestScenario::setRepeatCount%42042CF100E5.body preserve=yes
357
 
358
	return ( m_repeatCount = value );
359
 
360
  //## end TestScenario::setRepeatCount%42042CF100E5.body
361
}
362
 
363
//## Operation: setScenarioName%42084D300222
364
std::string & TestScenario::setScenarioName (const std::string &value)
365
{
366
  //## begin TestScenario::setScenarioName%42084D300222.body preserve=yes
367
 
368
	return ( m_scenarioName = value );
369
 
370
  //## end TestScenario::setScenarioName%42084D300222.body
371
}
372
 
373
// Additional Declarations
374
  //## begin TestScenario%42030C2C00B8.declarations preserve=yes
375
  //## end TestScenario%42030C2C00B8.declarations
376
 
377
//## begin module%42030C2C00B8.epilog preserve=yes
378
//## end module%42030C2C00B8.epilog