Lodestar
An integrated real-time control package in C++
SignalBase.hpp
1 //
2 // Created by Hamza El-Kebir on 12/22/21.
3 //
4 
5 #ifndef LODESTAR_SIGNALBASE_HPP
6 #define LODESTAR_SIGNALBASE_HPP
7 
8 #include "Lodestar/GlobalConstants.hpp"
9 #include <set>
10 
11 namespace ls {
12  namespace blocks {
16  class SignalBase {
17  public:
18  SignalBase() : id_(0)
19  {}
20 
21  SignalBase(unsigned int id) : id_(id)
22  {}
23 
28  static unsigned int next()
29  {
30  return ID++;
31  }
32 
33  unsigned int id() const
34  { return id_; }
35 
36  inline
37  SignalBase *getConnection(int idx)
38  {
39  if (idx < 0 || idx >= connectionNumber)
40  return nullptr;
41 
42  return *::std::next(connectionPtrs.begin(), idx);
43  }
44 
45  int slotId;
46 
47  int blockId;
48 
49  bool isInput;
50 
51  int connectionNumber = 0;
52 
53  ::std::set<SignalBase *> connectionPtrs; // Set containing SignalBase pointers that are connected.
54  protected:
55 
56  static unsigned int ID;
57  unsigned int id_;
58  };
59  }
60 }
61 
62 
63 #endif //LODESTAR_SIGNALBASE_HPP
ls::blocks::SignalBase::next
static unsigned int next()
Definition: SignalBase.hpp:28
ls
Main Lodestar code.
Definition: BilinearTransformation.hpp:12
ls::blocks::SignalBase::connectionPtrs
::std::set< SignalBase * > connectionPtrs
Number of connections the SignalBase is currently engaged in.
Definition: SignalBase.hpp:53
ls::blocks::SignalBase::connectionNumber
int connectionNumber
True if the signal is an input, false otherwise.
Definition: SignalBase.hpp:51
ls::blocks::SignalBase::blockId
int blockId
Slot index identifier (local counter from 0).
Definition: SignalBase.hpp:47
ls::blocks::SignalBase::isInput
bool isInput
Block index (global counter).
Definition: SignalBase.hpp:49
ls::blocks::SignalBase
Definition: SignalBase.hpp:16