HyperspaceExplorer 0.7.1
|
Carries a description of a Displayable class, including its relation to other Displayables. More...
#include <DisplayableClass.h>
Classes | |
struct | DisplayableClassException |
Thrown when a DisplayableClass object is requested that has not been registered. More... | |
Public Member Functions | |
DisplayableClass (const std::string &name, const std::string &description, const std::string &parent_name) | |
std::string | getName () const |
std::string | getDescription () const |
void | addDisplayable (const std::string &displayable_name) |
Adds a subclass to the current node. | |
std::vector< std::string > | getDisplayableNames () const |
Returns the names of the Displayable classes inheriting from the class described in this node. | |
std::vector< Displayable * > | getDisplayables () const |
Not yet implemented. What was this about, again? | |
std::vector< DisplayableClass > | getSubClasses () const |
Returns the classes which inherit from the class described in the current node. | |
void | printSubclasses () const |
Print the list of classes inheriting from the current node. | |
Static Public Member Functions | |
static DisplayableClass & | findClass (const std::string &class_name) |
Retrieves the info stored for the class with the name class_name . | |
static const DisplayableClass & | makeRootNode (const std::string &class_name, const std::string &description) |
Generate the root node of the inheritance hierarchy. | |
static DisplayableClass & | getRootNode () |
The root node of the inheritance hierarchy. | |
Private Types | |
typedef std::map< std::string, DisplayableClass * > | subclass_container_type |
typedef std::vector< std::string > | displayable_container_type |
typedef subclass_container_type::iterator | subclass_iterator |
typedef subclass_container_type::const_iterator | subclass_const_iterator |
Private Member Functions | |
DisplayableClass (const std::string &name, const std::string &description) | |
Create a DisplayableClass without a parent node. This may happen only once and creates the root node. | |
void | addSubClass (DisplayableClass &child) |
DisplayableClass & | findSubClass (const std::string &class_name) |
Private Attributes | |
std::string | class_name_ |
std::string | class_description_ |
subclass_container_type | subclasses_ |
displayable_container_type | displayables_ |
Static Private Attributes | |
static DisplayableClass * | root_node_ = NULL |
static Tree< DisplayableClass > | class_tree_ |
Carries a description of a Displayable class, including its relation to other Displayables.
Displayable classes belong to several categories - for instance, RealFunction, Surface or Object. Each of these classes contains subclasses, such as Torus1, Horizon or Hypersponge. These classes are arranged in a tree-like structure, mirroring the inheritance diagram of the classes. DisplayableClass represents one node in that inheritance tree.
The information stored in DisplayableClass nodes and the entire tree can be used to print a tree of the inheritance diagram, or to generate a menu structure of these classes.
Subclasses of Displayable must use the FunctionFactory::registerFunction() method on declaration (in the header file), such as this:
class MyNewDisplayableSubclass: public Displayable { // ... }; namespace { Displayable *createMyNewDisplayableSubclass() { return new MyNewDisplayableSubclass(); } const bool registeredXYZ = // you must use a variable name that is unique in the anonymous namespace TheFunctionFactory::Instance().registerFunction(createMyNewDisplayableSubclass, "Displayable"); }
std::vector< Displayable * > DisplayableClass::getDisplayables | ( | ) | const |
Not yet implemented. What was this about, again?
Damn, I must remember to comment functions as soon as I write them.
DisplayableClass & DisplayableClass::getRootNode | ( | ) | [static] |
The root node of the inheritance hierarchy.
If this does not point to the class Displayable, shoot me.
Referenced by findClass(), makeRootNode(), and C4DView::Menu4D::Menu4D().
const DisplayableClass & DisplayableClass::makeRootNode | ( | const std::string & | class_name, |
const std::string & | description | ||
) | [static] |
Generate the root node of the inheritance hierarchy.
This function must be called in the header file Displayable.h. It must be called before any subclasses of Displayable are declared.
References getRootNode().