00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019
00020
00021 #ifndef SOME_LIB_INFO_HEADER
00022 #define SOME_LIB_INFO_HEADER
00023
00024 #include "UserConfig.h"
00025 #include "BasicDynLib.h"
00026 #include "SOMEClassCatalog.h"
00027 #include "SOMEDefines.h"
00028 #include <vector>
00029 #include <set>
00030 #include <string>
00031 #include <exception>
00032
00033 namespace SOME
00034 {
00035
00040 class LibCatalog
00041 {
00042 public:
00043 LibCatalog(BasicDynLib*);
00044 ~LibCatalog();
00045
00046 const std::string & getPath() const;
00047
00048
00049 void setLibTitle(const std::string&);
00050 void setVersion(const std::string&);
00051 SOME::ClassCatalog *addClassCatalog(const std::string& classname,
00052 const std::string& category,
00053 ClassCatalog::ConstructFunc def = NULL,
00054 ClassCatalog::ConstructFunc one = NULL,
00055 ClassCatalog::ConstructFunc two = NULL);
00056
00057 bool hasSingleClass()
00058 {
00059 return classes.size() == 1;
00060 }
00061
00062 bool hasClass(const std::string&);
00063 const ClassCatalog& getClass(const std::string&);
00064
00065 typedef std::vector < ClassCatalog > ClassContainer;
00066 ClassContainer getCategory(const std::string&);
00067
00068
00069 ClassContainer getByCategory(const std::string& key, const std::string& value);
00070
00071
00072 std::set < std::string > enumCategory( const std::string& key );
00073
00074
00075
00076 std::set < std::string > enumCategory( const std::string& key, std::map < std::string, std::string > &catmap );
00077
00078
00079
00080 ClassContainer getByCategory( std::map < std::string, std::string > &keys );
00081
00082 private:
00083 BasicDynLib* lib;
00084 ClassContainer classes;
00085
00086 std::string title;
00087 std::string version;
00088
00089 ClassContainer::size_type class_index_cache;
00090 };
00091
00092 class ClassDoesNotExist: public std::exception
00093 {
00094 public:
00095 ClassDoesNotExist(const std::string& classname)
00096 {
00097 whatstr = classname + " does not exist in any of the libraries loaded.";
00098 }
00099
00100 ClassDoesNotExist(const std::string& libtitle, const std::string& classname)
00101 {
00102 whatstr = classname + " does not exist in the library: " + libtitle;
00103 }
00104
00105 const char* what()
00106 {
00107 return whatstr.c_str();
00108 }
00109
00110 private:
00111 std::string whatstr;
00112 };
00113
00114 }
00115
00116
00117
00118 SOME_EXPORT void initSOMELibCatalog(SOME::LibCatalog*);
00119
00120
00121 #endif //SOME_LIB_INFO_HEADER