OpenWalnut
1.5.0dev
|
A class abstracting module meta information. More...
#include <WModuleMetaInformation.h>
Classes | |
struct | Author |
Structure to contain all supported author information. More... | |
struct | Online |
Structure to encapsulate the META info online resources. More... | |
struct | Screenshot |
Structure to encapsulate a screenshot info. More... | |
Public Types | |
typedef std::shared_ptr< WModuleMetaInformation > | SPtr |
Convenience typedef for a std::shared_ptr< WModuleMetaInformation >. More... | |
typedef std::shared_ptr< const WModuleMetaInformation > | ConstSPtr |
Convenience typedef for a std::shared_ptr< const WModuleMetaInformation >. More... | |
Public Member Functions | |
WModuleMetaInformation (std::string name) | |
Constructor. More... | |
WModuleMetaInformation (std::shared_ptr< WModule > module) | |
Construct a meta info object that loads all information from the specified file. More... | |
virtual | ~WModuleMetaInformation () |
Destructor. More... | |
std::string | getName () const |
The name of the module. More... | |
boost::filesystem::path | getIcon () const |
Get the icon path. More... | |
bool | isIconAvailable () const |
Check whether the meta info contained an icon. More... | |
std::string | getWebsite () const |
The URL to a module website. More... | |
std::string | getDescription () const |
A module description. More... | |
boost::filesystem::path | getHelp () const |
Path to a text or HTML file containing some module help. More... | |
std::vector< Author > | getAuthors () const |
A list of authors. More... | |
std::vector< Online > | getOnlineResources () const |
A list of online resources. More... | |
std::vector< std::string > | getTags () const |
A list of tags provided for the module. More... | |
std::vector< Screenshot > | getScreenshots () const |
Returns the list of screenshots. More... | |
template<typename ResultType > | |
ResultType | query (std::string path, ResultType defaultValue=ResultType()) const |
Query a value from the META file. More... | |
template<typename ResultType > | |
std::vector< ResultType > | query (std::string path, const std::vector< ResultType > &defaultValues) const |
Query multiple values from the META file. More... | |
bool | valueExists (std::string path) const |
Check whether the value specified by "path" exists. More... | |
Private Attributes | |
std::string | m_name |
The name of the module providing this meta information. More... | |
std::string | m_description |
The default description if none was specified in the META file. More... | |
WStructuredTextParser::StructuredValueTree | m_metaData |
The tree representing the data. More... | |
bool | m_loaded |
If true, m_metaData should be queried in all getters. More... | |
boost::filesystem::path | m_localPath |
The module local path. More... | |
A class abstracting module meta information.
It encapsulates module name, description, icon, author lists, help resources, online resources and much more. It is guaranteed to, at least, provide a module name. Everything else is optional. It also encapsulates the WStructuredTextParser class for loading the data.
Definition at line 43 of file WModuleMetaInformation.h.
typedef std::shared_ptr< const WModuleMetaInformation > WModuleMetaInformation::ConstSPtr |
Convenience typedef for a std::shared_ptr< const WModuleMetaInformation >.
Definition at line 54 of file WModuleMetaInformation.h.
typedef std::shared_ptr< WModuleMetaInformation > WModuleMetaInformation::SPtr |
Convenience typedef for a std::shared_ptr< WModuleMetaInformation >.
Definition at line 49 of file WModuleMetaInformation.h.
|
explicit |
Constructor.
The help object will be empty, meaning there is no further meta info available. The name is the only required value. Of course, this is of limited use in most cases.
name | the name of the module |
Definition at line 36 of file WModuleMetaInformation.cpp.
|
explicit |
Construct a meta info object that loads all information from the specified file.
If the file exist and could not be parsed, only an error log is printed. No exception is thrown.
module | The module to load the meta file for. |
Definition at line 43 of file WModuleMetaInformation.cpp.
References wlog::error(), m_loaded, m_metaData, m_name, and WException::what().
|
virtual |
std::vector< WModuleMetaInformation::Author > WModuleMetaInformation::getAuthors | ( | ) | const |
A list of authors.
If the META file did not contain any author information, this returns the OpenWalnut Team as author.
Definition at line 144 of file WModuleMetaInformation.cpp.
References m_loaded, m_metaData, and m_name.
std::string WModuleMetaInformation::getDescription | ( | ) | const |
A module description.
Can be empty but is initialized with the description of the module given on construction.
Definition at line 120 of file WModuleMetaInformation.cpp.
References m_description, m_loaded, m_metaData, and m_name.
boost::filesystem::path WModuleMetaInformation::getHelp | ( | ) | const |
Path to a text or HTML file containing some module help.
Can be invalid. Check for existence before opening.
Definition at line 132 of file WModuleMetaInformation.cpp.
References m_loaded, m_localPath, m_metaData, and m_name.
boost::filesystem::path WModuleMetaInformation::getIcon | ( | ) | const |
Get the icon path.
Can be invalid. Check for existence before opening.
Definition at line 84 of file WModuleMetaInformation.cpp.
References m_loaded, m_localPath, m_metaData, and m_name.
std::string WModuleMetaInformation::getName | ( | ) | const |
The name of the module.
Will always return the name of the module given on construction.
Definition at line 79 of file WModuleMetaInformation.cpp.
References m_name.
std::vector< WModuleMetaInformation::Online > WModuleMetaInformation::getOnlineResources | ( | ) | const |
A list of online resources.
Can be empty.
Definition at line 181 of file WModuleMetaInformation.cpp.
References WModuleMetaInformation::Online::m_description, m_loaded, m_metaData, WModuleMetaInformation::Online::m_name, m_name, and WModuleMetaInformation::Online::m_url.
std::vector< WModuleMetaInformation::Screenshot > WModuleMetaInformation::getScreenshots | ( | ) | const |
Returns the list of screenshots.
Definition at line 229 of file WModuleMetaInformation.cpp.
References WModuleMetaInformation::Screenshot::m_description, WModuleMetaInformation::Screenshot::m_filename, m_loaded, m_metaData, and m_name.
std::vector< std::string > WModuleMetaInformation::getTags | ( | ) | const |
A list of tags provided for the module.
Definition at line 217 of file WModuleMetaInformation.cpp.
References m_loaded, m_metaData, and m_name.
std::string WModuleMetaInformation::getWebsite | ( | ) | const |
The URL to a module website.
Can be empty.
Definition at line 108 of file WModuleMetaInformation.cpp.
References m_loaded, m_metaData, and m_name.
bool WModuleMetaInformation::isIconAvailable | ( | ) | const |
Check whether the meta info contained an icon.
Definition at line 96 of file WModuleMetaInformation.cpp.
References m_loaded, m_metaData, and m_name.
|
inline |
Query multiple values from the META file.
ResultType | the type of the result of the query. The function tries to cast the found value to this type. If this is not possible, the default value will be returned. |
path | the absolute path in the META file. Please be aware that, if you specify a value inside your modules meta block, you need to add the module name too. The path is absolute! |
defaultValues | the default value to return in case of an non-existing element or cast problems. |
WTypeMismatch | if the value cannot be cast to the specified target type |
Definition at line 247 of file WModuleMetaInformation.h.
References m_metaData.
|
inline |
Query a value from the META file.
ResultType | the type of the result of the query. The function tries to cast the found value to this type. If this is not possible, the default value will be returned. |
path | the absolute path in the META file. Please be aware that, if you specify a value inside your modules meta block, you need to add the module name too. The path is absolute! |
defaultValue | the default value to return in case of an non-existing element or cast problems. |
WTypeMismatch | if the value cannot be cast to the specified target type |
Definition at line 227 of file WModuleMetaInformation.h.
References m_metaData.
bool WModuleMetaInformation::valueExists | ( | std::string | path | ) | const |
Check whether the value specified by "path" exists.
path | the absolute path in the META file. Please be aware that, if you specify a value inside your modules meta block, you need to add the module name too. The path is absolute! |
Definition at line 264 of file WModuleMetaInformation.cpp.
References m_loaded, and m_metaData.
|
private |
The default description if none was specified in the META file.
Initialized with the description of the module specified during construction.
Definition at line 274 of file WModuleMetaInformation.h.
Referenced by getDescription().
|
private |
If true, m_metaData should be queried in all getters.
If false, you can query m_meta but it will only tell you that the desired value could not be found.
Definition at line 285 of file WModuleMetaInformation.h.
Referenced by getAuthors(), getDescription(), getHelp(), getIcon(), getOnlineResources(), getScreenshots(), getTags(), getWebsite(), isIconAvailable(), valueExists(), and WModuleMetaInformation().
|
private |
The module local path.
Used for several meta infos returning a path.
Definition at line 290 of file WModuleMetaInformation.h.
|
private |
The tree representing the data.
Definition at line 279 of file WModuleMetaInformation.h.
Referenced by getAuthors(), getDescription(), getHelp(), getIcon(), getOnlineResources(), getScreenshots(), getTags(), getWebsite(), isIconAvailable(), query(), valueExists(), and WModuleMetaInformation().
|
private |
The name of the module providing this meta information.
Definition at line 268 of file WModuleMetaInformation.h.
Referenced by getAuthors(), getDescription(), getHelp(), getIcon(), getName(), getOnlineResources(), getScreenshots(), getTags(), getWebsite(), isIconAvailable(), and WModuleMetaInformation().