1
/* This file is part of Charon.
3
Charon is free software: you can redistribute it and/or modify
4
it under the terms of the GNU Lesser General Public License as published by
5
the Free Software Foundation, either version 3 of the License, or
6
(at your option) any later version.
8
Charon is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
GNU Lesser General Public License for more details.
13
You should have received a copy of the GNU Lesser General Public License
14
along with Charon. If not, see <http://www.gnu.org/licenses/>.
16
/** @file AbstractData.hxx
17
* Declaration and implementation of the abstract class
19
* @author <a href="mailto:jmgottfried@web.de">Jens-Malte Gottfried</a>
24
#ifndef _ABSTRACT_DATA_HXX_
25
#define _ABSTRACT_DATA_HXX_
27
/// Interface for data acces.
28
/// This is the common interface for parameters and
30
/// Data access is only provided read only.
32
class AbstractROData {
34
virtual ~AbstractROData() {};
36
/// Cast operator to get data (get copy)
37
virtual operator T() const = 0;
40
/// Also returns internal data (const reference)
41
virtual const T& operator()() const = 0;
44
/// Interface for data assignment and readout.
45
/// This is the common interface for parameters and
46
/// output slots. (Input slots are read only.)
48
class AbstractData : public AbstractROData<T> {
50
virtual ~AbstractData() {};
52
/// data assignment operator
53
/// @param B data to assign
54
virtual T& operator=(const T& B) = 0;
57
/// Non const version.
58
virtual T& operator()() = 0;
61
/// Common interface for read-only access to multiple data members
64
class AbstractMultiROData {
66
virtual ~AbstractMultiROData() {};
68
/// Access to specific member (read-only).
69
/// @param pos data position
70
/// @throws std::string error message if pos out of range
71
virtual const T& operator[](unsigned int pos) const = 0;
73
/// Access to number of members
74
/// (for iterations using operator[])
75
virtual unsigned int size() const = 0;
78
/// Common interface for read-write access to multiple data members
81
class AbstractMultiData : public AbstractMultiROData<T> {
83
virtual ~AbstractMultiData() {};
85
/// Access to specific member (read-write).
86
/// @param pos data position
87
/// @throws std::string error message if pos out of range
88
virtual T& operator[](unsigned int pos) = 0;
91
#endif // _ABSTRACT_DATA_HXX_