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%4205D0C403E2.cm preserve=no
7
//## end module%4205D0C403E2.cm
8
 
9
//## begin module%4205D0C403E2.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%4205D0C403E2.cp
19
 
20
//## Module: TransactionStructure%4205D0C403E2; Pseudo Package body
21
//## Subsystem: MASS::Dev::Tools::TxnTestManager::src%41F5A79001E4
22
//## Source file: Z:\MASS_Dev\Tools\TxnTestManager\src\TransactionStructure.cpp
23
 
24
//## begin module%4205D0C403E2.additionalIncludes preserve=no
25
//## end module%4205D0C403E2.additionalIncludes
26
 
27
//## begin module%4205D0C403E2.includes preserve=yes
28
#pragma warn -com
29
#include <LoggingMacros.h>
30
#pragma warn +com
31
//## end module%4205D0C403E2.includes
32
 
33
// IXmlSchemaWrapperSchema
34
#include "IXmlSchemaWrapperSchema.h"
35
// IXmlSchemaWrapperElement
36
#include "IXmlSchemaWrapperElement.h"
37
// IXmlSchemaWrapperHandle
38
#include "IXmlSchemaWrapperHandle.h"
39
// IXmlSchemaWrapperFactory
40
#include "IXmlSchemaWrapperFactory.h"
41
// IXmlSchemaWrapperStream
42
#include "IXmlSchemaWrapperStream.h"
43
// TransactionStream
44
#include "TransactionStream.h"
45
// TransactionStructure
46
#include "TransactionStructure.h"
47
//## begin module%4205D0C403E2.additionalDeclarations preserve=yes
48
//## end module%4205D0C403E2.additionalDeclarations
49
 
50
 
51
// Class TransactionStructure 
52
 
53
//## Operation: TransactionStructure%4205D148027B
54
TransactionStructure::TransactionStructure (const std::string &name, const int &iteration, XMLSchema::IXmlSchemaWrapperFactory &schemaFactory, XMLSchema::IXmlSchemaWrapperSchema &schema, const bool &isHeader)
55
  //## begin TransactionStructure::TransactionStructure%4205D148027B.hasinit preserve=no
56
      : m_structureName(name),
57
        m_isHeader(isHeader),
58
        m_structureHandle(0),
59
        m_structure(0),
60
        m_schemaFactory(&schemaFactory),
61
        m_schema(&schema)
62
  //## end TransactionStructure::TransactionStructure%4205D148027B.hasinit
63
  //## begin TransactionStructure::TransactionStructure%4205D148027B.initialization preserve=yes
64
  //## end TransactionStructure::TransactionStructure%4205D148027B.initialization
65
{
66
  //## begin TransactionStructure::TransactionStructure%4205D148027B.body preserve=yes
67
 
68
	m_structureHandle = &m_schemaFactory->createHandle();
69
 
70
	if ( m_schema->createStructure(
71
			name.c_str(),
72
			iteration,
73
			*m_structureHandle ) )
74
	{
75
		if ( ( m_structure = m_schema->createSchemaElement(
76
					m_structureHandle->c_str(),
77
					"" ) ) == 0 )
78
		{
79
			m_schema->destroyStructure( m_structureHandle->c_str() );
80
 
81
			m_schemaFactory->destroyHandle( *m_structureHandle );
82
			m_structureHandle = 0;
83
 
84
			MTHROW( std::runtime_error, \
85
				"Cannot create structure \"" << name << "\"." );
86
		}
87
	}
88
	else
89
	{
90
		m_schemaFactory->destroyHandle( *m_structureHandle );
91
		m_structureHandle = 0;
92
 
93
		MTHROW( std::runtime_error, \
94
			"Cannot create structure \"" << name << "\"." );
95
	}
96
 
97
  //## end TransactionStructure::TransactionStructure%4205D148027B.body
98
}
99
 
100
 
