Subversion Repositories DevTools

Rev

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