Class IIOPath
Defined in File iio_path.hpp
Class Documentation
-
class IIOPath
Represents and manipulates Industrial I/O (IIO) paths that are used to uniquely identify IIO devices, attributes, and channels from a context.
Examples of valid paths types:
CONTEXT: “”
CONTEXT_ATTR: “context-attribute”
DEVICE: “device-name”
DEVICE_ATTR: “device-name/attribute-name”
CHANNEL: “device-name/chn-prefix_channel-name”
CHANNEL_ATTR: “device-name/chn-prefix_channel-name/attribute-name”
Public Functions
-
explicit IIOPath(std::string path, char delimiter = '/')
Constructs an IIOPath object.
- Parameters:
path – The base path for the IIO object.
delimiter – The character used to separate path segments (default is ‘/’).
-
std::string basePath() const
Retrieves the original path used to create this object.
- Returns:
The base path as a string.
-
std::string getContextAttrSegment() const
Extracts the context attribute segment from the path.
- Returns:
The context attribute as a string.
-
std::string getDeviceSegment() const
Extracts the device name segment from the path.
- Returns:
The device name as a string.
-
std::string getDeviceAttrSegment() const
Extracts the device attribute segment from the path.
- Returns:
The device attribute as a string.
-
std::string getChannelSegment() const
Extracts the channel name segment from the path.
- Returns:
The channel name as a string.
-
std::pair<bool, std::string> getExtendedChannelSegment() const
Extracts the channel information segment from the path.
Note
The boolean variable helps to uniquely identify channels with the same name but different types (input/output).
- Returns:
A pair containing a boolean indicating if the channel is of output type and the channel name as a string.
-
bool hasExtendedChannelFormat() const
Whether the channel segment has the extended syntax format.
-
std::string getChannelAttrSegment() const
Extracts the channel attribute segment from the path.
- Returns:
The channel attribute as a string.
-
std::string append(const std::string &suffix)
Appends a suffix to the current IIO path.
The suffix is used to create a new path pointing to a specific attribute or nested element.
- Parameters:
suffix – The string to append to the base path.
- Returns:
The updated path as a string.
-
bool isValid(const IIOPathType type)
Validates the current IIO path based on the specified type.
This function checks if the current path conforms to the expected structure for the given IIOPathType. It ensures that the path contains the necessary segments and follows the correct format for the specified type.
- Parameters:
type – The type of IIO path to validate (e.g.,
CONTEXT
,DEVICE
,CHANNEL
).- Returns:
True if the path is valid for the specified type, false otherwise.
-
std::vector<std::string> split(const std::string &str)
Splits a string into segments based on the delimiter.
- Parameters:
str – The input string to be split.
- Returns:
A vector of substrings obtained by splitting the input string.
Public Static Functions
-
static std::pair<bool, std::string> getExtendedChannelSegment(std::string chn_segment)
-
static bool hasExtendedChannelFormat(std::string chn_segment)
-
static std::string toExtendedChannelSegment(bool output, std::string chn_name)
Constructs the channel segment of the path.
- Parameters:
output – A boolean indicating if the channel is an output channel.
chn_name – The name of the channel.
- Returns:
The constructed channel segment as a string.
-
static std::string toTopicName(std::string path)
Converts a path to a ROS2 topic name.
Note
ROS2 topic names cannot contain ‘-’ characters.
- Parameters:
path – The input path to be converted.
- Returns:
The converted topic name as a string.