Subversion Repositories DevTools

Rev

Rev 2222 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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 ) );
125
		for ( unsigned repeat = 0; repeat < m_repeatCount && generated; ++repeat )
126
		{
127
			for ( std::vector< TransactionSpecification * >::iterator
128
					where = m_orderedTransactionCollection.begin();
129
				  where != m_orderedTransactionCollection.end();
130
				  ++where )
131
			{
132
				if ( !(*where)->generate(
133
							stream,
134
							generateHeaders,
135
							evaluationContext ) )
136
				{
137
					generated = false;
138
					break;
139
				}
140
			}
141
		}
142
	}
143
	return ( generated );
144
 
145
  //## end TestScenario::generate%420455D80390.body
146
}
147
 
148
//## Operation: getBatchSize%42042C5E0029
149
const unsigned & TestScenario::getBatchSize () const
150
{
151
  //## begin TestScenario::getBatchSize%42042C5E0029.body preserve=yes
152
 
153
	return ( m_batchSize );
154
 
155
  //## end TestScenario::getBatchSize%42042C5E0029.body
156
}
157
 
158
//## Operation: getIteration%420460EA003C
159
const Iteration& TestScenario::getIteration () const
160
{
161
  //## begin TestScenario::getIteration%420460EA003C.body preserve=yes
162
 
163
	return ( *m_iteration );  
164
 
165
  //## end TestScenario::getIteration%420460EA003C.body
166
}
167
 
168
//## Operation: getRepeatCount%42042C5D02F8
169
const unsigned & TestScenario::getRepeatCount () const
170
{
171
  //## begin TestScenario::getRepeatCount%42042C5D02F8.body preserve=yes
172
 
173
	return ( m_repeatCount );
174
 
175
  //## end TestScenario::getRepeatCount%42042C5D02F8.body
176
}
177
 
178
//## Operation: getScenarioName%42084D3A0270
179
const std::string & TestScenario::getScenarioName () const
180
{
181
  //## begin TestScenario::getScenarioName%42084D3A0270.body preserve=yes
182
 
183
	return ( m_scenarioName );
184
 
185
  //## end TestScenario::getScenarioName%42084D3A0270.body
186
}
187
 
188
//## Operation: getScenarioNumber%4203252300A6
189
const int & TestScenario::getScenarioNumber () const
190
{
191
  //## begin TestScenario::getScenarioNumber%4203252300A6.body preserve=yes
192
 
193
	return ( m_scenario );
194
 
195
  //## end TestScenario::getScenarioNumber%4203252300A6.body
196
}
197
 
198
//## Operation: getTransactionCount%420890BF03BE
199
const unsigned TestScenario::getTransactionCount () const
200
{
201
  //## begin TestScenario::getTransactionCount%420890BF03BE.body preserve=yes
202
 
203
	return ( m_transaction.size() * m_repeatCount );
204
 
205
  //## end TestScenario::getTransactionCount%420890BF03BE.body
206
}
207
 
208
//## Operation: getTransactionSpecification%420328E00043
209
TransactionSpecification& TestScenario::getTransactionSpecification (const int &transaction, const std::string &payloadStructureName)
210
{
211
  //## begin TestScenario::getTransactionSpecification%420328E00043.body preserve=yes
212
 
213
	std::map< int, TransactionSpecification * >::const_iterator
214
		instance = m_transaction.find( transaction );
215
 
216
	if ( instance != m_transaction.end() )
217
	{
218
		return ( *instance->second );
219
	}
220
	else
221
	{
222
		TransactionSpecification * object = 0;
223
 
224
		try
225
		{
226
			object = new TransactionSpecification( transaction, payloadStructureName, *this );
227
 
228
			m_orderedTransactionCollection.push_back( object );
229
			if ( m_transaction.insert(
230
					std::map< int, TransactionSpecification * >::value_type(
231
						transaction,
232
						object ) ).second )
233
			{
234
				return ( *object );
235
			}
236
			else
237
			{
238
				MTHROW( std::runtime_error, \
239
					"Cannot add transaction \"" \
240
					<< transaction \
241
					<< "\" to scenario " \
242
					<< m_scenario \
243
					<< '.' );
244
			}
245
		}
246
		catch ( ... )
247
		{
248
			delete object;
249
			object = 0;
250
 
251
			throw;
252
		}
253
	}
254
 
255
  //## end TestScenario::getTransactionSpecification%420328E00043.body
256
}
257
 
258
//## Operation: setBatchSize%42042CF100D5
259
const unsigned & TestScenario::setBatchSize (const unsigned &value)
260
{
261
  //## begin TestScenario::setBatchSize%42042CF100D5.body preserve=yes
262
 
263
	return ( m_batchSize = value );
264
 
265
  //## end TestScenario::setBatchSize%42042CF100D5.body
266
}
267
 
268
//## Operation: setRepeatCount%42042CF100E5
269
const unsigned & TestScenario::setRepeatCount (const unsigned &value)
270
{
271
  //## begin TestScenario::setRepeatCount%42042CF100E5.body preserve=yes
272
 
273
	return ( m_repeatCount = value );
274
 
275
  //## end TestScenario::setRepeatCount%42042CF100E5.body
276
}
277
 
278
//## Operation: setScenarioName%42084D300222
279
std::string & TestScenario::setScenarioName (const std::string &value)
280
{
281
  //## begin TestScenario::setScenarioName%42084D300222.body preserve=yes
282
 
283
	return ( m_scenarioName = value );
284
 
285
  //## end TestScenario::setScenarioName%42084D300222.body
286
}
287
 
288
// Additional Declarations
289
  //## begin TestScenario%42030C2C00B8.declarations preserve=yes
290
  //## end TestScenario%42030C2C00B8.declarations
291
 
292
//## begin module%42030C2C00B8.epilog preserve=yes
293
//## end module%42030C2C00B8.epilog