-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add generation of CGMESProfile class for cpp, add profile URIs and ci…
…m namespace Signed-off-by: Thomas Günther <[email protected]>
- Loading branch information
Showing
7 changed files
with
200 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
cimgen/languages/cpp/templates/cpp_cgmesProfile_header_template.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef CGMESPROFILE_HPP | ||
#define CGMESPROFILE_HPP | ||
/* | ||
Generated from the CGMES files via cimgen: https://github.com/sogno-platform/cimgen | ||
*/ | ||
|
||
#include <list> | ||
#include <string> | ||
|
||
enum class CGMESProfile : unsigned short | ||
{ | ||
{{#profiles}} | ||
{{short_name}}, | ||
{{/profiles}} | ||
}; | ||
|
||
const CGMESProfile UnknownProfile = static_cast<CGMESProfile>(-1); | ||
|
||
const std::list<CGMESProfile>& getProfileList(); | ||
|
||
std::string getProfileShortName(CGMESProfile profile); | ||
std::string getProfileLongName(CGMESProfile profile); | ||
const std::list<std::string>& getProfileURIs(CGMESProfile profile); | ||
|
||
CGMESProfile getProfileFromShortName(const std::string& name); | ||
CGMESProfile getProfileFromLongName(const std::string& name); | ||
|
||
std::string getCimNamespace(); | ||
|
||
#endif // CGMESPROFILE_HPP |
110 changes: 110 additions & 0 deletions
110
cimgen/languages/cpp/templates/cpp_cgmesProfile_object_template.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
Generated from the CGMES files via cimgen: https://github.com/sogno-platform/cimgen | ||
*/ | ||
#include "CGMESProfile.hpp" | ||
|
||
#include <list> | ||
#include <map> | ||
#include <string> | ||
|
||
static const std::list<CGMESProfile> ProfileList = | ||
{ | ||
{{#profiles}} | ||
CGMESProfile::{{short_name}}, | ||
{{/profiles}} | ||
}; | ||
|
||
static const std::map<CGMESProfile, std::string> ProfileShortNames = | ||
{ | ||
{{#profiles}} | ||
{ CGMESProfile::{{short_name}}, "{{short_name}}" }, | ||
{{/profiles}} | ||
}; | ||
|
||
static const std::map<CGMESProfile, std::string> ProfileLongNames = | ||
{ | ||
{{#profiles}} | ||
{ CGMESProfile::{{short_name}}, "{{long_name}}" }, | ||
{{/profiles}} | ||
}; | ||
|
||
static const std::map<CGMESProfile, std::list<std::string>> ProfileURIs = | ||
{ | ||
{{#profiles}} | ||
{ CGMESProfile::{{short_name}}, { {{#uris}}"{{uri}}", {{/uris}}} }, | ||
{{/profiles}} | ||
}; | ||
|
||
static const std::string CimNamespace = "{{cim_namespace}}"; | ||
|
||
const std::list<CGMESProfile>& | ||
getProfileList() | ||
{ | ||
return ProfileList; | ||
} | ||
|
||
std::string | ||
getProfileShortName(CGMESProfile profile) | ||
{ | ||
auto it = ProfileShortNames.find(profile); | ||
if (it != ProfileShortNames.end()) | ||
{ | ||
return it->second; | ||
} | ||
return ""; // unknown profile | ||
} | ||
|
||
std::string | ||
getProfileLongName(CGMESProfile profile) | ||
{ | ||
auto it = ProfileLongNames.find(profile); | ||
if (it != ProfileLongNames.end()) | ||
{ | ||
return it->second; | ||
} | ||
return ""; // unknown profile | ||
} | ||
|
||
const std::list<std::string>& | ||
getProfileURIs(CGMESProfile profile) | ||
{ | ||
static std::list<std::string> empty_list; | ||
auto it = ProfileURIs.find(profile); | ||
if (it != ProfileURIs.end()) | ||
{ | ||
return it->second; | ||
} | ||
return empty_list; // unknown profile | ||
} | ||
|
||
CGMESProfile | ||
getProfileFromShortName(const std::string& name) | ||
{ | ||
for (const auto& profile : ProfileShortNames) | ||
{ | ||
if (name == profile.second) | ||
{ | ||
return profile.first; | ||
} | ||
} | ||
return UnknownProfile; | ||
} | ||
|
||
CGMESProfile | ||
getProfileFromLongName(const std::string& name) | ||
{ | ||
for (const auto& profile : ProfileLongNames) | ||
{ | ||
if (name == profile.second) | ||
{ | ||
return profile.first; | ||
} | ||
} | ||
return UnknownProfile; | ||
} | ||
|
||
std::string | ||
getCimNamespace() | ||
{ | ||
return CimNamespace; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters