Subversion Repositories DevTools

Rev

Rev 2265 | Details | Compare with Previous | 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%4209BA4C03B8.cm preserve=no
7
//## end module%4209BA4C03B8.cm
8
 
9
//## begin module%4209BA4C03B8.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
12
//	disclosed in whole
13
//	or in part to any third party nor used in any manner
14
//	whatsoever other
15
//	than for the purposes expressly consented to by ERG in
16
//	writing.
17
//
18
//	This material is also copyright and may not be
19
//	reproduced, stored in a
20
//	retrieval system or transmitted in any form or by any
21
//	means in whole or
22
//	in part without the express written consent of ERG.
23
//## end module%4209BA4C03B8.cp
24
 
25
//## Module: UdFileManifest%4209BA4C03B8; Pseudo Package body
26
//## Subsystem: MASS::Dev::Tools::TxnTestManager::src%41F5A79001E4
27
//## Source file: Z:\MASS_Dev\Tools\TxnTestManager\src\UdFileManifest.cpp
28
 
29
//## begin module%4209BA4C03B8.additionalIncludes preserve=no
30
//## end module%4209BA4C03B8.additionalIncludes
31
 
32
//## begin module%4209BA4C03B8.includes preserve=yes
33
#pragma warn -com
34
#include <LoggingMacros.h>
35
#pragma warn +com
36
//## end module%4209BA4C03B8.includes
37
 
38
// UdFileManifest
39
#include "UdFileManifest.h"
40
// TransactionStream
41
#include "TransactionStream.h"
42
//## begin module%4209BA4C03B8.additionalDeclarations preserve=yes
43
 
44
#include <ctype>
45
/**
46
	Example UD Manifest file.  Lines starting with a # are comments and are
47
	ignored.
48
 
49
	#UD Manifest
50
	#0000000101-SY1-903ECU-00000005
51
	/afc/ergdce/var/DCE/ud/drained/CvXK71l0_903ECU.devud
52
	/afc/ergdce/var/DCE/ud/drained/CvXLn1Y0_903ECU.devud
53
	/afc/ergdce/var/DCE/ud/drained/CvXP49b0_903ECU.devud
54
	/afc/ergdce/var/DCE/ud/drained/CvXtDCw0_903ECU.devud
55
	/afc/ergdce/var/DCE/ud/drained/CvXtE0U0_903ECU.devud
56
	/afc/ergdce/var/DCE/ud/drained/CvnNj8c0_903ECU.devud
57
	/afc/ergdce/var/DCE/ud/drained/CvnRVA10_903ECU.devud
58
	#total = 7
59
	#end
60
 */
61
//## end module%4209BA4C03B8.additionalDeclarations
62
 
63
 
64
// Class UdFileManifest 
65
 
66
//## Operation: UdFileManifest%4209BAA8031C
67
UdFileManifest::UdFileManifest (const std::string &folder, const std::string &prefix, const std::string &suffix, const std::string &pathmapTarget)
68
  //## begin UdFileManifest::UdFileManifest%4209BAA8031C.hasinit preserve=no
69
      : m_count(0),
2265 kivins 70
        m_folder("..\\data\\summaries"),
2267 kivins 71
	     m_pathmapTarget(folder),  // yes we deliberately use folder for pathmapTarget
2263 kivins 72
        m_prefix(prefix),
73
        m_stream(0),
74
        m_suffix(suffix)
75
  //## end UdFileManifest::UdFileManifest%4209BAA8031C.hasinit
76
  //## begin UdFileManifest::UdFileManifest%4209BAA8031C.initialization preserve=yes
77
  //## end UdFileManifest::UdFileManifest%4209BAA8031C.initialization
78
{
79
  //## begin UdFileManifest::UdFileManifest%4209BAA8031C.body preserve=yes
80
 
81
	open();  
82
 
83
  //## end UdFileManifest::UdFileManifest%4209BAA8031C.body
84
}
85
 
86
 
