Subversion Repositories DevTools

Rev

Rev 2228 | Details | Compare with Previous | 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%420310A60071.cm preserve=no
7
//## end module%420310A60071.cm
8
 
9
//## begin module%420310A60071.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%420310A60071.cp
19
 
20
//## Module: Iteration%420310A60071; Pseudo Package body
21
//## Subsystem: MASS::Dev::Tools::TxnTestManager::src%41F5A79001E4
22
//## Source file: Z:\MASS_Dev\Tools\TxnTestManager\src\Iteration.cpp
23
 
24
//## begin module%420310A60071.additionalIncludes preserve=no
25
//## end module%420310A60071.additionalIncludes
26
 
27
//## begin module%420310A60071.includes preserve=yes
28
#pragma warn -com
29
#include <LoggingMacros.h>
30
#pragma warn +com
31
//## end module%420310A60071.includes
32
 
33
// EvaluationContext
34
#include "EvaluationContext.h"
35
// TransactionStream
36
#include "TransactionStream.h"
37
// Iteration
38
#include "Iteration.h"
39
// TestScenario
40
#include "TestScenario.h"
2228 sbetterm 41
// IXmlSchemaWrapperSchema
42
#include "IXmlSchemaWrapperSchema.h"
43
// IXmlSchemaWrapperString
44
#include "IXmlSchemaWrapperString.h"
45
// IXmlSchemaWrapperFactory
46
#include "IXmlSchemaWrapperFactory.h"
2218 sbetterm 47
//## begin module%420310A60071.additionalDeclarations preserve=yes
2236 mhunt 48
#include <stdlib>
2218 sbetterm 49
//## end module%420310A60071.additionalDeclarations
50
 
51
 
2228 sbetterm 52
// Class Iteration
2218 sbetterm 53
 
54
//## Operation: Iteration%420311980081
55
Iteration::Iteration (const std::string &projectCode, const int &iteration, XMLSchema::IXmlSchemaWrapperFactory &factory, XMLSchema::IXmlSchemaWrapperSchema &schema, const std::string &schemaHandle)
56
  //## begin Iteration::Iteration%420311980081.hasinit preserve=no
57
      : m_schemaHandle(schemaHandle),
58
        m_schema(0),
59
        m_factory(0)
60
  //## end Iteration::Iteration%420311980081.hasinit
61
  //## begin Iteration::Iteration%420311980081.initialization preserve=yes
62
 
63
,	m_projectCode( projectCode ),
64
	m_iteration( iteration )
65
 
66
  //## end Iteration::Iteration%420311980081.initialization
67
{
68
  //## begin Iteration::Iteration%420311980081.body preserve=yes
69
 
70
	m_factory	= &factory;
71
	m_schema	= &schema;
72
 
73
  //## end Iteration::Iteration%420311980081.body
74
}
75
 
76
 
77
Iteration::~Iteration()
78
{
79
  //## begin Iteration::~Iteration%420310A60071_dest.body preserve=yes
80
 
81
	for ( std::map< int, TestScenario * >::iterator
82
			where = m_scenario.begin();
83
		  where != m_scenario.end();
84
		  ++where )
85
	{
86
		delete where->second;
87
		where->second = 0;
88
	}
89
 
90
	m_schema	= 0;	// We don't own this object.
91
	m_factory	= 0;	// We don't own this object.
92
 
93
  //## end Iteration::~Iteration%420310A60071_dest.body
94
}
95
 
96
 
97
 
98
//## Other Operations (implementation)
2228 sbetterm 99
//## Operation: findTestScenario%428D756A034D
100
TestScenario& Iteration::findTestScenario (const int &scenario)
101
{
102
  //## begin Iteration::findTestScenario%428D756A034D.body preserve=yes
103
 
104
	std::map< int, TestScenario * >::const_iterator
105
		instance = m_scenario.find( scenario );
106
 
107
	if ( instance != m_scenario.end() )
108
	{
109
		return ( *instance->second );
110
	}
111
 
112
	MTHROW( std::runtime_error, \
113
		"Cannot find scenario " << scenario << '.' );
114
 
115
  //## end Iteration::findTestScenario%428D756A034D.body
116
}
117
 
2218 sbetterm 118
//## Operation: generate%42045A4D0198
119
const bool Iteration::generate (TransactionStream& stream, const bool &generateHeaders, EvaluationContext& evaluationContext)
120
{
121
  //## begin Iteration::generate%42045A4D0198.body preserve=yes
122
 
123
	bool generated = true;
124
	for ( std::vector< TestScenario * >::iterator
125
			where = m_orderedScenarioCollection.begin();
126
		  where != m_orderedScenarioCollection.end();
127
		  ++where )
128
	{
129
		if ( !(*where)->generate(
130
					stream,
131
					generateHeaders,
132
					evaluationContext ) )
133
		{
134
			generated = false;
135
			break;
136
		}
137
	}
138
	return ( generated );
139
 
140
  //## end Iteration::generate%42045A4D0198.body
141
}
142
 
