World Ocean Simulation System (WOSS) library
transducer-handler.h
Go to the documentation of this file.
1/* WOSS - World Ocean Simulation System -
2 *
3 * Copyright (C) 2009 Federico Guerra
4 * and regents of the SIGNET lab, University of Padova
5 *
6 * Author: Federico Guerra - federico@guerra-tlc.com
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation;
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22/*
23 * This software has been developed by Federico Guerra and SIGNET lab,
24 * University of Padova, in collaboration with the NATO Centre for
25 * Maritime Research and Experimentation (http://www.cmre.nato.int ;
26 * E-mail: pao@cmre.nato.int), whose support is gratefully acknowledged.
27 */
28
29
40#ifndef WOSS_TRANSDUCER_HANDLER_DEFINITIONS_H
41#define WOSS_TRANSDUCER_HANDLER_DEFINITIONS_H
42
43
44// #include <cmath>
45// #include <cassert>
46// #include <iostream>
47#include <string>
48#include <map>
49
50
51namespace woss {
52
53
54 class Transducer;
55
56
64
65
66 protected:
67
68
72 typedef ::std::map< ::std::string, Transducer* > TransducerMap;
73 typedef TransducerMap::iterator TMIter;
74 typedef TransducerMap::reverse_iterator TMRIter;
75 typedef TransducerMap::const_iterator TMCIter;
76 typedef TransducerMap::const_reverse_iterator TMCRIter;
77
78
79 public:
80
81
86
92
97 TransducerHandler( TransducerMap& transduc_map );
98
99
100 virtual ~TransducerHandler();
101
102
110 bool insertValue( const ::std::string& name, Transducer* const transducer );
111
112
119 TransducerHandler& replaceValue( const ::std::string& name, Transducer* const transducer );
120
121
127 const Transducer* const getValue( const ::std::string& name ) const;
128
129
135 TransducerHandler& eraseValue( const ::std::string& name );
136
137
142 int size() const;
143
148 bool empty() const;
149
150
156
157
162 TMCIter begin() const;
163
168 TMCIter end() const;
169
174 TMCRIter rbegin() const;
175
180 TMCRIter rend() const;
181
188 virtual bool importValueAscii( const ::std::string& type_name, const ::std::string& file_name );
189
196 virtual bool importValueBinary( const ::std::string& type_name, const ::std::string& file_name );
197
198
205 virtual bool writeValueAscii( const ::std::string& type_name, const ::std::string& file_name );
206
213 virtual bool writeValueBinary( const ::std::string& type_name, const ::std::string& file_name );
214
215
222
223
228 TransducerHandler& setDebug( bool flag );
229
230 bool getDebug() { return debug; }
231
232
233 protected:
234
235
239 static const ::std::string TRANSDUCER_NOT_VALID;
240
241
245 bool debug;
246
247
252
253
254 };
255
256
258
259 inline int TransducerHandler::size() const {
260 return transducer_map.size();
261 }
262
263
264 inline bool TransducerHandler::empty() const {
265 return transducer_map.empty();
266 }
267
268
269 inline TransducerHandler::TMCIter TransducerHandler::begin() const {
270 return transducer_map.begin();
271 }
272
273
274 inline TransducerHandler::TMCIter TransducerHandler::end() const {
275 return transducer_map.end();
276 }
277
278
279 inline TransducerHandler::TMCRIter TransducerHandler::rbegin() const {
280 return transducer_map.rbegin();
281 }
282
283 inline TransducerHandler::TMCRIter TransducerHandler::rend() const {
284 return transducer_map.rend();
285 }
286
287
289 debug = flag;
290 return *this;
291 }
292
293
294}
295
296
297#endif // WOSS_TRANSDUCER_HANDLER_DEFINITIONS_H
298
Transducer creator and handler class.
Definition transducer-handler.h:63
bool debug
Definition transducer-handler.h:245
virtual bool importValueAscii(const ::std::string &type_name, const ::std::string &file_name)
Definition transducer-handler.cpp:150
TransducerHandler & clear()
Definition transducer-handler.cpp:140
TransducerHandler()
Definition transducer-handler.cpp:52
TMCRIter rend() const
Definition transducer-handler.h:283
TransducerHandler & setDebug(bool flag)
Definition transducer-handler.h:288
virtual bool writeValueAscii(const ::std::string &type_name, const ::std::string &file_name)
Definition transducer-handler.cpp:175
TransducerHandler & operator=(const TransducerHandler &x)
Definition transducer-handler.cpp:88
TransducerMap transducer_map
Definition transducer-handler.h:251
TMCRIter rbegin() const
Definition transducer-handler.h:279
TransducerHandler & eraseValue(const ::std::string &name)
Definition transducer-handler.cpp:130
TMCIter begin() const
Definition transducer-handler.h:269
TMCIter end() const
Definition transducer-handler.h:274
bool insertValue(const ::std::string &name, Transducer *const transducer)
Definition transducer-handler.cpp:102
static const ::std::string TRANSDUCER_NOT_VALID
Definition transducer-handler.h:239
TransducerHandler & replaceValue(const ::std::string &name, Transducer *const transducer)
Definition transducer-handler.cpp:109
virtual bool writeValueBinary(const ::std::string &type_name, const ::std::string &file_name)
Definition transducer-handler.cpp:189
bool empty() const
Definition transducer-handler.h:264
::std::map< ::std::string, Transducer * > TransducerMap
Definition transducer-handler.h:72
int size() const
Definition transducer-handler.h:259
virtual bool importValueBinary(const ::std::string &type_name, const ::std::string &file_name)
Definition transducer-handler.cpp:162
const Transducer *const getValue(const ::std::string &name) const
Definition transducer-handler.cpp:121
Transducer class.
Definition transducer-definitions.h:70