6 #ifndef DYNAMIC_GRAPH_SIGNAL_PTR_H
7 #define DYNAMIC_GRAPH_SIGNAL_PTR_H
9 #include <dynamic-graph/exception-signal.h>
10 #include <dynamic-graph/signal.h>
26 template <
class T,
class Time>
27 class SignalPtr :
public virtual Signal<T, Time> {
29 using SignalBase<Time>::getName;
32 Signal<T, Time> *signalPtr;
34 bool transmitAbstract;
35 SignalBase<Time> *abstractTransmitter;
36 T *transmitAbstractData;
38 inline bool autoref()
const {
return signalPtr ==
this; }
41 SignalPtr(Signal<T, Time> *ptr, std::string name =
"")
42 : Signal<T, Time>(name),
45 transmitAbstract(false),
46 abstractTransmitter(NULL) {}
48 virtual ~SignalPtr() { signalPtr = NULL; }
52 Signal<T, Time> *getPtr();
53 const Signal<T, Time> *getPtr()
const;
54 SignalBase<Time> *getAbstractPtr();
55 const SignalBase<Time> *getAbstractPtr()
const;
56 virtual void plug(SignalBase<Time> *ref);
58 virtual void unplug() { plug(NULL); }
60 virtual bool isPlugged()
const {
return (NULL != signalPtr); }
61 virtual SignalBase<Time> *getPluged()
const {
return signalPtr; }
62 virtual bool isAbstractPluged()
const;
63 virtual const Time &getTime()
const;
66 inline Signal<T, Time> *operator->() {
return getPtr(); }
67 inline const Signal<T, Time> *operator->()
const {
return getPtr(); }
68 inline Signal<T, Time> &operator*() {
return *getPtr(); }
69 inline const Signal<T, Time> &operator*()
const {
return *getPtr(); }
70 inline operator bool()
const {
return isPlugged(); }
73 virtual bool needUpdate(
const Time &t)
const;
74 virtual std::ostream &writeGraph(std::ostream &os)
const;
75 virtual std::ostream &display(std::ostream &os)
const;
81 virtual const T &operator()(
const Time &t);
84 virtual const T &access(
const Time &t);
85 virtual const T &accessCopy()
const;
87 inline void setConstantDefault(
const T &t) {
88 Signal<T, Time>::setConstant(t);
91 virtual inline void setConstantDefault() { setConstantDefault(accessCopy()); }
92 inline void unsetConstantDefault() { modeNoThrow =
false; }
94 virtual void checkCompatibility();
101 virtual void setConstant(
const T &t) {
103 Signal<T, Time>::setConstant(t);
105 virtual void setReference(
const T *t,
106 typename Signal<T, Time>::Mutex *m = NULL) {
108 Signal<T, Time>::setReference(t, m);
110 virtual void setFunction(boost::function2<T &, T &, Time> t,
111 typename Signal<T, Time>::Mutex *m = NULL) {
113 Signal<T, Time>::setFunction(t, m);
121 virtual inline Signal<T, Time> &operator=(
const T &t) {
126 virtual std::ostream &displayDependencies(std::ostream &os,
127 const int depth = -1,
128 std::string space =
"",
129 std::string next1 =
"",
130 std::string next2 =
"")
const;
133 using Signal<T, Time>::addDependency;
134 virtual void addDependency() {}
135 using Signal<T, Time>::removeDependency;
136 virtual void removeDependency() {}
137 virtual void clearDependencies() {}
142 #include <dynamic-graph/signal-ptr.t.cpp>