143
//## Operation: getFormatVersion%4208BDE6025B
144
const int Iteration::getFormatVersion () const
145
{
146
  //## begin Iteration::getFormatVersion%4208BDE6025B.body preserve=yes
147
 
148
	XMLSchema::IXmlSchemaWrapperString * attributeValue = 0;
149
 
150
	try
151
	{
152
		attributeValue = &m_factory->createString();
153
		if ( m_schema->getAttributeProperty(
154
				m_schemaHandle.c_str(),
155
				"",
156
				"majorversion",
157
				*attributeValue ) )
158
		{
159
			const int majorVersion = atoi( attributeValue->c_str() );
160
 
161
			if ( m_schema->getAttributeProperty(
162
					m_schemaHandle.c_str(),
163
					"",
164
					"minorversion",
165
					*attributeValue ) )
166
			{
167
				const int minorVersion = atoi( attributeValue->c_str() );
168
				return ( ( majorVersion << 16 ) + ( minorVersion << 8 ) );
169
			}
170
		}
171
	}
172
	__finally
173
	{
174
		m_factory->destroyString( *attributeValue );
175
		attributeValue = 0;
176
	}
177
 
178
	MTHROW( std::runtime_error, \
179
		"Cannot read format version from schema." );
180
 
181
  //## end Iteration::getFormatVersion%4208BDE6025B.body
182
}
183
 
184
//## Operation: getIterationId%4203119303AD
185
const int & Iteration::getIterationId () const
186
{
187
  //## begin Iteration::getIterationId%4203119303AD.body preserve=yes
188
 
189
	return ( m_iteration );
190
 
191
  //## end Iteration::getIterationId%4203119303AD.body
192
}
193
 
194
//## Operation: getProjectCode%4203118E02F2
195
const std::string & Iteration::getProjectCode () const
196
{
197
  //## begin Iteration::getProjectCode%4203118E02F2.body preserve=yes
198
 
199
	return ( m_projectCode );
200
 
201
  //## end Iteration::getProjectCode%4203118E02F2.body
202
}
203
 
204
//## Operation: getSchema%420460A8000E
205
XMLSchema::IXmlSchemaWrapperSchema & Iteration::getSchema () const
206
{
207
  //## begin Iteration::getSchema%420460A8000E.body preserve=yes
208
 
209
	return ( *m_schema );
210
 
211
  //## end Iteration::getSchema%420460A8000E.body
212
}
213
 
214
//## Operation: getSchemaWrapperFactory%42045F8B030B
215
XMLSchema::IXmlSchemaWrapperFactory & Iteration::getSchemaWrapperFactory () const
216
{
217
  //## begin Iteration::getSchemaWrapperFactory%42045F8B030B.body preserve=yes
218
 
219
	return ( *m_factory );
220
 
221
  //## end Iteration::getSchemaWrapperFactory%42045F8B030B.body
222
}
223
 
224
//## Operation: getTestScenario%420312AF031E
225
TestScenario& Iteration::getTestScenario (const int &scenario)
226
{
227
  //## begin Iteration::getTestScenario%420312AF031E.body preserve=yes
228
 
229
	std::map< int, TestScenario * >::const_iterator
230
		instance = m_scenario.find( scenario );
231
 
232
	if ( instance != m_scenario.end() )
233
	{
234
		return ( *instance->second );
235
	}
236
	else
237
	{
238
		TestScenario * object = 0;
239
 
240
		try
241
		{
242
			object = new TestScenario( scenario, *this );
243
 
244
			m_orderedScenarioCollection.push_back( object );
245
			if ( m_scenario.insert(
246
					std::map< int, TestScenario * >::value_type(
247
						scenario,
248
						object ) ).second )
249
			{
250
				return ( *object );
251
			}
252
			else
253
			{
254
				MTHROW( std::runtime_error, \
255
					"Cannot add scenario \"" \
256
					<< scenario \
257
					<< "\" to iteration " \
258
					<< m_iteration \
259
					<< '.' );
260
			}
261
		}
262
		catch ( ... )
263
		{
264
			delete object;
265
			object = 0;
266
 
267
			throw;
268
		}
269
	}
270
 
271
  //## end Iteration::getTestScenario%420312AF031E.body
272
}
273
 
274
//## Operation: getTransactionCount%420890E2017C
275
const unsigned Iteration::getTransactionCount () const
276
{
277
  //## begin Iteration::getTransactionCount%420890E2017C.body preserve=yes
278
 
279
	unsigned int count = 0;
280
 
281
	for ( std::map< int, TestScenario * >::const_iterator
282
			where = m_scenario.begin();
283
		  where != m_scenario.end();
284
		  ++where )
285
	{
286
		count += where->second->getTransactionCount();
287
	}
288
 
289
	return ( count );
290
 
291
  //## end Iteration::getTransactionCount%420890E2017C.body
292
}
293
 
294
// Additional Declarations
295
  //## begin Iteration%420310A60071.declarations preserve=yes
296
  //## end Iteration%420310A60071.declarations
297
 
298
//## begin module%420310A60071.epilog preserve=yes
299
//## end module%420310A60071.epilog