objdict.h
Go to the documentation of this file.
1 #ifndef H_OBJDICT
2 #define H_OBJDICT
3 
5 #include <boost/unordered_map.hpp>
6 #include <boost/unordered_set.hpp>
7 #include <boost/thread/mutex.hpp>
8 #include <boost/make_shared.hpp>
9 #include <boost/function.hpp>
10 #include <typeinfo>
11 #include <vector>
12 #include "exceptions.h"
13 
14 namespace canopen{
15 
16 class TypeGuard{
17  const std::type_info& (*get_type)();
18  size_t type_size;
19 
20  template<typename T> class TypeInfo{
21  public:
22  static const std::type_info& id() { return typeid(T); }
23  };
24  TypeGuard(const std::type_info& (*ti)(), const size_t s): get_type(ti), type_size(s) {}
25 public:
26 
27  template<typename T> bool is_type() const {
28  return valid() && get_type() == typeid(T);
29  }
30 
31  bool operator==(const TypeGuard &other) const {
32  return valid() && other.valid() && (get_type() == other.get_type());
33  }
34 
35  TypeGuard(): get_type(0), type_size(0) {}
36  bool valid() const { return get_type != 0; }
37  size_t get_size() const { return type_size; }
38  template<typename T> static TypeGuard create() { return TypeGuard(TypeInfo<T>::id, sizeof(T)); }
39 };
40 
41 class String: public std::vector<char>{
42 public:
43  String() {}
44  String(const std::string &str) : std::vector<char>(str.begin(), str.end()) {}
45  operator const char * () const {
46  return &at(0);
47  }
48  operator const std::string () const {
49  return std::string(begin(), end());
50  }
51 };
52 
53 class HoldAny{
56  bool empty;
57 public:
58  HoldAny() : empty(true) {}
59 
60  const TypeGuard& type() const{ return type_guard; }
61 
62  template<typename T> HoldAny(const T &t) : type_guard(TypeGuard::create<T>()), empty(false){
63  buffer.resize(sizeof(T));
64  *(T*)&(buffer.front()) = t;
65  }
66  HoldAny(const std::string &t): type_guard(TypeGuard::create<std::string>()), empty(false){
67  if(!type_guard.is_type<std::string>()){
68  BOOST_THROW_EXCEPTION(std::bad_cast());
69  }
70  buffer = t;
71  }
72  HoldAny(const TypeGuard &t): type_guard(t), empty(true){ }
73 
74  bool is_empty() const { return empty; }
75 
76  const String& data() const {
77  if(empty){
78  BOOST_THROW_EXCEPTION(std::length_error("buffer empty"));
79  }
80  return buffer;
81  }
82 
83  template<typename T> const T & get() const{
84  if(!type_guard.is_type<T>()){
85  BOOST_THROW_EXCEPTION(std::bad_cast());
86  }else if(empty){
87  BOOST_THROW_EXCEPTION(std::length_error("buffer empty"));
88  }
89  return *(T*)&(buffer.front());
90  }
91 };
92 
93 template<> const String & HoldAny::get() const;
94 
95 struct DeviceInfo{
96  std::string vendor_name;
97  uint32_t vendor_number;
98  std::string product_name;
99  uint32_t product_number;
100  uint32_t revision_number;
101  std::string order_code;
102  boost::unordered_set<uint32_t> baudrates;
105  uint8_t granularity;
108  uint16_t nr_of_rx_pdo;
109  uint16_t nr_of_tx_pdo;
111  boost::unordered_set<uint16_t> dummy_usage;
112 };
113 
114 #define THROW_WITH_KEY(e,k) BOOST_THROW_EXCEPTION(boost::enable_error_info(e) << ObjectDict::key_info(k))
115 
117 protected:
118 public:
119  class Key{
120  static size_t fromString(const std::string &str);
121  public:
122  const size_t hash;
123  Key(const uint16_t i) : hash((i<<16)| 0xFFFF) {}
124  Key(const uint16_t i, const uint8_t s): hash((i<<16)| s) {}
125  Key(const std::string &str): hash(fromString(str)) {}
126  bool hasSub() const { return (hash & 0xFFFF) != 0xFFFF; }
127  uint8_t sub_index() const { return hash & 0xFFFF; }
128  uint16_t index() const { return hash >> 16;}
129  bool operator==(const Key &other) const { return hash == other.hash; }
130  operator std::string() const;
131  };
132  struct KeyHash {
133  std::size_t operator()(const Key& k) const { return k.hash; }
134  };
135 
136  enum Code{
137  NULL_DATA = 0x00,
138  DOMAIN_DATA = 0x02,
139  DEFTYPE = 0x05,
140  DEFSTRUCT = 0x06,
141  VAR = 0x07,
142  ARRAY = 0x08,
143  RECORD = 0x09
144  };
145  enum DataTypes{
146  DEFTYPE_INTEGER8 = 0x0002,
147  DEFTYPE_INTEGER16 = 0x0003,
148  DEFTYPE_INTEGER32 = 0x0004,
149  DEFTYPE_UNSIGNED8 = 0x0005,
150  DEFTYPE_UNSIGNED16 = 0x0006,
151  DEFTYPE_UNSIGNED32 = 0x0007,
152  DEFTYPE_REAL32 = 0x0008,
153  DEFTYPE_VISIBLE_STRING = 0x0009,
154  DEFTYPE_OCTET_STRING = 0x000A,
155  DEFTYPE_UNICODE_STRING = 0x000B,
156  DEFTYPE_DOMAIN = 0x000F,
157  DEFTYPE_REAL64 = 0x0010,
158  DEFTYPE_INTEGER64 = 0x0015,
159  DEFTYPE_UNSIGNED64 = 0x001B
160  };
161  struct Entry{
163  uint16_t index;
164  uint8_t sub_index;
165  uint16_t data_type;
166  bool constant;
167  bool readable;
168  bool writable;
169  bool mappable;
170  std::string desc;
173 
174  Entry() {}
175 
176  Entry(const Code c, const uint16_t i, const uint16_t t, const std::string & d, const bool r = true, const bool w = true, bool m = false, const HoldAny def = HoldAny(), const HoldAny init = HoldAny()):
177  obj_code(c), index(i), sub_index(0),data_type(t),readable(r), writable(w), mappable(m), desc(d), def_val(def), init_val(init) {}
178 
179  Entry(const uint16_t i, const uint8_t s, const uint16_t t, const std::string & d, const bool r = true, const bool w = true, bool m = false, const HoldAny def = HoldAny(), const HoldAny init = HoldAny()):
180  obj_code(VAR), index(i), sub_index(s),data_type(t),readable(r), writable(w), mappable(m), desc(d), def_val(def), init_val(init) {}
181 
182  operator Key() const { return Key(index, sub_index); }
183  const HoldAny & value() const { return !init_val.is_empty() ? init_val : def_val; }
184 
185  };
186  typedef boost::shared_ptr<const Entry> EntryConstSharedPtr;
187 
188  const Entry& operator()(uint16_t i) const{
189  return *at(Key(i));
190  }
191  const Entry& operator()(uint16_t i, uint8_t s) const{
192  return *at(Key(i,s));
193  }
194  const EntryConstSharedPtr& get(const Key &k) const{
195  return at(k);
196  }
197  bool has(uint16_t i, uint8_t s) const{
198  return dict_.find(Key(i,s)) != dict_.end();
199  }
200  bool has(uint16_t i) const{
201  return dict_.find(Key(i)) != dict_.end();
202  }
203  bool has(const Key &k) const{
204  return dict_.find(k) != dict_.end();
205  }
206  bool insert(bool is_sub, EntryConstSharedPtr e){
207  std::pair<boost::unordered_map<Key, EntryConstSharedPtr>::iterator, bool> res = dict_.insert(std::make_pair(is_sub?Key(e->index,e->sub_index):Key(e->index),e));
208  return res.second;
209  }
210  bool iterate(boost::unordered_map<Key, EntryConstSharedPtr>::const_iterator &it) const;
211  typedef std::list<std::pair<std::string, std::string> > Overlay;
212  typedef boost::shared_ptr<ObjectDict> ObjectDictSharedPtr;
213  static ObjectDictSharedPtr fromFile(const std::string &path, const Overlay &overlay = Overlay());
215 
216  ObjectDict(const DeviceInfo &info): device_info(info) {}
217  typedef boost::error_info<struct tag_objectdict_key, ObjectDict::Key> key_info;
218 protected:
219  const EntryConstSharedPtr& at(const Key &key) const{
220  try{
221  return dict_.at(key);
222  }
223  catch(const std::out_of_range &e){
224  THROW_WITH_KEY(e, key);
225  }
226  }
227 
228  boost::unordered_map<Key, EntryConstSharedPtr > dict_;
229 };
231 typedef boost::shared_ptr<const ObjectDict> ObjectDictConstSharedPtr;
232 
233 std::size_t hash_value(ObjectDict::Key const& k);
234 
235 template<typename T> class NodeIdOffset{
237  T (*adder)(const uint8_t &, const T &);
238 
239  static T add(const uint8_t &u, const T &t) {
240  return u+t;
241  }
242 public:
243  NodeIdOffset(const T &t): offset(t), adder(add) {}
244 
245  static const T apply(const HoldAny &val, const uint8_t &u){
246  if(!val.is_empty()){
247  if(TypeGuard::create<T>() == val.type() ){
248  return val.get<T>();
249  }else{
250  const NodeIdOffset<T> &no = val.get< NodeIdOffset<T> >();
251  return no.adder(u, no.offset);
252  }
253  }else{
254  BOOST_THROW_EXCEPTION(std::bad_cast());
255  }
256 
257  }
258 };
259 
260 template<typename T> std::ostream& operator<<(std::ostream& stream, const NodeIdOffset<T> &n) {
261  //stream << "Offset: " << n.apply(0);
262  return stream;
263  }
264 std::ostream& operator<<(std::ostream& stream, const ObjectDict::Key &k);
265 
266 class AccessException : public Exception{
267 public:
268  AccessException(const std::string &w) : Exception(w) {}
269 };
270 
271 
273 public:
276  typedef boost::shared_ptr<ObjectStorage> ObjectStorageSharedPtr;
277 
278 protected:
279  class Data: boost::noncopyable{
280  boost::mutex mutex;
282  bool valid;
283 
284  ReadDelegate read_delegate;
285  WriteDelegate write_delegate;
286 
287  template <typename T> T & access(){
288  if(!valid){
289  THROW_WITH_KEY(std::length_error("buffer not valid"), key);
290  }
291  return *(T*)&(buffer.front());
292  }
293  template <typename T> T & allocate(){
294  if(!valid){
295  buffer.resize(sizeof(T));
296  valid = true;
297  }
298  return access<T>();
299  }
300  public:
304  size_t size() { boost::mutex::scoped_lock lock(mutex); return buffer.size(); }
305 
306  template<typename T> Data(const ObjectDict::Key &k, const ObjectDict::EntryConstSharedPtr &e, const T &val, const ReadDelegate &r, const WriteDelegate &w)
307  : valid(false), read_delegate(r), write_delegate(w), type_guard(TypeGuard::create<T>()), entry(e), key(k){
308  assert(!r.empty());
309  assert(!w.empty());
310  assert(e);
311  allocate<T>() = val;
312  }
313  Data(const ObjectDict::Key &k, const ObjectDict::EntryConstSharedPtr &e, const TypeGuard &t, const ReadDelegate &r, const WriteDelegate &w)
314  : valid(false), read_delegate(r), write_delegate(w), type_guard(t), entry(e), key(k){
315  assert(!r.empty());
316  assert(!w.empty());
317  assert(e);
318  assert(t.valid());
319  buffer.resize(t.get_size());
320  }
321  void set_delegates(const ReadDelegate &r, const WriteDelegate &w){
322  boost::mutex::scoped_lock lock(mutex);
323  if(r) read_delegate = r;
324  if(w) write_delegate = w;
325  }
326  template<typename T> const T get(bool cached) {
327  boost::mutex::scoped_lock lock(mutex);
328 
329  if(!entry->readable){
330  THROW_WITH_KEY(AccessException("no read access"), key);
331 
332  }
333 
334  if(entry->constant) cached = true;
335 
336  if(!valid || !cached){
337  allocate<T>();
338  read_delegate(*entry, buffer);
339  }
340  return access<T>();
341  }
342  template<typename T> void set(const T &val) {
343  boost::mutex::scoped_lock lock(mutex);
344 
345  if(!entry->writable){
346  if(access<T>() != val){
347  THROW_WITH_KEY(AccessException("no write access"), key);
348  }
349  }else{
350  allocate<T>() = val;
351  write_delegate(*entry, buffer);
352  }
353  }
354  template<typename T> void set_cached(const T &val) {
355  boost::mutex::scoped_lock lock(mutex);
356  if(!valid || val != access<T>() ){
357  if(!entry->writable){
358  THROW_WITH_KEY(AccessException("no write access and not cached"), key);
359  }else{
360  allocate<T>() = val;
361  write_delegate(*entry, buffer);
362  }
363  }
364  }
365  void init();
366  void reset();
367  void force_write();
368 
369  };
370  typedef boost::shared_ptr<Data> DataSharedPtr;
371 public:
372  template<const uint16_t dt> struct DataType{
373  typedef void type;
374  };
375 
376  template<typename T> class Entry{
377  DataSharedPtr data;
378  public:
379  typedef T type;
380  bool valid() const { return data != 0; }
381  const T get() {
382  if(!data) BOOST_THROW_EXCEPTION( PointerInvalid("ObjectStorage::Entry::get()") );
383 
384  return data->get<T>(false);
385  }
386  bool get(T & val){
387  try{
388  val = get();
389  return true;
390  }catch(...){
391  return false;
392  }
393  }
394  const T get_cached() {
395  if(!data) BOOST_THROW_EXCEPTION( PointerInvalid("ObjectStorage::Entry::get_cached()") );
396 
397  return data->get<T>(true);
398  }
399  bool get_cached(T & val){
400  try{
401  val = get_cached();
402  return true;
403  }catch(...){
404  return false;
405  }
406  }
407  void set(const T &val) {
408  if(!data) BOOST_THROW_EXCEPTION( PointerInvalid("ObjectStorage::Entry::set(val)") );
409  data->set(val);
410  }
411  bool set_cached(const T &val) {
412  if(!data) return false;
413  try{
414  data->set_cached(val);
415  return true;
416  }catch(...){
417  return false;
418  }
419  }
420 
421  Entry() {}
422  Entry(DataSharedPtr &d)
423  : data(d){
424  assert(data);
425  }
426  Entry(ObjectStorageSharedPtr storage, uint16_t index)
427  : data(storage->entry<type>(index).data) {
428  assert(data);
429  }
430  Entry(ObjectStorageSharedPtr storage, uint16_t index, uint8_t sub_index)
431  : data(storage->entry<type>(index, sub_index).data) {
432  assert(data);
433  }
434  Entry(ObjectStorageSharedPtr storage, const ObjectDict::Key &k)
435  : data(storage->entry<type>(k).data) {
436  assert(data);
437  }
438  const ObjectDict::Entry & desc() const{
439  return *(data->entry);
440  }
441  };
442 
443  void reset();
444 
445 protected:
446  boost::unordered_map<ObjectDict::Key, DataSharedPtr > storage_;
447  boost::mutex mutex_;
448 
449  void init_nolock(const ObjectDict::Key &key, const ObjectDict::EntryConstSharedPtr &entry);
450 
451  ReadDelegate read_delegate_;
452  WriteDelegate write_delegate_;
453  size_t map(const ObjectDict::EntryConstSharedPtr &e, const ObjectDict::Key &key, const ReadDelegate & read_delegate, const WriteDelegate & write_delegate);
454 public:
455  template<typename T> Entry<T> entry(const ObjectDict::Key &key){
456  boost::mutex::scoped_lock lock(mutex_);
457 
458  boost::unordered_map<ObjectDict::Key, DataSharedPtr >::iterator it = storage_.find(key);
459 
460  if(it == storage_.end()){
461  const ObjectDict::EntryConstSharedPtr e = dict_->get(key);
462 
463  DataSharedPtr data;
464  TypeGuard type = TypeGuard::create<T>();
465 
466  if(!e->def_val.is_empty()){
467  T val = NodeIdOffset<T>::apply(e->def_val, node_id_);
468  data = boost::make_shared<Data>(key, e,val, read_delegate_, write_delegate_);
469  }else{
470  if(!e->def_val.type().valid() || e->def_val.type() == type) {
471  data = boost::make_shared<Data>(key,e,type, read_delegate_, write_delegate_);
472  }else{
473  THROW_WITH_KEY(std::bad_cast(), key);
474  }
475  }
476 
477  std::pair<boost::unordered_map<ObjectDict::Key, DataSharedPtr >::iterator, bool> ok = storage_.insert(std::make_pair(key, data));
478  it = ok.first;
479  }
480 
481  if(!it->second->type_guard.is_type<T>()){
482  THROW_WITH_KEY(std::bad_cast(), key);
483  }
484  return Entry<T>(it->second);
485  }
486 
487  size_t map(uint16_t index, uint8_t sub_index, const ReadDelegate & read_delegate, const WriteDelegate & write_delegate);
488 
489  template<typename T> Entry<T> entry(uint16_t index){
490  return entry<T>(ObjectDict::Key(index));
491  }
492  template<typename T> Entry<T> entry(uint16_t index, uint8_t sub_index){
493  return entry<T>(ObjectDict::Key(index,sub_index));
494  }
495 
496  template<typename T> void entry(Entry<T> &e, uint16_t index){ // TODO: migrate to bool
497  e = entry<T>(ObjectDict::Key(index));
498  }
499  template<typename T> void entry(Entry<T> &e, uint16_t index, uint8_t sub_index){ // TODO: migrate to bool
500  e = entry<T>(ObjectDict::Key(index,sub_index));
501  }
502  template<typename T> bool entry(Entry<T> &e, const ObjectDict::Key &k){
503  try{
504  e = entry<T>(k);
505  return true;
506  }catch(...){
507  return false;
508  }
509  }
510  typedef boost::function<std::string()> ReadStringFuncType;
511  ReadStringFuncType getStringReader(const ObjectDict::Key &key, bool cached = false);
512  typedef boost::function<void(const std::string &)> WriteStringFuncType;
513  WriteStringFuncType getStringWriter(const ObjectDict::Key &key, bool cached = false);
514 
515  const ObjectDictConstSharedPtr dict_;
516  const uint8_t node_id_;
517 
518  ObjectStorage(ObjectDictConstSharedPtr dict, uint8_t node_id, ReadDelegate read_delegate, WriteDelegate write_delegate);
519 
520  void init(const ObjectDict::Key &key);
521  void init_all();
522 };
524 
525 template<> String & ObjectStorage::Data::access();
527 
528 template<> struct ObjectStorage::DataType<ObjectDict::DEFTYPE_INTEGER8> { typedef int8_t type;};
529 template<> struct ObjectStorage::DataType<ObjectDict::DEFTYPE_INTEGER16> { typedef int16_t type;};
530 template<> struct ObjectStorage::DataType<ObjectDict::DEFTYPE_INTEGER32> { typedef int32_t type;};
531 template<> struct ObjectStorage::DataType<ObjectDict::DEFTYPE_INTEGER64> { typedef int64_t type;};
532 template<> struct ObjectStorage::DataType<ObjectDict::DEFTYPE_UNSIGNED8> { typedef uint8_t type;};
533 
534 template<> struct ObjectStorage::DataType<ObjectDict::DEFTYPE_UNSIGNED16> { typedef uint16_t type;};
535 template<> struct ObjectStorage::DataType<ObjectDict::DEFTYPE_UNSIGNED32> { typedef uint32_t type;};
536 template<> struct ObjectStorage::DataType<ObjectDict::DEFTYPE_UNSIGNED64> { typedef uint64_t type;};
537 
538 template<> struct ObjectStorage::DataType<ObjectDict::DEFTYPE_REAL32> { typedef float type;};
539 template<> struct ObjectStorage::DataType<ObjectDict::DEFTYPE_REAL64> { typedef double type;};
540 
541 template<> struct ObjectStorage::DataType<ObjectDict::DEFTYPE_VISIBLE_STRING> { typedef String type;};
542 template<> struct ObjectStorage::DataType<ObjectDict::DEFTYPE_OCTET_STRING> { typedef String type;};
543 template<> struct ObjectStorage::DataType<ObjectDict::DEFTYPE_UNICODE_STRING> { typedef String type;};
544 template<> struct ObjectStorage::DataType<ObjectDict::DEFTYPE_DOMAIN> { typedef String type;};
545 
546 template<typename T, typename R> static R *branch_type(const uint16_t data_type){
547  switch(ObjectDict::DataTypes(data_type)){
548  case ObjectDict::DEFTYPE_INTEGER8: return T::template func< ObjectDict::DEFTYPE_INTEGER8 >;
549  case ObjectDict::DEFTYPE_INTEGER16: return T::template func< ObjectDict::DEFTYPE_INTEGER16 >;
550  case ObjectDict::DEFTYPE_INTEGER32: return T::template func< ObjectDict::DEFTYPE_INTEGER32 >;
551  case ObjectDict::DEFTYPE_INTEGER64: return T::template func< ObjectDict::DEFTYPE_INTEGER64 >;
552 
553  case ObjectDict::DEFTYPE_UNSIGNED8: return T::template func< ObjectDict::DEFTYPE_UNSIGNED8 >;
554  case ObjectDict::DEFTYPE_UNSIGNED16: return T::template func< ObjectDict::DEFTYPE_UNSIGNED16 >;
555  case ObjectDict::DEFTYPE_UNSIGNED32: return T::template func< ObjectDict::DEFTYPE_UNSIGNED32 >;
556  case ObjectDict::DEFTYPE_UNSIGNED64: return T::template func< ObjectDict::DEFTYPE_UNSIGNED64 >;
557 
558  case ObjectDict::DEFTYPE_REAL32: return T::template func< ObjectDict::DEFTYPE_REAL32 >;
559  case ObjectDict::DEFTYPE_REAL64: return T::template func< ObjectDict::DEFTYPE_REAL64 >;
560 
561  case ObjectDict::DEFTYPE_VISIBLE_STRING: return T::template func< ObjectDict::DEFTYPE_VISIBLE_STRING >;
562  case ObjectDict::DEFTYPE_OCTET_STRING: return T::template func< ObjectDict::DEFTYPE_OCTET_STRING >;
563  case ObjectDict::DEFTYPE_UNICODE_STRING: return T::template func< ObjectDict::DEFTYPE_UNICODE_STRING >;
564  case ObjectDict::DEFTYPE_DOMAIN: return T::template func< ObjectDict::DEFTYPE_DOMAIN >;
565 
566  default:
567  throw std::bad_cast();
568  }
569 }
570 
571 } // canopen
572 
573 #endif // !H_OBJDICT
const uint8_t node_id_
Definition: objdict.h:516
bool has(const Key &k) const
Definition: objdict.h:203
static T add(const uint8_t &u, const T &t)
Definition: objdict.h:239
const ObjectDictConstSharedPtr dict_
Definition: objdict.h:515
const ObjectDict::EntryConstSharedPtr entry
Definition: objdict.h:302
size_t type_size
Definition: objdict.h:18
const std::type_info &(* get_type)()
Definition: objdict.h:17
std::list< std::pair< std::string, std::string > > Overlay
Definition: objdict.h:211
boost::shared_ptr< ObjectDict > ObjectDictSharedPtr
Definition: objdict.h:212
uint8_t sub_index() const
Definition: objdict.h:127
boost::shared_ptr< Data > DataSharedPtr
Definition: objdict.h:370
uint32_t vendor_number
Definition: objdict.h:97
boost::unordered_map< Key, EntryConstSharedPtr > dict_
Definition: objdict.h:228
const TypeGuard type_guard
Definition: objdict.h:301
Entry< T > entry(uint16_t index)
Definition: objdict.h:489
bool has(uint16_t i) const
Definition: objdict.h:200
Entry(ObjectStorageSharedPtr storage, uint16_t index, uint8_t sub_index)
Definition: objdict.h:430
Data(const ObjectDict::Key &k, const ObjectDict::EntryConstSharedPtr &e, const T &val, const ReadDelegate &r, const WriteDelegate &w)
Definition: objdict.h:306
const ObjectDict::Entry & desc() const
Definition: objdict.h:438
uint16_t index() const
Definition: objdict.h:128
boost::function< void(const std::string &)> WriteStringFuncType
Definition: objdict.h:512
Entry< T > entry(const ObjectDict::Key &key)
Definition: objdict.h:455
const String & data() const
Definition: objdict.h:76
String buffer
Definition: objdict.h:54
boost::mutex mutex_
Definition: objdict.h:447
static const T apply(const HoldAny &val, const uint8_t &u)
Definition: objdict.h:245
uint32_t product_number
Definition: objdict.h:99
bool is_empty() const
Definition: objdict.h:74
const TypeGuard & type() const
Definition: objdict.h:60
bool dynamic_channels_supported
Definition: objdict.h:106
boost::unordered_set< uint16_t > dummy_usage
Definition: objdict.h:111
bool simple_boot_up_slave
Definition: objdict.h:104
Key(const std::string &str)
Definition: objdict.h:125
String(const std::string &str)
Definition: objdict.h:44
const Entry & operator()(uint16_t i) const
Definition: objdict.h:188
boost::function< std::string()> ReadStringFuncType
Definition: objdict.h:510
boost::shared_ptr< const ObjectDict > ObjectDictConstSharedPtr
Definition: objdict.h:231
void set_cached(const T &val)
Definition: objdict.h:354
Entry(const Code c, const uint16_t i, const uint16_t t, const std::string &d, const bool r=true, const bool w=true, bool m=false, const HoldAny def=HoldAny(), const HoldAny init=HoldAny())
Definition: objdict.h:176
fastdelegate::FastDelegate2< const ObjectDict::Entry &, const String & > WriteDelegate
Definition: objdict.h:275
boost::unordered_set< uint32_t > baudrates
Definition: objdict.h:102
uint32_t revision_number
Definition: objdict.h:100
bool has(uint16_t i, uint8_t s) const
Definition: objdict.h:197
bool operator==(const Key &other) const
Definition: objdict.h:129
uint8_t granularity
Definition: objdict.h:105
uint16_t nr_of_rx_pdo
Definition: objdict.h:108
const T & get() const
Definition: objdict.h:83
ObjectDict::ObjectDictSharedPtr ObjectDictSharedPtr
Definition: objdict.h:230
Key(const uint16_t i, const uint8_t s)
Definition: objdict.h:124
std::size_t operator()(const Key &k) const
Definition: objdict.h:133
bool valid() const
Definition: objdict.h:36
ReadDelegate read_delegate_
Definition: objdict.h:451
static R * branch_type(const uint16_t data_type)
Definition: objdict.h:546
bool hasSub() const
Definition: objdict.h:126
boost::unordered_map< ObjectDict::Key, DataSharedPtr > storage_
Definition: objdict.h:446
const size_t hash
Definition: objdict.h:122
ObjectDict(const DeviceInfo &info)
Definition: objdict.h:216
uint16_t nr_of_tx_pdo
Definition: objdict.h:109
const EntryConstSharedPtr & at(const Key &key) const
Definition: objdict.h:219
void set_delegates(const ReadDelegate &r, const WriteDelegate &w)
Definition: objdict.h:321
bool simple_boot_up_master
Definition: objdict.h:103
bool set_cached(const T &val)
Definition: objdict.h:411
std::string vendor_name
Definition: objdict.h:96
static const std::type_info & id()
Definition: objdict.h:22
Entry(ObjectStorageSharedPtr storage, const ObjectDict::Key &k)
Definition: objdict.h:434
std::size_t hash_value(ObjectDict::Key const &k)
Definition: objdict.cpp:10
ReadDelegate read_delegate
Definition: objdict.h:284
Entry< T > entry(uint16_t index, uint8_t sub_index)
Definition: objdict.h:492
void entry(Entry< T > &e, uint16_t index)
Definition: objdict.h:496
const Entry & operator()(uint16_t i, uint8_t s) const
Definition: objdict.h:191
boost::shared_ptr< const Entry > EntryConstSharedPtr
Definition: objdict.h:186
TypeGuard type_guard
Definition: objdict.h:55
const DeviceInfo device_info
Definition: objdict.h:214
fastdelegate::FastDelegate2< const ObjectDict::Entry &, String & > ReadDelegate
Definition: objdict.h:274
bool insert(bool is_sub, EntryConstSharedPtr e)
Definition: objdict.h:206
void entry(Entry< T > &e, uint16_t index, uint8_t sub_index)
Definition: objdict.h:499
WriteDelegate write_delegate_
Definition: objdict.h:452
TypeGuard(const std::type_info &(*ti)(), const size_t s)
Definition: objdict.h:24
HoldAny(const std::string &t)
Definition: objdict.h:66
Entry(DataSharedPtr &d)
Definition: objdict.h:422
size_t get_size() const
Definition: objdict.h:37
const ObjectDict::Key key
Definition: objdict.h:303
HoldAny(const T &t)
Definition: objdict.h:62
#define THROW_WITH_KEY(e, k)
Definition: objdict.h:114
std::string order_code
Definition: objdict.h:101
std::ostream & operator<<(std::ostream &stream, const NodeIdOffset< T > &n)
Definition: objdict.h:260
AccessException(const std::string &w)
Definition: objdict.h:268
bool is_type() const
Definition: objdict.h:27
HoldAny(const TypeGuard &t)
Definition: objdict.h:72
static TypeGuard create()
Definition: objdict.h:38
bool operator==(const TypeGuard &other) const
Definition: objdict.h:31
Entry(ObjectStorageSharedPtr storage, uint16_t index)
Definition: objdict.h:426
ObjectStorage::ObjectStorageSharedPtr ObjectStorageSharedPtr
Definition: objdict.h:523
const HoldAny & value() const
Definition: objdict.h:183
boost::error_info< struct tag_objectdict_key, ObjectDict::Key > key_info
Definition: objdict.h:217
std::string product_name
Definition: objdict.h:98
T(* adder)(const uint8_t &, const T &)
Definition: objdict.h:237
boost::shared_ptr< ObjectStorage > ObjectStorageSharedPtr
Definition: objdict.h:276
Data(const ObjectDict::Key &k, const ObjectDict::EntryConstSharedPtr &e, const TypeGuard &t, const ReadDelegate &r, const WriteDelegate &w)
Definition: objdict.h:313
bool entry(Entry< T > &e, const ObjectDict::Key &k)
Definition: objdict.h:502
WriteDelegate write_delegate
Definition: objdict.h:285
Entry(const uint16_t i, const uint8_t s, const uint16_t t, const std::string &d, const bool r=true, const bool w=true, bool m=false, const HoldAny def=HoldAny(), const HoldAny init=HoldAny())
Definition: objdict.h:179
NodeIdOffset(const T &t)
Definition: objdict.h:243
Key(const uint16_t i)
Definition: objdict.h:123


canopen_master
Author(s): Mathias Lüdtke
autogenerated on Fri May 14 2021 02:59:40