iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ModuleManifest.H
Go to the documentation of this file.
1 /*! @file
2  @author Randolph Voorhies
3  @copyright GNU Public License (GPL v3)
4  @section License
5  @verbatim
6  // ////////////////////////////////////////////////////////////////////////
7  // The iLab Neuromorphic Robotics Toolkit (NRT) //
8  // Copyright 2010-2012 by the University of Southern California (USC) //
9  // and the iLab at USC. //
10  // //
11  // iLab - University of Southern California //
12  // Hedco Neurociences Building, Room HNB-10 //
13  // Los Angeles, Ca 90089-2520 - USA //
14  // //
15  // See http://ilab.usc.edu for information about this project. //
16  // ////////////////////////////////////////////////////////////////////////
17  // This file is part of The iLab Neuromorphic Robotics Toolkit. //
18  // //
19  // The iLab Neuromorphic Robotics Toolkit is free software: you can //
20  // redistribute it and/or modify it under the terms of the GNU General //
21  // Public License as published by the Free Software Foundation, either //
22  // version 3 of the License, or (at your option) any later version. //
23  // //
24  // The iLab Neuromorphic Robotics Toolkit is distributed in the hope //
25  // that it will be useful, but WITHOUT ANY WARRANTY; without even the //
26  // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
27  // PURPOSE. See the GNU General Public License for more details. //
28  // //
29  // You should have received a copy of the GNU General Public License //
30  // along with The iLab Neuromorphic Robotics Toolkit. If not, see //
31  // <http://www.gnu.org/licenses/>. //
32  // ////////////////////////////////////////////////////////////////////////
33  @endverbatim */
34 
35 
36 #ifndef INCLUDE_NRT_CORE_UTIL_MODULEMANIFEST_H
37 #define INCLUDE_NRT_CORE_UTIL_MODULEMANIFEST_H
38 
39 #include <string>
40 #include <vector>
41 #include <nrt/External/cereal/types/string.hpp>
42 #include <nrt/External/cereal/types/vector.hpp>
43 #include <nrt/Core/Typing/Enum.H>
44 
45 /*! \defgroup manifest Module, Macro-Module, and Network meta-data (anifest) information
46  \ingroup util */
47 
48 namespace nrt
49 {
50  //! Enum for the manifest type
51  /*! \ingroup manifest */
52  NRT_DEFINE_ENUM_CLASS(ManifestType, (Module) (MacroModule) (Network));
53 
54  //! Encapsulates the manifest meta-information about an NRT Module
55  /*! \ingroup manifest */
57  {
58  struct subscriberportdescription
59  {
60  std::string name;
61  std::string inmsg;
62  std::string retmsg;
63  std::string description;
64 
65  template <class Archive>
66  void serialize(Archive & ar)
67  { ar( name, inmsg, retmsg, description ); }
68  };
69 
70  struct checkerportdescription
71  {
72  std::string name;
73  std::string msg;
74  std::string description;
75 
76  template <class Archive>
77  void serialize(Archive & ar)
78  { ar( name, msg, description ); }
79  };
80 
81  struct posterportdescription
82  {
83  std::string name;
84  std::string outmsg;
85  std::string retmsg;
86  std::string description;
87 
88  template <class Archive>
89  void serialize(Archive & ar)
90  { ar( name, outmsg, retmsg, description ); }
91  };
92 
93  // General
94  struct general_t
95  {
96  ManifestType type;
97  std::string displayname;
98  std::string classname; // class name or macro-module name
99  std::vector<std::string> category;
100  std::string synopsis;
101  std::string description;
102  std::vector<std::string> keywords;
103  std::vector<subscriberportdescription> subscriberports;
104  std::vector<checkerportdescription> checkerports;
105  std::vector<posterportdescription> posterports;
106 
107  template <class Archive>
108  void serialize(Archive & ar)
109  {
110  ar(type, displayname, classname, category, synopsis, description, keywords,
111  subscriberports, checkerports, posterports);
112  }
113  } general;
114 
115  // Authorship
116  struct authorship_t
117  {
118  std::string author;
119  std::string email;
120  std::string mainurl;
121  std::string supporturl;
122  std::string otherurl;
123  std::string address;
124 
125  template <class Archive>
126  void serialize(Archive & ar)
127  { ar( author, email, mainurl, supporturl, otherurl, address ); }
128  } authorship;
129 
130  // Licensing
131  struct licensing_t
132  {
133  std::string version;
134  std::string copyright;
135  std::string license;
136  std::string distribution;
137  std::string restrictions;
138 
139  template <class Archive>
140  void serialize(Archive & ar)
141  { ar( version, copyright, license, distribution, restrictions ); }
142  } licensing;
143 
144  // Files
145  struct files_t
146  {
147  std::string icon;
148  std::string screenshots;
149  std::string videos;
150  std::string objectfile;
151  std::string docfiles;
152  std::string examples;
153 
154  template <class Archive>
155  void serialize(Archive & ar)
156  { ar( icon, screenshots, videos, objectfile, docfiles, examples ); }
157  } files;
158 
159  // NRT
160  struct nrt_t
161  {
162  std::string package;
163  std::string nrtversion;
164  std::string arch;
165  std::string locale;
166 
167  template <class Archive>
168  void serialize(Archive & ar)
169  { ar( package, nrtversion, arch, locale ); }
170  } nrt;
171 
172  // OS
173  struct os_t
174  {
175  std::string name;
176  std::string version;
177  std::string depends;
178 
179  template <class Archive>
180  void serialize(Archive & ar)
181  { ar( name, version, depends ); }
182  } os;
183 
184  template <class Archive>
185  void serialize(Archive & ar)
186  { ar( general, authorship, licensing, files, nrt, os ); }
187  };
188 
189  //! Create a manifest where some fields are populated from the NRTAUTHOR environment variable
190  /*! \relates ModuleManifest */
191  ModuleManifest createManifestFromEnv();
192 
193  //! Pseudo-constructor that loads a module manifest from file
194  /*! \relates ModuleManifest */
195  ModuleManifest readManifest(std::string const & filename);
196 
197  //! Save a module manifest to file
198  /*! \relates ModuleManifest */
199  void writeManifest(std::string const & filename, nrt::ModuleManifest const & manifest);
200 }
201 
202 #endif // INCLUDE_NRT_CORE_UTIL_MODULEMANIFEST_H
203