NEST  2.6.0,not_revisioned_source_dir@0
node.h
Go to the documentation of this file.
1 /*
2  * node.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 NODE_H
24 #define NODE_H
25 #include <bitset>
26 #include <string>
27 #include <sstream>
28 #include <vector>
29 #include <deque>
30 #include <utility>
31 #include "nest.h"
32 #include "nest_time.h"
33 #include "nest_names.h"
34 #include "dictdatum.h"
35 #include "histentry.h"
36 #include "event.h"
37 
42 namespace nest {
43 
44  class Scheduler;
45  class Model;
46 
47  class Subnet;
48  class Network;
49  class Archiving_Node;
50  class histentry;
51 
52 
80  /* BeginDocumentation
81  Name: Node - General properties of all nodes.
82  Parameters:
83  frozen booltype - Whether the node is updated during simulation
84  global_id integertype - The global id of the node (cf. local_id)
85  local booltype - Whether the node is available on the local process
86  local_id integertype - The id of the node in the current (cf. global_id)
87  model literaltype - The model type the node was created from
88  parent integertype - The global id of the parent subnet
89  state integertype - The state of the node (see the help on elementstates for details)
90  thread integertype - The id of the thread the node is assigned to (valid locally)
91  vp integertype - The id of the virtual process the node is assigned to (valid globally)
92  SeeAlso: GetStatus, SetStatus, elementstates
93  */
94 
95 
96  class Node
97  {
98  friend class Network;
99  friend class Scheduler;
100  friend class Subnet;
101  friend class proxynode;
102  friend class Synapse;
103  friend class Model;
104 
105  Node& operator=(const Node&);
106 
107  public:
108 
109  Node();
110  Node(Node const &);
111  virtual ~Node();
112 
119  virtual Node *clone() const{ return 0; }
120 
126  virtual bool has_proxies() const;
127 
131  virtual bool potential_global_receiver() const;
132 
136  virtual void set_has_proxies(const bool);
137 
141  virtual void set_local_receiver(const bool);
142 
147  virtual bool local_receiver() const;
148 
155  virtual bool one_node_per_process() const;
156 
163  virtual bool is_off_grid() const;
164 
165 
170  virtual bool is_proxy() const;
171 
178  std::string get_name() const;
179 
187  index get_gid() const;
188 
194  index get_lid() const;
195 
201  index get_subnet_index() const;
202 
210  int get_model_id() const;
211 
219  Subnet* get_parent() const;
220 
224  virtual
225  std::string print_network(int , int, std::string = "") {return std::string();}
226 
230  bool is_frozen() const;
231 
236  static Network* network();
237 
241  bool is_local() const;
242 
258  void init_state();
259 
269  void init_buffers();
270 
278  virtual void calibrate()=0;
279 
286  virtual void finalize() {}
287 
300  virtual
301  void update(Time const &, const long_t, const long_t)=0;
302 
303 
326  virtual
327  void set_status(const DictionaryDatum&)=0;
328 
335  virtual
336  void get_status(DictionaryDatum&) const=0;
337 
338  public:
365  virtual port send_test_event(Node& receiving_node, rport receptor_type, synindex syn_id, bool dummy_target);
366 
392 
399  virtual
401 
408  virtual
410 
421  virtual
422  void handle(SpikeEvent& e);
423 
430  virtual
431  void handle(RateEvent& e);
432 
439  virtual
440  void handle(DataLoggingRequest& e);
441 
450  virtual
451  void handle(DataLoggingReply& e);
452 
459  virtual
460  void handle(CurrentEvent& e);
461 
468  virtual
469  void handle(ConductanceEvent& e);
470 
477  virtual
478  void handle(DoubleDataEvent& e);
479 
484  virtual
486 
492  virtual
493  void get_K_values(double_t t, double_t& Kminus, double_t& triplet_Kminus);
494 
499  virtual
500  void get_history(double_t t1, double_t t2,
501  std::deque<histentry>::iterator* start,
502  std::deque<histentry>::iterator* finish);
503 
517  virtual
518  void event_hook(DSSpikeEvent&);
519 
520  virtual
521  void event_hook(DSCurrentEvent&);
522 
528  void set_thread(thread);
529 
533  thread get_thread() const;
534 
539  void set_vp(thread);
540 
544  thread get_vp() const;
545 
550  void set_model_id(int);
551 
555  virtual bool is_subnet() const;
556 
566 
573  void set_status_base(const DictionaryDatum&);
574 
578  bool is_model_prototype() const;
579 
584  void set_thread_lid(const index);
585 
589  index get_thread_lid() const;
590 
592  bool buffers_initialized() const { return buffers_initialized_; }
593 
594  void set_buffers_initialized(bool initialized) { buffers_initialized_ = initialized; }
595 
596  private:
597 
598  void set_lid_(index);
599  void set_parent_(Subnet *);
600  void set_gid_(index);
601  void set_subnet_index_(index);
602 
610  virtual
612 
613  protected:
614 
623  virtual
624  size_t num_thread_siblings_() const { return 0;}
625 
635  virtual
636  Node* get_thread_sibling_(index) const { assert(false); return 0; }
637 
641  virtual
642  Node* get_thread_sibling_safe_(index) const { assert(false); return 0; }
643 
654  virtual void init_state_(Node const&) =0;
655 
662  virtual void init_buffers_() =0;
663 
664  Model & get_model_() const;
665 
667  void set_frozen_(bool frozen) { frozen_ = frozen; }
668 
674  template <typename ConcreteNode>
675  const ConcreteNode& downcast(const Node&);
676 
677  private:
681 
686 
693  int model_id_;
697  bool frozen_;
699 
700  protected:
701  static Network* net_;
702  };
703 
704  inline
705  bool Node::is_frozen() const
706  {
707  return frozen_;
708  }
709 
710  inline
711  bool Node::has_proxies() const
712  {
713  return true;
714  }
715 
716  inline
718  {
719  return false;
720  }
721 
722  inline
723  bool Node::local_receiver() const
724  {
725  return false;
726  }
727 
728  inline
730  {
731  return false;
732  }
733 
734  inline
735  bool Node::is_off_grid() const
736  {
737  return false;
738  }
739 
740  inline
741  bool Node::is_proxy() const
742  {
743  return false;
744  }
745 
746  inline
748  {
749  return lid_;
750  }
751 
752  inline
754  {
755  return gid_;
756  }
757 
758  inline
760  {
761  return subnet_index_;
762  }
763 
764  inline
766  {
767  gid_=i;
768  }
769 
770  inline
772  {
773  lid_=i;
774  }
775 
776  inline
778  {
779  subnet_index_ = i;
780  }
781 
782  inline
783  int Node::get_model_id() const
784  {
785  return model_id_;
786  }
787 
788  inline
789  void Node::set_model_id(int i)
790  {
791  model_id_ = i;
792  }
793 
794  inline
796  {
797  return vp_ == invalid_thread_;
798  }
799 
800  inline
802  {
803  return parent_;
804  }
805 
806  inline
808  {
809  parent_=c;
810  }
811 
812  inline
814  {
815  return net_;
816  }
817 
818  inline
820  {
821  thread_ = t;
822  }
823 
824  inline
826  {
827  return thread_;
828  }
829 
830  inline
832  {
833  vp_ = vp;
834  }
835 
836  inline
838  {
839  return vp_;
840  }
841 
842  template <typename ConcreteNode>
843  const ConcreteNode& Node::downcast(const Node& n)
844  {
845  ConcreteNode const* tp = dynamic_cast<ConcreteNode const*>(&n);
846  assert(tp != 0);
847  return *tp;
848  }
849 
850  inline
851  void Node::set_thread_lid(const index tlid)
852  {
853  thread_lid_ = tlid;
854  }
855 
856  inline
858  {
859  return thread_lid_;
860  }
861 
862 } // namespace
863 
864 #endif
void set_thread(thread)
Store the number of the thread to which the node is assigned.
Definition: node.h:819
size_t index
Unsigned long type for enumerations.
Definition: nest.h:109
Base class for all subnet nodes.
Definition: subnet.h:67
void set_thread_lid(const index)
set thread local index
Definition: node.h:851
const Name receptor_type("receptor_type")
Connection parameters.
Definition: nest_names.h:240
bool is_model_prototype() const
Returns true if node is model prototype.
Definition: node.h:795
index get_gid() const
Return global Network ID.
Definition: node.h:753
Definition: lockptrdatum.h:40
friend class Synapse
Definition: node.h:102
virtual double_t get_K_value(double_t t)
return the Kminus value at t (in ms).
Definition: node.cpp:273
bool buffers_initialized() const
True if buffers have been initialized.
Definition: node.h:592
const Name frozen("frozen")
Node parameter.
Definition: nest_names.h:142
virtual void get_K_values(double_t t, double_t &Kminus, double_t &triplet_Kminus)
write the Kminus and triplet_Kminus values at t (in ms) to the provided locations.
Definition: node.cpp:279
"Callback request event" for use in Device.
Definition: event.h:374
void init_state()
Set state variables to the default values for the model.
Definition: node.cpp:66
bool is_local() const
Returns true if the node is allocated in the local process.
Definition: node.cpp:99
void set_gid_(index)
Set global node id.
Definition: node.h:765
int model_id_
Model ID.
Definition: node.h:693
virtual void set_status(const DictionaryDatum &)=0
Change properties of the node according to the entries in the dictionary.
index lid_
Local element id (within parent).
Definition: node.h:679
DictionaryDatum get_status_base()
Return a dictionary with the node's properties.
Definition: node.cpp:109
virtual size_t num_thread_siblings_() const
Return the number of thread siblings in SiblingContainer.
Definition: node.h:624
virtual port send_test_event(Node &receiving_node, rport receptor_type, synindex syn_id, bool dummy_target)
Send an event to the receiving_node passed as an argument.
Definition: node.cpp:169
Node & operator=(const Node &)
not implemented
virtual bool one_node_per_process() const
Returns true if the node exists only once per process, but does not have proxies on remote threads...
Definition: node.h:729
virtual bool is_subnet() const
Definition: node.cpp:311
virtual void finalize()
Finalize node.
Definition: node.h:286
virtual void calibrate()=0
Re-calculate dependent parameters of the node.
Event for electrical currents.
Definition: event.h:420
long_t rport
Connection port number to distinguish incoming connections, also called receiver port.
Definition: nest.h:147
virtual bool has_proxies() const
Returns true if the node has proxies on remote threads.
Definition: node.h:711
bool frozen_
node shall not be updated if true
Definition: node.h:697
Part of definition of Archiving_Node which is capable of recording and managing a spike history...
bool is_frozen() const
Returns true if node is frozen, i.e., shall not be updated.
Definition: node.h:705
void set_buffers_initialized(bool initialized)
Definition: node.h:594
virtual void get_status(DictionaryDatum &) const =0
Export properties of the node by setting entries in the status dictionary.
assert(pNet!=0)
index get_thread_lid() const
get thread local index
Definition: node.h:857
virtual bool local_receiver() const
Returns true if the node only receives events from nodes/devices on the same thread.
Definition: node.h:723
virtual Node * clone() const
Virtual copy constructor.
Definition: node.h:119
virtual bool potential_global_receiver() const
Returns true for potential global receivers (e.g.
Definition: node.h:717
virtual void init_state_(Node const &)=0
Private function to initialize the state of a node to model defaults.
void set_subnet_index_(index)
Index into node array in subnet.
Definition: node.h:777
index thread_lid_
Local id of this node in the thread-local vector of nodes.
Definition: node.h:685
index gid_
Global element id (within network).
Definition: node.h:678
void set_model_id(int)
Set the model id.
Definition: node.h:789
Provide logged data through request transmitting reference.
Definition: event.h:563
Definition: nest_time.h:130
void set_status_base(const DictionaryDatum &)
Set status dictionary of a node.
Definition: node.cpp:151
index subnet_index_
Index of node in parent's node array.
Definition: node.h:680
virtual void update(Time const &, const long_t, const long_t)=0
Bring the node from state $t$ to $t+n*dt$.
std::string get_name() const
Return class name.
Definition: node.cpp:83
void init_buffers()
Initialize buffers of a node.
Definition: node.cpp:73
Node()
Definition: node.cpp:37
virtual void get_history(double_t t1, double_t t2, std::deque< histentry >::iterator *start, std::deque< histentry >::iterator *finish)
return the spike history for (t1,t2].
Definition: node.cpp:284
Base class for all Models.
Definition: model.h:48
const Name start("start")
Device parameters.
Definition: nest_names.h:263
virtual void unregister_stdp_connection(double_t)
Unregister a STDP connection.
Definition: node.cpp:187
Subnet * parent_
Pointer to parent.
Definition: node.h:694
void set_frozen_(bool frozen)
Mark node as frozen.
Definition: node.h:667
virtual bool is_proxy() const
Returns true if the node is a proxy node.
Definition: node.h:741
const Name vp("vp")
Node parameter.
Definition: nest_names.h:341
Main administrative interface to the network.
Definition: network.h:135
Event for firing rate information.
Definition: event.h:387
Subnet * get_parent() const
Return pointer to parent subnet.
Definition: node.h:801
index get_subnet_index() const
Return the index to the node in the node array of the parent subnet.
Definition: node.h:759
virtual ~Node()
Definition: node.cpp:63
virtual void register_stdp_connection(double_t)
Register a STDP connection.
Definition: node.cpp:178
virtual DictionaryDatum get_status_dict_()
Return a new dictionary datum .
Definition: node.cpp:104
virtual Node * get_thread_sibling_(index) const
Return the specified member of a SiblingContainer.
Definition: node.h:636
virtual void set_has_proxies(const bool)
Sets has_proxies_ member variable (to switch to global spike detection mode)
Definition: node.cpp:291
long_t port
Connection port number to distinguis outgoing connections.
Definition: nest.h:155
thread get_vp() const
Retrieve the number of the virtual process to which the node is assigned.
Definition: node.h:837
virtual void handle(SpikeEvent &e)
Handle incoming spike events.
Definition: node.cpp:198
static Network * net_
Pointer to global network driver.
Definition: node.h:701
double double_t
Double precision floating point numbers.
Definition: nest.h:93
void set_vp(thread)
Store the number of the virtual process to which the node is assigned.
Definition: node.h:831
virtual port handles_test_event(SpikeEvent &, rport receptor_type)
Check if the node can handle a particular event and receptor type.
Definition: node.cpp:203
thread thread_
thread node is assigned to
Definition: node.h:695
int get_model_id() const
Return model ID of the node.
Definition: node.h:783
Request data to be logged/logged data to be sent.
Definition: event.h:486
static Network * network()
Return pointer to network driver class.
Definition: node.h:813
virtual void set_local_receiver(const bool)
Sets local_receiver_ member variable (to switch to global spike detection mode)
Definition: node.cpp:296
unsigned char synindex
Unsigned char type for enumerations of synapse types.
Definition: nest.h:115
Definition: event.h:685
thread get_thread() const
Retrieve the number of the thread to which the node is assigned.
Definition: node.h:825
void set_parent_(Subnet *)
Set pointer to parent subnet.
Definition: node.h:807
const Name n("n")
Number of synaptic release sites (int >=0) (Tsodyks2_connection)
Definition: nest_names.h:202
thread vp_
virtual process node is assigned to
Definition: node.h:696
Default types used by the NEST kernel.
Event for spike information.
Definition: event.h:320
const thread invalid_thread_
Value for invalid connection port number.
Definition: nest.h:138
virtual void init_buffers_()=0
Private function to initialize the buffers of a node.
Base class for all NEST network objects.
Definition: node.h:96
bool buffers_initialized_
Buffers have been initialized.
Definition: node.h:698
virtual Node * get_thread_sibling_safe_(index) const
Return specified member of a SiblingContainer, with access control.
Definition: node.h:642
virtual std::string print_network(int, int, std::string="")
Prints out one line of the tree view of the network.
Definition: node.h:225
Schedule update of Nodes and Events during simulation.
Definition: scheduler.h:66
virtual void event_hook(DSSpikeEvent &)
Modify Event object parameters during event delivery.
Definition: node.cpp:301
const Name c("c")
Specific to Izhikevich 2003.
Definition: nest_names.h:62
const ConcreteNode & downcast(const Node &)
Auxiliary function to downcast a Node to a concrete class derived from Node.
Definition: node.h:843
index get_lid() const
Return local node ID.
Definition: node.h:747
int_t thread
Thread index type.
Definition: nest.h:133
void set_lid_(index)
Set local id, relative to the parent subnet.
Definition: node.h:771
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
virtual bool is_off_grid() const
Returns true if the node if it sends/receives -grid events This is used to discriminate between diffe...
Definition: node.h:735
const double e
Definition: numerics.cpp:62
Model & get_model_() const
Definition: node.cpp:91
Proxy Node to provide Nodes, where there aren't real Nodes to be.
Definition: proxynode.h:45
"Callback request event" for use in Device.
Definition: event.h:465
Event for electrical conductances.
Definition: event.h:616