101
TransactionStructure::~TransactionStructure()
102
{
103
  //## begin TransactionStructure::~TransactionStructure%4205D0C403E2_dest.body preserve=yes
104
 
105
	if ( m_structure )
106
	{
107
		m_schema->destroySchemaElement( *m_structure );
108
		m_structure = 0;
109
	}
110
 
111
	if ( m_structureHandle )
112
	{
113
		m_schema->destroyStructure( m_structureHandle->c_str() );
114
		m_schemaFactory->destroyHandle( *m_structureHandle );
115
		m_structureHandle = 0;
116
	}
117
 
118
	m_schemaFactory = 0;	// We don't own this object.
119
	m_schema = 0;			// We don't own this object.
120
 
121
  //## end TransactionStructure::~TransactionStructure%4205D0C403E2_dest.body
122
}
123
 
124
 
125
 
126
//## Other Operations (implementation)
127
//## Operation: getName%4205D7B602F0
128
const std::string & TransactionStructure::getName () const
129
{
130
  //## begin TransactionStructure::getName%4205D7B602F0.body preserve=yes
131
 
132
	return ( m_structureName );
133
 
134
  //## end TransactionStructure::getName%4205D7B602F0.body
135
}
136
 
137
//## Operation: getSchemaElement%4206D93203BB
138
XMLSchema::IXmlSchemaWrapperElement & TransactionStructure::getSchemaElement ()
139
{
140
  //## begin TransactionStructure::getSchemaElement%4206D93203BB.body preserve=yes
141
 
142
	return ( *m_structure );  
143
 
144
  //## end TransactionStructure::getSchemaElement%4206D93203BB.body
145
}
146
 
147
//## Operation: isHeader%4207123A020C
148
const bool TransactionStructure::isHeader () const
149
{
150
  //## begin TransactionStructure::isHeader%4207123A020C.body preserve=yes
151
 
152
	return ( m_isHeader );  
153
 
154
  //## end TransactionStructure::isHeader%4207123A020C.body
155
}
156
 
157
//## Operation: write%4207140A0268
158
const bool TransactionStructure::write (TransactionStream& stream)
159
{
160
  //## begin TransactionStructure::write%4207140A0268.body preserve=yes
161
 
162
	XMLSchema::IXmlSchemaWrapperStream * wrapperStream = 0;
163
	try
164
	{
165
		wrapperStream = &m_schemaFactory->createXdrStream();
166
 
167
		if ( m_schema->serialise(
168
				m_structureHandle->c_str(),
169
				*wrapperStream ) )
170
		{
171
			void const *	buffer = 0;
172
			unsigned int	length = 0;
173
 
174
			if ( wrapperStream->getData( buffer, length ) )
175
			{
176
				return ( stream.write( buffer, length ) );
177
			}
178
			else
179
			{
180
				MERROR( "Cannot get buffer for \"" << m_structureName << "\"." )
181
			}
182
		}
183
		else
184
		{
185
			MERROR( "Cannot serialise \"" << m_structureName << "\"." )
186
		}
187
	}
188
	__finally
189
	{
190
		if ( wrapperStream )
191
		{
192
			m_schemaFactory->destroyStream( *wrapperStream );
193
			wrapperStream = 0;
194
		}
195
	}
196
 
197
	return ( false );
198
 
199
  //## end TransactionStructure::write%4207140A0268.body
200
}
201
 
202
//## Operation: write%4236929B00A3
203
const bool TransactionStructure::write (XMLSchema::IXmlSchemaWrapperStream& stream, XMLSchema::IXmlSchemaWrapperQualification &qualifier)
204
{
205
  //## begin TransactionStructure::write%4236929B00A3.body preserve=yes
206
 
207
	return ( m_schema->serialise(
208
					m_structureHandle->c_str(),
209
					stream,
210
					&qualifier ) );
211
 
212
  //## end TransactionStructure::write%4236929B00A3.body
213
}
214
 
215
// Additional Declarations
216
  //## begin TransactionStructure%4205D0C403E2.declarations preserve=yes
217
  //## end TransactionStructure%4205D0C403E2.declarations
218
 
219
//## begin module%4205D0C403E2.epilog preserve=yes
220
//## end module%4205D0C403E2.epilog