HyperspaceExplorer 0.7.1
DisplayableClass.h
00001 /*
00002     <one line to give the program's name and a brief idea of what it does.>
00003     Copyright (C) <year>  <name of author>
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License along
00016     with this program; if not, write to the Free Software Foundation, Inc.,
00017     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018 
00019 */
00020 
00021 #ifndef DISPLAYABLECLASS_H
00022 #define DISPLAYABLECLASS_H
00023 
00024 #include "Tree.h"
00025 
00026 #include <stdexcept>
00027 #include <string>
00028 #include <vector>
00029 #include <map>
00030 
00031 class Displayable;
00032 
00034 
00058 class DisplayableClass {
00059 
00060 public:
00061 
00063   struct DisplayableClassException: public std::logic_error {
00064     DisplayableClassException(const std::string &message): std::logic_error(message) { }
00065   };
00066 
00067   DisplayableClass(const std::string &name, const std::string &description, const std::string &parent_name);
00068 
00069   std::string getName() const;
00070   std::string getDescription() const;
00071 
00073   void addDisplayable(const std::string &displayable_name);
00075   std::vector<std::string> getDisplayableNames() const;
00077 
00078   std::vector<Displayable*> getDisplayables() const;
00079 
00081   std::vector<DisplayableClass> getSubClasses() const;
00082 
00084   static DisplayableClass &findClass(const std::string &class_name);
00085 
00087 
00090   static const DisplayableClass &makeRootNode(const std::string &class_name,
00091                                               const std::string &description);
00093 
00094   static DisplayableClass &getRootNode();
00095 
00097   void printSubclasses() const;
00098 //  void print() const;
00099 
00100 private:
00101 
00102   typedef std::map<std::string, DisplayableClass *> subclass_container_type;
00103   typedef std::vector<std::string> displayable_container_type;
00104   typedef subclass_container_type::iterator subclass_iterator;
00105   typedef subclass_container_type::const_iterator subclass_const_iterator;
00106 
00108   DisplayableClass(const std::string & name, const std::string &description);
00109 
00110   void addSubClass(DisplayableClass &child);
00111 
00112   DisplayableClass &findSubClass(const std::string &class_name);
00113 
00114   std::string class_name_;
00115   std::string class_description_;
00116 
00117   subclass_container_type subclasses_;
00118   displayable_container_type displayables_;
00119 
00120   static DisplayableClass *root_node_;
00121 
00122   static Tree<DisplayableClass> class_tree_;
00123 
00124 };
00125 
00126 #endif // DISPLAYABLECLASS_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends

Generated on Mon Apr 9 2012 20:25:14 for HyperspaceExplorer 0.7.1 by doxygen 1.7.4  -  Hosted bySourceForge.net Logo