24#ifndef __DOTS_INTERNAL_TYPE_UTILITIES_H__
25#define __DOTS_INTERNAL_TYPE_UTILITIES_H__
27#include <Safir/Dob/Typesystem/ToolSupport/Internal/BasicTypeOperations.h>
40namespace TypeUtilities
49 return LlufId_Generate64(name.c_str());
60 return Safir::Dob::Typesystem::ToolSupport::Internal::BasicTypeOperations::MemberTypeToString(memberType).c_str();
70 template <
class RepositoryT>
71 const char*
GetTypeName(
const RepositoryT* repository, DotsC_TypeId typeId)
73 return Safir::Dob::Typesystem::ToolSupport::Internal::BasicTypeOperations::TypeIdToTypeName(repository, typeId);
83 template <
class RepositoryT,
class DescriptionT>
84 const char*
GetTypeName(
const RepositoryT* repository,
const DescriptionT* member)
86 DotsC_MemberType mt=member->GetMemberType();
87 if (mt==EnumerationMemberType || mt==ObjectMemberType)
89 return GetTypeName(repository, member->GetTypeId());
102 template <
class RepositoryT>
103 bool IsOfType(
const RepositoryT* repository, DotsC_TypeId tid, DotsC_TypeId ofTid)
109 return Safir::Dob::Typesystem::ToolSupport::Internal::BasicTypeOperations::IsOfType(repository, ObjectMemberType, tid, ObjectMemberType, ofTid);
119 template <
class EnumDescriptionT>
122 size_t pos=valueName.rfind(
'.');
123 if (pos==std::string::npos)
125 for (
int i=0; i<description->GetNumberOfValues(); ++i)
127 if (valueName==description->GetValueName(i))
135 std::string strippedValueName=valueName.substr(pos+1);
136 for (
int i=0; i<description->GetNumberOfValues(); ++i)
138 if (strippedValueName==description->GetValueName(i))
154 template <
class PropertyDescriptionT,
class MemberDescriptionT>
157 for (
int i=0; i<pd->GetNumberOfMembers(); ++i)
159 const MemberDescriptionT* md=pd->GetMember(i);
160 if (memberName==md->GetName())
162 return static_cast<DotsC_MemberIndex
>(i);
176 template <
class ClassDescriptionT,
class ParameterDescriptionT>
177 const ParameterDescriptionT*
GetParameterByName(
const ClassDescriptionT* cd,
const std::string& paramName)
179 size_t dot=paramName.rfind(
'.');
180 if (dot==std::string::npos)
182 for (
int i=0; i<cd->GetNumberOfParameters(); ++i)
184 const ParameterDescriptionT* pd=cd->GetParameter(i);
185 if (paramName==pd->GetName())
193 std::string shortName=paramName.substr(dot+1);
194 for (
int i=0; i<cd->GetNumberOfParameters(); ++i)
196 const ParameterDescriptionT* pd=cd->GetParameter(i);
197 if (shortName==pd->GetName())
209 template <
class RepT,
class Traits=Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepT> >
224 size_t pos=parameterName.rfind(
'.');
225 if (pos==std::string::npos)
230 std::string className=parameterName.substr(0, pos);
237 return GetParameterByName<ClassDescriptionType, ParameterDescriptionType>(cd, parameterName.substr(pos+1));
251 std::ostringstream os;
252 os<<key.typeId<<key.instanceId;
253 return LlufId_Generate64(os.str().c_str());
256 template <
class ParameterDescriptionT,
class KeyT>
259 assert(pd->GetCollectionType()==DictionaryCollectionType);
This namespace contains all the functionality and definitions of the SAFIR SDK.
Definition Backdoor.h:31
bool IsOfType(const RepositoryT *repository, DotsC_TypeId tid, DotsC_TypeId ofTid)
Check if a type is the same or a subtype of another type.
Definition TypeUtilities.h:103
DotsC_MemberIndex GetPropertyMemberIndex(const PropertyDescriptionT *pd, const std::string &memberName)
Get index of a property member.
Definition TypeUtilities.h:155
int GetIndexOfEnumValue(const EnumDescriptionT *description, const std::string &valueName)
Get the index (ordinal) of an enumeration value.
Definition TypeUtilities.h:120
DotsC_Int64 ToUnifiedDictionaryKey(DotsC_Int64 key)
ToUnifiedDictionaryKey - Convert all keys to an int64 that is the internal key format.
Definition TypeUtilities.h:246
DotsC_TypeId CalculateTypeId(const std::string &name)
Calculates a typeId from a string.
Definition TypeUtilities.h:47
const ParameterDescriptionT * GetParameterByName(const ClassDescriptionT *cd, const std::string ¶mName)
Get parameter by name when the classDescription is already retrieved.
Definition TypeUtilities.h:177
const char * GetTypeName(DotsC_MemberType memberType)
Finds corresponding type name to a memberType.
Definition TypeUtilities.h:58
int GetDictionaryIndexFromKey(const ParameterDescriptionT *pd, const KeyT &key)
Definition TypeUtilities.h:257
Helper class to get ParameterDescription from a fully qualified name without having the ClassDescript...
Definition TypeUtilities.h:211
Traits::ParameterDescriptionType ParameterDescriptionType
Definition TypeUtilities.h:214
Traits::ClassDescriptionType ClassDescriptionType
Definition TypeUtilities.h:213
const ParameterDescriptionType * operator()(const RepositoryType *rep, const std::string ¶meterName) const
Get ParameterDescription from a fully qualified name.
Definition TypeUtilities.h:222
Traits::RepositoryType RepositoryType
Definition TypeUtilities.h:212