| 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%425A0C2601FD.cm preserve=no
|
|
|
7 |
//## end module%425A0C2601FD.cm
|
|
|
8 |
|
|
|
9 |
//## begin module%425A0C2601FD.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%425A0C2601FD.cp
|
|
|
19 |
|
|
|
20 |
//## Module: UdDrainFile%425A0C2601FD; Pseudo Package body
|
|
|
21 |
//## Subsystem: MASS::Dev::Tools::TxnTestManager::src%41F5A79001E4
|
|
|
22 |
//## Source file: Z:\MASS_Dev\Tools\TxnTestManager\src\UdDrainFile.cpp
|
|
|
23 |
|
|
|
24 |
//## begin module%425A0C2601FD.additionalIncludes preserve=no
|
|
|
25 |
//## end module%425A0C2601FD.additionalIncludes
|
|
|
26 |
|
|
|
27 |
//## begin module%425A0C2601FD.includes preserve=yes
|
|
|
28 |
#pragma warn -com
|
|
|
29 |
#include <LoggingMacros.h>
|
|
|
30 |
#pragma warn +com
|
|
|
31 |
//## end module%425A0C2601FD.includes
|
|
|
32 |
|
|
|
33 |
// IXmlSchemaWrapperElement
|
|
|
34 |
#include "IXmlSchemaWrapperElement.h"
|
|
|
35 |
// IXmlSchemaWrapperHandle
|
|
|
36 |
#include "IXmlSchemaWrapperHandle.h"
|
|
|
37 |
// IXmlSchemaWrapperFactory
|
|
|
38 |
#include "IXmlSchemaWrapperFactory.h"
|
|
|
39 |
// IXmlSchemaWrapperSchema
|
|
|
40 |
#include "IXmlSchemaWrapperSchema.h"
|
|
|
41 |
// UdDrainFile
|
|
|
42 |
#include "UdDrainFile.h"
|
|
|
43 |
//## begin module%425A0C2601FD.additionalDeclarations preserve=yes
|
|
|
44 |
//## end module%425A0C2601FD.additionalDeclarations
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
// Class UdDrainFile
|
|
|
48 |
|
|
|
49 |
//## Operation: UdDrainFile%425A132E0282
|
|
|
50 |
UdDrainFile::UdDrainFile (XMLSchema::IXmlSchemaWrapperFactory &schemaFactory, XMLSchema::IXmlSchemaWrapperSchema &schema)
|
|
|
51 |
//## begin UdDrainFile::UdDrainFile%425A132E0282.hasinit preserve=no
|
|
|
52 |
: m_headed(false),
|
|
|
53 |
m_schemaFactory(&schemaFactory),
|
|
|
54 |
m_schema(&schema),
|
|
|
55 |
m_structureHandle(0),
|
|
|
56 |
m_structure(0)
|
|
|
57 |
//## end UdDrainFile::UdDrainFile%425A132E0282.hasinit
|
|
|
58 |
//## begin UdDrainFile::UdDrainFile%425A132E0282.initialization preserve=yes
|
|
|
59 |
//## end UdDrainFile::UdDrainFile%425A132E0282.initialization
|
|
|
60 |
{
|
|
|
61 |
//## begin UdDrainFile::UdDrainFile%425A132E0282.body preserve=yes
|
|
|
62 |
//## end UdDrainFile::UdDrainFile%425A132E0282.body
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
UdDrainFile::~UdDrainFile()
|
|
|
67 |
{
|
|
|
68 |
//## begin UdDrainFile::~UdDrainFile%425A0C2601FD_dest.body preserve=yes
|
|
|
69 |
|
|
|
70 |
if ( m_structure )
|
|
|
71 |
{
|
|
|
72 |
m_schema->destroySchemaElement( *m_structure );
|
|
|
73 |
m_structure = 0;
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
if ( m_structureHandle )
|
|
|
77 |
{
|
|
|
78 |
m_schema->destroyStructure( m_structureHandle->c_str() );
|
|
|
79 |
m_schemaFactory->destroyHandle( *m_structureHandle );
|
|
|
80 |
m_structureHandle = 0;
|
|
|
81 |
}
|
|
|
82 |
m_schemaFactory = 0; // We don't own this object.
|
|
|
83 |
m_schema = 0; // We don't own this object.
|
|
|
84 |
|
|
|
85 |
//## end UdDrainFile::~UdDrainFile%425A0C2601FD_dest.body
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
//## Other Operations (implementation)
|
|
|
91 |
//## Operation: getTransactionCount%425A1A1901D3
|
|
|
92 |
const unsigned int UdDrainFile::getTransactionCount () const
|
|
|
93 |
{
|
|
|
94 |
//## begin UdDrainFile::getTransactionCount%425A1A1901D3.body preserve=yes
|
|
|
95 |
|
|
|
96 |
unsigned int count = 0;
|
|
|
97 |
|
|
|
98 |
if ( m_structure )
|
|
|
99 |
{
|
|
|
100 |
XMLSchema::IXmlSchemaWrapperElement * attribute = 0;
|
|
|
101 |
|
|
|
102 |
try
|
|
|
103 |
{
|
|
|
104 |
if ( m_headed )
|
|
|
105 |
{
|
|
|
106 |
attribute = m_structure->createSchemaElement( "NoOfItems" );
|
|
|
107 |
}
|
|
|
108 |
else
|
|
|
109 |
{
|
|
|
110 |
attribute = m_structure->createSchemaElement( "NoOfItems" );
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
if ( attribute )
|
|
|
114 |
{
|
|
|
115 |
if ( !attribute->getUnsignedInteger32( count ) )
|
|
|
116 |
{
|
|
|
117 |
MTHROW( std::runtime_error, \
|
|
|
118 |
"Cannot read the number of transactions in drain file." );
|
|
|
119 |
}
|
|
|
120 |
}
|
|
|
121 |
}
|
|
|
122 |
__finally
|
|
|
123 |
{
|
|
|
124 |
m_structure->destroySchemaElement( *attribute );
|
|
|
125 |
attribute = 0;
|
|
|
126 |
}
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
return ( count );
|
|
|
130 |
|
|
|
131 |
//## end UdDrainFile::getTransactionCount%425A1A1901D3.body
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
//## Operation: read%425A1133022E
|
|
|
135 |
const bool UdDrainFile::read (const bool &hasHeader, const int &iteration, const char *fileName)
|
|
|
136 |
{
|
|
|
137 |
//## begin UdDrainFile::read%425A1133022E.body preserve=yes
|
|
|
138 |
|
|
|
139 |
XMLSchema::IXmlSchemaWrapperStream * stream = 0;
|
|
|
140 |
|
|
|
141 |
try
|
|
|
142 |
{
|
|
|
143 |
m_structureHandle = &m_schemaFactory->createHandle();
|
|
|
144 |
|
|
|
145 |
m_headed = hasHeader;
|
|
|
146 |
if ( m_schema->createStructure(
|
|
|
147 |
( m_headed ? "Mass_BatchUsageData_t" : "Mass_UDRecords_t" ),
|
|
|
148 |
iteration,
|
|
|
149 |
*m_structureHandle ) )
|
|
|
150 |
{
|
|
|
151 |
if ( ( m_structure = m_schema->createSchemaElement(
|
|
|
152 |
m_structureHandle->c_str(),
|
|
|
153 |
"" ) ) != 0 )
|
|
|
154 |
{
|
|
|
155 |
stream = &m_schemaFactory->createXdrStream();
|
|
|
156 |
|
|
|
157 |
if ( !m_schema->deserialise(
|
|
|
158 |
m_structureHandle->c_str(),
|
|
|
159 |
*stream ) )
|
|
|
160 |
{
|
|
|
161 |
MERROR( "Cannot serialise \"" << fileName << "\"." )
|
|
|
162 |
return ( false );
|
|
|
163 |
}
|
|
|
164 |
|
|
|
165 |
return ( true );
|
|
|
166 |
}
|
|
|
167 |
}
|
|
|
168 |
else
|
|
|
169 |
{
|
|
|
170 |
m_schemaFactory->destroyHandle( *m_structureHandle );
|
|
|
171 |
m_structureHandle = 0;
|
|
|
172 |
}
|
|
|
173 |
}
|
|
|
174 |
__finally
|
|
|
175 |
{
|
|
|
176 |
if ( stream )
|
|
|
177 |
{
|
|
|
178 |
m_schemaFactory->destroyStream( *stream );
|
|
|
179 |
stream = 0;
|
|
|
180 |
}
|
|
|
181 |
}
|
|
|
182 |
|
|
|
183 |
return ( false );
|
|
|
184 |
|
|
|
185 |
//## end UdDrainFile::read%425A1133022E.body
|
|
|
186 |
}
|
|
|
187 |
|
|
|
188 |
// Additional Declarations
|
|
|
189 |
//## begin UdDrainFile%425A0C2601FD.declarations preserve=yes
|
|
|
190 |
//## end UdDrainFile%425A0C2601FD.declarations
|
|
|
191 |
|
|
|
192 |
//## begin module%425A0C2601FD.epilog preserve=yes
|
|
|
193 |
//## end module%425A0C2601FD.epilog
|