47 #ifndef _MIRA_CHANNELPROPERTY_H_ 48 #define _MIRA_CHANNELPROPERTY_H_ 80 const std::string&
getID()
const {
97 virtual bool isValid()
const = 0;
125 virtual void update() = 0;
165 template <
typename Reflector>
167 r.member(
"Channel",
channelID,
"The ID of the channel");
175 return property->isValid();
185 return property->getAvailableChannels();
213 template <
typename T>
220 mProcessedUpdates(0),
221 mDataChangedFn(NULL),
222 mDataIntervalChangedFn(NULL),
223 mChannelChangedFn(NULL)
229 return mChannel.isValid();
237 return MIRA_FW.getChannelManager().getChannelsOfType<T>();
250 if(mChannel.isValid()) {
257 if (mChannelChangedFn)
260 mProcessedUpdates = -1;
268 mDataChangedFn = dataChangedFn;
269 mDataIntervalChangedFn = NULL;
272 template<
typename Class>
275 mDataChangedFn = boost::bind(f, obj, _1);
276 mDataIntervalChangedFn = NULL;
281 mDataChangedFn = NULL;
282 mDataIntervalChangedFn = dataChangedFn;
285 template<
typename Class>
288 mDataChangedFn = NULL;
289 mDataIntervalChangedFn = boost::bind(f, obj, _1);
294 mChannelChangedFn = channelChangedFn;
297 template<
typename Class>
300 mChannelChangedFn = boost::bind(f, obj);
313 MIRA_THROW(XRuntime,
"No channel specified.");
328 mProcessedUpdates = -1;
336 int64 updates = mDataUpdates;
341 if ((updates != mProcessedUpdates) && (mDataChangedFn || mDataIntervalChangedFn) )
343 mProcessedUpdates = updates;
344 if ( mDataChangedFn )
345 mDataChangedFn(mChannel.read());
347 if ( !mLastUpdate.
isValid() ) {
351 catch ( XInvalidRead& ) {
359 if (!tInterval.
empty())
361 mDataIntervalChangedFn( tInterval );
384 template<
typename Reflector>
389 r.property(name.c_str(),
390 getter<ChannelPropertyProxy>(
391 boost::bind(proxyGetter, &channel, authorityProvider)),
392 setter<ChannelPropertyProxy>(
393 boost::bind(proxySetter, &channel, _1, authorityProvider)),
407 IAuthorityProvider* authorityProvider) {
408 This->mAuthorityProvider = authorityProvider;
409 return ChannelPropertyProxy(This->mChannelID, This);
416 int64 mProcessedUpdates;
417 boost::function<void (ChannelRead<T>)> mDataChangedFn;
418 boost::function<void (ChannelReadInterval<T>)> mDataIntervalChangedFn;
419 boost::function<void ()> mChannelChangedFn;
An object that allows read access to a whole interval of channel data.
Definition: ChannelReadInterval.h:72
Type trait that indicates whether pointer tracking can be enabled for this type.
Definition: IsObjectTrackable.h:68
virtual ~ChannelPropertyBase()
Definition: ChannelProperty.h:75
bool empty() const
Definition: ChannelReadInterval.h:169
Abstract base class for all derived property node classes.
Definition: PropertyNode.h:202
TypedPropertyNode< ChannelPropertyProxy > * property
Definition: ChannelProperty.h:435
ChannelPropertyProxy(const std::string &id, ChannelPropertyBase *p)
Definition: ChannelProperty.h:160
static void channelProperty(Reflector &r, const std::string &name, ChannelProperty &channel, const std::string &comment, IAuthorityProvider *authorityProvider)
Special property-method that should be called within the reflect method to specify a ChannelProperty...
Definition: ChannelProperty.h:385
ChannelPropertyDelegateLineEdit(PropertyNode *p, QWidget *parent)
tick_type milliseconds() const
Returns normalized number of milliseconds (0..999)
Definition: Time.h:285
An exception that occurs whenever a channel has no data.
Definition: Channel.h:88
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
void setDataChangedCallback(boost::function< void(ChannelRead< T >)> dataChangedFn)
Definition: ChannelProperty.h:266
bool isValid() const
Returns true if this contains a valid time.
Definition: Time.h:580
std::string channelID
Definition: ChannelProperty.h:190
Class object which supports some kind of class reflection.
Definition: Class.h:97
IAuthorityProvider * mAuthorityProvider
Definition: ChannelProperty.h:140
std::string mName
Definition: ChannelProperty.h:138
#define MIRA_FW
Macro for accessing the framework instance.
Definition: Framework.h:74
bool isOptional() const
For internal use only.
Definition: ChannelProperty.h:116
Provides MIRA_SPLIT_REFLECT macros.
Provides type trait that indicates whether pointer/object tracking should be enabled for a certain ty...
Channel< T > getChannel()
Obtains the set or chosen channel.
Definition: ChannelProperty.h:310
An object that allows read access to data of a channel.
Definition: ChannelReadWrite.h:494
virtual std::list< std::pair< std::string, Typename > > getAvailableChannels()=0
Returns list of (channelID,typename) pairs containing the channels that match the desired type...
void unsubscribe(const std::string &channelID)
Unsubscribe from a given channel.
virtual void set(const std::string &id, IAuthorityProvider *authorityProvider)
Sets the channelID and a necessary authority provider that is used to obtain the authority for subscr...
Definition: ChannelProperty.h:244
#define MIRA_THROW(ex, msg)
Macro for throwing an exception.
Definition: Exception.h:82
ChannelPropertyProxy()
Definition: ChannelProperty.h:159
virtual void update()=0
Tell the property to update the assigned channel.
const_iterator end() const
Definition: ChannelReadInterval.h:164
Contains the base interface of all Reflectors, Serializers, etc.
void setDataIntervalChangedCallback(void(Class::*f)(ChannelReadInterval< T >), Class *obj)
Definition: ChannelProperty.h:286
ChannelProperty()
Definition: ChannelProperty.h:218
Serializer that handles properties and creates PropertyNodes.
virtual bool isValid() const
Returns true, if an existing channel is set. Must be implemented in derived class.
Definition: ChannelProperty.h:228
const std::string & getName() const
Returns the name of the property.
Definition: ChannelProperty.h:90
Abstract interface for classes that can provide an authority via the getAuthority() method...
Definition: AuthorityProvider.h:61
const std::string & getID() const
Returns the channelID that was set by the user.
Definition: ChannelProperty.h:80
void setName(const std::string &name)
Sets the name of the property.
Definition: ChannelProperty.h:85
Base class for ChannelProperty template class.
Definition: ChannelProperty.h:70
ChannelPropertyBase()
Definition: ChannelProperty.h:74
Authorities act as a facade to the framework.
Definition: Authority.h:94
virtual uint32 getDataUpdateCount() const
Returns the number of data updates the channel has received.
Definition: ChannelProperty.h:232
Const iterator for iterating over the interval.
Definition: ChannelReadInterval.h:85
void setDataIntervalChangedCallback(boost::function< void(ChannelReadInterval< T >)> dataChangedFn)
Definition: ChannelProperty.h:279
void reflect(Reflector &r)
Definition: ChannelProperty.h:166
ChannelPropertyBase * property
Definition: ChannelProperty.h:191
virtual std::list< std::pair< std::string, Typename > > getAvailableChannels()
Returns list of (channelID,typename) pairs containing the channels that match the desired type...
Definition: ChannelProperty.h:236
void setChannelChangedCallback(boost::function< void()> channelChangedFn)
Definition: ChannelProperty.h:292
virtual void update()
Tell the property to update the assigned channel.
Definition: ChannelProperty.h:333
std::string mChannelID
Definition: ChannelProperty.h:139
virtual bool isValid() const =0
Returns true, if an existing channel is set. Must be implemented in derived class.
bool mOptional
Definition: ChannelProperty.h:141
The concrete typed ChannelProperty template class.
Definition: ChannelProperty.h:214
FrameworkVis export macro declaration.
virtual Authority & getAuthority()=0
Return the authority as reference.
void setChannelChangedCallback(void(Class::*f)(), Class *obj)
Definition: ChannelProperty.h:298
void setOptional()
For internal use only.
Definition: ChannelProperty.h:111
Abstract interface for classes that can provide an authority.
Special LineEdit for ChannelProperty delegate for Property Editor.
Definition: ChannelProperty.h:427
Proxy class that is returned/set by the getter and setter methods of ChannelProperty.
Definition: ChannelProperty.h:154
The framework that holds all manager classes and provides startup and shutdown of all framework relat...
virtual void set(const std::string &id, IAuthorityProvider *authorityProvider)
Sets the channelID and a necessary authority provider that is used to obtain the authority for subscr...
Definition: ChannelProperty.h:131
void setDataChangedCallback(void(Class::*f)(ChannelRead< T >), Class *obj)
Definition: ChannelProperty.h:273
Channel< T > subscribe(const std::string &channelID, const Duration &storageDuration=Duration::seconds(0))
Subscribes authority to a given channel.
Abstract base class for all typed property nodes.
Definition: PropertyNode.h:70
bool isValid() const
Returns true, if an existing channel is set.
Definition: ChannelProperty.h:173
Provides definition for getters and setters that are used with the serialization framework.
std::list< std::pair< std::string, Typename > > getAvailableChannels()
Returns list of (channelID,typename) pairs containing the channels that match the desired type...
Definition: ChannelProperty.h:182
virtual uint32 getDataUpdateCount() const =0
Returns the number of data updates the channel has received.
void callback(ChannelRead< T > channel)
Definition: ChannelProperty.h:371