query_plugins.h
Go to the documentation of this file.
1 
7 #ifndef QUERY_PLUGINS_H
8 #define QUERY_PLUGINS_H
9 
10 #include <argos3/core/utility/plugins/factory.h>
11 #include <argos3/core/utility/logging/argos_log.h>
12 
13 #include <map>
14 #include <vector>
15 #include <string>
16 
17 namespace argos {
18 
19  /****************************************/
20  /****************************************/
21 
23  std::string Label;
24  std::string Author;
25  std::string Version;
26  std::string BriefDescription;
27  std::string LongDescription;
28  std::string Status;
29 
30  SQueryResultItem(std::string str_label,
31  std::string str_author,
32  std::string str_version,
33  std::string str_brief_description,
34  std::string str_long_description,
35  std::string str_status) :
36  Label(str_label),
37  Author(str_author),
38  Version(str_version),
39  BriefDescription(str_brief_description),
40  LongDescription(str_long_description),
41  Status(str_status) {}
42  };
43 
44  typedef std::vector<SQueryResultItem> TQueryResult;
45 
46  /****************************************/
47  /****************************************/
48 
49  void QueryPlugins(const std::string& str_query);
50 
51  /****************************************/
52  /****************************************/
53 
54  void QueryShowPluginDescription(const std::string& str_query);
55 
56  /****************************************/
57  /****************************************/
58 
59  template <class TYPE>
60  void QuerySearchPlugins(const std::string& str_query,
61  TQueryResult& t_result) {
63  for(typename CFactory<TYPE>::TTypeMap::const_iterator it = tTypeMap.begin();
64  it != tTypeMap.end();
65  ++it) {
66  /* If the current plugin name contains the passed query */
67  if(it->first.find(str_query) != std::string::npos) {
68  t_result.push_back(
70  it->first,
71  it->second->Author,
72  it->second->Version,
73  it->second->BriefDescription,
74  it->second->LongDescription,
75  it->second->Status));
76  }
77  }
78  }
79 
80  /****************************************/
81  /****************************************/
82 
83  template <class TYPE>
84  void QueryShowList(const std::string& str_header) {
86  LOG << str_header << std::endl << std::endl;
87  for(typename CFactory<TYPE>::TTypeMap::iterator it = tTypeMap.begin();
88  it != tTypeMap.end();
89  ++it) {
90  LOG << " [ " << it->first << " ]" << std::endl;
91  LOG << " " << it->second->BriefDescription << std::endl << std::endl;
92  }
93  }
94 
95  /****************************************/
96  /****************************************/
97 
98 }
99 
100 #endif
101 
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
void QueryShowList(const std::string &str_header)
Definition: query_plugins.h:84
void QueryPlugins(const std::string &str_query)
void QuerySearchPlugins(const std::string &str_query, TQueryResult &t_result)
Definition: query_plugins.h:60
CARGoSLog LOG(std::cout, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_GREEN))
Definition: argos_log.h:179
void QueryShowPluginDescription(const std::string &str_query)
std::vector< SQueryResultItem > TQueryResult
Definition: query_plugins.h:44
std::string BriefDescription
Definition: query_plugins.h:26
SQueryResultItem(std::string str_label, std::string str_author, std::string str_version, std::string str_brief_description, std::string str_long_description, std::string str_status)
Definition: query_plugins.h:30
std::string LongDescription
Definition: query_plugins.h:27
Basic factory template.
Definition: factory.h:59
static TTypeMap & GetTypeMap()
Creates and returns the TYPE map.
Definition: factory_impl.h:18
std::map< std::string, STypeInfo * > TTypeMap
The map of registered TYPEs.
Definition: factory.h:82