From be2926499af2e372c313d965533be3a7ee0dcf4d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 16 May 2016 11:19:10 +0200 Subject: add tobii eyex sdk --- Tobii EyeX/include/eyex-cpp/APIException.hpp | 83 ++++ Tobii EyeX/include/eyex-cpp/AsyncData.hpp | 36 ++ Tobii EyeX/include/eyex-cpp/AsyncData.inl | 54 +++ Tobii EyeX/include/eyex-cpp/Behavior.hpp | 64 +++ Tobii EyeX/include/eyex-cpp/Behavior.inl | 198 ++++++++++ Tobii EyeX/include/eyex-cpp/Bounds.hpp | 43 +++ Tobii EyeX/include/eyex-cpp/Bounds.inl | 86 +++++ Tobii EyeX/include/eyex-cpp/Callbacks.hpp | 26 ++ Tobii EyeX/include/eyex-cpp/Command.hpp | 38 ++ Tobii EyeX/include/eyex-cpp/Command.inl | 70 ++++ Tobii EyeX/include/eyex-cpp/Context.hpp | 91 +++++ Tobii EyeX/include/eyex-cpp/Context.inl | 427 +++++++++++++++++++++ Tobii EyeX/include/eyex-cpp/Environment.hpp | 45 +++ Tobii EyeX/include/eyex-cpp/Environment.inl | 70 ++++ Tobii EyeX/include/eyex-cpp/EyeX.hpp | 105 +++++ Tobii EyeX/include/eyex-cpp/HandleWrapper.hpp | 44 +++ Tobii EyeX/include/eyex-cpp/HandleWrapper.inl | 61 +++ .../include/eyex-cpp/InteractionAgentBase.hpp | 79 ++++ .../include/eyex-cpp/InteractionAgentBase.inl | 183 +++++++++ Tobii EyeX/include/eyex-cpp/InteractionContext.cpp | 28 ++ Tobii EyeX/include/eyex-cpp/InteractionEvent.hpp | 35 ++ Tobii EyeX/include/eyex-cpp/InteractionEvent.inl | 63 +++ Tobii EyeX/include/eyex-cpp/InteractionObject.hpp | 63 +++ Tobii EyeX/include/eyex-cpp/InteractionObject.inl | 162 ++++++++ Tobii EyeX/include/eyex-cpp/Interactor.hpp | 67 ++++ Tobii EyeX/include/eyex-cpp/Interactor.inl | 257 +++++++++++++ Tobii EyeX/include/eyex-cpp/Mask.hpp | 34 ++ Tobii EyeX/include/eyex-cpp/Mask.inl | 58 +++ Tobii EyeX/include/eyex-cpp/Notification.hpp | 34 ++ Tobii EyeX/include/eyex-cpp/Notification.inl | 49 +++ Tobii EyeX/include/eyex-cpp/Property.cpp | 19 + Tobii EyeX/include/eyex-cpp/Property.hpp | 46 +++ Tobii EyeX/include/eyex-cpp/Property.inl | 90 +++++ Tobii EyeX/include/eyex-cpp/PropertyBag.hpp | 32 ++ Tobii EyeX/include/eyex-cpp/PropertyBag.inl | 36 ++ .../include/eyex-cpp/PropertyValueResolver.hpp | 34 ++ .../include/eyex-cpp/PropertyValueResolver.inl | 266 +++++++++++++ Tobii EyeX/include/eyex-cpp/Query.hpp | 34 ++ Tobii EyeX/include/eyex-cpp/Query.inl | 58 +++ Tobii EyeX/include/eyex-cpp/Snapshot.hpp | 53 +++ Tobii EyeX/include/eyex-cpp/Snapshot.inl | 159 ++++++++ Tobii EyeX/include/eyex-cpp/StateBag.hpp | 44 +++ Tobii EyeX/include/eyex-cpp/StateBag.inl | 82 ++++ 43 files changed, 3606 insertions(+) create mode 100755 Tobii EyeX/include/eyex-cpp/APIException.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/AsyncData.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/AsyncData.inl create mode 100755 Tobii EyeX/include/eyex-cpp/Behavior.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/Behavior.inl create mode 100755 Tobii EyeX/include/eyex-cpp/Bounds.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/Bounds.inl create mode 100755 Tobii EyeX/include/eyex-cpp/Callbacks.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/Command.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/Command.inl create mode 100755 Tobii EyeX/include/eyex-cpp/Context.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/Context.inl create mode 100755 Tobii EyeX/include/eyex-cpp/Environment.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/Environment.inl create mode 100755 Tobii EyeX/include/eyex-cpp/EyeX.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/HandleWrapper.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/HandleWrapper.inl create mode 100755 Tobii EyeX/include/eyex-cpp/InteractionAgentBase.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/InteractionAgentBase.inl create mode 100755 Tobii EyeX/include/eyex-cpp/InteractionContext.cpp create mode 100755 Tobii EyeX/include/eyex-cpp/InteractionEvent.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/InteractionEvent.inl create mode 100755 Tobii EyeX/include/eyex-cpp/InteractionObject.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/InteractionObject.inl create mode 100755 Tobii EyeX/include/eyex-cpp/Interactor.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/Interactor.inl create mode 100755 Tobii EyeX/include/eyex-cpp/Mask.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/Mask.inl create mode 100755 Tobii EyeX/include/eyex-cpp/Notification.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/Notification.inl create mode 100755 Tobii EyeX/include/eyex-cpp/Property.cpp create mode 100755 Tobii EyeX/include/eyex-cpp/Property.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/Property.inl create mode 100755 Tobii EyeX/include/eyex-cpp/PropertyBag.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/PropertyBag.inl create mode 100755 Tobii EyeX/include/eyex-cpp/PropertyValueResolver.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/PropertyValueResolver.inl create mode 100755 Tobii EyeX/include/eyex-cpp/Query.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/Query.inl create mode 100755 Tobii EyeX/include/eyex-cpp/Snapshot.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/Snapshot.inl create mode 100755 Tobii EyeX/include/eyex-cpp/StateBag.hpp create mode 100755 Tobii EyeX/include/eyex-cpp/StateBag.inl (limited to 'Tobii EyeX/include/eyex-cpp') diff --git a/Tobii EyeX/include/eyex-cpp/APIException.hpp b/Tobii EyeX/include/eyex-cpp/APIException.hpp new file mode 100755 index 0000000..d270c04 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/APIException.hpp @@ -0,0 +1,83 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * APIException.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_APIEXCEPTION__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_APIEXCEPTION__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +class APIException +{ +public: + APIException(TX_RESULT result, const std::string& message = "") + : _result(result), _message(message) + { } + + TX_RESULT GetResult() const + { + return _result; + } + + std::string GetMessage() const + { + return _message; + } + +private: + TX_RESULT _result; + std::string _message; +}; + +/*********************************************************************************************************************/ + +inline bool TX_VALIDATE(TX_RESULT result) +{ + if(result == TX_RESULT_OK) + return true; + + throw EyeX::APIException(result, "Error"); +} + +/*********************************************************************************************************************/ + +inline bool TX_VALIDATE(TX_RESULT result, TX_RESULT falseResult) +{ + if(result == falseResult) + return false; + + return TX_VALIDATE(result); +} + +/*********************************************************************************************************************/ + +inline bool TX_VALIDATE(TX_RESULT result, TX_RESULT falseResult1, TX_RESULT falseResult2) +{ + if(result == falseResult2) + return false; + + return TX_VALIDATE(result, falseResult1); +} + +template +inline std::string GetString(TX_RESULT (*pFn)(THandle1, TX_STRING, TX_SIZE*), THandle2 handle, TX_SIZE estimatedLength = 0) +{ + std::string str; + TX_VALIDATE(GetString(&str, pFn, handle, estimatedLength)); + return str; +} + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_APIEXCEPTION__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/AsyncData.hpp b/Tobii EyeX/include/eyex-cpp/AsyncData.hpp new file mode 100755 index 0000000..6ce342f --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/AsyncData.hpp @@ -0,0 +1,36 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * CommandResult.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_ASYNCDATA__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_ASYNCDATA__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +class AsyncData : + public InteractionObjectBase +{ +public: + AsyncData(const std::shared_ptr& spContext, TX_CONSTHANDLE hAsyncData); + + bool TryGetResultCode(TX_RESULT* pResultCode) const; + std::shared_ptr GetData() const; + + template + std::shared_ptr GetDataAs() const; +}; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_ASYNCDATA__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/AsyncData.inl b/Tobii EyeX/include/eyex-cpp/AsyncData.inl new file mode 100755 index 0000000..55f42f5 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/AsyncData.inl @@ -0,0 +1,54 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * AsyncData.inl + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_ASYNCDATA__INL__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_ASYNC__INL__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +inline AsyncData::AsyncData(const std::shared_ptr& spContext, TX_CONSTHANDLE hAsyncData) +: InteractionObjectBase(spContext, hAsyncData) +{ } + +/*********************************************************************************************************************/ + +inline bool AsyncData::TryGetResultCode(TX_RESULT* pResultCode) const +{ + return TX_VALIDATE(txGetAsyncDataResultCode(_hObject, pResultCode), TX_RESULT_NOTFOUND); +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr AsyncData::GetData() const +{ + Tx::Utils::ScopedHandle hData; + if(!TX_VALIDATE(txGetAsyncDataContent(_hObject, &hData), TX_RESULT_NOTFOUND)) + return nullptr; + + auto spData = _spContext->CreateObject(hData); + return spData; +} + +/*********************************************************************************************************************/ + +template +std::shared_ptr AsyncData::GetDataAs() const +{ + return std::dynamic_pointer_cast(GetData()); +} + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_ASYNCDATA__INL__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Behavior.hpp b/Tobii EyeX/include/eyex-cpp/Behavior.hpp new file mode 100755 index 0000000..c40d7bc --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Behavior.hpp @@ -0,0 +1,64 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * Behavior.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Behavior__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_Behavior__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +class Behavior : + public InteractionObject +{ +public: + Behavior(const std::shared_ptr& spContext, TX_HANDLE hBehavior); + + TX_BEHAVIORTYPE GetType() const; + +public: + void SetData(const std::shared_ptr& spData); + std::shared_ptr GetData() const; + + void SetGazePointDataBehaviorParams(const TX_GAZEPOINTDATAPARAMS& pParams); + bool TryGetGazePointDataBehaviorParams(TX_GAZEPOINTDATAPARAMS* pParams) const; + bool TryGetGazePointDataEventParams(TX_GAZEPOINTDATAEVENTPARAMS* pEventParams) const; + + void SetActivatableBehaviorParams(const TX_ACTIVATABLEPARAMS& pParams); + bool TryGetActivatableBehaviorParams(TX_ACTIVATABLEPARAMS* pParams) const; + + void SetPannableBehaviorParams(const TX_PANNABLEPARAMS& pParams); + bool TryGetPannableBehaviorParams(TX_PANNABLEPARAMS* pParams) const; + bool TryGetPannableEventType(TX_PANNABLEEVENTTYPE* pEventType) const; + bool TryGetPannablePanEvent(TX_PANNABLEPANEVENTPARAMS* pEventParams) const; + bool TryGetPannableStepEvent(TX_PANNABLESTEPEVENTPARAMS* pEventParams) const; + bool TryGetPannableHandsFreeEvent(TX_PANNABLEHANDSFREEEVENTPARAMS* pEventParams) const; + + bool TryGetActivatableEventType(TX_ACTIVATABLEEVENTTYPE* pEventType) const; + bool TryGetActivationFocusChangedEventParams(TX_ACTIVATIONFOCUSCHANGEDEVENTPARAMS* pEventParams) const; + + void SetGazeAwareBehaviorParams(const TX_GAZEAWAREPARAMS& pParams); + bool TryGetGazeAwareBehaviorParams(TX_GAZEAWAREPARAMS* pParams) const; + bool TryGetGazeAwareEventParams(TX_GAZEAWAREEVENTPARAMS* pEventParams) const; + + void SetFixationDataBehaviorParams(const TX_FIXATIONDATAPARAMS& params); + bool TryGetFixationDataBehaviorParams(TX_FIXATIONDATAPARAMS* pParams) const; + bool TryGetFixationDataEventParams(TX_FIXATIONDATAEVENTPARAMS* pEventParams) const; + + bool TryGetEyePositionDataEventParams(TX_EYEPOSITIONDATAEVENTPARAMS* pEventParams) const; +}; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Behavior__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Behavior.inl b/Tobii EyeX/include/eyex-cpp/Behavior.inl new file mode 100755 index 0000000..5e4f71b --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Behavior.inl @@ -0,0 +1,198 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * Behavior.inl + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Behavior__INL__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_Behavior__INL__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +inline Behavior::Behavior(const std::shared_ptr& spContext, TX_HANDLE hBehavior) +: InteractionObject(spContext, hBehavior) +{} + +/*********************************************************************************************************************/ + +inline TX_BEHAVIORTYPE Behavior::GetType() const +{ + TX_BEHAVIORTYPE behaviorType; + TX_VALIDATE(txGetBehaviorType(_hObject, &behaviorType)); + return behaviorType; +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Behavior::GetData() const +{ + auto spProperty = GetProperty(TX_LITERAL_DATA); + + std::shared_ptr spData; + if(spProperty->TryGetValue(&spData)) + return spData; + + return nullptr; +} + +/*********************************************************************************************************************/ + +inline void Behavior::SetData(const std::shared_ptr& spData) +{ + auto spProperty = GetProperty(TX_LITERAL_DATA); + spProperty->SetValue(spData); +} + +/*********************************************************************************************************************/ + +inline void Behavior::SetGazePointDataBehaviorParams(const TX_GAZEPOINTDATAPARAMS& params) +{ + TX_VALIDATE(txSetGazePointDataBehaviorParams(_hObject, ¶ms)); +} + +/*********************************************************************************************************************/ + +inline bool Behavior::TryGetGazePointDataBehaviorParams(TX_GAZEPOINTDATAPARAMS* pParams) const +{ + return TX_VALIDATE(txGetGazePointDataBehaviorParams(_hObject, pParams), TX_RESULT_INVALIDBEHAVIORTYPE); +} + +/*********************************************************************************************************************/ + +inline void Behavior::SetActivatableBehaviorParams(const TX_ACTIVATABLEPARAMS& params) +{ + TX_VALIDATE(txSetActivatableBehaviorParams(_hObject, ¶ms)); +} + +/*********************************************************************************************************************/ + +inline bool Behavior::TryGetActivatableBehaviorParams(TX_ACTIVATABLEPARAMS* pParams) const +{ + return TX_VALIDATE(txGetActivatableBehaviorParams(_hObject, pParams), TX_RESULT_INVALIDBEHAVIORTYPE); +} + +/*********************************************************************************************************************/ + +inline void Behavior::SetPannableBehaviorParams(const TX_PANNABLEPARAMS& params) +{ + TX_VALIDATE(txSetPannableBehaviorParams(_hObject, ¶ms)); +} + +/*********************************************************************************************************************/ + +inline bool Behavior::TryGetPannableBehaviorParams(TX_PANNABLEPARAMS* pParams) const +{ + return TX_VALIDATE(txGetPannableBehaviorParams(_hObject, pParams), TX_RESULT_INVALIDBEHAVIORTYPE); +} + +/*********************************************************************************************************************/ + +inline bool Behavior::TryGetPannableEventType(TX_PANNABLEEVENTTYPE* pEventType) const +{ + return TX_VALIDATE(txGetPannableEventType(_hObject, pEventType), TX_RESULT_INVALIDBEHAVIORTYPE); +} + +/*********************************************************************************************************************/ + +inline bool Behavior::TryGetPannablePanEvent(TX_PANNABLEPANEVENTPARAMS* pEventParams) const +{ + return TX_VALIDATE(txGetPannablePanEventParams(_hObject, pEventParams), TX_RESULT_INVALIDBEHAVIORTYPE, TX_RESULT_NOTFOUND); +} + +/*********************************************************************************************************************/ + +inline bool Behavior::TryGetPannableStepEvent(TX_PANNABLESTEPEVENTPARAMS* pEventParams) const +{ + return TX_VALIDATE(txGetPannableStepEventParams(_hObject, pEventParams), TX_RESULT_INVALIDBEHAVIORTYPE, TX_RESULT_NOTFOUND); +} + +/*********************************************************************************************************************/ + +inline bool Behavior::TryGetPannableHandsFreeEvent(TX_PANNABLEHANDSFREEEVENTPARAMS* pEventParams) const +{ + return TX_VALIDATE(txGetPannableHandsFreeEventParams(_hObject, pEventParams), TX_RESULT_INVALIDBEHAVIORTYPE, TX_RESULT_NOTFOUND); +} + +/*********************************************************************************************************************/ + +inline bool Behavior::TryGetActivatableEventType(TX_ACTIVATABLEEVENTTYPE* pEventType) const +{ + return TX_VALIDATE(txGetActivatableEventType(_hObject, pEventType), TX_RESULT_INVALIDBEHAVIORTYPE); +} + +/*********************************************************************************************************************/ + +inline bool Behavior::TryGetActivationFocusChangedEventParams(TX_ACTIVATIONFOCUSCHANGEDEVENTPARAMS* pEventParams) const +{ + return TX_VALIDATE(txGetActivationFocusChangedEventParams(_hObject, pEventParams), TX_RESULT_INVALIDBEHAVIORTYPE, TX_RESULT_NOTFOUND); +} + +/*********************************************************************************************************************/ + +inline void Behavior::SetGazeAwareBehaviorParams(const TX_GAZEAWAREPARAMS& params) +{ + TX_VALIDATE(txSetGazeAwareBehaviorParams(_hObject, ¶ms)); +} + +/*********************************************************************************************************************/ + +inline bool Behavior::TryGetGazeAwareBehaviorParams(TX_GAZEAWAREPARAMS* pParams) const +{ + return TX_VALIDATE(txGetGazeAwareBehaviorParams(_hObject, pParams), TX_RESULT_INVALIDBEHAVIORTYPE, TX_RESULT_NOTFOUND); +} + +/*********************************************************************************************************************/ + +inline bool Behavior::TryGetGazeAwareEventParams(TX_GAZEAWAREEVENTPARAMS* pEventParams) const +{ + return TX_VALIDATE(txGetGazeAwareBehaviorEventParams(_hObject, pEventParams), TX_RESULT_INVALIDBEHAVIORTYPE); +} + +/*********************************************************************************************************************/ + +inline void Behavior::SetFixationDataBehaviorParams(const TX_FIXATIONDATAPARAMS& params) +{ + TX_VALIDATE(txSetFixationDataBehaviorParams(_hObject, ¶ms)); +} + +/*********************************************************************************************************************/ + +inline bool Behavior::TryGetFixationDataBehaviorParams(TX_FIXATIONDATAPARAMS* pParams) const +{ + return TX_VALIDATE(txGetFixationDataBehaviorParams(_hObject, pParams), TX_RESULT_INVALIDBEHAVIORTYPE); +} + +/*********************************************************************************************************************/ + +inline bool Behavior::TryGetFixationDataEventParams(TX_FIXATIONDATAEVENTPARAMS* pEventParams) const +{ + return TX_VALIDATE(txGetFixationDataEventParams(_hObject, pEventParams), TX_RESULT_INVALIDBEHAVIORTYPE, TX_RESULT_NOTFOUND); +} + +/*********************************************************************************************************************/ + +inline bool Behavior::TryGetGazePointDataEventParams(TX_GAZEPOINTDATAEVENTPARAMS* pEventParams) const +{ + return TX_VALIDATE(txGetGazePointDataEventParams(_hObject, pEventParams), TX_RESULT_INVALIDBEHAVIORTYPE, TX_RESULT_NOTFOUND); +} + +/*********************************************************************************************************************/ + +inline bool Behavior::TryGetEyePositionDataEventParams(TX_EYEPOSITIONDATAEVENTPARAMS* pEventParams) const +{ + return TX_VALIDATE(txGetEyePositionDataEventParams(_hObject, pEventParams), TX_RESULT_INVALIDBEHAVIORTYPE, TX_RESULT_NOTFOUND); +} + +/*********************************************************************************************************************/ + + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Behavior__INL__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Bounds.hpp b/Tobii EyeX/include/eyex-cpp/Bounds.hpp new file mode 100755 index 0000000..f355ac4 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Bounds.hpp @@ -0,0 +1,43 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * Bounds.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Bounds__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_Bounds__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +class Bounds : + public InteractionObject +{ +public: + Bounds(const std::shared_ptr& spContext, TX_HANDLE hBounds); + + TX_BOUNDSTYPE GetType() const; + +public: + bool TryGetRectangularData(TX_REAL* pX, TX_REAL* pY, TX_REAL* pWidth, TX_REAL* pHeight) const; + void SetRectangularData(TX_REAL x, TX_REAL y, TX_REAL width, TX_REAL height); + + bool TryGetRectangularData(TX_RECT* pData) const; + void SetRectangularData(const TX_RECT& data); + + std::shared_ptr GetData() const; + void SetData(const std::shared_ptr& spData); +}; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Bounds__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Bounds.inl b/Tobii EyeX/include/eyex-cpp/Bounds.inl new file mode 100755 index 0000000..495e779 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Bounds.inl @@ -0,0 +1,86 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * Bounds.inl + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Bounds__INL__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_Bounds__INL__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +inline Bounds::Bounds(const std::shared_ptr& spContext, TX_HANDLE hBounds) +: InteractionObject(spContext, hBounds) +{} + +/*********************************************************************************************************************/ + +inline TX_BOUNDSTYPE Bounds::GetType() const +{ + TX_BOUNDSTYPE boundsType; + TX_VALIDATE(txGetBoundsType(_hObject, &boundsType)); + return boundsType; +} + +/*********************************************************************************************************************/ + + +inline bool Bounds::TryGetRectangularData(TX_REAL* pX, TX_REAL* pY, TX_REAL* pWidth, TX_REAL* pHeight) const +{ + return txGetRectangularBoundsData(_hObject, pX, pY, pWidth, pHeight) == TX_RESULT_OK; +} + +/*********************************************************************************************************************/ + +inline void Bounds::SetRectangularData(TX_REAL x, TX_REAL y, TX_REAL width, TX_REAL height) +{ + txSetRectangularBoundsData(_hObject, x, y, width, height); +} + +/*********************************************************************************************************************/ + +inline bool Bounds::TryGetRectangularData(TX_RECT* pData) const +{ + return TryGetRectangularData(&pData->X, &pData->Y, &pData->Width, &pData->Height); +} + +/*********************************************************************************************************************/ + +inline void Bounds::SetRectangularData(const TX_RECT& data) +{ + SetRectangularData(data.X, data.Y, data.Width, data.Height); +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Bounds::GetData() const +{ + auto spProperty = GetProperty(TX_LITERAL_DATA); + + std::shared_ptr spData; + if(spProperty->TryGetValue(&spData)) + return spData; + + return nullptr; +} + +/*********************************************************************************************************************/ + +inline void Bounds::SetData(const std::shared_ptr& spData) +{ + auto spProperty = GetProperty(TX_LITERAL_DATA); + spProperty->SetValue(spData); +} + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Bounds__INL__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Callbacks.hpp b/Tobii EyeX/include/eyex-cpp/Callbacks.hpp new file mode 100755 index 0000000..84bd702 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Callbacks.hpp @@ -0,0 +1,26 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * Callbacks.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_CALLBACKS__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_CALLBACKS__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +typedef std::function ConnectionStateChangedHandler; +typedef std::function&)> AsyncDataHandler; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_CALLBACKS__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Command.hpp b/Tobii EyeX/include/eyex-cpp/Command.hpp new file mode 100755 index 0000000..ef1f189 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Command.hpp @@ -0,0 +1,38 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * Command.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Command__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_Command__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +class Command : + public InteractionObject +{ +public: + Command(const std::shared_ptr& spContext, TX_HANDLE hCommand); + + TX_COMMANDTYPE GetType() const; + void ExecuteAsync(AsyncDataHandler fnHandler); + +public: + std::shared_ptr GetData() const; + void SetData(const std::shared_ptr& spData); +}; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Command__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Command.inl b/Tobii EyeX/include/eyex-cpp/Command.inl new file mode 100755 index 0000000..953687f --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Command.inl @@ -0,0 +1,70 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * Command.inl + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Command__INL__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_Command__INL__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +inline Command::Command(const std::shared_ptr& spContext, TX_HANDLE hCommand) +: InteractionObject(spContext, hCommand) +{} + +/*********************************************************************************************************************/ + +inline TX_COMMANDTYPE Command::GetType() const +{ + TX_COMMANDTYPE commandType; + TX_VALIDATE(txGetCommandType(_hObject, &commandType)); + return commandType; +} + +/*********************************************************************************************************************/ + +inline void Command::ExecuteAsync(AsyncDataHandler fnHandler) +{ + auto spThis = shared_from_this(); + auto fnProxy = [&, spThis, fnHandler](TX_CONSTHANDLE hAsyncData) + { + GetContext()->InvokeAsyncDataHandler(hAsyncData, fnHandler); + }; + + TX_VALIDATE(Tx::ExecuteCommandAsync(_hObject, fnProxy)); +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Command::GetData() const +{ + auto spProperty = GetProperty(TX_LITERAL_DATA); + + std::shared_ptr spData; + if(spProperty->TryGetValue(&spData)) + return spData; + + return nullptr; +} + +/*********************************************************************************************************************/ + +inline void Command::SetData(const std::shared_ptr& spData) +{ + auto spProperty = GetProperty(TX_LITERAL_DATA); + spProperty->SetValue(spData); +} + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Command__INL__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Context.hpp b/Tobii EyeX/include/eyex-cpp/Context.hpp new file mode 100755 index 0000000..c6cefa0 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Context.hpp @@ -0,0 +1,91 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * Context.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Context__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_Context__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +class Context : + public std::enable_shared_from_this +{ + Context(bool trackObjects); + +public: + static std::shared_ptr Create(bool trackObjects); + virtual ~Context(); + + TX_CONTEXTHANDLE GetHandle() const; + void SetName(const std::string& name); + std::string GetName() const; + + TX_TICKET RegisterConnectionStateChangedHandler(ConnectionStateChangedHandler fnConnectionStateChangedHandler); + void UnregisterConnectionStateChangedHandler(TX_TICKET ticket); + + void EnableConnection(); + void DisableConnection(); + void Shutdown(); + + + TX_TICKET RegisterMessageHandler(TX_MESSAGETYPE messageType, std::shared_ptr spOptions, AsyncDataHandler fnAsyncDataHandler); + void UnregisterMessageHandler(TX_TICKET ticket); + + void RegisterStateObserver(const std::string& statePath); + void UnregisterStateObserver(const std::string& statePath); + void GetStateAsync(const std::string& statePath, AsyncDataHandler fnCompletion) const; + std::shared_ptr GetState(const std::string& statePath) const; + + TX_TICKET RegisterStateChangedHandler(const std::string& statePath, AsyncDataHandler fnHandler); + void UnregisterStateChangedHandler(TX_TICKET ticket); + + template + void SetStateAsync(const std::string& statePath, const TValue& value, AsyncDataHandler fnCompletion = nullptr); + + std::vector> GetTrackedObjects() const; + + std::shared_ptr CreateObject(TX_HANDLE hObject) const; + std::shared_ptr CreateObject(Tx::Utils::ScopedHandle& hObject) const; + std::shared_ptr CreateProperty(TX_PROPERTYHANDLE hProperty) const; + + std::shared_ptr CreateBag(TX_PROPERTYBAGTYPE bagType = TX_PROPERTYBAGTYPE_OBJECT) const; + std::shared_ptr CreateStateBag(const std::string& statePath) const; + std::shared_ptr CreateSnapshot() const; + std::shared_ptr CreateGlobalInteractorSnapshot(TX_CONSTSTRING globalInteractorId, std::shared_ptr* pspInteractor) const; + std::shared_ptr CreateCommand(TX_COMMANDTYPE commandType) const; + std::shared_ptr CreateActionCommand(TX_ACTIONTYPE actionType) const; + + void DisableBuiltinKeys(const std::string& windowId, AsyncDataHandler fnCompletion = nullptr) const; + void EnableBuiltinKeys(const std::string& windowId, AsyncDataHandler fnCompletion = nullptr) const; + + void LaunchConfigurationTool(TX_CONFIGURATIONTOOL configurationTool, AsyncDataHandler fnCompletion = nullptr) const; + + template + std::shared_ptr CreateObject(TX_HANDLE hObject) const; + + template + std::shared_ptr CreateObject(Tx::Utils::ScopedHandle& hObject) const; + + void WriteLogMessage(TX_LOGLEVEL level, const std::string& scope, const std::string& message); + void PerformScheduledJobs(); + + void InvokeAsyncDataHandler(TX_CONSTHANDLE hAsyncData, AsyncDataHandler fnHandler) const; + +private: + TX_CONTEXTHANDLE _hContext; +}; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Context__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Context.inl b/Tobii EyeX/include/eyex-cpp/Context.inl new file mode 100755 index 0000000..1e9089a --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Context.inl @@ -0,0 +1,427 @@ +/********************************************************************************************************************* +* Copyright 2013-2014 Tobii Technology AB. All rights reserved. +* Context.inl +*********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Context__INL__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_Context__INL__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +inline std::shared_ptr Context::Create(bool trackObjects) +{ + return std::shared_ptr(new Context(trackObjects)); +} + +/*********************************************************************************************************************/ + +inline Context::Context(bool trackObjects) + : _hContext(TX_EMPTY_HANDLE) +{ + TX_VALIDATE(txCreateContext(&_hContext, trackObjects ? TX_TRUE : TX_FALSE)); +} + +/*********************************************************************************************************************/ + +inline void Context::Shutdown() +{ + txShutdownContext(_hContext, 1000, TX_TRUE); +} + +/*********************************************************************************************************************/ + +inline Context::~Context() +{ + txReleaseContext(&_hContext); +} + +/*********************************************************************************************************************/ + +inline TX_CONTEXTHANDLE Context::GetHandle() const +{ + return _hContext; +} + +/*********************************************************************************************************************/ + +inline void Context::SetName(const std::string& name) +{ + TX_VALIDATE(txSetContextName(_hContext, name.c_str())); +} + +/*********************************************************************************************************************/ + +inline std::string Context::GetName() const +{ + std::string name; + TX_VALIDATE(Tx::Utils::GetString(&name, txGetContextName, _hContext)); + return name; +} + +/*********************************************************************************************************************/ + +inline TX_TICKET Context::RegisterConnectionStateChangedHandler(ConnectionStateChangedHandler fnConnectionStateChangedHandler) +{ + TX_TICKET ticket; + TX_VALIDATE(Tx::RegisterConnectionStateChangedHandler(_hContext, &ticket, fnConnectionStateChangedHandler)); + return ticket; +} + +/*********************************************************************************************************************/ + +inline void Context::UnregisterConnectionStateChangedHandler(TX_TICKET ticket) +{ + TX_VALIDATE(txUnregisterConnectionStateChangedHandler(_hContext, ticket)); +} + +/*********************************************************************************************************************/ + +inline void Context::EnableConnection() +{ + TX_VALIDATE(txEnableConnection(_hContext)); +} + +/*********************************************************************************************************************/ + +inline void Context::DisableConnection() +{ + TX_VALIDATE(txDisableConnection(_hContext)); +} + +/*********************************************************************************************************************/ + +inline TX_TICKET Context::RegisterMessageHandler(TX_MESSAGETYPE messageType, std::shared_ptr spOptions, AsyncDataHandler fnMessageHandler) +{ + auto fnProxy = [&, fnMessageHandler](TX_CONSTHANDLE hAsyncData) + { + InvokeAsyncDataHandler(hAsyncData, fnMessageHandler); + }; + + auto hOptions = spOptions ? spOptions->GetHandle() : nullptr; + + TX_TICKET ticket = 0; + Tx::RegisterMessageHandler(_hContext, &ticket, messageType, hOptions, fnProxy); + return ticket; +} + +/*********************************************************************************************************************/ + +inline void Context::UnregisterMessageHandler(TX_TICKET ticket) +{ + TX_VALIDATE(txUnregisterMessageHandler(_hContext, ticket)); +} + +/*********************************************************************************************************************/ + +inline void Context::RegisterStateObserver(const std::string& statePath) +{ + TX_VALIDATE(txRegisterStateObserver(_hContext, statePath.c_str())); +} + +/*********************************************************************************************************************/ + +inline void Context::UnregisterStateObserver(const std::string& statePath) +{ + TX_VALIDATE(txUnregisterStateObserver(_hContext, statePath.c_str())); +} + +/*********************************************************************************************************************/ + +inline void Context::GetStateAsync(const std::string& statePath, AsyncDataHandler fnCompletion) const +{ + auto callback = [&, fnCompletion](TX_CONSTHANDLE hAsyncData) + { + InvokeAsyncDataHandler(hAsyncData, fnCompletion); + }; + + TX_VALIDATE(Tx::GetStateAsync(_hContext, statePath.c_str(), callback)); +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Context::GetState(const std::string& statePath) const +{ + Tx::Utils::ScopedHandle hStateBag; + TX_VALIDATE(txGetState(_hContext, statePath.c_str(), &hStateBag)); + + std::shared_ptr spStateBag; + if(hStateBag) + spStateBag = CreateObject(hStateBag); + + return spStateBag; +} + +/*********************************************************************************************************************/ + +inline TX_TICKET Context::RegisterStateChangedHandler(const std::string& statePath, AsyncDataHandler fnHandler) +{ + auto callback = [&, fnHandler](TX_CONSTHANDLE hAsyncData) + { + InvokeAsyncDataHandler(hAsyncData, fnHandler); + }; + + TX_TICKET ticket; + TX_VALIDATE(Tx::RegisterStateChangedHandler(_hContext, &ticket, statePath.c_str(), callback)); + + return ticket; +} + +/*********************************************************************************************************************/ + +inline void Context::UnregisterStateChangedHandler(TX_TICKET ticket) +{ + TX_VALIDATE(txUnregisterStateChangedHandler(_hContext, ticket)); +} + +/*********************************************************************************************************************/ + +template +inline void Context::SetStateAsync(const std::string& statePath, const TValue& value, AsyncDataHandler fnCompletion) +{ + auto stateBag = CreateStateBag(statePath); + stateBag->SetStateValue(statePath, value); + stateBag->SetAsync(fnCompletion); +} + +/*********************************************************************************************************************/ + +inline std::vector> Context::GetTrackedObjects() const +{ + std::vector objectHandles; + TX_VALIDATE(Tx::Utils::GetBufferData(objectHandles, txGetTrackedObjects, _hContext)); + + std::vector> objects; + + for(auto& hObject : objectHandles) + { + auto spObject = CreateObject(hObject); + objects.push_back(spObject); + } + + return objects; +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Context::CreateObject(TX_HANDLE hObject) const +{ + TX_INTERACTIONOBJECTTYPE objectType; + TX_VALIDATE(txGetObjectType(hObject, &objectType)); + + switch(objectType) + { + case TX_INTERACTIONOBJECTTYPE_BEHAVIOR: + return CreateObject(hObject); + + case TX_INTERACTIONOBJECTTYPE_BOUNDS: + return CreateObject(hObject); + + case TX_INTERACTIONOBJECTTYPE_COMMAND: + return CreateObject(hObject); + + case TX_INTERACTIONOBJECTTYPE_QUERY: + return CreateObject(hObject); + + case TX_INTERACTIONOBJECTTYPE_EVENT: + return CreateObject(hObject); + + case TX_INTERACTIONOBJECTTYPE_INTERACTOR: + return CreateObject(hObject); + + case TX_INTERACTIONOBJECTTYPE_SNAPSHOT: + return CreateObject(hObject); + + case TX_INTERACTIONOBJECTTYPE_PROPERTYBAG: + return CreateObject(hObject); + + case TX_INTERACTIONOBJECTTYPE_STATEBAG: + return CreateObject(hObject); + + case TX_INTERACTIONOBJECTTYPE_NOTIFICATION: + return CreateObject(hObject); + } + + throw APIException(TX_RESULT_UNKNOWN, "Unknown interaction object type"); +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Context::CreateObject(Tx::Utils::ScopedHandle& hObject) const +{ + auto spObject = CreateObject((TX_HANDLE)hObject); + + if(spObject) + hObject.Detach(); + + return spObject; +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Context::CreateProperty(TX_PROPERTYHANDLE hProperty) const +{ + auto spProperty = std::make_shared(shared_from_this(), hProperty); + return spProperty; +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Context::CreateBag(TX_PROPERTYBAGTYPE bagType) const +{ + Tx::Utils::ScopedHandle hBag; + TX_VALIDATE(txCreatePropertyBag(_hContext, &hBag, bagType)); + auto spBag = CreateObject(hBag); + return spBag; +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Context::CreateStateBag(const std::string& statePath) const +{ + Tx::Utils::ScopedHandle hStateBag; + TX_VALIDATE(txCreateStateBag(_hContext, &hStateBag, statePath.c_str())); + auto spStateBag = CreateObject(hStateBag); + return spStateBag; +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Context::CreateSnapshot() const +{ + Tx::Utils::ScopedHandle hSnapshot; + TX_VALIDATE(txCreateSnapshot(_hContext, &hSnapshot)); + auto spSnapshot = CreateObject(hSnapshot); + return spSnapshot; +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Context::CreateGlobalInteractorSnapshot(TX_CONSTSTRING globalInteractorId, std::shared_ptr* pspInteractor) const +{ + Tx::Utils::ScopedHandle hSnapshot, hInteractor; + TX_VALIDATE(txCreateGlobalInteractorSnapshot(_hContext, globalInteractorId, &hSnapshot, &hInteractor)); + *pspInteractor = CreateObject(hInteractor); + auto spSnapshot = CreateObject(hSnapshot); + return spSnapshot; +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Context::CreateCommand(TX_COMMANDTYPE commandType) const +{ + Tx::Utils::ScopedHandle hCommand; + TX_VALIDATE(txCreateCommand(_hContext, &hCommand, commandType)); + auto spCommand = CreateObject(hCommand); + return spCommand; +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Context::CreateActionCommand(TX_ACTIONTYPE actionType) const +{ + Tx::Utils::ScopedHandle hCommand; + TX_VALIDATE(txCreateActionCommand(_hContext, &hCommand, actionType)); + auto spCommand = CreateObject(hCommand); + return spCommand; +} + +/*********************************************************************************************************************/ + +inline void Context::DisableBuiltinKeys(const std::string& windowId, AsyncDataHandler fnCompletion) const +{ + auto callback = [&, fnCompletion](TX_CONSTHANDLE hAsyncData) + { + InvokeAsyncDataHandler(hAsyncData, fnCompletion); + }; + + TX_VALIDATE(Tx::DisableBuiltinKeys(_hContext, windowId.c_str(), callback)); +} + +/*********************************************************************************************************************/ + +inline void Context::EnableBuiltinKeys(const std::string& windowId, AsyncDataHandler fnCompletion) const +{ + auto callback = [&, fnCompletion](TX_CONSTHANDLE hAsyncData) + { + InvokeAsyncDataHandler(hAsyncData, fnCompletion); + }; + + TX_VALIDATE(Tx::EnableBuiltinKeys(_hContext, windowId.c_str(), callback)); +} + +/*********************************************************************************************************************/ + +inline void Context::LaunchConfigurationTool(TX_CONFIGURATIONTOOL configurationTool, AsyncDataHandler fnCompletion) const +{ + auto callback = [&, fnCompletion](TX_CONSTHANDLE hAsyncData) + { + InvokeAsyncDataHandler(hAsyncData, fnCompletion); + }; + + TX_VALIDATE(Tx::LaunchConfigurationTool(_hContext, configurationTool, callback)); +} + +/*********************************************************************************************************************/ + +template +inline std::shared_ptr Context::CreateObject(TX_HANDLE hObject) const +{ + return std::make_shared(shared_from_this(), hObject); +} + +/*********************************************************************************************************************/ + +template +inline std::shared_ptr Context::CreateObject(Tx::Utils::ScopedHandle& hObject) const +{ + auto spObject = CreateObject((TX_HANDLE)hObject); + + if(spObject) + hObject.Detach(); + + return spObject; +} + +/*********************************************************************************************************************/ + +inline void Context::WriteLogMessage(TX_LOGLEVEL level, const std::string& scope, const std::string& message) +{ + TX_VALIDATE(txWriteLogMessage(level, scope.c_str(), message.c_str())); +} + +/*********************************************************************************************************************/ + +inline void Context::PerformScheduledJobs() +{ + TX_VALIDATE(txPerformScheduledJobs(_hContext)); +} + +/*********************************************************************************************************************/ + +inline void Context::InvokeAsyncDataHandler(TX_CONSTHANDLE hAsyncData, AsyncDataHandler fnHandler) const +{ + if(!fnHandler) + return; + + try + { + auto upAsyncData = std::unique_ptr(new AsyncData(shared_from_this(), hAsyncData)); + fnHandler(upAsyncData); + } + catch(...) + { } +} + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Context__INL__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Environment.hpp b/Tobii EyeX/include/eyex-cpp/Environment.hpp new file mode 100755 index 0000000..5a4a8c8 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Environment.hpp @@ -0,0 +1,45 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * Environment.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_ENVIRONMENT__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_ENVIRONMENT__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +class Environment +{ + Environment( + TX_EYEXCOMPONENTOVERRIDEFLAGS flags, + TX_LOGGINGMODEL* pLoggingModel, + TX_THREADINGMODEL* pThreadingModel, + TX_SCHEDULINGMODEL* pSchedulingModel, + void* pMemoryModel); +public: + virtual ~Environment(); + + static std::shared_ptr Initialize( + TX_EYEXCOMPONENTOVERRIDEFLAGS flags, + TX_LOGGINGMODEL* pLoggingModel, + TX_THREADINGMODEL* pThreadingModel, + TX_SCHEDULINGMODEL* pSchedulingModel, + void* pMemoryModel); + + TX_EYEXAVAILABILITY GetEyeXAvailability(); + static bool IsInitialized(); +}; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_ENVIRONMENT__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Environment.inl b/Tobii EyeX/include/eyex-cpp/Environment.inl new file mode 100755 index 0000000..fa83b1f --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Environment.inl @@ -0,0 +1,70 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * Environment.inl + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_ENVIRONMENT__INL__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_ENVIRONMENT__INL__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +inline Environment::Environment( + TX_EYEXCOMPONENTOVERRIDEFLAGS flags, + TX_LOGGINGMODEL* pLoggingModel, + TX_THREADINGMODEL* pThreadingModel, + TX_SCHEDULINGMODEL* pSchedulingModel, + void* pMemoryModel) +{ + TX_VALIDATE(txInitializeEyeX(flags, pLoggingModel, pThreadingModel, pSchedulingModel, pMemoryModel)); +} + +/*********************************************************************************************************************/ + +inline Environment::~Environment() +{ + TX_VALIDATE(txUninitializeEyeX()); +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Environment::Initialize( + TX_EYEXCOMPONENTOVERRIDEFLAGS flags, + TX_LOGGINGMODEL* pLoggingModel, + TX_THREADINGMODEL* pThreadingModel, + TX_SCHEDULINGMODEL* pSchedulingModel, + void* pMemoryModel) +{ + return std::shared_ptr(new Environment(flags, pLoggingModel, pThreadingModel, pSchedulingModel, pMemoryModel)); +} + +/*********************************************************************************************************************/ + +inline TX_EYEXAVAILABILITY Environment::GetEyeXAvailability() +{ + TX_EYEXAVAILABILITY availability; + TX_VALIDATE(txGetEyeXAvailability(&availability)); + return availability; +} + +/*********************************************************************************************************************/ + +inline bool Environment::IsInitialized() +{ + TX_BOOL res; + txIsEyeXInitialized(&res); + return res != TX_FALSE; +} + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_ENVIRONMENT__INL__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/EyeX.hpp b/Tobii EyeX/include/eyex-cpp/EyeX.hpp new file mode 100755 index 0000000..b0c8123 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/EyeX.hpp @@ -0,0 +1,105 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * EyeX.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_TX__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_TX__HPP__ + +/*********************************************************************************************************************/ + +#define TX_NAMESPACE_BEGIN namespace EyeX { +#define TX_NAMESPACE_END } + +/*********************************************************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*********************************************************************************************************************/ + +#define TOBII_TX_DETAIL + +#include "eyex/EyeX.h" + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +class Environment; +class InteractionObject; +class Property; +class PropertyBag; +class Bounds; +class Behavior; +class Interactor; +class Snapshot; +class SnapshotResult; +class Command; +class CommandResult; +class Query; +class InteractionEvent; +class Notification; +class AsyncData; +class StateBag; +class Mask; + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#include "APIException.hpp" +#include "Callbacks.hpp" +#include "Environment.hpp" +#include "PropertyValueResolver.hpp" +#include "Context.hpp" +#include "HandleWrapper.hpp" +#include "InteractionObject.hpp" +#include "Behavior.hpp" +#include "Bounds.hpp" +#include "Command.hpp" +#include "AsyncData.hpp" +#include "InteractionEvent.hpp" +#include "Query.hpp" +#include "Snapshot.hpp" +#include "Interactor.hpp" +#include "Property.hpp" +#include "PropertyBag.hpp" +#include "Notification.hpp" +#include "StateBag.hpp" +#include "Mask.hpp" +#include "InteractionAgentBase.hpp" + +/*********************************************************************************************************************/ + +#include "PropertyValueResolver.inl" +#include "Environment.inl" +#include "Context.inl" +#include "HandleWrapper.inl" +#include "InteractionObject.inl" +#include "Behavior.inl" +#include "Bounds.inl" +#include "Command.inl" +#include "AsyncData.inl" +#include "InteractionEvent.inl" +#include "Query.inl" +#include "Snapshot.inl" +#include "Interactor.inl" +#include "Property.inl" +#include "PropertyBag.inl" +#include "Notification.inl" +#include "StateBag.inl" +#include "Mask.inl" +#include "InteractionAgentBase.inl" + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_TX__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/HandleWrapper.hpp b/Tobii EyeX/include/eyex-cpp/HandleWrapper.hpp new file mode 100755 index 0000000..d32b83c --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/HandleWrapper.hpp @@ -0,0 +1,44 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * HandleWrapper.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_HANDLEWRAPPER__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_HANDLEWRAPPER__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +template +class HandleWrapper : + public std::enable_shared_from_this> +{ +public: + HandleWrapper(const std::shared_ptr& spContext, THandle hObject); + virtual ~HandleWrapper(); + + std::shared_ptr GetContext() const; + THandle GetHandle() const; + +protected: + template + inline static std::string GetString(TX_RESULT (*pFn)(THandle1, TX_STRING, TX_SIZE*), THandle2 handle, TX_SIZE estimatedLength = 0); + +protected: + std::shared_ptr _spContext; + THandle _hObject; +}; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_HANDLEWRAPPER__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/HandleWrapper.inl b/Tobii EyeX/include/eyex-cpp/HandleWrapper.inl new file mode 100755 index 0000000..eae842e --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/HandleWrapper.inl @@ -0,0 +1,61 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * InteractionObject.inl + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_HANDLEWRAPPER__INL__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_HANDLEWRAPPER__INL__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +template +inline HandleWrapper::HandleWrapper(const std::shared_ptr& spContext, THandle hObject) +: _spContext(spContext), _hObject(hObject) +{} + +/*********************************************************************************************************************/ + +template +inline HandleWrapper::~HandleWrapper() +{ } + +/*********************************************************************************************************************/ + +template +inline std::shared_ptr HandleWrapper::GetContext() const +{ + return _spContext; +} + +/*********************************************************************************************************************/ + +template +inline THandle HandleWrapper::GetHandle() const +{ + return _hObject; +} + +/*********************************************************************************************************************/ + +template +template +inline static std::string HandleWrapper::GetString(TX_RESULT (*pFn)(THandle1, TX_STRING, TX_SIZE*), THandle2 handle, TX_SIZE estimatedLength) +{ + std::string str; + TX_VALIDATE(Tx::Utils::GetString(&str, pFn, handle, estimatedLength)); + return str; +} + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_HANDLEWRAPPER__INL__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/InteractionAgentBase.hpp b/Tobii EyeX/include/eyex-cpp/InteractionAgentBase.hpp new file mode 100755 index 0000000..3ca22d4 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/InteractionAgentBase.hpp @@ -0,0 +1,79 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * InteractionAgentBase.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_INTERACTIONAGENTBASE__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_INTERACTIONAGENTBASE__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +class InteractionAgentBase +{ +public: + void Initialize(); + void Uninitialize(); + + std::shared_ptr GetContext() const; + +protected: + InteractionAgentBase(bool trackObjects = true); + + virtual void OnInitialize() {} + virtual void OnUninitialize() {} + virtual void OnRegisterQueryHandlers(); + + virtual void OnConnectionStateChanged(TX_CONNECTIONSTATE state) {} + virtual void OnNotification(const std::shared_ptr& spNotification) {} + virtual void OnQuery(const std::shared_ptr& spQuery) {} + virtual void OnEvent(const std::shared_ptr& spEvent) {} + + virtual std::shared_ptr InitializeEyeX(); + virtual TX_LOGGINGMODEL* GetLoggingModel(); + virtual TX_THREADINGMODEL* GetThreadingModel() { return nullptr; } + virtual TX_SCHEDULINGMODEL* GetSchedulingModel() { return nullptr; } + + void RegisterQueryHandler(const std::string& processId); + + bool IsRunning() const; + +private: + bool _isRunning; + + std::shared_ptr _spContext; + TX_TICKET _connectionStateChangedHandlerTicket; + std::vector _messageHandlerTickets; + std::shared_ptr _spSystem; + bool _trackObjects; + + TX_LOGGINGMODEL _defaultLoggingModel; +}; + +/*********************************************************************************************************************/ + +class AutoRespondingInteractionAgentBase : + public InteractionAgentBase +{ +public: + AutoRespondingInteractionAgentBase(bool trackObjects = true); + +protected: + void OnQuery(const std::shared_ptr& spQuery) override; + + virtual bool PrepareSnapshot(const std::shared_ptr& spSnapshot) { return false; } + virtual void OnSnapshotResult(const std::unique_ptr& upAsyncData) {} +}; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_INTERACTIONAGENTBASE__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/InteractionAgentBase.inl b/Tobii EyeX/include/eyex-cpp/InteractionAgentBase.inl new file mode 100755 index 0000000..c949822 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/InteractionAgentBase.inl @@ -0,0 +1,183 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * InteractionAgentBase.inl + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_INTERACTIONAGENTBASE__INL__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_INTERACTIONAGENTBASE__INL__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +inline InteractionAgentBase::InteractionAgentBase(bool trackObjects) : +_trackObjects(trackObjects) +{ + memset(&_defaultLoggingModel, 0, sizeof(_defaultLoggingModel)); + _defaultLoggingModel.Targets = TX_LOGTARGET_CONSOLE; + +#if _DEBUG + _defaultLoggingModel.Targets = (TX_LOGTARGET)(_defaultLoggingModel.Targets | TX_LOGTARGET_TRACE); +#endif +} + +/*********************************************************************************************************************/ + +inline void InteractionAgentBase::Initialize() +{ + _isRunning = true; + _spSystem = InitializeEyeX(); + _spContext = Context::Create(_trackObjects); + + _connectionStateChangedHandlerTicket = _spContext->RegisterConnectionStateChangedHandler([this] (TX_CONNECTIONSTATE state) { + OnConnectionStateChanged(state); + }); + + auto eventHandlerTicket = _spContext->RegisterMessageHandler(TX_MESSAGETYPE_EVENT, nullptr, [this] (const std::unique_ptr& upAsyncData) { + auto spEvent = upAsyncData->GetDataAs(); + OnEvent(spEvent); + }); + + auto notificationHandlerTicket = _spContext->RegisterMessageHandler(TX_MESSAGETYPE_NOTIFICATION, nullptr, [this] (const std::unique_ptr& upAsyncData) { + auto spNotification = upAsyncData->GetDataAs(); + OnNotification(spNotification); + }); + + _messageHandlerTickets.push_back(eventHandlerTicket); + _messageHandlerTickets.push_back(notificationHandlerTicket); + + OnRegisterQueryHandlers(); + OnInitialize(); + + _spContext->EnableConnection(); +} + +/*********************************************************************************************************************/ + +inline void InteractionAgentBase::Uninitialize() +{ + _isRunning = false; + + OnUninitialize(); + _spContext->DisableConnection(); + + for(auto messageHandlerTicket : _messageHandlerTickets) + _spContext->UnregisterMessageHandler(messageHandlerTicket); + + _spContext->Shutdown(); + _spContext->UnregisterConnectionStateChangedHandler(_connectionStateChangedHandlerTicket); + + _spContext.reset(); + _spSystem.reset(); +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr InteractionAgentBase::GetContext() const +{ + return _spContext; +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr InteractionAgentBase::InitializeEyeX() +{ + auto pLoggingModel = GetLoggingModel(); + auto pThreadingModel = GetThreadingModel(); + auto pSchedulingModel = GetSchedulingModel(); + + auto overrideFlags = TX_EYEXCOMPONENTOVERRIDEFLAG_NONE; + + if(pLoggingModel) + overrideFlags = (TX_EYEXCOMPONENTOVERRIDEFLAGS)(overrideFlags | TX_EYEXCOMPONENTOVERRIDEFLAG_LOGGINGMODEL); + + if(pThreadingModel) + overrideFlags = (TX_EYEXCOMPONENTOVERRIDEFLAGS)(overrideFlags | TX_EYEXCOMPONENTOVERRIDEFLAG_INTERNAL_THREADINGMODEL); + + if(pSchedulingModel) + overrideFlags = (TX_EYEXCOMPONENTOVERRIDEFLAGS)(overrideFlags | TX_EYEXCOMPONENTOVERRIDEFLAG_INTERNAL_SCHEDULINGMODEL); + + return Environment::Initialize(overrideFlags, pLoggingModel, pThreadingModel, pSchedulingModel, nullptr); +} + +/*********************************************************************************************************************/ + +inline void InteractionAgentBase::OnRegisterQueryHandlers() +{ + auto currentProcessId = GetCurrentProcessId(); + auto currentProcessIdStr = std::to_string(currentProcessId); + RegisterQueryHandler(currentProcessIdStr); +} + +/*********************************************************************************************************************/ + +inline void InteractionAgentBase::RegisterQueryHandler(const std::string& processId) +{ + auto spOptions = _spContext->CreateBag(); + auto spProcessIdProeprty = spOptions->CreateProperty(TX_LITERAL_TARGETPROCESSID); + spProcessIdProeprty->SetValue(processId); + + auto fnQueryHandler = [this](const std::unique_ptr& upAsyncData) + { + auto spQuery = upAsyncData->GetDataAs(); + OnQuery(spQuery); + }; + + auto ticket = _spContext->RegisterMessageHandler(TX_MESSAGETYPE_QUERY, spOptions, fnQueryHandler); + _messageHandlerTickets.push_back(ticket); +} + +/*********************************************************************************************************************/ + +inline TX_LOGGINGMODEL* InteractionAgentBase::GetLoggingModel() +{ + return &_defaultLoggingModel; +} + +/*********************************************************************************************************************/ + +inline bool InteractionAgentBase::IsRunning() const +{ + return _isRunning; +} + +/*********************************************************************************************************************/ + +inline AutoRespondingInteractionAgentBase::AutoRespondingInteractionAgentBase(bool trackObjects) + : InteractionAgentBase(trackObjects) +{ } + +/*********************************************************************************************************************/ + +inline void AutoRespondingInteractionAgentBase::OnQuery(const std::shared_ptr& spQuery) +{ + auto spSnapshot = Snapshot::CreateSnapshotForQuery(spQuery); + + try + { + if(!PrepareSnapshot(spSnapshot)) + return; + } + catch(...) + { + GetContext()->WriteLogMessage(TX_LOGLEVEL_ERROR, "AutoRespondingInteractionAgentBase", "Custom snapshot preparation throw an exception"); + return; + } + + spSnapshot->CommitAsync([this](const std::unique_ptr& upAsyncData) + { + OnSnapshotResult(upAsyncData); + }); +} + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_INTERACTIONAGENTBASE__INL__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/InteractionContext.cpp b/Tobii EyeX/include/eyex-cpp/InteractionContext.cpp new file mode 100755 index 0000000..ac08a78 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/InteractionContext.cpp @@ -0,0 +1,28 @@ +//--------------------------------------------------------------------------------------------------------------------- +// InteractionContext.cpp +//--------------------------------------------------------------------------------------------------------------------- + +#include "Precompiled.hpp" +#include "InteractionContext.hpp" +#include "InteractionObject.hpp" +#include "InteractionCommand.hpp" +#include "InteractionBehavior.hpp" +#include "InteractionBounds.hpp" +#include "Interactor.hpp" +#include "InteractionQuery.hpp" +#include "InteractionEvent.hpp" +#include "InteractionSnapshot.hpp" +#include "Property.hpp" +#include "PropertyBag.hpp" + +//--------------------------------------------------------------------------------------------------------------------- + +TOBIIGAZE_NAMESPACE_BEGIN + +//--------------------------------------------------------------------------------------------------------------------- + +//--------------------------------------------------------------------------------------------------------------------- + +TOBIIGAZE_NAMESPACE_END + +//--------------------------------------------------------------------------------------------------------------------- diff --git a/Tobii EyeX/include/eyex-cpp/InteractionEvent.hpp b/Tobii EyeX/include/eyex-cpp/InteractionEvent.hpp new file mode 100755 index 0000000..2e6839f --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/InteractionEvent.hpp @@ -0,0 +1,35 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * InteractionEvent.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_INTERACTIONEVENT__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_INTERACTIONEVENT__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +class InteractionEvent : + public InteractionObject +{ +public: + InteractionEvent(const std::shared_ptr& spContext, TX_HANDLE hEvent); + + std::string GetInteractorId() const; + std::vector> GetBehaviors() const; + bool TryGetBehavior(std::shared_ptr* pspBehavior, TX_BEHAVIORTYPE behaviorType) const; +}; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_INTERACTIONEVENT__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/InteractionEvent.inl b/Tobii EyeX/include/eyex-cpp/InteractionEvent.inl new file mode 100755 index 0000000..b650bef --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/InteractionEvent.inl @@ -0,0 +1,63 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * InteractionEvent.inl + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_INTERACTIONEVENT__INL__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_INTERACTIONEVENT__INL__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +inline InteractionEvent::InteractionEvent(const std::shared_ptr& spContext, TX_HANDLE hEvent) +: InteractionObject(spContext, hEvent) +{} + +/*********************************************************************************************************************/ + +inline std::string InteractionEvent::GetInteractorId() const +{ + return GetString(txGetEventInteractorId, _hObject); +} + +/*********************************************************************************************************************/ + +inline std::vector> InteractionEvent::GetBehaviors() const +{ + std::vector behaviorHandles; + TX_VALIDATE(Tx::Utils::GetBufferData(behaviorHandles, txGetEventBehaviors, _hObject)); + + std::vector> behaviors; + for(auto& hBehavior : behaviorHandles) + { + auto spBehavior = _spContext->CreateObject(hBehavior); + behaviors.push_back(spBehavior); + } + + return behaviors; +} + +/*********************************************************************************************************************/ + +inline bool InteractionEvent::TryGetBehavior(std::shared_ptr* pspBehavior, TX_BEHAVIORTYPE behaviorType) const +{ + Tx::Utils::ScopedHandle hBehavior; + if(!TX_VALIDATE(txGetEventBehavior(_hObject, &hBehavior, behaviorType), TX_RESULT_NOTFOUND)) + return false; + + *pspBehavior = _spContext->CreateObject(hBehavior); + return true; +} + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_INTERACTIONEVENT__INL__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/InteractionObject.hpp b/Tobii EyeX/include/eyex-cpp/InteractionObject.hpp new file mode 100755 index 0000000..75d4171 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/InteractionObject.hpp @@ -0,0 +1,63 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * InteractionObject.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_INTERACTIONOBJECT__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_INTERACTIONOBJECT__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +template +class InteractionObjectBase : + public HandleWrapper +{ +public: + InteractionObjectBase(const std::shared_ptr& spContext, THandle hObject); + + TX_INTERACTIONOBJECTTYPE GetObjectType() const; + + bool TryGetProperty(std::shared_ptr* pspProperty, const std::string& propertyName) const; + std::shared_ptr GetProperty(const std::string& propertyName) const; + std::vector> GetProperties() const; + void CopyPropertiesTo(const std::shared_ptr& spObject) const; + std::string FormatAsText() const; + +public: + template + typename PropertyValueResolver::ValueType GetPropertyValue(const std::string& propertyName) const; + + template + bool TryGetPropertyValue(TValue* pValue, const std::string& propertyName) const; +}; + +/*********************************************************************************************************************/ + +class InteractionObject : + public InteractionObjectBase +{ +public: + InteractionObject(const std::shared_ptr& spContext, TX_HANDLE hObject); + virtual ~InteractionObject(); + + std::shared_ptr CreateProperty(const std::string& propertyName); + +public: + template + void SetPropertyValue(const std::string& propertyName, const TValue& value); +}; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_INTERACTIONOBJECT__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/InteractionObject.inl b/Tobii EyeX/include/eyex-cpp/InteractionObject.inl new file mode 100755 index 0000000..5722ce6 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/InteractionObject.inl @@ -0,0 +1,162 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * InteractionObject.inl + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_INTERACTIONOBJECT__INL__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_INTERACTIONOBJECT__INL__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +template +inline InteractionObjectBase::InteractionObjectBase(const std::shared_ptr& spContext, THandle hObject) +: HandleWrapper(spContext, hObject) +{ } + +/*********************************************************************************************************************/ + +template +inline TX_INTERACTIONOBJECTTYPE InteractionObjectBase::GetObjectType() const +{ + TX_INTERACTIONOBJECTTYPE objectType; + TX_VALIDATE(txGetObjectType(_hObject, &objectType)); + return objectType; +} + +/*********************************************************************************************************************/ + +template +inline bool InteractionObjectBase::TryGetProperty(std::shared_ptr* pspProperty, const std::string& propertyName) const +{ + TX_PROPERTYHANDLE hProperty; + auto result = txGetProperty(_hObject, &hProperty, propertyName.c_str()); + if(result == TX_RESULT_NOTFOUND) + return false; + + *pspProperty = _spContext->CreateProperty(hProperty); + return true; +} + +/*********************************************************************************************************************/ + +template +inline std::shared_ptr InteractionObjectBase::GetProperty(const std::string& propertyName) const +{ + std::shared_ptr spProperty; + if(TryGetProperty(&spProperty, propertyName)) + return spProperty; + + throw APIException(TX_RESULT_NOTFOUND, "Property not found"); +} + +/*********************************************************************************************************************/ + +template +inline std::vector> InteractionObjectBase::GetProperties() const +{ + std::vector propertyHandles; + TX_VALIDATE(Tx::Utils::GetBufferData(propertyHandles, txGetProperties, _hObject)); + + std::vector> properties; + for(auto& hProperty : propertyHandles) + { + auto spProperty = _spContext->CreateProperty(hProperty); + properties.push_back(spProperty); + } + + return properties; +} + +/*********************************************************************************************************************/ + +template +inline void InteractionObjectBase::CopyPropertiesTo(const std::shared_ptr& spObject) const +{ + TX_VALIDATE(txCopyProperties(_hObject, spObject->GetHandle())); +} + +/*********************************************************************************************************************/ + +template +inline std::string InteractionObjectBase::FormatAsText() const +{ + return GetString(txFormatObjectAsText, _hObject, 512); +} + +/*********************************************************************************************************************/ + +template +template +inline typename PropertyValueResolver::ValueType InteractionObjectBase::GetPropertyValue(const std::string& propertyName) const +{ + auto spProperty = GetProperty(propertyName); + return spProperty->GetValue(); +} + +/*********************************************************************************************************************/ + +template +template +inline bool InteractionObjectBase::TryGetPropertyValue(TValue* pValue, const std::string& propertyName) const +{ + std::shared_ptr spProperty; + if(!TryGetProperty(&spProperty, propertyName)) + return false; + + if(!spProperty->TryGetValue(pValue)) + return false; + + return true; +} + +/*********************************************************************************************************************/ + + +/*********************************************************************************************************************/ + +inline InteractionObject::InteractionObject(const std::shared_ptr& spContext, TX_HANDLE hObject) +: InteractionObjectBase(spContext, hObject) +{ } + +/*********************************************************************************************************************/ + +inline InteractionObject::~InteractionObject() +{ + txReleaseObject(&_hObject); +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr InteractionObject::CreateProperty(const std::string& propertyName) +{ + TX_PROPERTYHANDLE hProperty; + TX_VALIDATE(txCreateProperty(_hObject, &hProperty, propertyName.c_str())); + auto spProperty = _spContext->CreateProperty(hProperty); + return spProperty; +} + +/*********************************************************************************************************************/ + +template +inline void InteractionObject::SetPropertyValue(const std::string& propertyName, const TValue& value) +{ + std::shared_ptr spProperty; + if(!TryGetProperty(&spProperty, propertyName)) + spProperty = CreateProperty(propertyName); + + spProperty->SetValue(value); +} + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_INTERACTIONOBJECT__INL__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Interactor.hpp b/Tobii EyeX/include/eyex-cpp/Interactor.hpp new file mode 100755 index 0000000..046adb0 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Interactor.hpp @@ -0,0 +1,67 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * Interactor.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_INTERACTOR__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_INTERACTOR__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +class Interactor : + public InteractionObject +{ +public: + Interactor(const std::shared_ptr& spContext, TX_HANDLE hInteractor); + + std::string GetId() const; + std::string GetParentId() const; + std::string GetWindowId() const; + + bool GetEnabled() const; + void SetEnabled(bool enabled); + + bool GetDeleted() const; + void SetDeleted(bool deleted); + + double GetZ() const; + void SetZ(double z); + + void CreateGazePointDataBehavior(const TX_GAZEPOINTDATAPARAMS& params); + void CreateActivatableBehavior(const TX_ACTIVATABLEPARAMS& params); + void CreatePannableBehavior(const TX_PANNABLEPARAMS& params); + void CreateGazeAwareBehavior(const TX_GAZEAWAREPARAMS& params); + void CreateFixationDataBehaviorParams(const TX_FIXATIONDATAPARAMS& params); + + std::shared_ptr GetBounds() const; + std::vector> GetBehaviors() const; + std::shared_ptr CreateBounds(TX_BOUNDSTYPE boundsType); + void DeleteBounds(); + + std::shared_ptr CreateBehavior(TX_BEHAVIORTYPE behaviorType); + void DeleteBehavior(TX_BEHAVIORTYPE behaviorType); + bool TryGetBehavior(std::shared_ptr *pspBehavior, TX_BEHAVIORTYPE behaviorType) const; + + std::shared_ptr CreateMask(TX_MASKTYPE maskType, int columnCount, int rowCount, const TX_BYTE* pData); + void RemoveMask(); + std::shared_ptr GetMask() const; + + void SetMaskBounds(const TX_RECT& bounds); + void ClearMaskBounds(); + bool TryGetMaskBounds(TX_RECT* pBounds) const; +}; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_INTERACTOR__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Interactor.inl b/Tobii EyeX/include/eyex-cpp/Interactor.inl new file mode 100755 index 0000000..5246609 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Interactor.inl @@ -0,0 +1,257 @@ +/********************************************************************************************************************* +* Copyright 2013-2014 Tobii Technology AB. All rights reserved. +* Interactor.inl +*********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_INTERACTOR__INL__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_INTERACTOR__INL__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +inline Interactor::Interactor(const std::shared_ptr& spContext, TX_HANDLE hInteractor) +: InteractionObject(spContext, hInteractor) +{} + +/*********************************************************************************************************************/ + +inline bool Interactor::GetEnabled() const +{ + int isEnabled; + TX_VALIDATE(txGetInteractorEnabled(_hObject, &isEnabled)); + return isEnabled != 0; +} + +/*********************************************************************************************************************/ + +inline void Interactor::SetEnabled(bool enabled) +{ + TX_VALIDATE(txSetInteractorEnabled(_hObject, enabled ? 1 : 0)); +} + +/*********************************************************************************************************************/ + +inline bool Interactor::GetDeleted() const +{ + int isDeleted; + TX_VALIDATE(txGetInteractorDeleted(_hObject, &isDeleted)); + return isDeleted != 0; +} + +/*********************************************************************************************************************/ + +inline void Interactor::SetDeleted(bool deleted) +{ + TX_VALIDATE(txSetInteractorDeleted(_hObject, deleted ? 1 : 0)); +} + +/*********************************************************************************************************************/ + +inline std::string Interactor::GetId() const +{ + return GetString(txGetInteractorId, _hObject); +} + +/*********************************************************************************************************************/ + +inline std::string Interactor::GetParentId() const +{ + return GetString(txGetInteractorParentId, _hObject); +} + +/*********************************************************************************************************************/ + +inline std::string Interactor::GetWindowId() const +{ + return GetString(txGetInteractorWindowId, _hObject); +} + +/*********************************************************************************************************************/ + +inline double Interactor::GetZ() const +{ + double z; + TX_VALIDATE(txGetInteractorZ(_hObject, &z)); + return z; +} + +/*********************************************************************************************************************/ + +inline void Interactor::SetZ(double z) +{ + TX_VALIDATE(txSetInteractorZ(_hObject, z)); +} + +/*********************************************************************************************************************/ + +inline void Interactor::CreateGazePointDataBehavior(const TX_GAZEPOINTDATAPARAMS& params) +{ + + TX_VALIDATE(txCreateGazePointDataBehavior(_hObject, ¶ms)); +} + +/*********************************************************************************************************************/ + +inline void Interactor::CreateActivatableBehavior(const TX_ACTIVATABLEPARAMS& params) +{ + TX_VALIDATE(txCreateActivatableBehavior(_hObject, ¶ms)); +} + +/*********************************************************************************************************************/ + +inline void Interactor::CreatePannableBehavior(const TX_PANNABLEPARAMS& params) +{ + TX_VALIDATE(txCreatePannableBehavior(_hObject, ¶ms)); +} + +/*********************************************************************************************************************/ + +inline void Interactor::CreateGazeAwareBehavior(const TX_GAZEAWAREPARAMS& params) +{ + TX_VALIDATE(txCreateGazeAwareBehavior(_hObject, ¶ms)); +} + +/*********************************************************************************************************************/ + +inline void Interactor::CreateFixationDataBehaviorParams(const TX_FIXATIONDATAPARAMS& params) +{ + TX_VALIDATE(txCreateFixationDataBehavior(_hObject, ¶ms)); +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Interactor::GetBounds() const +{ + TX_HANDLE hBounds; + if (!TX_VALIDATE(txGetInteractorBounds(_hObject, &hBounds), TX_RESULT_NOTFOUND)) + return nullptr; + + return _spContext->CreateObject(hBounds); +} + +/*********************************************************************************************************************/ + +inline std::vector> Interactor::GetBehaviors() const +{ + std::vector behaviorHandles; + TX_VALIDATE(Tx::Utils::GetBufferData(behaviorHandles, txGetInteractorBehaviors, _hObject)); + + std::vector> behaviors; + for(auto& hBehavior : behaviorHandles) + { + auto spBehavior = _spContext->CreateObject(hBehavior); + behaviors.push_back(spBehavior); + } + + return behaviors; +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Interactor::CreateBounds(TX_BOUNDSTYPE boundsType) +{ + Tx::Utils::ScopedHandle hBounds; + TX_VALIDATE(txCreateInteractorBounds(_hObject, &hBounds, boundsType)); + auto spBounds = _spContext->CreateObject(hBounds); + return spBounds; +} + +/*********************************************************************************************************************/ + +inline void Interactor::DeleteBounds() +{ + TX_VALIDATE(txDeleteInteractorBounds(_hObject)); +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Interactor::CreateBehavior(TX_BEHAVIORTYPE behaviorType) +{ + Tx::Utils::ScopedHandle hBehavior; + TX_VALIDATE(txCreateInteractorBehavior(_hObject, &hBehavior, behaviorType)); + auto spBehavior = _spContext->CreateObject(hBehavior); + return spBehavior; +} + +/*********************************************************************************************************************/ + +inline void Interactor::DeleteBehavior(TX_BEHAVIORTYPE behaviorType) +{ + TX_VALIDATE(txRemoveInteractorBehavior(_hObject, behaviorType)); +} + +/*********************************************************************************************************************/ + +inline bool Interactor::TryGetBehavior(std::shared_ptr *pspBehavior, TX_BEHAVIORTYPE behaviorType) const +{ + Tx::Utils::ScopedHandle hBehavior; + if (!TX_VALIDATE(txGetInteractorBehavior(_hObject, &hBehavior, behaviorType), TX_RESULT_NOTFOUND)) + return false; + + *pspBehavior = _spContext->CreateObject(hBehavior); + return true; +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Interactor::CreateMask(TX_MASKTYPE maskType, int columnCount, int rowCount, const TX_BYTE* pData) +{ + Tx::Utils::ScopedHandle hMask; + TX_VALIDATE(txCreateMask(_hObject, &hMask, maskType, columnCount, rowCount, pData)); + auto spMask = _spContext->CreateObject(hMask); + return spMask; +} + +/*********************************************************************************************************************/ + +inline void Interactor::RemoveMask() +{ + TX_VALIDATE(txRemoveMask(_hObject)); +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Interactor::GetMask() const +{ + Tx::Utils::ScopedHandle hMask; + TX_VALIDATE(txGetMask(_hObject, &hMask)); + auto spMask = _spContext->CreateObject(hMask); + return spMask; +} + +/*********************************************************************************************************************/ + +inline void Interactor::SetMaskBounds(const TX_RECT& bounds) +{ + TX_VALIDATE(txSetMaskBounds(_hObject, &bounds)); +} + +/*********************************************************************************************************************/ + +inline void Interactor::ClearMaskBounds() +{ + TX_VALIDATE(txClearMaskBounds(_hObject)); +} + +/*********************************************************************************************************************/ + +inline bool Interactor::TryGetMaskBounds(TX_RECT* pBounds) const +{ + if(!TX_VALIDATE(txGetMaskBounds(_hObject, pBounds), TX_RESULT_NOTFOUND)) + return false; + + return true; +} + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + + /*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_INTERACTOR__INL__) + + /*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Mask.hpp b/Tobii EyeX/include/eyex-cpp/Mask.hpp new file mode 100755 index 0000000..a2b9458 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Mask.hpp @@ -0,0 +1,34 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * Mask.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_MASK__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_MASK__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +class Mask : + public InteractionObject +{ +public: + Mask(const std::shared_ptr& spContext, TX_HANDLE hMask); + int GetColumnCount() const; + int GetRowCount() const; + void GetData(std::vector& data) const; +}; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_MASK__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Mask.inl b/Tobii EyeX/include/eyex-cpp/Mask.inl new file mode 100755 index 0000000..3e7ed2d --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Mask.inl @@ -0,0 +1,58 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * Mask.inl + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_MASK__INL__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_MASK__INL__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +inline Mask::Mask(const std::shared_ptr& spContext, TX_HANDLE hMask) +: InteractionObject(spContext, hMask) +{ } + +/*********************************************************************************************************************/ + +inline int Mask::GetColumnCount() const +{ + int columnCount, rowCount; + TX_VALIDATE(txGetMaskData(_hObject, &columnCount, &rowCount, nullptr, nullptr)); + return columnCount; +} + +/*********************************************************************************************************************/ + +inline int Mask::GetRowCount() const +{ + int columnCount, rowCount; + TX_VALIDATE(txGetMaskData(_hObject, &columnCount, &rowCount, nullptr, nullptr)); + return rowCount; +} + +/*********************************************************************************************************************/ + +inline void Mask::GetData(std::vector& data) const +{ + int columnCount, rowCount, dataSize = 0; + if(TX_VALIDATE(txGetMaskData(_hObject, &columnCount, &rowCount, nullptr, &dataSize))) + return; + + data.resize(dataSize); + TX_VALIDATE(txGetMaskData(_hObject, &columnCount, &rowCount, &data[0], &dataSize)); +} + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_MASK__INL__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Notification.hpp b/Tobii EyeX/include/eyex-cpp/Notification.hpp new file mode 100755 index 0000000..6d342da --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Notification.hpp @@ -0,0 +1,34 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * Notification.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Notification__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_Notification__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +class Notification : + public InteractionObject +{ +public: + Notification(const std::shared_ptr& spContext, TX_HANDLE hNotification); + + TX_NOTIFICATIONTYPE GetNotificationType() const; + std::shared_ptr GetData() const; +}; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Notification__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Notification.inl b/Tobii EyeX/include/eyex-cpp/Notification.inl new file mode 100755 index 0000000..180fcd2 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Notification.inl @@ -0,0 +1,49 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * Notification.inl + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Notification__INL__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_Notification__INL__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +inline Notification::Notification(const std::shared_ptr& spContext, TX_HANDLE hNotification) +: InteractionObject(spContext, hNotification) +{ } + +/*********************************************************************************************************************/ + +inline TX_NOTIFICATIONTYPE Notification::GetNotificationType() const +{ + TX_NOTIFICATIONTYPE notificationType; + TX_VALIDATE(txGetNotificationType(_hObject, ¬ificationType)); + return notificationType; +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Notification::GetData() const +{ + Tx::Utils::ScopedHandle hData; + if(!TX_VALIDATE(txGetNotificationData(_hObject, &hData), TX_RESULT_NOTFOUND)) + return nullptr; + + auto spData = _spContext->CreateObject(hData); + return spData; +} + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Notification__INL__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Property.cpp b/Tobii EyeX/include/eyex-cpp/Property.cpp new file mode 100755 index 0000000..b5da8af --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Property.cpp @@ -0,0 +1,19 @@ +//--------------------------------------------------------------------------------------------------------------------- +// Property.cpp +//--------------------------------------------------------------------------------------------------------------------- + +#include "Precompiled.hpp" +#include "Property.hpp" +#include "InteractionContext.hpp" + +//--------------------------------------------------------------------------------------------------------------------- + +TOBIIGAZE_NAMESPACE_BEGIN + +//--------------------------------------------------------------------------------------------------------------------- + +//--------------------------------------------------------------------------------------------------------------------- + +TOBIIGAZE_NAMESPACE_END + +//--------------------------------------------------------------------------------------------------------------------- diff --git a/Tobii EyeX/include/eyex-cpp/Property.hpp b/Tobii EyeX/include/eyex-cpp/Property.hpp new file mode 100755 index 0000000..2ff87c0 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Property.hpp @@ -0,0 +1,46 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * Property.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_PROPERTY__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_PROPERTY__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +class Property : + public HandleWrapper +{ +public: + Property(const std::shared_ptr& spContext, TX_PROPERTYHANDLE hProperty); + + TX_PROPERTYVALUETYPE GetValueType() const; + std::string GetName() const; + TX_PROPERTYFLAGS GetFlags() const; + + void Clear(); + + template + bool TryGetValue(TValue* pValue) const; + + template + typename PropertyValueResolver::ValueType GetValue() const; + + template + void SetValue(const TValue& value); +}; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_PROPERTY__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Property.inl b/Tobii EyeX/include/eyex-cpp/Property.inl new file mode 100755 index 0000000..9469af4 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Property.inl @@ -0,0 +1,90 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * Property.inl + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_PROPERTY__INL__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_PROPERTY__INL__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +template +bool Property::TryGetValue(TValue* pValue) const +{ + if(PropertyValueResolver().GetValue(this, pValue) == TX_RESULT_OK) + return true; + + return false; +} + +/*********************************************************************************************************************/ + +template +typename PropertyValueResolver::ValueType Property::GetValue() const +{ + TValue value; + if(TryGetValue(&value)) + return value; + + throw APIException(TX_RESULT_INVALIDPROPERTYTYPE, "Invalid property type"); +} + +/*********************************************************************************************************************/ + +template +void Property::SetValue(const TValue& value) +{ + TX_VALIDATE(PropertyValueResolver().SetValue(this, value)); +} + +/*********************************************************************************************************************/ + +inline Property::Property(const std::shared_ptr& spContext, TX_PROPERTYHANDLE hProperty) +: HandleWrapper(spContext, hProperty) +{} + +/*********************************************************************************************************************/ + +inline TX_PROPERTYVALUETYPE Property::GetValueType() const +{ + TX_PROPERTYVALUETYPE valueType; + TX_VALIDATE(txGetPropertyValueType(_hObject, &valueType)); + return valueType; +} + +/*********************************************************************************************************************/ + +inline std::string Property::GetName() const +{ + return GetString(txGetPropertyName, _hObject); +} + +/*********************************************************************************************************************/ + +inline TX_PROPERTYFLAGS Property::GetFlags() const +{ + TX_PROPERTYFLAGS flags; + TX_VALIDATE(txGetPropertyFlags(_hObject, &flags)); + return flags; +} + +/*********************************************************************************************************************/ + +inline void Property::Clear() +{ + TX_VALIDATE(txClearPropertyValue(_hObject)); +} + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_PROPERTY__INL__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/PropertyBag.hpp b/Tobii EyeX/include/eyex-cpp/PropertyBag.hpp new file mode 100755 index 0000000..045c939 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/PropertyBag.hpp @@ -0,0 +1,32 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * PropertyBag.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_PROPERTYBAG__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_PROPERTYBAG__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +class PropertyBag : + public InteractionObject +{ +public: + PropertyBag(const std::shared_ptr& spContext, TX_HANDLE hBag); + + TX_PROPERTYBAGTYPE GetType() const; +}; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_PROPERTYBAG__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/PropertyBag.inl b/Tobii EyeX/include/eyex-cpp/PropertyBag.inl new file mode 100755 index 0000000..7b508f2 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/PropertyBag.inl @@ -0,0 +1,36 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * PropertyBag.inl + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_PROPERTYBAG__INL__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_PROPERTYBAG__INL__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +inline PropertyBag::PropertyBag(const std::shared_ptr& spContext, TX_HANDLE hBag) +: InteractionObject(spContext, hBag) +{} + +/*********************************************************************************************************************/ + +inline TX_PROPERTYBAGTYPE PropertyBag::GetType() const +{ + TX_PROPERTYBAGTYPE bagType; + TX_VALIDATE(txGetPropertyBagType(_hObject, &bagType)); + return bagType; +} + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_PROPERTYBAG__INL__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/PropertyValueResolver.hpp b/Tobii EyeX/include/eyex-cpp/PropertyValueResolver.hpp new file mode 100755 index 0000000..87018a7 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/PropertyValueResolver.hpp @@ -0,0 +1,34 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * PropertyValueResolver.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_PROPERTYVALUERESOLVER__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_PROPERTYVALUERESOLVER__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +template +struct PropertyValueResolverBase +{ + typedef TValue ValueType; +}; + +/*********************************************************************************************************************/ + +template +struct PropertyValueResolver; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_PROPERTYVALUERESOLVER__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/PropertyValueResolver.inl b/Tobii EyeX/include/eyex-cpp/PropertyValueResolver.inl new file mode 100755 index 0000000..0bd2a28 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/PropertyValueResolver.inl @@ -0,0 +1,266 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * PropertyValueResolver.inl + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_PROPERTYVALUERESOLVER__INL__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_PROPERTYVALUERESOLVER__INL__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +template +struct PropertyValueResolver : + public PropertyValueResolverBase +{ + TX_RESULT GetValue(const Property* pProperty, TValue* pValue) const + { + return txGetPropertyValueAsInteger(pProperty->GetHandle(), (int*)pValue); + } + + TX_RESULT SetValue(Property* pProperty, TValue value) const + { + return txSetPropertyValueAsInteger(pProperty->GetHandle(), (int)value); + } +}; + +/*********************************************************************************************************************/ + +template <> +struct PropertyValueResolver : + public PropertyValueResolverBase +{ + TX_RESULT GetValue(const Property* pProperty, bool* pValue) const + { + int intValue; + auto result = txGetPropertyValueAsInteger(pProperty->GetHandle(), &intValue); + if(result != TX_RESULT_OK) + return result; + + *pValue = intValue != 0; + return TX_RESULT_OK; + } + + TX_RESULT SetValue(Property* pProperty, bool value) const + { + auto intValue = value ? 1 : 0; + return txSetPropertyValueAsInteger(pProperty->GetHandle(), intValue); + } +}; + +/*********************************************************************************************************************/ + +template <> +struct PropertyValueResolver : + public PropertyValueResolverBase +{ + TX_RESULT GetValue(const Property* pProperty, double* pValue) const + { + return txGetPropertyValueAsReal(pProperty->GetHandle(), pValue); + } + + TX_RESULT SetValue(Property* pProperty, double value) const + { + return txSetPropertyValueAsReal(pProperty->GetHandle(), value); + } +}; + +/*********************************************************************************************************************/ + +template <> +struct PropertyValueResolver : + public PropertyValueResolverBase +{ + TX_RESULT GetValue(const Property* pProperty, float* pValue) const + { + double doubleValue; + auto result = txGetPropertyValueAsReal(pProperty->GetHandle(), &doubleValue); + if(result != TX_RESULT_OK) + return result; + + *pValue = (float)doubleValue; + return TX_RESULT_OK; + } + + TX_RESULT SetValue(Property* pProperty, float value) const + { + return txSetPropertyValueAsReal(pProperty->GetHandle(), value); + } +}; + +/*********************************************************************************************************************/ + +template <> +struct PropertyValueResolver : + public PropertyValueResolverBase +{ + TX_RESULT GetValue(const Property* pProperty, std::string* pValue) const + { + return Tx::Utils::GetString(pValue, txGetPropertyValueAsString, pProperty->GetHandle()); + } + + TX_RESULT SetValue(Property* pProperty, const std::string& value) const + { + return txSetPropertyValueAsString(pProperty->GetHandle(), value.c_str()); + } +}; + +/*********************************************************************************************************************/ + +template +struct PropertyValueResolver> : + public PropertyValueResolverBase> +{ + TX_RESULT GetValue(const Property* pProperty, std::shared_ptr* pspValue) const + { + Tx::Utils::ScopedHandle hObject; + auto result = txGetPropertyValueAsObject(pProperty->GetHandle(), &hObject); + if(result != TX_RESULT_OK) + return result; + + // CreateObject will detach scoped handle. + *pspValue = pProperty->GetContext()->CreateObject(hObject); + return TX_RESULT_OK; + } + + TX_RESULT SetValue(Property* pProperty, const std::shared_ptr& spValue) const + { + return txSetPropertyValueAsObject(pProperty->GetHandle(), spValue->GetHandle()); + } +}; + +/*********************************************************************************************************************/ + +template +struct CompositePropertyValueResolver : + public PropertyValueResolverBase +{ + TX_RESULT GetValue(const Property* pProperty, TValue* pValue) const + { + std::shared_ptr spObject; + if(!pProperty->TryGetValue(&spObject)) + return TX_RESULT_NOTFOUND; + + try + { + return GetContent(spObject, pValue); + } + catch(...) + { + return TX_RESULT_NOTFOUND; + } + + return TX_RESULT_OK; + } + + TX_RESULT SetValue(Property* pProperty, const TX_RECT& value) const + { + try + { + auto spObject = pProperty->GetContext()->CreateBag(); + auto result = SetContent(spObject, value); + if(result != TX_RESULT_OK) + return result; + + pProperty->SetValue(spObject); + } + catch(...) + { + return TX_RESULT_NOTFOUND; + } + + return TX_RESULT_OK; + } + + virtual TX_RESULT GetContent(const std::shared_ptr& spObject, TValue* pValue) const = 0; + virtual TX_RESULT SetContent(const std::shared_ptr& spObject, const TValue& Value) const = 0; +}; + +/*********************************************************************************************************************/ + +template <> +struct PropertyValueResolver : + public CompositePropertyValueResolver +{ + TX_RESULT GetContent(const std::shared_ptr& spObject, ValueType* pValue) const + { + if(spObject->TryGetPropertyValue(&pValue->X, TX_LITERAL_X) && + spObject->TryGetPropertyValue(&pValue->Y, TX_LITERAL_Y) && + spObject->TryGetPropertyValue(&pValue->Width, TX_LITERAL_WIDTH) && + spObject->TryGetPropertyValue(&pValue->Height, TX_LITERAL_HEIGHT)) + return TX_RESULT_OK; + + return TX_RESULT_NOTFOUND; + } + + TX_RESULT SetContent(const std::shared_ptr& spObject, const ValueType& value) const + { + spObject->SetPropertyValue(TX_LITERAL_X, value.X); + spObject->SetPropertyValue(TX_LITERAL_Y, value.Y); + spObject->SetPropertyValue(TX_LITERAL_WIDTH, value.Width); + spObject->SetPropertyValue(TX_LITERAL_HEIGHT, value.Height); + + return TX_RESULT_OK; + } +}; + +/*********************************************************************************************************************/ + +template <> +struct PropertyValueResolver : + public CompositePropertyValueResolver +{ + TX_RESULT GetContent(const std::shared_ptr& spObject, ValueType* pValue) const + { + if(spObject->TryGetPropertyValue(&pValue->X, TX_LITERAL_X) && + spObject->TryGetPropertyValue(&pValue->Y, TX_LITERAL_Y)) + return TX_RESULT_OK; + + return TX_RESULT_NOTFOUND; + } + + TX_RESULT SetContent(const std::shared_ptr& spObject, const ValueType& value) const + { + spObject->SetPropertyValue(TX_LITERAL_X, value.X); + spObject->SetPropertyValue(TX_LITERAL_Y, value.Y); + + return TX_RESULT_OK; + } +}; + +/*********************************************************************************************************************/ + +template <> +struct PropertyValueResolver : + public CompositePropertyValueResolver +{ + TX_RESULT GetContent(const std::shared_ptr& spObject, ValueType* pValue) const + { + if(spObject->TryGetPropertyValue(&pValue->Width, TX_LITERAL_WIDTH) && + spObject->TryGetPropertyValue(&pValue->Height, TX_LITERAL_HEIGHT)) + return TX_RESULT_OK; + + return TX_RESULT_NOTFOUND; + } + + TX_RESULT SetContent(const std::shared_ptr& spObject, const ValueType& value) const + { + spObject->SetPropertyValue(TX_LITERAL_WIDTH, value.Width); + spObject->SetPropertyValue(TX_LITERAL_HEIGHT, value.Height); + + return TX_RESULT_OK; + } +}; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_PROPERTYVALUERESOLVER__INL__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Query.hpp b/Tobii EyeX/include/eyex-cpp/Query.hpp new file mode 100755 index 0000000..6420fd2 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Query.hpp @@ -0,0 +1,34 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * Query.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Query__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_Query__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +class Query : + public InteractionObject +{ +public: + Query(const std::shared_ptr& spContext, TX_HANDLE hQuery); + + std::shared_ptr GetBounds() const; + std::vector GetWindowIds() const; +}; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Query__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Query.inl b/Tobii EyeX/include/eyex-cpp/Query.inl new file mode 100755 index 0000000..9b6c2e7 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Query.inl @@ -0,0 +1,58 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * Query.inl + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Query__INL__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_Query__INL__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +inline Query::Query(const std::shared_ptr& spContext, TX_HANDLE hQuery) +: InteractionObject(spContext, hQuery) +{} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Query::GetBounds() const +{ + Tx::Utils::ScopedHandle hBounds; + TX_VALIDATE(txGetQueryBounds(_hObject, &hBounds)); + auto spBounds = _spContext->CreateObject(hBounds); + return spBounds; +} + +/*********************************************************************************************************************/ + +inline std::vector Query::GetWindowIds() const +{ + TX_SIZE windowIdCount; + TX_VALIDATE(txGetQueryWindowIdCount(_hObject, &windowIdCount)); + + std::vector windowIds; + for (int i = 0; i < windowIdCount; i++) + { + std::string windowId; + TX_VALIDATE(Tx::Utils::GetString(&windowId, [i, this](TX_CHAR* pBuf, TX_SIZE* pSize) + { + return txGetQueryWindowId(_hObject, i, pBuf, pSize); + })); + + windowIds.push_back(windowId); + } + return windowIds; +} + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Query__INL__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Snapshot.hpp b/Tobii EyeX/include/eyex-cpp/Snapshot.hpp new file mode 100755 index 0000000..1b1befb --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Snapshot.hpp @@ -0,0 +1,53 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * Snapshot.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Snapshot__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_Snapshot__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +class Snapshot : + public InteractionObject +{ +public: + Snapshot(const std::shared_ptr& spContext, TX_HANDLE hSnapshot); + static std::shared_ptr CreateSnapshotForQuery(const std::shared_ptr& spQuery); + static std::shared_ptr CreateSnapshotWithQueryBounds(const std::shared_ptr& spQuery); + + + std::shared_ptr GetBounds() const; + std::shared_ptr CreateBounds(TX_BOUNDSTYPE boundsType); + void SetBoundsFromQuery(); + void DeleteBounds(); + + std::vector> GetInteractors() const; + + std::shared_ptr CreateInteractor( + const std::string& interactorId, + const std::string& parentId, + const std::string& windowId); + + void RemoveInteractor(const std::string& interactorId); + + std::vector GetWindowIds(); + void AddWindowId(const std::string& windowId); + + void CommitAsync(AsyncDataHandler fnHandler) const; +}; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Snapshot__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/Snapshot.inl b/Tobii EyeX/include/eyex-cpp/Snapshot.inl new file mode 100755 index 0000000..553d00e --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/Snapshot.inl @@ -0,0 +1,159 @@ +/********************************************************************************************************************* +* Copyright 2013-2014 Tobii Technology AB. All rights reserved. +* Snapshot.inl +*********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Snapshot__INL__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_Snapshot__INL__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + + inline Snapshot::Snapshot(const std::shared_ptr& spContext, TX_HANDLE hSnapshot) + : InteractionObject(spContext, hSnapshot) +{} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Snapshot::CreateSnapshotForQuery(const std::shared_ptr& spQuery) +{ + Tx::Utils::ScopedHandle hSnapshot; + TX_VALIDATE(txCreateSnapshotForQuery(spQuery->GetHandle(), &hSnapshot)); + + auto spContext = spQuery->GetContext(); + auto spSnapshot = spContext->CreateObject(hSnapshot); + return spSnapshot; +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Snapshot::CreateSnapshotWithQueryBounds(const std::shared_ptr& spQuery) +{ + Tx::Utils::ScopedHandle hSnapshot; + TX_VALIDATE(txCreateSnapshotWithQueryBounds(spQuery->GetHandle(), &hSnapshot)); + + auto spContext = spQuery->GetContext(); + auto spSnapshot = spContext->CreateObject(hSnapshot); + return spSnapshot; +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Snapshot::GetBounds() const +{ + Tx::Utils::ScopedHandle hBounds; + if (!TX_VALIDATE(txGetSnapshotBounds(_hObject, &hBounds), TX_RESULT_NOTFOUND)) + return nullptr; + + auto spBounds = _spContext->CreateObject(hBounds); + return spBounds; +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Snapshot::CreateBounds(TX_BOUNDSTYPE boundsType) +{ + Tx::Utils::ScopedHandle hBounds; + TX_VALIDATE(txCreateSnapshotBounds(_hObject, &hBounds, boundsType)); + auto spBounds = _spContext->CreateObject(hBounds); + return spBounds; +} + +/*********************************************************************************************************************/ + +inline void Snapshot::DeleteBounds() +{ + TX_VALIDATE(txDeleteSnapshotBounds(_hObject)); +} + +/*********************************************************************************************************************/ + +inline std::vector> Snapshot::GetInteractors() const +{ + std::vector interactorHandles; + TX_VALIDATE(Tx::Utils::GetBufferData(interactorHandles, txGetInteractors, _hObject)); + + std::vector> interactors; + for(auto& hInteractor : interactorHandles) + { + auto spInteractor = _spContext->CreateObject(hInteractor); + interactors.push_back(spInteractor); + } + + return interactors; +} + +/*********************************************************************************************************************/ + +inline std::shared_ptr Snapshot::CreateInteractor( + const std::string& interactorId, + const std::string& parentId, + const std::string& windowId) +{ + Tx::Utils::ScopedHandle hInteractor; + TX_VALIDATE(txCreateInteractor(_hObject, &hInteractor, interactorId.c_str(), parentId.c_str(), windowId.c_str())); + auto spInteractor = _spContext->CreateObject(hInteractor); + return spInteractor; +} + +/*********************************************************************************************************************/ + +inline void Snapshot::RemoveInteractor(const std::string& interactorId) +{ + TX_VALIDATE(txRemoveInteractor(_hObject, interactorId.c_str())); +} + +/*********************************************************************************************************************/ + +inline std::vector Snapshot::GetWindowIds() +{ + int windowIdCount = 0; + TX_VALIDATE(txGetSnapshotWindowIdCount(_hObject, &windowIdCount)); + + std::vector windowIds; + for (int i = 0; i < windowIdCount; i++) + { + std::string windowId; + TX_VALIDATE(Tx::Utils::GetString(&windowId, [i, this](TX_CHAR* pBuf, TX_SIZE* pSize) + { + return txGetSnapshotWindowId(_hObject, i, pBuf, pSize); + })); + + windowIds.push_back(windowId); + } + + return windowIds; +} + +/*********************************************************************************************************************/ + +inline void Snapshot::AddWindowId(const std::string& windowId) +{ + TX_VALIDATE(txAddSnapshotWindowId(_hObject, windowId.c_str())); +} + +/*********************************************************************************************************************/ + +inline void Snapshot::CommitAsync(AsyncDataHandler fnHandler) const +{ + auto spThis = shared_from_this(); + auto fnProxy = [&, spThis, fnHandler](TX_CONSTHANDLE hAsyncData) + { + GetContext()->InvokeAsyncDataHandler(hAsyncData, fnHandler); + }; + + TX_VALIDATE(Tx::CommitSnapshotAsync(_hObject, fnProxy)); +} + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_Snapshot__INL__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/StateBag.hpp b/Tobii EyeX/include/eyex-cpp/StateBag.hpp new file mode 100755 index 0000000..3b663ba --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/StateBag.hpp @@ -0,0 +1,44 @@ +/********************************************************************************************************************* + * Copyright 2013-2014 Tobii Technology AB. All rights reserved. + * StateBag.hpp + *********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_STATEBAG__HPP__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_STATEBAG__HPP__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +class StateBag : + public InteractionObject +{ +public: + StateBag(const std::shared_ptr& spContext, TX_HANDLE hBag); + + std::string GetStatePath() const; + + template + bool TryGetStateValue(TValue* pValue, const std::string& valuePath) const; + + template + void SetStateValue(const std::string& valuePath, const TValue& value); + + void SetAsync(AsyncDataHandler fnCompletion = nullptr); + +private: + bool TryGetPropertyForStateValue(std::shared_ptr* pspProperty, const std::string& valuePath, bool createIfNotExists) const; +}; + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_STATEBAG__HPP__) + +/*********************************************************************************************************************/ diff --git a/Tobii EyeX/include/eyex-cpp/StateBag.inl b/Tobii EyeX/include/eyex-cpp/StateBag.inl new file mode 100755 index 0000000..83e054a --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/StateBag.inl @@ -0,0 +1,82 @@ +/********************************************************************************************************************* +* Copyright 2013-2014 Tobii Technology AB. All rights reserved. +* StateBag.inl +*********************************************************************************************************************/ + +#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_STATEBAG__INL__) +#define __TOBII_TX_CLIENT_CPPBINDINGS_STATEBAG__INL__ + +/*********************************************************************************************************************/ + +TX_NAMESPACE_BEGIN + +/*********************************************************************************************************************/ + +inline StateBag::StateBag(const std::shared_ptr& spContext, TX_HANDLE hBag) + : InteractionObject(spContext, hBag) +{} + +/*********************************************************************************************************************/ + +inline std::string StateBag::GetStatePath() const +{ + return GetString(txGetStateBagPath, _hObject); +} + +/*********************************************************************************************************************/ + +template +inline bool StateBag::TryGetStateValue(TValue* pValue, const std::string& valuePath) const +{ + std::shared_ptr spProperty; + if(!TryGetPropertyForStateValue(&spProperty, valuePath, false)) + return false; + + return spProperty->TryGetValue(pValue); +} + +/*********************************************************************************************************************/ + +template +inline void StateBag::SetStateValue(const std::string& valuePath, const TValue& value) +{ + std::shared_ptr spProperty; + TryGetPropertyForStateValue(&spProperty, valuePath, true); + spProperty->SetValue(value); +} + +/*********************************************************************************************************************/ + +inline void StateBag::SetAsync(AsyncDataHandler fnCompletion) +{ + auto spThis = shared_from_this(); + + auto callback = [&, spThis, fnCompletion](TX_CONSTHANDLE hAsyncData) + { + GetContext()->InvokeAsyncDataHandler(hAsyncData, fnCompletion); + }; + + TX_VALIDATE(Tx::SetStateAsync(GetHandle(), callback)); +} + +/*********************************************************************************************************************/ + +inline bool StateBag::TryGetPropertyForStateValue(std::shared_ptr* pspProperty, const std::string& valuePath, bool createIfNotExists) const +{ + TX_PROPERTYHANDLE hProperty; + if (!TX_VALIDATE(txGetPropertyForStateValue(_hObject, &hProperty, valuePath.c_str(), createIfNotExists ? TX_TRUE : TX_FALSE), TX_RESULT_NOTFOUND)) + return false; + + *pspProperty = _spContext->CreateProperty(hProperty); + return true; +} + +/*********************************************************************************************************************/ + +TX_NAMESPACE_END + +/*********************************************************************************************************************/ + +#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_STATEBAG__INL__) + +/*********************************************************************************************************************/ -- cgit v1.2.3