diff options
author | Philip Rauwolf <rauwolf@itestra.de> | 2013-02-14 17:27:57 +0100 |
---|---|---|
committer | Philip Rauwolf <rauwolf@itestra.de> | 2013-02-15 09:39:21 +0100 |
commit | ab95ee931881126204372f51c568efbd0334b5c7 (patch) | |
tree | 5f209aa6f7fcde401c3a6cb26b10de1084b36d26 | |
parent | 61b9e08e3b2a1a3eefab7a1407ac91894e96634a (diff) | |
download | genivi-common-api-runtime-ab95ee931881126204372f51c568efbd0334b5c7.tar.gz |
Added generation of hash functions for enumerations in order to make
them usable as key-types within std::unordered_map
3 files changed, 23 insertions, 1 deletions
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceGenerator.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceGenerator.xtend index 58ccee8..09eb019 100644 --- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceGenerator.xtend +++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceGenerator.xtend @@ -64,6 +64,11 @@ class FInterfaceGenerator { «fInterface.generateVariantComparators» } + + + namespace std { + «fInterface.generateHashers» + } #endif // «fInterface.defineName»_H_ ''' diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCollectionGenerator.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCollectionGenerator.xtend index 41c881a..e9ffb28 100644 --- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCollectionGenerator.xtend +++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCollectionGenerator.xtend @@ -63,7 +63,11 @@ class FTypeCollectionGenerator { «fTypeCollection.generateTypeWriters» «fTypeCollection.generateVariantComparators» - + } + + + namespace std { + «fTypeCollection.generateHashers» } #endif // «fTypeCollection.defineName»_H_ diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCommonAreaGenerator.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCommonAreaGenerator.xtend index 2d2ee1a..46b25ed 100644 --- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCommonAreaGenerator.xtend +++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCommonAreaGenerator.xtend @@ -214,4 +214,17 @@ class FTypeCommonAreaGenerator { return baseList } + + def generateHashers(FTypeCollection fTypes) ''' + «FOR type: fTypes.types» + «IF type.isFEnumerationType» + template<> + struct hash<commonapi::tests::DerivedTypeCollection::TestEnum> { + inline size_t operator()(const «type.getClassNamespaceWithName(type.name, fTypes, fTypes.name)»& «type.name.toFirstLower») const { + return static_cast<«type.getFEnumerationType.backingType.primitiveTypeName»>(«type.name.toFirstLower»); + } + }; + «ENDIF» + «ENDFOR» + ''' }
\ No newline at end of file |