#pragma once #include "Utilities\commondefs.hpp" #include "Input\EventSerialization.hpp" #ifdef __INPUT_RAWEVENT_CPP_ #define RAW_EVENT_DECL FDX_DLL_EXPORT #else #define RAW_EVENT_DECL FDX_DLL_IMPORT #endif //namespace parameter = boost::parameter; using namespace std; namespace Input { //BOOST_PARAMETER_NAME(vflag) //BOOST_PARAMETER_NAME(src) //BOOST_PARAMETER_NAME(etype) //BOOST_PARAMETER_NAME(etime) //BOOST_PARAMETER_NAME(etimeSrc) //class RawEvent; // predeclare for template use /** This list contains the event types defined by DOM Level 2 Events. (x indicates redefined in DOM Level 3) The different types of such events that can occur are: x The abort event occurs when page loading is stopped before an image has been allowed to completely load. This event applies to OBJECT elements. x The blur event occurs when an element loses focus either via the pointing device or by tabbing navigation. This event is valid for the following elements: LABEL, INPUT, SELECT, TEXTAREA, and BUTTON. The change event occurs when a control loses the input focus and its value has been modified since gaining focus. This event is valid for INPUT, SELECT, and TEXTAREA. element. x The error event occurs when an image does not load properly or when an error occurs during script execution. This event is valid for OBJECT elements, BODY elements, and FRAMESET element. x The focus event occurs when an element receives focus either via a pointing device or by tabbing navigation. This event is valid for the following elements: LABEL, INPUT, SELECT, TEXTAREA, and BUTTON. x The load event occurs when the DOM implementation finishes loading all content within a document, all frames within a FRAMESET, or an OBJECT element. The reset event occurs when a form is reset. This event only applies to the FORM element. x The resize event occurs when a document view is resized x The scroll event occurs when a document view is scrolled. x The select event occurs when a user selects some text in a text field. This event is valid for INPUT and TEXTAREA elements. The submit event occurs when a form is submitted. This event only applies to the FORM element. x The unload event occurs when the DOM implementation removes a document from a window or frame. This event is valid for BODY and FRAMESET elements. NOTE: The change, submit, and reset events were removed from DOM Level 3 Events, since they were specific to HTML forms, and are specified in [HTML5]. This table contains the complete list of event types defined by DOM Level 3 Events. (* indicates redefinition from DOM Level 2 ) The type attribute contains the local name of the event type. The bubble attr indicates if the event accomplish the bubbling phase or not (all events accomplish the capture and target phases). The intfc attr indicates the DOM interface implemented by the event object. The cancel attr indicates if the default action associated with the event can be canceled. Attributes mean: type = string id of event type; sync = whether event is synchronous or asynchronous; bubble = whether event can be processed in bubbling phase; intfc = data structure used for event data; cancel = whether event is cancellable * * * * * * * * * DOM4 Working Draft */ class RawEvent { public: RAW_EVENT_DECL RawEvent(); RAW_EVENT_DECL RawEvent(const parameter_strings & parms); //BOOST_PARAMETER_CONSTRUCTOR( // RawEvent, (RawEventImpl), tag, // (optional // (vflag, *) // (src, *) // (etype, *) // (etime, *) // (etimeSrc, *) // )) // no semicolon /** Making the destructor virtual insures that deletions will be handled appropriately. The downside is that the vtable pointer doesn't mean anything if instances are put on the bus. This also means that Boost::Serialization should know how to handle derived class instances. */ RAW_EVENT_DECL virtual ~RawEvent(); DECL_CLASS_COMMON_TYPES(RawEvent); RAW_EVENT_DECL void initialize(const parameter_strings & parms); ///Give comparisons value semantics RAW_EVENT_DECL bool operator==(RawEvent const& cmp) const; /** A singleton RawEvent with no data that can be used in place of a null RawEvent ptr when it makes algorithms work more nicely **/ RAW_EVENT_DECL static RawEvent::shared_ptr NOP; public: /// ///Since this event will be on the bus all the time, we need a way to ///know if it actually contains valid data. See Event.hpp to determine who actually reads this. ///By default, assume this is true (why else would we create an instance?) /// bool valid; /// ///Identifier of the device where this event came from. Note that this is not ///necessarily the "machine" the event came from, just the "device". A "machine" ///may have multiple "devices" attached to it. Note that this is a superset of /// the "isTrusted" flag introduced in DOM L3 /// std::string source; ///From W3C DOM Level 3 Events, section 4.1 /// The name of the event type. Specifications that define events, content authors, and authoring tools must use case-sensitive event type names. /// The uninitialized value of this attribute must be "" (the empty string). /// /// This can be used to construct the appropriate instance when received by the Interaction Manager. /// std::string evtype; /// (from W3C DOM L3 Events) /// Used to specify the time at which the event was created in milliseconds relative to 1970-01-01T00:00:00Z. This value is the un-initialized value of this attribute. /// /// When this event occurred - using the timeSource to which this is attached. /// timestamp eventTime; /// ///The identifier of the source of this event's timestamp. This can be used to ///help account for clock synchronization issues if we need to coordinate events ///from different clock sources. This may not be the same as the source above. /// std::string timeSource; //template //RawEventImpl(ArgumentPack const& args) //{ // valid = args[_vflag | true]; // source = args[_src | "" ]; // evtype = args[_etype | "" ]; // eventTime = args[_etime | 0 ]; // timeSource = args[_etimeSrc | "" ]; //} protected: friend class boost::serialization::access; template RAW_EVENT_DECL void serialize(Archive &ar, const unsigned int version); //{ // ar & valid; // ar & source; // ar & evtype; // ar & boost::serialization::make_binary_object(&eventTime, sizeof(eventTime)); // ar & timeSource; //} }; }; BOOST_CLASS_EXPORT_KEY(Input::RawEvent);