Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef AI_COMPOSITE_COMPONENT_HPP_INCLUDED
00022 #define AI_COMPOSITE_COMPONENT_HPP_INCLUDED
00023
00024 class config;
00025
00026 #include <iostream>
00027 #include <map>
00028 #include <string>
00029 #include <vector>
00030
00031 #include <boost/shared_ptr.hpp>
00032
00033 #ifdef _MSC_VER
00034 #pragma warning(push)
00035
00036 #pragma warning(disable:4250)
00037 #endif
00038
00039
00040 namespace ai {
00041
00042
00043 struct path_element {
00044 path_element()
00045 : property()
00046 , id()
00047 , position(0)
00048 {
00049 }
00050
00051 std::string property;
00052 std::string id;
00053 int position;
00054 };
00055
00056 class base_property_handler;
00057 typedef boost::shared_ptr<base_property_handler> property_handler_ptr;
00058 typedef std::map<std::string,property_handler_ptr> property_handler_map;
00059
00060 class component {
00061 public:
00062 component()
00063 : property_handlers_()
00064 {
00065 }
00066
00067 virtual std::string get_id() const = 0;
00068 virtual std::string get_name() const = 0;
00069 virtual std::string get_engine() const = 0;
00070 virtual ~component() {};
00071 virtual component* get_child(const path_element &child);
00072 virtual std::vector<component*> get_children(const std::string &type);
00073 virtual std::vector<std::string> get_children_types();
00074 virtual bool change_child(const path_element &child, const config &cfg);
00075 virtual bool add_child(const path_element &child, const config &cfg);
00076 virtual bool delete_child(const path_element &child);
00077
00078 property_handler_map& property_handlers();
00079
00080 private:
00081 property_handler_map property_handlers_;
00082 };
00083
00084 class component_manager {
00085 public:
00086 static bool add_component(component *root, const std::string &path, const config &cfg);
00087 static bool change_component(component *root, const std::string &path, const config &cfg);
00088 static bool delete_component(component *root, const std::string &path);
00089 static std::string print_component_tree(component *root, const std::string &path);
00090 };
00091
00092
00093 }
00094
00095 std::ostream &operator<<(std::ostream &o, const ai::path_element &e);
00096
00097 #ifdef _MSC_VER
00098 #pragma warning(pop)
00099 #endif
00100
00101 #endif