~charon-developers/charon-core/trunk

« back to all changes in this revision

Viewing changes to src/AbstractData.hxx

  • Committer: jmgottfried
  • Date: 2010-03-16 15:18:38 UTC
  • Revision ID: svn-v4:7d56a235-2f8b-4627-957e-5f30cc86da59:charon-core/trunk:680
moved header files to seperate include directory

this makes e.g. Compile and Load test work even if charon-core is not yet installed
and gives a chance to get charon-meta working

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  This file is part of Charon.
2
 
 
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.
7
 
 
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.
12
 
 
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/>.
15
 
*/
16
 
/** @file AbstractData.hxx
17
 
 *  Declaration and implementation of the abstract class
18
 
 *  AbstractData.
19
 
 *  @author <a href="mailto:jmgottfried@web.de">Jens-Malte Gottfried</a>
20
 
 *
21
 
 *  @date 10.04.2009
22
 
 */
23
 
 
24
 
#ifndef _ABSTRACT_DATA_HXX_
25
 
#define _ABSTRACT_DATA_HXX_
26
 
 
27
 
/// Interface for data acces.
28
 
/// This is the common interface for parameters and
29
 
/// slots.
30
 
/// Data access is only provided read only.
31
 
template<typename T>
32
 
class AbstractROData {
33
 
public:
34
 
        virtual ~AbstractROData() {};
35
 
 
36
 
        /// Cast operator to get data (get copy)
37
 
        virtual operator T() const = 0;
38
 
 
39
 
        /// Call operator.
40
 
        /// Also returns internal data (const reference)
41
 
        virtual const T& operator()() const = 0;
42
 
};
43
 
 
44
 
/// Interface for data assignment and readout.
45
 
/// This is the common interface for parameters and
46
 
/// output slots. (Input slots are read only.)
47
 
template<typename T>
48
 
class AbstractData : public AbstractROData<T> {
49
 
public:
50
 
        virtual ~AbstractData() {};
51
 
 
52
 
        /// data assignment operator
53
 
        /// @param B         data to assign
54
 
        virtual T& operator=(const T& B) = 0;
55
 
 
56
 
        /// Call operator.
57
 
        /// Non const version.
58
 
        virtual T& operator()() = 0;
59
 
};
60
 
 
61
 
/// Common interface for read-only access to multiple data members
62
 
/// like arrays etc.
63
 
template<typename T>
64
 
class AbstractMultiROData {
65
 
public:
66
 
        virtual ~AbstractMultiROData() {};
67
 
 
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;
72
 
 
73
 
        /// Access to number of members
74
 
        /// (for iterations using operator[])
75
 
        virtual unsigned int size() const = 0;
76
 
};
77
 
 
78
 
/// Common interface for read-write access to multiple data members
79
 
/// like arrays etc.
80
 
template<typename T>
81
 
class AbstractMultiData : public AbstractMultiROData<T> {
82
 
public:
83
 
        virtual ~AbstractMultiData() {};
84
 
 
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;
89
 
};
90
 
 
91
 
#endif // _ABSTRACT_DATA_HXX_
92