NEST  2.6.0,not_revisioned_source_dir@0
lockptrdatum.h
Go to the documentation of this file.
1 /*
2  * lockptrdatum.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 LOCKPTRDATUM_H
24 #define LOCKPTRDATUM_H
25 
26 #include "datum.h"
27 #include "lockptr.h"
28 
29 // prefixed all references to members of lockPTR, TypedDatum with this->,
30 // since HP's aCC otherwise complains about them not being declared
31 // according to ISO Standard Sec. 14.6.2(3) [temp.dep]
32 // HEP, 2001-08-09
33 
34 /* lockPTRDatum<class D, SLIType *slt>:
35  Constraints:
36  This class must not be a base class.
37  The equals operator depends on that fact.
38 */
39 template <class D, SLIType *slt>
40 class lockPTRDatum: public lockPTR<D>, public TypedDatum<slt>
41 {
42  Datum * clone(void) const
43  {
44  return new lockPTRDatum<D,slt>(*this);
45  }
46 
47  public:
48 
50 
51 // template<SLIType *st>
52 // lockPTRDatum(const lockPTRDatum<D,st> &d):lockPTR<D>(d), TypedDatum<slt>(){}
53 
54  lockPTRDatum(const lockPTR<D> d): lockPTR<D>(d), TypedDatum<slt>() {}
55 
56  /* Constructor from D* d
57  By the definition of lockPTR, d must be unique. It will be
58  destructed/deallocated by the implementation of lockPTR,
59  therefore no references should be kept after construction,
60  including constructing any other instances of this class with
61  that data, except via copy constructor.
62  */
63  lockPTRDatum(D *d): lockPTR<D>(d), TypedDatum<slt>() {}
64 
65  /* Constructor from D d
66  Like the above, this is actually a constructor to a D*, so d
67  should be dynamically allocated, and any reference discarded
68  after this construction.
69  */
70  lockPTRDatum(D& d): lockPTR<D>(d), TypedDatum<slt>() {}
71 
72  ~lockPTRDatum() {} // this class must not be a base class
73 
74  void print(std::ostream &) const;
75  void pprint(std::ostream &) const;
76  void info(std::ostream &) const;
77 
78 
79  // tests for equality via lockPTR<D>::operator==
80  // It is defined as identity of the underly D, i.e. &this->D == &other->D
81  bool equals(const Datum *) const;
82 
83  /* operator=
84  The assignment operator is defaulted.
85  Therefore, lockPTR<D>::operator= is called, and
86  TypedDatum<slt>::operator= is called.
87  The TypedDatum = is simply return *this.
88  */
89  // lockPTRDatum<D, sli>& operator=(const lockPTRDatum<D, sli>&)
90 
91  /* operator==
92  lockPTRDatum should only use the equals method for equality testing.
93  Thus, the inherited lockPTR<D>::operator== is made private. No
94  implementation is defined.
95  */
96  private:
97  bool operator==(lockPTR<D>&);
98 };
99 
100 
101 /******************************************/
102 
103 #endif
void pprint(std::ostream &) const
Definition: lockptrdatum_impl.h:46
lockPTRDatum()
Definition: lockptrdatum.h:49
Definition: datum.h:166
Definition: lockptrdatum.h:40
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
~lockPTRDatum()
Definition: lockptrdatum.h:72
lockPTRDatum(const lockPTR< D > d)
Definition: lockptrdatum.h:54
lockPTRDatum(D &d)
Definition: lockptrdatum.h:70
Datum * clone(void) const
Virtual copy constructor.
Definition: lockptrdatum.h:42
void info(std::ostream &) const
Definition: lockptrdatum_impl.h:61
bool equals(const Datum *) const
Definition: lockptrdatum_impl.h:38
This template is the standard safe-pointer implementation of SYNOD.
Definition: lockptr.h:84
Definition: datum.h:33
lockPTRDatum(D *d)
Definition: lockptrdatum.h:63
bool operator==(lockPTR< D > &)
void print(std::ostream &) const
Definition: lockptrdatum_impl.h:55