1 #ifndef _STATEFS_PROPERTY_HPP_
2 #define _STATEFS_PROPERTY_HPP_
4 #include <statefs/provider.hpp>
15 typedef std::shared_ptr<handle_type> handle_ptr;
17 PropTraits(std::string
const& aname, std::string
const& adefval)
18 : name(name), defval(adefval) {}
20 handle_ptr create()
const
22 return std::make_shared<handle_type>(name, defval);
30 Namespace& operator << (Namespace &ns, PropTraits<T>
const &t)
36 template <
typename T,
typename HandleT>
38 (
Namespace &ns, std::shared_ptr<BasicPropertyOwner<T, HandleT> >
const &p)
40 ns.insert(std::static_pointer_cast<ANode>(p));
44 typedef std::function<int (std::string const&)> setter_type;
47 int read_from(T &src,
char *dst, statefs_size_t len, statefs_off_t off)
55 memcpy(dst, &src[off], len);
60 setter_type property_setter(std::shared_ptr<AnalogProperty>
const &);
63 setter_type setter(std::shared_ptr<BasicPropertyOwner<T, std::string> >
const& h)
65 return property_setter(h->get_impl());
74 statefs_ssize_t size()
const;
78 int read(std::string *h,
char *dst, statefs_size_t len, statefs_off_t);
80 int write(std::string *h,
char const *src
81 , statefs_size_t len, statefs_off_t off)
94 friend setter_type property_setter(std::shared_ptr<AnalogProperty>
const &);
95 virtual int update(std::string
const&);
112 virtual int update(std::string
const&);
126 statefs_ssize_t size()
const;
130 int read(std::string *h,
char *dst, statefs_size_t len
131 , statefs_off_t off);
133 int write(std::string *h,
char const *src
134 , statefs_size_t len, statefs_off_t off);
136 void disconnect() { }
148 inline int DiscreteProperty::getattr()
const
153 inline bool DiscreteProperty::connect(::
statefs_slot *slot)
159 inline void DiscreteProperty::disconnect()
164 inline int BasicWriter::getattr()
const
169 inline statefs_ssize_t BasicWriter::size()
const
179 inline int BasicWriter::read
180 (std::string *h,
char *dst, statefs_size_t len, statefs_off_t off)
187 #endif // _STATEFS_PROPERTY_HPP_