go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
xoutbase.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright UMC Utrecht and contributors
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef xoutbase_h
19#define xoutbase_h
20
21#include <iostream>
22#include <ostream>
23#include <map>
24#include <string>
25
26namespace xoutlibrary
27{
28
40{
41public:
43 using Self = xoutbase;
44
45 using CStreamMapType = std::map<std::string, std::ostream *>;
46 using XStreamMapType = std::map<std::string, Self *>;
47 using CStreamMapEntryType = CStreamMapType::value_type;
48 using XStreamMapEntryType = XStreamMapType::value_type;
49
51 virtual ~xoutbase() = 0;
52
54 Self & operator[](const char * cellname);
55
70 template <class T>
72 operator<<(const T & _arg)
73 {
74 return this->SendToTargets(_arg);
75 }
76
77
79 operator<<(std::ostream & (*pf)(std::ostream &))
80 {
81 return this->SendToTargets(pf);
82 }
83
84
86 operator<<(std::ios & (*pf)(std::ios &))
87 {
88 return this->SendToTargets(pf);
89 }
90
91
93 operator<<(std::ios_base & (*pf)(std::ios_base &))
94 {
95 return this->SendToTargets(pf);
96 }
97
98
99 virtual void
101
105 virtual int
106 AddTargetCell(const char * name, std::ostream * cell);
107
108 virtual int
109 AddTargetCell(const char * name, Self * cell);
110
111 virtual int
112 RemoveTargetCell(const char * name);
113
115 virtual int
116 AddOutput(const char * name, std::ostream * output);
117
118 virtual int
119 AddOutput(const char * name, Self * output);
120
121 virtual int
122 RemoveOutput(const char * name);
123
124 virtual void
125 SetOutputs(const CStreamMapType & outputmap);
126
127 virtual void
128 SetOutputs(const XStreamMapType & outputmap);
129
131 virtual const CStreamMapType &
133
134 virtual const XStreamMapType &
136
137protected:
139 xoutbase() = default;
140
141 void
143
144 virtual void
146
150
155
156private:
157 template <class T>
158 Self &
159 SendToTargets(const T & _arg)
160 {
162 for (const auto & cell : m_CTargetCells)
163 {
164 *(cell.second) << _arg;
165 }
166
168 for (const auto & cell : m_XTargetCells)
169 {
170 *(cell.second) << _arg;
171 }
172
173 return *this;
174 } // end SendToTargets
175};
176
177} // end namespace xoutlibrary
178
179#endif // end #ifndef xoutbase_h
Base class for xout.
Definition: xoutbase.h:40
Self & SendToTargets(const T &_arg)
Definition: xoutbase.h:159
virtual void SetOutputs(const CStreamMapType &outputmap)
XStreamMapType m_XTargetCells
Definition: xoutbase.h:154
XStreamMapType::value_type XStreamMapEntryType
Definition: xoutbase.h:48
virtual void WriteBufferedData()
virtual int AddTargetCell(const char *name, std::ostream *cell)
virtual int AddOutput(const char *name, std::ostream *output)
virtual const CStreamMapType & GetCOutputs()
Self & operator<<(const T &_arg)
Definition: xoutbase.h:72
virtual int AddTargetCell(const char *name, Self *cell)
XStreamMapType m_XOutputs
Definition: xoutbase.h:149
virtual void SetOutputs(const XStreamMapType &outputmap)
CStreamMapType m_CTargetCells
Definition: xoutbase.h:153
void SetCTargetCells(const CStreamMapType &cellmap)
virtual int AddOutput(const char *name, Self *output)
virtual int RemoveOutput(const char *name)
CStreamMapType::value_type CStreamMapEntryType
Definition: xoutbase.h:47
virtual int RemoveTargetCell(const char *name)
std::map< std::string, std::ostream * > CStreamMapType
Definition: xoutbase.h:45
CStreamMapType m_COutputs
Definition: xoutbase.h:148
Self & operator[](const char *cellname)
std::map< std::string, Self * > XStreamMapType
Definition: xoutbase.h:46
virtual void SetXTargetCells(const XStreamMapType &cellmap)
virtual const XStreamMapType & GetXOutputs()


Generated on 2023-01-13 for elastix by doxygen 1.9.6 elastix logo