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