1 /*
2  *  namedatum.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 NAMEDATUM_H
24 #define NAMEDATUM_H
25 /*
26     Defines Datum classes which are derived from Names:
27     class NameDatum;
28     class LiteralDatum;
29     class BoolDatum;
30 */
31 
32 // Include all headers, needed to use token and datum objects
33 
34 // C++ includes:
35 #include <string>
36 #include <typeinfo>
37 
38 // Generated includes:
39 #include "config.h"
40 
41 // Includes from sli:
42 #include "aggregatedatum.h"
43 #include "interpret.h"
44 #include "name.h"
45 
46 /* These are declarations to specialize the static memory pool BEFORE
47    we instantiate the AggregateDatum. Note, that this is only a declaration,
48    because we do not provide an initializer (see ISO14882 Sec.  14.7.3.15.)
49    The definition is given in the *.CC file with the appropriate
50    initializer.
51 
52    Note that SUN's Forte 6.2 and 7 does not handle this correctly,
53    so we have to use a compiler-switch. 11/2002 Gewaltig
54 
55    The Alpha cxx V6.3-002 says that storage class extern is not allowed here,
56    so I removed it. 15.2.2002 Diesmann
57 */
58 #ifndef HAVE_STATIC_TEMPLATE_DECLARATION_FAILS
59 template <>
60 sli::pool AggregateDatum< Name, &SLIInterpreter::Nametype >::memory;
61 
62 template <>
63 sli::pool AggregateDatum< Name, &SLIInterpreter::Literaltype >::memory;
64 #endif
65 
66 
67 class NameDatum : public AggregateDatum< Name, &SLIInterpreter::Nametype >
68 {
69   Datum*
clone(void)70   clone( void ) const
71   {
72     return new NameDatum( *this );
73   }
74 
75   Datum*
get_ptr()76   get_ptr()
77   {
78     Datum::addReference();
79     return this;
80   }
81 
82 public:
NameDatum(const Name & n)83   NameDatum( const Name& n )
84     : AggregateDatum< Name, &SLIInterpreter::Nametype >( n )
85   {
86     set_executable();
87   }
NameDatum(const NameDatum & n)88   NameDatum( const NameDatum& n )
89     : AggregateDatum< Name, &SLIInterpreter::Nametype >( n )
90   {
91   }
~NameDatum()92   ~NameDatum()
93   {
94     set_executable();
95   }
96 };
97 
98 class LiteralDatum : public AggregateDatum< Name, &SLIInterpreter::Literaltype >
99 {
100   Datum*
clone(void)101   clone( void ) const
102   {
103     return new LiteralDatum( *this );
104   }
105 
106   Datum*
get_ptr()107   get_ptr()
108   {
109     Datum::addReference();
110     return this;
111   }
112 
113 public:
LiteralDatum(const Name & n)114   LiteralDatum( const Name& n )
115     : AggregateDatum< Name, &SLIInterpreter::Literaltype >( n )
116   {
117     set_executable();
118   }
LiteralDatum(const LiteralDatum & n)119   LiteralDatum( const LiteralDatum& n )
120     : AggregateDatum< Name, &SLIInterpreter::Literaltype >( n )
121   {
122     set_executable();
123   }
~LiteralDatum()124   ~LiteralDatum()
125   {
126   }
127   void pprint( std::ostream& ) const;
128 };
129 
130 #endif
131