6 #ifndef MOTORCORTEX_CORE_PS_INFO_H
7 #define MOTORCORTEX_CORE_PS_INFO_H
16 namespace parameter_server {
19 unsigned int data_type;
20 unsigned int data_size;
33 void setName(
const char* name);
35 inline const char* getName()
const;
37 void setPath(
const char* path);
39 inline const char* getPath()
const;
41 inline size_t getPathLength()
const;
43 void setId(
unsigned int id);
45 inline unsigned int getId()
const;
47 void setUserGroup(motorcortex_UserGroup user_group);
49 inline motorcortex_UserGroup getUserGroup()
const;
51 void setUnit(motorcortex_Unit unit);
53 inline motorcortex_Unit getUnit()
const;
55 void setDataType(
unsigned int data_type);
57 inline unsigned int getDataType()
const;
59 void setDataSize(
unsigned int data_size);
61 inline unsigned int getDataSize()
const;
63 void setFlags(
unsigned int flags);
65 inline unsigned int getFlags()
const;
67 void setPermissions(
unsigned int permissions);
69 inline unsigned int getPermissions()
const;
71 void setType(motorcortex_ParameterType& type);
73 inline motorcortex_ParameterType getType()
const;
75 void setNumberOfElements(
unsigned int number_of_elements);
77 inline unsigned int getNumberOfElements()
const;
79 void toggleOverwrite(
bool overwrite);
81 inline bool hasOverwrite()
const;
83 void toggleLink(
bool link);
85 inline bool hasLink()
const;
87 unsigned int getHash()
const;
92 unsigned int number_of_elements_{};
93 std::atomic<unsigned int> flags_{};
94 unsigned int permissions_{};
95 motorcortex_ParameterType param_type_{};
96 motorcortex_UserGroup group_id_{};
97 motorcortex_Unit unit_{};
104 info->data_type = getDataType();
105 info->data_size = getDataSize();
106 info->number_of_elements = getNumberOfElements();
107 info->flags = getFlags();
108 info->permissions = getPermissions();
109 info->param_type = getType();
110 info->group_id = getUserGroup();
111 info->unit = getUnit();
112 size_t path_len = getPathLength() < (
sizeof(info->path) - 1) ? getPathLength() : sizeof(info->path) - 1;
113 std::strncpy(info->path, getPath(), path_len);
115 info->path[path_len] = 0;
121 inline const DataTypeInfo& ParameterInfo::getDataTypeInfo()
const {
return data_type_info_; }
123 inline const char* ParameterInfo::getName()
const {
return name_.c_str(); }
125 inline const char* ParameterInfo::getPath()
const {
return path_.c_str(); }
127 inline size_t ParameterInfo::getPathLength()
const {
return path_.length(); }
129 inline unsigned int ParameterInfo::getId()
const {
return id_; }
131 inline motorcortex_UserGroup ParameterInfo::getUserGroup()
const {
return group_id_; }
133 inline motorcortex_Unit ParameterInfo::getUnit()
const {
return unit_; }
135 inline unsigned int ParameterInfo::getDataType()
const {
return data_type_info_.data_type; }
137 inline unsigned int ParameterInfo::getDataSize()
const {
return data_type_info_.data_size; }
139 inline unsigned int ParameterInfo::getFlags()
const {
return flags_.load(std::memory_order_relaxed); }
141 inline unsigned int ParameterInfo::getPermissions()
const {
return permissions_; }
143 inline void ParameterInfo::setType(motorcortex_ParameterType& type) { param_type_ = type; }
145 inline motorcortex_ParameterType ParameterInfo::getType()
const {
return param_type_; }
147 inline unsigned int ParameterInfo::getNumberOfElements()
const {
return number_of_elements_; }
149 inline bool ParameterInfo::hasOverwrite()
const {
150 return static_cast<bool>(flags_.load(std::memory_order_relaxed) & OVERWRITE_IS_ACTIVE);
153 inline bool ParameterInfo::hasLink()
const {
154 return static_cast<bool>(flags_.load(std::memory_order_relaxed) & motorcortex_ParameterFlag_LINK_IS_ACTIVE);
161 #endif // MOTORCORTEX_CORE_PS_INFO_H