NEST  2.6.0,not_revisioned_source_dir@0
conn_parameter.h
Go to the documentation of this file.
1 /*
2  * conn_parameter.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 CONN_PARAMETER_H
24 #define CONN_PARAMETER_H
25 
26 #include <limits>
27 #include <vector>
28 
29 #include "randomgen.h"
30 #include "randomdev.h"
31 #include "token.h"
32 #include "exceptions.h"
33 
46 namespace nest
47 {
48 
50  {
51  public:
53  virtual ~ConnParameter() {}
54 
68  virtual double value_double(index, index, librandom::RngPtr&) const =0;
69  virtual long_t value_int(index, index, librandom::RngPtr&) const =0;
70 
76  virtual size_t number_of_values() const { return 0; }
77 
78  static ConnParameter* create(const Token&);
79  };
80 
81 
88  {
89  public:
90  ScalarDoubleParameter(double value) : value_(value) {}
91 
92  double value_double(index, index, librandom::RngPtr&) const { return value_; }
93  long_t value_int(index, index, librandom::RngPtr&) const { throw KernelException("ConnParameter calls value function with false return type."); }
94 
95  private:
96  double value_;
97  };
98 
105  {
106  public:
108 
109  double value_double(index, index, librandom::RngPtr&) const { throw KernelException("ConnParameter calls value function with false return type."); }
111 
112  private:
114  };
115 
116 
126  {
127  public:
128  ArrayParameter(const std::vector<double>& values)
129  : values_(values), next_(values_.begin())
130  {}
131 
132  size_t number_of_values() const { return values_.size(); }
133 
134  //double value(index sgid, index tgid, librandom::RngPtr&) const
136 
137  {
138  //return values_[sgid];
139  if ( next_ != values_.end() )
140  return *next_++;
141  else
142  throw KernelException("Parameter values exhausted.");
143  }
144  long_t value_int(index, index, librandom::RngPtr&) const { throw KernelException("ConnParameter calls value function with false return type."); }
145 
146  private:
147  std::vector<double> values_;
148  mutable std::vector<double>::iterator next_;
149  };
150 
151 
158  {
159  public:
161 
162  double value_double(index, index, librandom::RngPtr& rng) const { return (*rdv_)(rng); }
163  long_t value_int(index, index, librandom::RngPtr& rng) const { return (*rdv_)(rng); }
164 
165  private:
167  };
168 
169 } // namespace nest
170 
171 #endif
size_t index
Unsigned long type for enumerations.
Definition: nest.h:109
virtual long_t value_int(index, index, librandom::RngPtr &) const =0
ScalarDoubleParameter(double value)
Definition: conn_parameter.h:90
RandomParameter(const DictionaryDatum &)
Definition: conn_parameter.cpp:61
long_t value_int(index, index, librandom::RngPtr &) const
Definition: conn_parameter.h:144
long_t value_int(index, index, librandom::RngPtr &rng) const
Definition: conn_parameter.h:163
std::vector< double >::iterator next_
Definition: conn_parameter.h:148
Array parameter, returning values in order.
Definition: conn_parameter.h:125
Single integer value.
Definition: conn_parameter.h:104
ArrayParameter(const std::vector< double > &values)
Definition: conn_parameter.h:128
size_t number_of_values() const
Returns number of values available.
Definition: conn_parameter.h:132
Single double value.
Definition: conn_parameter.h:87
double value_double(index, index, librandom::RngPtr &) const
Return parameter value.
Definition: conn_parameter.h:135
std::vector< double > values_
Definition: conn_parameter.h:147
Random scalar value.
Definition: conn_parameter.h:157
Definition: conn_parameter.h:49
virtual ~ConnParameter()
Definition: conn_parameter.h:53
Base class for all Kernel exceptions.
Definition: exceptions.h:54
double value_double(index, index, librandom::RngPtr &rng) const
Return parameter value.
Definition: conn_parameter.h:162
ScalarIntegerParameter(long_t value)
Definition: conn_parameter.h:107
long_t value_int(index, index, librandom::RngPtr &) const
Definition: conn_parameter.h:110
long_t value_
Definition: conn_parameter.h:113
ConnParameter()
Definition: conn_parameter.h:52
virtual double value_double(index, index, librandom::RngPtr &) const =0
Return parameter value.
static ConnParameter * create(const Token &)
Definition: conn_parameter.cpp:32
virtual size_t number_of_values() const
Returns number of values available.
Definition: conn_parameter.h:76
A type-independent container for C++-types.
Definition: token.h:68
librandom::RdvPtr rdv_
Definition: conn_parameter.h:166
double value_double(index, index, librandom::RngPtr &) const
Return parameter value.
Definition: conn_parameter.h:109
double value_double(index, index, librandom::RngPtr &) const
Return parameter value.
Definition: conn_parameter.h:92
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
double value_
Definition: conn_parameter.h:96
long_t value_int(index, index, librandom::RngPtr &) const
Definition: conn_parameter.h:93