diff --git a/src/client/pva/client.h b/src/client/pva/client.h index 21f6b3a..e594ad3 100644 --- a/src/client/pva/client.h +++ b/src/client/pva/client.h @@ -64,6 +64,17 @@ struct epicsShareClass Operation //! Does not wait for remote confirmation. void cancel(); + bool valid() const { return !!impl; } + +#if __cplusplus>=201103L + explicit operator bool() const { return valid(); } +#else +private: + typedef bool (Operation::*bool_type)() const; +public: + operator bool_type() const { return valid() ? &Operation::valid : 0; } +#endif + protected: std::tr1::shared_ptr impl; }; @@ -133,6 +144,17 @@ struct epicsShareClass Monitor epics::pvData::BitSet changed, overrun; + bool valid() const { return !!impl; } + +#if __cplusplus>=201103L + explicit operator bool() const { return valid(); } +#else +private: + typedef bool (Monitor::*bool_type)() const; +public: + operator bool_type() const { return valid() ? &Monitor::valid : 0; } +#endif + private: std::tr1::shared_ptr impl; friend struct MonitorSync; @@ -247,6 +269,17 @@ public: //! Channel name or an empty string std::string name() const; + bool valid() const { return !!impl; } + +#if __cplusplus>=201103L + explicit operator bool() const { return valid(); } +#else +private: + typedef bool (ClientChannel::*bool_type)() const; +public: + operator bool_type() const { return valid() ? &ClientChannel::valid : 0; } +#endif + //! callback for get() and rpc() struct GetCallback { virtual ~GetCallback() {} @@ -450,6 +483,17 @@ public: //! Clear channel cache void disconnect(); + + bool valid() const { return !!impl; } + +#if __cplusplus>=201103L + explicit operator bool() const { return valid(); } +#else +private: + typedef bool (ClientProvider::*bool_type)() const; +public: + operator bool_type() const { return valid() ? &ClientProvider::valid : 0; } +#endif };