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 2025 Federico Guerra
4 * and regents of the SIGNET lab, University of Padova
5 *
6 * Author: Federico Guerra - WOSS@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
32#ifndef WOSS_TRANSDUCER_HANDLER_DEFINITIONS_H
33#define WOSS_TRANSDUCER_HANDLER_DEFINITIONS_H
34
35
36#include <string>
37#include <unordered_map>
38#include <memory>
39
40
41namespace woss {
42
43 class Transducer;
44
52
53 protected:
54
58 using TransducerMap = std::unordered_map< std::string, std::unique_ptr<Transducer> >;
59 using TMIter = TransducerMap::iterator;
60 using TMCIter = TransducerMap::const_iterator;
61
62 public:
63
68
69 TransducerHandler( const TransducerHandler& copy ) = default;
70
72
77 TransducerHandler( TransducerMap& transduc_map );
78
79 virtual ~TransducerHandler() = default;
80
88 bool insertValue( const std::string& name, const Transducer& transducer );
89
96 TransducerHandler& replaceValue( const std::string& name, const Transducer& transducer );
97
103 std::unique_ptr<Transducer> getValue( const std::string& name ) const;
104
110 TransducerHandler& eraseValue( const std::string& name );
111
116 int size() const;
117
122 bool empty() const;
123
129
134 TMCIter begin() const;
135
140 TMCIter end() const;
141
148 virtual bool importValueAscii( const std::string& type_name, const std::string& file_name );
149
156 virtual bool importValueBinary( const std::string& type_name, const std::string& file_name );
157
164 virtual bool writeValueAscii( const std::string& type_name, const std::string& file_name );
165
172 virtual bool writeValueBinary( const std::string& type_name, const std::string& file_name );
173
175
177
182 TransducerHandler& setDebug( bool flag );
183
184 bool getDebug() const { return debug; }
185
186 protected:
187
188 void initializeNotValid();
189
193 static const std::string TRANSDUCER_NOT_VALID;
194
198 bool debug;
199
204
205 };
206
208
209 inline int TransducerHandler::size() const {
210 return transducer_map.size();
211 }
212
213 inline bool TransducerHandler::empty() const {
214 return transducer_map.empty();
215 }
216
218 return transducer_map.begin();
219 }
220
222 return transducer_map.end();
223 }
224
226 debug = flag;
227 return *this;
228 }
229
230}
231
232#endif // WOSS_TRANSDUCER_HANDLER_DEFINITIONS_H
233
Transducer creator and handler class.
Definition transducer-handler.h:51
bool debug
Definition transducer-handler.h:198
TransducerHandler & clear()
Definition transducer-handler.cpp:95
TransducerHandler()
Definition transducer-handler.cpp:44
TransducerHandler & eraseValue(const std::string &name)
Definition transducer-handler.cpp:89
TransducerHandler(const TransducerHandler &copy)=default
TransducerMap::iterator TMIter
Definition transducer-handler.h:59
TransducerHandler & operator=(TransducerHandler &&copy)=default
bool insertValue(const std::string &name, const Transducer &transducer)
Definition transducer-handler.cpp:65
virtual bool importValueBinary(const std::string &type_name, const std::string &file_name)
Definition transducer-handler.cpp:114
TransducerHandler & setDebug(bool flag)
Definition transducer-handler.h:225
std::unique_ptr< Transducer > getValue(const std::string &name) const
Definition transducer-handler.cpp:77
TransducerMap transducer_map
Definition transducer-handler.h:203
std::unordered_map< std::string, std::unique_ptr< Transducer > > TransducerMap
Definition transducer-handler.h:58
TMCIter begin() const
Definition transducer-handler.h:217
TMCIter end() const
Definition transducer-handler.h:221
TransducerHandler & operator=(const TransducerHandler &copy)=default
virtual bool importValueAscii(const std::string &type_name, const std::string &file_name)
Definition transducer-handler.cpp:101
virtual ~TransducerHandler()=default
virtual bool writeValueAscii(const std::string &type_name, const std::string &file_name)
Definition transducer-handler.cpp:128
virtual bool writeValueBinary(const std::string &type_name, const std::string &file_name)
Definition transducer-handler.cpp:143
bool empty() const
Definition transducer-handler.h:213
bool getDebug() const
Definition transducer-handler.h:184
TransducerHandler & replaceValue(const std::string &name, const Transducer &transducer)
Definition transducer-handler.cpp:71
void initializeNotValid()
Definition transducer-handler.cpp:59
static const std::string TRANSDUCER_NOT_VALID
Definition transducer-handler.h:193
TransducerMap::const_iterator TMCIter
Definition transducer-handler.h:60
int size() const
Definition transducer-handler.h:209
TransducerHandler(TransducerHandler &&tmp)=default
Transducer class.
Definition transducer-definitions.h:65
Definition ac-toolbox-arr-asc-reader.h:44