00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00031 #ifndef SIMTHETIC_DEVICEMANAGER_H
00032 #define SIMTHETIC_DEVICEMANAGER_H
00033
00034 #include <simthetic/propertylist.h>
00035 #include <simthetic/exceptions.h>
00036 #include <string>
00037
00038 #include <map>
00039
00040 namespace simth {
00041
00042 class DeviceDescriptionPriv;
00043 class DeviceManagerPriv;
00044
00058 class DLLIMPORT DeviceDescription {
00059 friend class DeviceManager;
00060 public:
00061 class IfaceDescr {
00062 public:
00063 IfaceDescr();
00064 IfaceDescr(const std::string& type,
00065 const std::string& description,
00066 const std::string& multiplied_by = "");
00068 std::string type;
00070 std::string description;
00077 std::string multiplied_by;
00078 };
00079 typedef std::vector<IfaceDescr> IfaceList;
00080 private:
00081 DeviceDescriptionPriv *d_ptr;
00082
00083
00084 DeviceDescription(DeviceDescriptionPriv *d_ptr);
00085
00086 public:
00088 DeviceDescription();
00090 DeviceDescription(const DeviceDescription&);
00092 DeviceDescription& operator=(const DeviceDescription&);
00094 ~DeviceDescription();
00095
00097 bool operator==(const DeviceDescription& d) const;
00098
00101 bool operator<(const DeviceDescription& d) const;
00102
00106 const std::string &name() const ;
00107
00111 const std::string &type() const ;
00112
00117 const std::string &extends() const ;
00118
00125 const std::string &type_escaped() const ;
00126
00128 unsigned nr_input_interfaces() const;
00130 unsigned nr_output_interfaces() const;
00134 const DeviceDescription::IfaceList& input_interfaces() const;
00138 const DeviceDescription::IfaceList& output_interfaces() const;
00139
00143 const PropertyList &properties() const;
00144
00148 const Property::list_string &libraries() const;
00149
00154 bool isAbstract() const;
00155
00159 const std::string& description() const;
00160
00162 void toStream(std::ostream &os) const;
00163
00168 static std::string typename_escape(const std::string& s);
00169
00174 static std::string typename_unescape(const std::string& s);
00175 };
00176
00177
00178
00179
00218 class DLLIMPORT DeviceManager {
00219 friend class DeviceManagerPriv;
00220 public:
00222 typedef simth::DeviceDescription DeviceDescription;
00223
00225 typedef std::string DDMapKey;
00226
00247 typedef std::map<DDMapKey, DeviceDescription> DDMap;
00248
00250 typedef std::vector<DeviceDescription> DeviceDescriptionList;
00251
00252 private:
00253 typedef Property::list_string list_string;
00254 list_string _folderlist;
00255
00256
00257
00258 std::string _getFilePath(const std::string &fname) const
00259 throw(file_not_found);
00260
00261
00262
00263 static std::string condensedString(const std::string &s);
00264
00265 public:
00275 DeviceManager(const std::string &folder="");
00276
00280 virtual ~DeviceManager();
00281
00284 const std::string& folder() const throw();
00285
00288 const Property::list_string& folderlist() const throw();
00289
00302 DDMap allAvailableDescriptions()
00303 throw(bad_device_file, bad_device_description, type_error);
00304
00309 DeviceDescriptionList allAvailableDescriptionsList()
00310 throw(bad_device_file, bad_device_description, type_error);
00311
00332 DeviceDescriptionList
00333 allDescriptionsFromFile(const std::string &fname)
00334 throw(file_not_found, bad_device_file, bad_device_description,
00335 type_error);
00336
00358 DeviceDescription descriptionFromFile(const std::string &fname,
00359 const std::string &dname)
00360 throw(file_not_found, bad_device_file, device_not_found, type_error);
00361
00364 Property::list_string allXMLFiles() const;
00365
00369 static bool string_to_bool(const std::string abstr);
00371
00372 };
00373
00374 #ifndef __GNUC__
00377 EXPIMP_TEMPLATE template DLLIMPORT DeviceManager::DDMap;
00378 EXPIMP_TEMPLATE template DLLIMPORT DeviceManager::DeviceDescriptionList;
00379 #endif
00380
00382 std::ostream& operator<<(std::ostream&os, const DeviceManager::DDMap& dds);
00383
00384 }
00385
00386
00387 #endif
00388
00389
00390