87
UdFileManifest::~UdFileManifest()
88
{
89
  //## begin UdFileManifest::~UdFileManifest%4209BA4C03B8_dest.body preserve=yes
90
 
91
	close();
92
 
93
  //## end UdFileManifest::~UdFileManifest%4209BA4C03B8_dest.body
94
}
95
 
96
void UdFileManifest::addTestDetails (const std::string &testDetails)
97
{
98
	   (*m_stream) << testDetails;
99
		(*m_stream) << std::endl;
2267 kivins 100
      //(*m_stream) <<  "UD is generated into " << m_pathmapTarget; 
101
		//(*m_stream) << std::endl;
2263 kivins 102
}
103
 
104
 
105
//## Other Operations (implementation)
106
//## Operation: addUdFile%4209BAC703E7
107
void UdFileManifest::addUdFile (const std::string &file)
108
{
109
  //## begin UdFileManifest::addUdFile%4209BAC703E7.body preserve=yes
110
 
111
	if ( file.length() )
112
	{
113
	   // output some spacing
114
	   (*m_stream) << "          ";
115
 
116
	   // format and output the path and filename
117
		const bool slash
118
			= m_pathmapTarget.find_last_of( "/\\" )
119
				== m_pathmapTarget.length() - 1;
120
		const std::string::size_type where = file.find_last_of( "/\\" );
121
 
2267 kivins 122
	   //(*m_stream) << m_pathmapTarget; //just put filename in manifest
2263 kivins 123
		if ( where != std::string::npos )
124
		{
125
			if ( !slash )
126
			{
127
				(*m_stream) << '/';
128
			}
129
			(*m_stream) << file.substr( where + 1 );
130
		}
131
		else
132
		{
133
			if ( !slash )
134
			{
135
				(*m_stream) << '/';
136
			}
137
			(*m_stream) << file;
138
		}
139
		(*m_stream) << std::endl;
140
		++m_count;
141
	}
142
 
143
  //## end UdFileManifest::addUdFile%4209BAC703E7.body
144
}
145
 
146
//## Operation: close%4209BAC10389
147
void UdFileManifest::close ()
148
{
149
  //## begin UdFileManifest::close%4209BAC10389.body preserve=yes
150
 
151
	if ( m_stream )
152
	{
153
		(*m_stream)
154
			<< "#total UD files generated = " << m_count << std::endl
155
			<< "#end" << std::endl;
156
 
157
		m_stream->close();
158
 
159
		delete m_stream;
160
		m_stream = 0;
161
	}
162
 
163
  //## end UdFileManifest::close%4209BAC10389.body
164
}
165
 
166
//## Operation: open%4209BAC10399
167
const bool UdFileManifest::open ()
168
{
169
  //## begin UdFileManifest::open%4209BAC10399.body preserve=yes
170
 
171
	close();	// Close the stream should it be open.
172
 
173
	std::string filename;
174
	TransactionStream::buildFileName(
175
		filename,
176
		m_folder,
177
		m_prefix,
178
		m_suffix,
179
		"",
180
 
181
 
182
	m_stream = new std::ofstream(
183
		filename.c_str(),
184
		std::ios_base::out );
185
	if ( m_stream->is_open() )
186
	{
187
		(*m_stream)
188
			<< "#Transaction Scenario Builder log file" << std::endl
189
			<< '#' << std::endl;
190
 
191
		return ( true );
192
	}
193
 
194
	// When we can't open the file, then roll back.
195
	delete m_stream;
196
	m_stream = 0;
197
 
198
	MERROR( "Cannot open \"" << filename << "\" for writing." );
199
	return ( false );
200
 
201
  //## end UdFileManifest::open%4209BAC10399.body
202
}
203
 
204
// Additional Declarations
205
  //## begin UdFileManifest%4209BA4C03B8.declarations preserve=yes
206
  //## end UdFileManifest%4209BA4C03B8.declarations
207
 
208
//## begin module%4209BA4C03B8.epilog preserve=yes
209
//## end module%4209BA4C03B8.epilog