From 72c46bdd7f5d430ab1ad1d420ed77c7f22df857a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 30 Sep 2017 15:01:35 +0200 Subject: rename --- Tobii-EyeX/include/eyex-cpp/StateBag.inl | 82 ++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 Tobii-EyeX/include/eyex-cpp/StateBag.inl (limited to 'Tobii-EyeX/include/eyex-cpp/StateBag.inl') 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