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/Snapshot.inl | 159 +++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100755 Tobii EyeX/include/eyex-cpp/Snapshot.inl (limited to 'Tobii EyeX/include/eyex-cpp/Snapshot.inl') 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__) + +/*********************************************************************************************************************/ -- cgit v1.2.3