19 #ifndef AI_COMPOSITE_ASPECT_HPP_INCLUDED
20 #define AI_COMPOSITE_ASPECT_HPP_INCLUDED
32 #include <boost/pointer_cast.hpp>
37 #pragma warning(disable:4250)
83 virtual bool active()
const;
131 virtual const T&
get()
const
231 assert (c->get_id()== this->
get_name());
235 LOG_STREAM(
debug,
aspect::log()) <<
"typesafe_known_aspect [" << this->
get_name() <<
"] : while setting aspect, got null. this might be caused by invalid [aspect] WML" << std::endl;
243 assert (c->get_id()==this->
get_name());
244 c->add_facet(-1, cfg);
247 LOG_STREAM(
debug,
aspect::log()) <<
"typesafe_known_aspect [" << this->
get_name() <<
"] : while adding facet to aspect, got null. this might be caused by target [aspect] being not composite" << std::endl;
274 _default[
"id"] =
"default_facet";
275 std::vector< aspect_ptr > default_aspects;
277 if (!default_aspects.empty()) {
286 std::function<void(typename aspect_type<T>::typesafe_ptr_vector&,
const config&)> factory_facets =
296 std::vector<aspect_ptr> facets_base;
344 std::vector< aspect_ptr > facets;
379 this->
name_ =
"standard_aspect";
382 LOG_STREAM(
debug,
aspect::log()) <<
"standard aspect has value: "<< std::endl << config_value_translator<T>::value_to_cfg(this->
get()) << std::endl;
422 this->
name_ =
"lua_aspect";
425 code_ = cfg[
"code"].str();
471 static factory_map *aspect_factories;
472 if (aspect_factories==
nullptr) {
475 return *aspect_factories;
485 factory_ptr ptr_to_this(
this);
486 get_list().insert(make_pair(name,ptr_to_this));
493 template<
class ASPECT>
517 static factory_map *aspect_factories;
518 if (aspect_factories==
nullptr) {
521 return *aspect_factories;
528 factory_ptr ptr_to_this(
this);
529 get_list().insert(make_pair(name,ptr_to_this));
535 template<
class ASPECT>
child_itors child_range(const std::string &key)
lua_aspect_factory(const std::string &name)
virtual config to_config() const
virtual bool add_facet(int pos, const config &cfg)
bool invalidate_on_tod_change_
aspect_ptr get_new_instance(readonly_context &context, const config &cfg, const std::string &id)
std::string operator()(boost::blank) const
virtual ~lua_aspect_factory()
virtual const variant & get_variant() const
const std::string & get_name() const
std::map< std::string, factory_ptr > factory_map
boost::shared_ptr< T > value_
static factory_map & get_list()
bool is_duplicate(const std::string &name)
aspect_factory(const std::string &name)
virtual void recalculate() const =0
virtual void set(aspect_ptr a)=0
property_handler_map & property_handlers()
virtual void recalculate() const =0
aspect_ptr get_new_instance(readonly_context &context, const config &cfg, const std::string &id, boost::shared_ptr< lua_ai_context > &l_ctx)
std::string operator()(int i) const
bool invalidate_on_minor_gamestate_change_
virtual aspect_ptr get_new_instance(readonly_context &context, const config &cfg, const std::string &id)=0
void handle_generic_event(const std::string &)
virtual bool redeploy(const config &cfg, const std::string &id)
virtual boost::shared_ptr< variant > get_variant_ptr() const =0
std::string operator()(unsigned long long i) const
virtual config to_config() const
register_aspect_factory(const std::string &name)
#define LOG_STREAM(level, domain)
aspect_type< T >::typesafe_ptr default_
std::string operator()(double i) const
Lua object(value) wrapper implementation.
virtual bool delete_all_facets()
GLdouble GLdouble GLdouble b
virtual bool active() const
virtual void add_facet(const config &cfg)
A small explanation about what's going on here: Each action has access to two game_info objects First...
virtual std::string get_id() const
virtual bool delete_all_facets()
static void register_facets_property(std::map< std::string, property_handler_ptr > &property_handlers, const std::string &property, std::vector< boost::shared_ptr< X > > &values, boost::shared_ptr< X > &def, std::function< void(std::vector< boost::shared_ptr< X > > &, const config &)> construction_factory)
virtual void recalculate() const
boost::shared_ptr< lua_object< T > > value_lua_
boost::shared_ptr< lua_ai_action_handler > handler_
static lg::log_domain & log()
GLsizei const GLfloat * value
static std::string quote_string(const std::string &s)
typesafe_aspect(readonly_context &context, const config &cfg, const std::string &id)
lua_aspect(readonly_context &context, const config &cfg, const std::string &id, boost::shared_ptr< lua_ai_context > &l_ctx)
known_aspect(const std::string &name)
GLboolean GLboolean GLboolean GLboolean a
std::string operator()(const std::string &s) const
config & add_child(const std::string &key)
virtual boost::shared_ptr< T > get_ptr() const
virtual ~typesafe_aspect()
Templates and utility-routines for strings and numbers.
virtual std::string get_engine() const
aspect(readonly_context &context, const config &cfg, const std::string &id)
bool invalidate_on_turn_start_
composite_aspect(readonly_context &context, const config &cfg, const std::string &id)
typesafe_known_aspect(const std::string &name, boost::shared_ptr< typesafe_aspect< T > > &where, aspect_map &aspects)
std::string operator()(bool b) const
std::vector< boost::shared_ptr< typesafe_aspect< T > > > typesafe_ptr_vector
std::string operator()(const t_string &s) const
virtual aspect_ptr get_new_instance(readonly_context &context, const config &cfg, const std::string &id, boost::shared_ptr< lua_ai_context > &l_ctx)=0
virtual void add_facet(const config &cfg)=0
std::map< std::string, aspect_ptr > aspect_map
static void parse_aspect_from_config(readonly_context &context, const config &cfg, const std::string &id, std::back_insert_iterator< std::vector< aspect_ptr > > b)
ai::lua_ai_action_handler * create_lua_ai_action_handler(char const *code, ai::lua_ai_context &context)
boost::shared_ptr< typesafe_aspect< T > > & where_
virtual std::string get_name() const
GLuint const GLchar * name
std::pair< const std::string, factory_ptr > factory_map_pair
bool has_attribute(const std::string &key) const
virtual const variant & get_variant() const =0
virtual ~aspect_factory()
config & child(const std::string &key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
static void value_to_cfg(const T &value, config &cfg)
static factory_map & get_list()
Standard logging facilities (interface).
game_lua_kernel * lua_kernel
boost::shared_ptr< lua_aspect_factory > factory_ptr
register_lua_aspect_factory(const std::string &name)
std::pair< const std::string, factory_ptr > factory_map_pair
aspect_type< T >::typesafe_ptr_vector facets_
boost::shared_ptr< variant > value_variant_
virtual boost::shared_ptr< variant > get_variant_ptr() const
const std::string & str() const
std::map< std::string, factory_ptr > factory_map
void create_facet(typename aspect_type< T >::typesafe_ptr_vector &facets, const config &cfg)
A config object defines a single node in a WML file, with access to child nodes.
boost::shared_ptr< aspect_factory > factory_ptr
bool invalidate_on_gamestate_change_
GLsizei const GLcharARB ** string
standard_aspect(readonly_context &context, const config &cfg, const std::string &id)