21 #ifndef GV_VIEWEREVENT__H
22 #define GV_VIEWEREVENT__H
32 class ViewerEventMixin ;
33 class ViewerEventMixinImp ;
42 enum Type { Up , Down , Drag , Move , Invalid } ;
55 std::string str()
const ;
58 explicit ViewerEvent(
const std::string & channel_name = std::string() ) ;
75 bool receive( std::vector<char> & , std::string * type_p =
nullptr ) ;
85 static int parse(
const std::string & event ,
const std::string & key ,
int default_ = -1 ) ;
120 std::ostream & operator<<( std::ostream & stream ,
const ViewerEvent::Info & event )
122 return stream <<
event.str() ;
A structure representing an interaction event received from a viewer process.
bool receive(std::vector< char > &, std::string *type_p=nullptr)
Receives the payload for an event on fd().
A class for receiving and handling events published from a viewer process.
bool init()
Tries to subscribe to the viewer's event channel.
ViewerEvent(const std::string &channel_name=std::string())
Constructor.
ViewerEventMixin(const std::string &channel)
Constructor.
An easy-to-use combination of a G::PublisherChannel object and a single G::PublisherSubscriber.
A pimple-pattern implementation class for Gv::ViewerEventMixin.
virtual void onViewerEvent(ViewerEvent::Info)=0
Callback that delivers an event from the viewer.
virtual ~ViewerEventMixin()
Destructor.
std::string channelName() const
Returns the channel name, as passed to the ctor.
int fd() const
Returns the subsription file descriptor, or minus one if not init()isalised.
Info apply(const std::string &)
Parses the event string and maintains an internal button state.
A mixin base-class containing a ViewerEvent object that integrates with the GNet::EventLoop.