NDS3  1.0.0
API reference manual
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pvDelegateOutImpl.h
1 /*
2  * Nominal Device Support v3 (NDS3)
3  *
4  * Copyright (c) 2015 Cosylab d.d.
5  *
6  * For more information about the license please refer to the license.txt
7  * file included in the distribution.
8  */
9 
10 #ifndef NDSDELEGATEPVOUTIMPL_H
11 #define NDSDELEGATEPVOUTIMPL_H
12 
13 #include "nds3/definitions.h"
14 #include "nds3/impl/pvBaseOutImpl.h"
15 
16 namespace nds
17 {
18 
32 template <typename T>
34 {
35 public:
39  typedef std::function<void (timespec*, T*)> initValue_t;
40 
44  typedef std::function<void (const timespec&, const T&)> write_t;
45 
53  PVDelegateOutImpl(const std::string& name, write_t writeFunction, initValue_t initValueFunction, const outputPvType_t pvType = outputPvType_t::generic);
54 
63  PVDelegateOutImpl(const std::string& name, write_t writeFunction, const outputPvType_t pvType = outputPvType_t::generic);
64 
73  virtual void read(timespec* pTimestamp, T* pValue) const;
74 
83  virtual void write(const timespec& timestamp, const T& value);
84 
90  virtual dataType_t getDataType() const;
91 
92 
93 private:
94  write_t m_writer;
95  initValue_t m_initializer;
96 
101  void dontInitialize(timespec*, T*);
102 
103 };
104 
105 }
106 #endif // NDSDELEGATEPVOUTIMPL_H
virtual dataType_t getDataType() const
Returns the PV's data type.
virtual void read(timespec *pTimestamp, T *pValue) const
Called when the control system wants to read the value.
virtual void write(const timespec &timestamp, const T &value)
Called when the control system wants to write a value.
std::function< void(timespec *, T *)> initValue_t
Definition of the method used to read the initial value.
Definition: pvDelegateOutImpl.h:39
Delegating Output PV. Delegates the read/write user defined functions.
Definition: pvDelegateOutImpl.h:33
The node's role is not specified.
outputPvType_t
Defines an output PV's role: this information is used to build the PV's external name when using the ...
Definition: definitions.h:130
Defines all the enumeration and common types used across the NDS library.
Base class for all the output PVs.
Definition: pvBaseOutImpl.h:26
std::function< void(const timespec &, const T &)> write_t
Definition of the method used to write.
Definition: pvDelegateOutImpl.h:44
PVDelegateOutImpl(const std::string &name, write_t writeFunction, initValue_t initValueFunction, const outputPvType_t pvType=outputPvType_t::generic)
Constructor. Specifies the methods used for read/write.
dataType_t
PV data types.
Definition: definitions.h:53