NEST  2.6.0,not_revisioned_source_dir@0
slitype.h
Go to the documentation of this file.
1 /*
2  * slitype.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 SLITYPE_H
24 #define SLITYPE_H
25 /*
26  class implementing SLI types
27 */
28 
29 #include <typeinfo>
30 #include <iostream>
31 #include "slifunction.h"
32 #include "name.h"
33 
34 
35 /* class SLIType represents the SLI type information. Each
36  Datum object carries a pointer to the SLIType object, representing the
37  SLI type of its contents.
38  class SLIType is such that there can be only one instance for each
39  typename.
40  The typename is assigned at a special position with local scope, e.g.
41  the constructor of a client class. This reduces the risk of running into
42  the static initialization problem, since class Name has static members
43  which might not be constructet when SLITypes are used as static
44  data members.
45 */
46 
47 class SLIInterpreter;
48 
49 class SLIType
50 {
51  unsigned int count;
52 
55 
56  SLIType& operator=(const SLIType &);
57  SLIType(const SLIType &);
58 
59  public:
60  SLIType(void): count(0), name(NULL), defaultaction(NULL) {}
61  ~SLIType() {}
62 
63  void settypename(const std::string &s);
64  void deletetypename(void);
65 
66  const Name &gettypename(void) const
67  {
68  // assert( name !=NULL);
69  return *name;
70  }
71 
73 
74 
75  SLIFunction * getaction(void) const
76  {
77  // assert(defaultaction != NULL);
78  // If this fails, we have created a datum before the types were initialised.
79  return defaultaction;
80  }
81 };
82 
83 // This shows how the type-objects are to be used
84 // class SLIInterpreter
85 // {
86 
87 // public:
88 // static const char* Integertypename;
89 // static const char* Doubletypename;
90 
91 // static SLIType Integertype;
92 // static SLIType Doubletype;
93 
94 // Interpreter(void);
95 // };
96 
97 // Interpreter::Interpreter(void)
98 // {
99 // Integertype.settypename(Integertypename);
100 // Doubletype.settypename(Doubletypename);
101 // }
102 
103 #endif
104 
void setdefaultaction(SLIFunction &)
Definition: slitype.cc:53
Definition: slifunction.h:35
Represent strings by ints to facilitate fast comparison.
Definition: name.h:53
unsigned int count
Definition: slitype.h:51
Name * name
Definition: slitype.h:53
SLIType(void)
Definition: slitype.h:60
~SLIType()
Definition: slitype.h:61
void deletetypename(void)
Definition: slitype.cc:43
SLIType & operator=(const SLIType &)
SLIFunction * defaultaction
Definition: slitype.h:54
Definition: interpret.h:69
Definition: slitype.h:49
SLIFunction * getaction(void) const
Definition: slitype.h:75
void settypename(const std::string &s)
Definition: slitype.cc:29
const Name & gettypename(void) const
Definition: slitype.h:66