Skip to content

Commit 36e2efb

Browse files
committed
update: more docs
1 parent 68efe60 commit 36e2efb

1 file changed

Lines changed: 141 additions & 50 deletions

File tree

include/robotkernel/robotkernel.h

Lines changed: 141 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,21 @@
2424
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2525
*/
2626

27+
/**
28+
* @file robotkernel.h
29+
* @brief Central API for interacting with the robotkernel framework.
30+
*
31+
* This header aggregates core robotkernel components and provides
32+
* high‑level functions for managing:
33+
* - services
34+
* - devices
35+
* - device listeners
36+
*
37+
* It also exposes global accessors for runtime names and paths.
38+
*
39+
* This file is part of robotkernel (LGPLv3 or later).
40+
*/
41+
2742
#ifndef ROBOTKERNEL_KERNEL_BASE_H
2843
#define ROBOTKERNEL_KERNEL_BASE_H
2944

@@ -37,85 +52,161 @@
3752

3853
namespace robotkernel {
3954

40-
//! add service to kernel
41-
/*!
42-
* \param owner service owner
43-
* \param name service name
44-
* \param service_definition service definition
45-
* \param callback service callback
55+
/**
56+
* @brief Add a service to the robotkernel runtime.
57+
*
58+
* Register a new service that can be called by name. Services are
59+
* identified by a tuple of `owner` and `name`. The service definition
60+
* and callback handle request/response behavior.
61+
*
62+
* @param owner
63+
* Logical owner or module of the service.
64+
*
65+
* @param name
66+
* Unique name for this service under the given owner.
67+
*
68+
* @param service_definition
69+
* YAML or textual definition of the service interface.
70+
*
71+
* @param callback
72+
* Function invoked when the service is called.
4673
*/
4774
extern void add_service(
48-
const std::string &owner,
49-
const std::string &name,
50-
const std::string &service_definition,
51-
service_callback_t callback);
75+
const std::string &owner,
76+
const std::string &name,
77+
const std::string &service_definition,
78+
service_callback_t callback);
5279

53-
//! remove on service given by name
54-
/*!
55-
* \param[in] owner Owner of service.
56-
* \param[in] name Name of service.
80+
/**
81+
* @brief Remove a previously registered service.
82+
*
83+
* Deregisters the named service for the given owner. After removal,
84+
* requests to this service will fail.
85+
*
86+
* @param owner
87+
* Owner of the registered service.
88+
*
89+
* @param name
90+
* Name of the service to remove.
5791
*/
5892
extern void remove_service(
59-
const std::string& owner,
60-
const std::string& name);
93+
const std::string &owner,
94+
const std::string &name);
6195

62-
//! adds a device listener
63-
/*
64-
* \param[in] dl device listener to add. this device listener
65-
* will be notified whenever a new device is added.
96+
/**
97+
* @brief Register a device listener.
98+
*
99+
* Adds a listener that will receive notifications when devices
100+
* are added or removed in the system.
101+
*
102+
* @param dl
103+
* Shared pointer to a listener instance.
66104
*/
67105
extern void add_device_listener(sp_device_listener_t dl);
68106

69-
//! remove a device listener
70-
/*
71-
* \param[in] dl device listener to reomve. this device listener
72-
* will no longer be notified when a new device is added.
107+
/**
108+
* @brief Remove a device listener.
109+
*
110+
* Stops sending notifications to this listener on future device
111+
* events.
112+
*
113+
* @param dl
114+
* Shared pointer to the listener to remove.
73115
*/
74116
extern void remove_device_listener(sp_device_listener_t dl);
75117

76-
//! add a named device
77-
/*
78-
* \param req device to add
118+
/**
119+
* @brief Add a device to the global registry.
120+
*
121+
* @param req
122+
* Shared pointer to a device instance.
79123
*/
80124
extern void add_device(sp_device_t req);
81125

82-
//! remove a named device
83-
/*!
84-
* \param req device to remove
126+
/**
127+
* @brief Remove a device from the global registry.
128+
*
129+
* @param req
130+
* Shared pointer to the device to remove.
85131
*/
86132
extern void remove_device(sp_device_t req);
87133

88-
//! get a device by name
89-
/*!
90-
* \param dev_name device name
91-
* \return device
134+
/**
135+
* @brief Retrieve a device by name.
136+
*
137+
* Returns a shared pointer to the device with the given name
138+
* or `nullptr` if no such device exists.
139+
*
140+
* @param dev_name
141+
* Unique name of the device.
142+
*
143+
* @return
144+
* Shared pointer to the found device or nullptr.
92145
*/
93-
extern std::shared_ptr<device> get_device(const std::string& dev_name);
146+
extern std::shared_ptr<device> get_device(const std::string &dev_name);
94147

95-
//! get a device by name
96-
/*!
97-
* \param dev_name device name
98-
* \return device
148+
/**
149+
* @brief Type‑safe device lookup helper.
150+
*
151+
* Templated helper that attempts to cast a generic device
152+
* pointer to a specific derived type (`T`). Throws if the
153+
* cast fails.
154+
*
155+
* @tparam T
156+
* The expected device type.
157+
*
158+
* @param dev_name
159+
* Name of the device to look up.
160+
*
161+
* @return
162+
* Shared pointer to the device of type `T`.
163+
*
164+
* @throws std::runtime_error
165+
* If the device is not of type `T` or does not exist.
99166
*/
100-
template <typename T>
101-
inline std::shared_ptr<T> get_device(const std::string& dev_name) {
102-
std::shared_ptr<T> retval = std::dynamic_pointer_cast<T>(get_device(dev_name));
103-
if (!retval)
167+
template<typename T>
168+
inline std::shared_ptr<T> get_device(const std::string &dev_name)
169+
{
170+
std::shared_ptr<T> retval =
171+
std::dynamic_pointer_cast<T>(get_device(dev_name));
172+
if (!retval) {
104173
throw std::runtime_error(robotkernel::helpers::string_printf(
105-
"device %s is not of type %s\n", dev_name.c_str(), typeid(T).name()));
106-
174+
"device %s is not of type %s\n",
175+
dev_name.c_str(),
176+
typeid(T).name()));
177+
}
107178
return retval;
108-
};
179+
}
109180

110-
//! get robotkernel name
181+
/**
182+
* @brief Get the configured robotkernel name.
183+
*
184+
* @return Identifier string for the running kernel.
185+
*/
111186
extern const std::string name(void);
187+
188+
/**
189+
* @brief Get the loaded configuration file name.
190+
*
191+
* @return YAML or config file name used at startup.
192+
*/
112193
extern const std::string config_file(void);
194+
195+
/**
196+
* @brief Get the path of the configuration file.
197+
*
198+
* @return Full filesystem path to the configuration file.
199+
*/
113200
extern const std::string config_file_path(void);
201+
202+
/**
203+
* @brief Get the path of the executable.
204+
*
205+
* @return Path to the running binary.
206+
*/
114207
extern const std::string exec_file_path(void);
115208

116-
}; // namespace robotkernel;
117-
209+
} // namespace robotkernel
118210

119211
#endif // ROBOTKERNEL_KERNEL_BASE_H
120212

121-

0 commit comments

Comments
 (0)