NEST  2.6.0,not_revisioned_source_dir@0
genericdatum.h
Go to the documentation of this file.
1 /*
2  * genericdatum.h
3  *
4  * This file is part of NEST.
5  *
6  * Copyright (C) 2004 The NEST Initiative
7  *
8  * NEST is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * NEST is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef GENERICDATUM_H
24 #define GENERICDATUM_H
25 /*
26  Datum template for generic C/C++ data types
27 */
28 #include "datum.h"
29 
30 /***********************************************************/
31 /* Concrete Generic Data Objects */
32 /***********************************************************/
33 
34 template<class D, SLIType *slt>
35 class GenericDatum: public TypedDatum<slt>
36 {
37 
38  virtual Datum * clone(void) const
39  {
40  return new GenericDatum<D,slt>(*this);
41  }
42 
43 protected:
44  D d;
45 public:
47  {
49  }
50  virtual ~GenericDatum() {}
51 
53  GenericDatum(const GenericDatum<D,slt>& gd): TypedDatum<slt>(gd), d(gd.d) {}
54 
55  const D& operator=(const D &d_s)
56  {
57  d = d_s;
58  return d;
59  }
60 
61  const D& get(void) const
62  {
63  return d;
64  }
65 
66  D& get(void)
67  {
68  return d;
69  }
70 
71  D& get_lval()
72  {
73  return d;
74  }
75 
76  void print(std::ostream& o) const
77  {
78  o << d;
79  }
80 
81  void pprint(std::ostream& o) const
82  {
83  o << d;
84  }
85 
86  void info(std::ostream &out) const
87  {
88  out << "GenericDatum<D,slt>::info\n";
89  out << "d = " << d << std::endl;
90  }
91 
92  bool equals(const Datum *dat) const
93  {
95  *ddc=dynamic_cast<GenericDatum<D,slt> * >(const_cast< Datum *>(dat));
96 
97 // std::cerr << "d = " << d << " ddc = " << ddc << " dat = " << dat << std::endl;
98 
99  if(ddc == NULL)
100  return false;
101 
102  return d == ddc->d;
103  }
104 
105 };
106 
107 
108 /******************************************/
109 
110 #endif
111 
112 
113 
114 
D & get_lval()
Definition: genericdatum.h:71
Definition: genericdatum.h:35
Definition: datum.h:166
GenericDatum()
Definition: genericdatum.h:46
void unset_executable()
Definition: datum.h:118
void info(std::ostream &out) const
Definition: genericdatum.h:86
GenericDatum(const GenericDatum< D, slt > &gd)
Definition: genericdatum.h:53
bool equals(const Datum *dat) const
Definition: genericdatum.h:92
GenericDatum(const D &d_s)
Definition: genericdatum.h:52
virtual ~GenericDatum()
Definition: genericdatum.h:50
D d
Definition: genericdatum.h:44
const D & operator=(const D &d_s)
Definition: genericdatum.h:55
virtual Datum * clone(void) const
Virtual copy constructor.
Definition: genericdatum.h:38
void pprint(std::ostream &o) const
Definition: genericdatum.h:81
void print(std::ostream &o) const
Definition: genericdatum.h:76
Definition: datum.h:33