Main Page   Class Hierarchy   Compound List   File List   Compound Members  

SOMELibCatalog.h

00001 /********************************************************************
00002 ** Copyright (C) 2000 SOMELib Project
00003 **
00004 ** This library is free software; you can redistribute it and/or
00005 ** modify it under the terms of the GNU Library General Public
00006 ** License as published by the Free Software Foundation; either
00007 ** version 2 of the License, or (at your option) any later version.
00008 **
00009 ** This library is distributed in the hope that it will be useful,
00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 ** Library General Public License for more details.
00013 **
00014 ** You should have received a copy of the GNU Library General Public
00015 ** License along with this library; if not, write to the
00016 ** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017 ** Boston, MA  02111-1307, USA.
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     //set this info in your plugin library
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     //get if the class catalog key == value
00069     ClassContainer getByCategory(const std::string& key, const std::string& value);
00070 
00071     //get all values for a peticular key in this lib
00072     std::set < std::string > enumCategory( const std::string& key );
00073 
00074     //get all values for a peticular key for classes in this lib
00075     //which corraspond to the category map
00076     std::set < std::string > enumCategory( const std::string& key, std::map < std::string, std::string > &catmap );
00077 
00078     //fix this for Microsoft's build since it does not like maps
00079     //get all class catalogs whoes categories corraspond to entries in a map
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 } //namespace SOME
00115 
00116 
00117 //implement this function in your library
00118 SOME_EXPORT void initSOMELibCatalog(SOME::LibCatalog*);
00119 
00120 
00121 #endif //SOME_LIB_INFO_HEADER

Generated at Fri Dec 8 14:24:48 2000 for SOMELib by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000