blob: 9cc8e392b842bb5a793a5e5629bd798321d9afad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2000 National Library of Medicine
All rights reserved.
See COPYRIGHT.txt for copyright details.
=========================================================================*/
#ifndef cmCabilData_h
#define cmCabilData_h
#include "cmStandardIncludes.h"
#include "cmCommand.h"
class cmCabilCommand;
/** \class cmCabilData
* \brief Hold data in one location for all cmCabilCommand subclasses.
*/
class cmCabilData
{
public:
/**
* The cmCabilData instance is owned by one cmCabilCommand, which is given
* to this constructor.
*/
cmCabilData(const cmCabilCommand* owner): m_Owner(owner) {}
~cmCabilData();
/**
* Returns true if the given cmCabilCommand is the owner of this
* cmCabilData.
*/
bool OwnerIs(const cmCabilCommand* owner) const
{ return (owner == m_Owner); }
/**
* Hold an output stream for all commands that use it. Maintain the
* first and last commands that reference it so that they can write the
* header/footer lines, if necessary.
*/
class OutputFile
{
public:
OutputFile(std::string, const cmCabilCommand*);
~OutputFile();
std::ostream& GetStream();
void SetLastReferencingCommand(const cmCabilCommand*);
bool FirstReferencingCommandIs(const cmCabilCommand*) const;
bool LastReferencingCommandIs(const cmCabilCommand*) const;
private:
std::ofstream m_FileStream;
const cmCabilCommand* m_FirstReferencingCommand;
const cmCabilCommand* m_LastReferencingCommand;
};
OutputFile* GetOutputFile(const std::string&, const cmCabilCommand*);
private:
typedef std::map<std::string, OutputFile*> OutputFiles;
/**
* The cmCabilCommand which created this instance of cmCabilCommand.
*/
const cmCabilCommand* m_Owner;
/**
* Hold all output streams by file name.
*/
OutputFiles m_OutputFiles;
};
#endif
|