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> 12 #include <dynamic-graph/deprecated.hh> 28 template <
class T,
class Time>
29 class SignalPtr :
public virtual Signal<T, Time> {
31 using SignalBase<Time>::getName;
34 Signal<T, Time> *signalPtr;
36 bool transmitAbstract;
37 SignalBase<Time> *abstractTransmitter;
38 T *transmitAbstractData;
40 inline bool autoref()
const {
return signalPtr ==
this; }
43 SignalPtr(Signal<T, Time> *ptr, std::string name =
"")
44 : Signal<T, Time>(name), signalPtr(ptr), modeNoThrow(false),
45 transmitAbstract(false), abstractTransmitter(NULL) {}
47 virtual ~SignalPtr() { signalPtr = NULL; }
51 Signal<T, Time> *getPtr();
52 const Signal<T, Time> *getPtr()
const;
53 SignalBase<Time> *getAbstractPtr();
54 const SignalBase<Time> *getAbstractPtr()
const;
55 virtual void plug(SignalBase<Time> *ref);
57 virtual void unplug() { plug(NULL); }
59 virtual bool isPlugged()
const {
return (NULL != signalPtr); }
60 virtual SignalBase<Time> *getPluged()
const {
return signalPtr; }
61 virtual bool isAbstractPluged()
const;
62 virtual const Time &getTime()
const;
65 inline Signal<T, Time> *operator->() {
return getPtr(); }
66 inline const Signal<T, Time> *operator->()
const {
return getPtr(); }
67 inline Signal<T, Time> &operator*() {
return *getPtr(); }
68 inline const Signal<T, Time> &operator*()
const {
return *getPtr(); }
69 inline operator bool()
const {
return isPlugged(); }
72 virtual bool needUpdate(
const Time &t)
const;
73 virtual std::ostream &writeGraph(std::ostream &os)
const;
74 virtual std::ostream &display(std::ostream &os)
const;
80 virtual const T &operator()(
const Time &t);
83 virtual const T &access(
const Time &t);
84 virtual const T &accessCopy()
const;
86 inline void setConstantDefault(
const T &t) {
87 Signal<T, Time>::setConstant(t);
90 virtual inline void setConstantDefault() { setConstantDefault(accessCopy()); }
91 inline void unsetConstantDefault() { modeNoThrow =
false; }
100 virtual void setConstant(
const T &t) {
102 Signal<T, Time>::setConstant(t);
104 virtual void setReference(
const T *t,
105 typename Signal<T, Time>::Mutex *m = NULL) {
107 Signal<T, Time>::setReference(t, m);
109 virtual void setFunction(boost::function2<T &, T &, Time> t,
110 typename Signal<T, Time>::Mutex *m = NULL) {
112 Signal<T, Time>::setFunction(t, m);
120 virtual inline Signal<T, Time> &operator=(
const T &t) {
125 virtual std::ostream &displayDependencies(std::ostream &os,
126 const int depth = -1,
127 std::string space =
"",
128 std::string next1 =
"",
129 std::string next2 =
"")
const;
132 using Signal<T, Time>::addDependency;
133 virtual void addDependency() {}
134 using Signal<T, Time>::removeDependency;
135 virtual void removeDependency() {}
136 virtual void clearDependencies() {}
141 #include <dynamic-graph/signal-ptr.t.cpp> virtual void checkCompatibility()