MIRA
|
An exception that occurred whenever a channel does not exist. More...
#include <fw/ChannelManager.h>
Classes | |
struct | ChannelInfo |
Informations about a channel that also provides ordering of channels by id. More... | |
Public Member Functions | |
ChannelManager () | |
~ChannelManager () | |
template<typename Reflector > | |
void | reflect (Reflector &r) |
Reflect method for serialization. More... | |
template<typename T > | |
ConcreteChannel< T > * | publish (const std::string &channelID, const std::string &publisherID, bool internal, const Typename &type, bool noAutoPromoteCheck=false) |
Publishes a channel with the given id. More... | |
void | enableAutoPromoteChannels (bool enable) |
Enable/disable automatic promotion of channel to typed in publish<void>(...) More... | |
bool | autoPromoteChannelsEnabled () |
Query if automatic promotion of channel to typed in publish<void>(...) is enabled. More... | |
void | enableCheckChannelRegistrations (bool enable) |
Enable/disable check for registration of channel types in publish<T>(...) (T!=void) More... | |
bool | checkChannelRegistrationsEnabled () |
Query if check for channel registrations in publish<T>(...) is enabled. More... | |
template<typename T > | |
ConcreteChannel< T > * | subscribe (const std::string &channelID, const std::string &subscriberID, const Duration &storageDuration, bool internal) |
Subscribes to a channel with the given id. More... | |
void | removePublisherFromAllChannels (const std::string &publisherID, bool internal) |
Remove a publisher from the publisher lists of all channels it has published. More... | |
void | removePublisher (const std::string &channelID, const std::string &publisherID, bool internal) |
Remove a publisher from the list of publishers of the given channel. More... | |
void | removeSubscriberFromAllChannels (const std::string &subscriberID) |
Remove a subscriber from the subscriber lists of all channels it is subscribed on. More... | |
void | removeSubscriber (const std::string &channelID, const std::string &subscriberID) |
Remove a subscriber from the subscriber list of channel channelID. More... | |
void | deductNumSubscribers (const std::string &channelID) |
Reduce the number of registered subscribers (subscribed without callback) on the channel by 1, by calling AbstractChannel::removeSubscriber() More... | |
template<typename T > | |
ConcreteChannel< T > * | getConcreteChannel (const std::string &channelID) |
Returns the existing channel with the given id. More... | |
std::set< std::string > | getChannels () const |
Get a list of all channels managed by this manager. More... | |
std::set< std::string > | getChannelList (bool publishedOnly=false, bool subscribedOnly=false) const |
Get a list of all channels managed by this manager, can be filtered for only those that have subscribers and/or publishers (any combination is possible). More... | |
std::set< std::string > | getSubscribedChannels (bool includeInternal=false) const |
Get a list of all channels we have subscriptions on. More... | |
std::set< std::string > | getSubscribedChannelsBy (const std::string &subscriberID) const |
Get a list of all channels that the given subscriber has subscribed on. More... | |
bool | isSubscribedOn (const std::string &subscriberID, const std::string &channelID) const |
Returns true if the subscriber is subscribed to the given channel. More... | |
std::map< std::string, Typename > | getPublishedChannels (bool includeInternal=false) const |
Get a list of all channels and their types we have publishers for. More... | |
std::set< std::string > | getPublishedChannelsBy (const std::string &publisherID) const |
Get a list of all channels that are currently published by the given publisher. More... | |
bool | hasPublished (const std::string &publisherID, const std::string &channelID) const |
Returns true if the publisher has published the given channel. More... | |
std::list< std::pair< std::string, Typename > > | getChannelsOfType (const Typename &type) const |
Returns a list of all channels that match the specified type. More... | |
template<typename T > | |
std::list< std::pair< std::string, Typename > > | getChannelsOfType () const |
Returns a list of all channels that match the specified type. More... | |
bool | hasSubscriber (const std::string &channelID) const |
Returns if we have at least one subscriber (including internal ones) for the given channel. More... | |
bool | hasPublisher (const std::string &channelID, bool includeInternal) const |
Returns if we have a publisher for a given channel. More... | |
uint32 | getNrPublishers (const std::string &channelID) const |
Get the number of publishers for that channel. More... | |
std::set< std::string > | getPublishers (const std::string &channelID, bool includeInternal=false) const |
Get all publishers for that channel. More... | |
uint32 | getNrSubscribers (const std::string &channelID) const |
Get the number of subscribers to that channel. More... | |
std::set< std::string > | getSubscribers (const std::string &channelID, bool includeInternal=false) const |
Get all subscribers for that channel. More... | |
bool | hasChannel (const std::string &channelID) const |
Returns true, if the specified channel with the fully qualified channelID exits. More... | |
int | getTypeId (const std::string &channelID) const |
Returns the type id of the specified channel with the fully qualified channelID or -1, if the channel is untyped. More... | |
void | setTypename (const std::string &channelID, const Typename &typenam) |
Sets the typename of the specified channel. More... | |
Typename | getTypename (const std::string &channelID) const |
Returns the typename of the specified channel with the fully qualified channelID. More... | |
void | setTypeMeta (const std::string &channelID, TypeMetaPtr meta) |
Sets the type meta information for the slots of the underlying channel buffer. More... | |
TypeMetaPtr | getTypeMeta (const std::string &channelID) const |
Returns the type meta information of the channel. More... | |
Time | getLastSlotTime (const std::string &channelID) const |
Returns the timestamp of the data in the slot that was last written to the channel with the fully qualified channelID or an invalid time when there was no data written at all. More... | |
std::size_t | getNrOfSlots (const std::string &channelID) const |
Returns the number of slots in the channel. More... | |
uint64 | getNrOfDataChanges (const std::string &channelID) const |
Returns the number of times data was written to the channel with the fully qualified channelID or an invalid time. More... | |
void | ensureChannel (const std::string &channelID) |
Just make sure the specified channel exists (by creating it if needed), without changing any attributes. More... | |
void | setStorageDuration (const std::string &channelID, const Duration &storageDuration) |
Sets storage duration for the specified channel. More... | |
void | setAutoIncreaseStorageDuration (const std::string &channelID, bool increase) |
Sets whether to auto-increase storage duration for the specified channel. More... | |
void | setMinSlots (const std::string &channelID, std::size_t minSlots) |
Sets desired minimum number of slots for the specified channel. More... | |
void | setMaxSlots (const std::string &channelID, std::size_t maxSlots) |
Sets the maximum number of slots for the specified channel. More... | |
Duration | getStorageDuration (const std::string &channelID) |
Query storage duration for the specified channel. More... | |
bool | isAutoIncreasingStorageDuration (const std::string &channelID) |
Query whether specified channel is auto-increasing storage duration. More... | |
std::size_t | getMinSlots (const std::string &channelID) |
Query desired minimum number of slots for the specified channel. More... | |
std::size_t | getMaxSlots (const std::string &channelID) |
Query desired maximum number of slots for the specified channel. More... | |
void | writeChannel (const std::string &channelID, const json::Value &value, Time time, std::string frameID, uint32 sequenceID) |
Writes a json value to the channel with given id. More... | |
void | writeChannel (const std::string &channelID, const json::Value &value, Time time=Time::now()) |
Writes a json value to the channel with given id. More... | |
void | writeChannel (const std::string &channelID, const json::Value &value, std::string frameID, Time time=Time::now()) |
Writes a json value to the channel with given id. More... | |
json::Value | readChannel (const std::string &channelID) |
Reads data from the channel with given id. More... | |
An exception that occurred whenever a channel does not exist.
This manager provides functionality to create, obtain and manage the channels in the framework. Channels provide a time ordered queue (history) of data slots (timestamp, value pairs).
ChannelManager | ( | ) |
~ChannelManager | ( | ) |
|
inline |
Reflect method for serialization.
|
inline |
Publishes a channel with the given id.
If the channel does not exist it will be created. If the channel is a polymorphic channel (i.e. T is a pointer type of a polymorphic type) then publishing the channel will fixate the channels type and future publish() calls with different types will result in a XBadCast exception.
XBadCast | if the channel exists but the types do not match. |
[in] | channelID | The channel id |
[in] | publisherID | The id of the publisher. If empty the channel will not be visible in a call to getPublishedChannels(). |
[in] | internal | The internal flag specifies if the publisher counts not as a public publisher to that channel (e.g. remote publishers) |
[in] | type | The typename of the channel's type |
[in] | noAutoPromoteCheck | If true, suppress checking for existence of a promoter for a typed channel |
|
inline |
Enable/disable automatic promotion of channel to typed in publish<void>(...)
|
inline |
Query if automatic promotion of channel to typed in publish<void>(...) is enabled.
|
inline |
Enable/disable check for registration of channel types in publish<T>(...) (T!=void)
|
inline |
Query if check for channel registrations in publish<T>(...) is enabled.
|
inline |
Subscribes to a channel with the given id.
The channel is created if not exists.
XBadCast | if the channel exists but the types do not match. |
[in] | channelID | The id of the data channel to subscribe to |
[in] | subscriberID | The id of the subscriber. If empty the channel will not be visible in a call to getSubscribedChannels(). |
[in] | storageDuration | The requested duration of how long data is stored in the channel (history). Note that the real history length may differ from this request because the number of slots in the channel is limited by its maximum length. Assuming we have only one writer to the channel that updates the channel each T milliseconds the real storage duration D can be computed by D = (maxSlots-1) * T. |
[in] | internal | The internal flag specifies if the subscriber counts not as a public subscriber to that channel (e.g. remote subscribers) |
void removePublisherFromAllChannels | ( | const std::string & | publisherID, |
bool | internal | ||
) |
Remove a publisher from the publisher lists of all channels it has published.
[in] | publisherID | The id of the publisher. |
[in] | internal | Is the publisher an internal one that does not count as a global publisher (only local in this framework) |
void removePublisher | ( | const std::string & | channelID, |
const std::string & | publisherID, | ||
bool | internal | ||
) |
Remove a publisher from the list of publishers of the given channel.
[in] | channelID | The channel ID |
[in] | publisherID | The id of the publisher. |
[in] | internal | Is the publisher an internal one that does not count as a global publisher (only local in this framework) |
void removeSubscriberFromAllChannels | ( | const std::string & | subscriberID | ) |
Remove a subscriber from the subscriber lists of all channels it is subscribed on.
void removeSubscriber | ( | const std::string & | channelID, |
const std::string & | subscriberID | ||
) |
Remove a subscriber from the subscriber list of channel channelID.
[in] | channelID | The channel ID |
[in] | subscriberID | The id of the subscriber. |
void deductNumSubscribers | ( | const std::string & | channelID | ) |
Reduce the number of registered subscribers (subscribed without callback) on the channel by 1, by calling AbstractChannel::removeSubscriber()
[in] | channelID | The channel ID |
|
inline |
Returns the existing channel with the given id.
[in] | channelID | The channel ID |
XBadCast | if the channel exists but the types do not match. |
XUnknownChannel | if the channel does not exist. |
std::set<std::string> getChannels | ( | ) | const |
Get a list of all channels managed by this manager.
std::set<std::string> getChannelList | ( | bool | publishedOnly = false , |
bool | subscribedOnly = false |
||
) | const |
Get a list of all channels managed by this manager, can be filtered for only those that have subscribers and/or publishers (any combination is possible).
[in] | publishedOnly | Only return channels that have (local) publishers. If false, this will not exclude any channels. |
[in] | subscribedOnly | Only return channels that have (local) subscribers (excluding internal subscribers). If false, this will not exclude any channels. |
std::set<std::string> getSubscribedChannels | ( | bool | includeInternal = false | ) | const |
Get a list of all channels we have subscriptions on.
[in] | includeInternal | If set to false (default) the returned list excludes channels that have only internal subscribers |
std::set<std::string> getSubscribedChannelsBy | ( | const std::string & | subscriberID | ) | const |
Get a list of all channels that the given subscriber has subscribed on.
[in] | subscriberID | Subscriber name |
Note: only works correctly for subscribers in the local framework. For remote subscribers, use AbstractAuthority::getSubscribedChannels (access the Authority e.g. using AuthorityManager).
bool isSubscribedOn | ( | const std::string & | subscriberID, |
const std::string & | channelID | ||
) | const |
Returns true if the subscriber is subscribed to the given channel.
std::map<std::string, Typename> getPublishedChannels | ( | bool | includeInternal = false | ) | const |
Get a list of all channels and their types we have publishers for.
[in] | includeInternal | If set to false (default) the returned list excludes channels that have only internal publishers |
std::set<std::string> getPublishedChannelsBy | ( | const std::string & | publisherID | ) | const |
Get a list of all channels that are currently published by the given publisher.
[in] | publisherID | Publisher name |
Note: only works correctly for publishers in the local framework. For remote publishers, use AbstractAuthority::getPublishedChannels (access the Authority e.g. using AuthorityManager).
bool hasPublished | ( | const std::string & | publisherID, |
const std::string & | channelID | ||
) | const |
Returns true if the publisher has published the given channel.
Returns a list of all channels that match the specified type.
Each list item is a pair where the first entry specifies the full qualified name of the channel and the second entry specifies the type of the channel.
|
inline |
Returns a list of all channels that match the specified type.
Each list item is a pair where the first entry specifies the full qualified name of the channel and the second entry specifies the type of the channel.
bool hasSubscriber | ( | const std::string & | channelID | ) | const |
Returns if we have at least one subscriber (including internal ones) for the given channel.
[in] | channelID | The channel id |
bool hasPublisher | ( | const std::string & | channelID, |
bool | includeInternal | ||
) | const |
Returns if we have a publisher for a given channel.
[in] | channelID | The channel id |
[in] | includeInternal | If true also internal publishers will count as a publisher for that channel. |
uint32 getNrPublishers | ( | const std::string & | channelID | ) | const |
Get the number of publishers for that channel.
std::set<std::string> getPublishers | ( | const std::string & | channelID, |
bool | includeInternal = false |
||
) | const |
Get all publishers for that channel.
uint32 getNrSubscribers | ( | const std::string & | channelID | ) | const |
Get the number of subscribers to that channel.
std::set<std::string> getSubscribers | ( | const std::string & | channelID, |
bool | includeInternal = false |
||
) | const |
Get all subscribers for that channel.
bool hasChannel | ( | const std::string & | channelID | ) | const |
Returns true, if the specified channel with the fully qualified channelID exits.
int getTypeId | ( | const std::string & | channelID | ) | const |
Returns the type id of the specified channel with the fully qualified channelID or -1, if the channel is untyped.
void setTypename | ( | const std::string & | channelID, |
const Typename & | typenam | ||
) |
Sets the typename of the specified channel.
Typename getTypename | ( | const std::string & | channelID | ) | const |
Returns the typename of the specified channel with the fully qualified channelID.
void setTypeMeta | ( | const std::string & | channelID, |
TypeMetaPtr | meta | ||
) |
Sets the type meta information for the slots of the underlying channel buffer.
TypeMetaPtr getTypeMeta | ( | const std::string & | channelID | ) | const |
Returns the type meta information of the channel.
Time getLastSlotTime | ( | const std::string & | channelID | ) | const |
Returns the timestamp of the data in the slot that was last written to the channel with the fully qualified channelID or an invalid time when there was no data written at all.
std::size_t getNrOfSlots | ( | const std::string & | channelID | ) | const |
Returns the number of slots in the channel.
uint64 getNrOfDataChanges | ( | const std::string & | channelID | ) | const |
Returns the number of times data was written to the channel with the fully qualified channelID or an invalid time.
|
inline |
Just make sure the specified channel exists (by creating it if needed), without changing any attributes.
void setStorageDuration | ( | const std::string & | channelID, |
const Duration & | storageDuration | ||
) |
Sets storage duration for the specified channel.
Sets the desired storage duration (the history). This method can increase the duration only. If the specified duration is smaller than a previous set duration the call will be ignored.
void setAutoIncreaseStorageDuration | ( | const std::string & | channelID, |
bool | increase | ||
) |
Sets whether to auto-increase storage duration for the specified channel.
Sets whether the storage duration is automatically increased on read accesses. If true, any read access specifying a timestamp will automatically increase the storage duration to the time difference between the timestamp and the most recent data (trying to ensure data is kept long enough for further such requests). The default is true.
void setMinSlots | ( | const std::string & | channelID, |
std::size_t | minSlots | ||
) |
Sets desired minimum number of slots for the specified channel.
Sets the desired min. number of slots for storing the history of a channel. This method can increase the min. number of slots only. Instead of specifying the min. number of slots you can also specify the desired storage duration using the setStorageDuration() method.
void setMaxSlots | ( | const std::string & | channelID, |
std::size_t | maxSlots | ||
) |
Sets the maximum number of slots for the specified channel.
Sets the max. number of slots that are used for storing the history of a channel. maxSlots must at least be 1. The default is 100.
Duration getStorageDuration | ( | const std::string & | channelID | ) |
Query storage duration for the specified channel.
bool isAutoIncreasingStorageDuration | ( | const std::string & | channelID | ) |
Query whether specified channel is auto-increasing storage duration.
std::size_t getMinSlots | ( | const std::string & | channelID | ) |
Query desired minimum number of slots for the specified channel.
std::size_t getMaxSlots | ( | const std::string & | channelID | ) |
Query desired maximum number of slots for the specified channel.
void writeChannel | ( | const std::string & | channelID, |
const json::Value & | value, | ||
Time | time, | ||
std::string | frameID, | ||
uint32 | sequenceID | ||
) |
Writes a json value to the channel with given id.
void writeChannel | ( | const std::string & | channelID, |
const json::Value & | value, | ||
Time | time = Time::now() |
||
) |
Writes a json value to the channel with given id.
If data was published to the channel before, the frameID of the latest data is copied, and the sequenceID is incremented.
void writeChannel | ( | const std::string & | channelID, |
const json::Value & | value, | ||
std::string | frameID, | ||
Time | time = Time::now() |
||
) |
Writes a json value to the channel with given id.
If data was published to the channel before, the sequenceID is incremented.
json::Value readChannel | ( | const std::string & | channelID | ) |
Reads data from the channel with given id.
If channel has type T it returns the json representation of T.