Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template adaptable_factory

boost::extensions::adaptable_factory —

Synopsis

template<typename Interface, typename Info = std::string, 
         typename TypeInfo = default_type_info> 
class adaptable_factory {
public:
  // construct/copy/destruct
  adaptable_factory();
  adaptable_factory(adaptable_factory< Interface > const &);
  adaptable_factory& operator=(adaptable_factory< Interface > const &);

  // public member functions
  Interface * create(boost::reflections::parameter_map &) const;
  function< Interface *()> 
  get_function(boost::reflections::parameter_map &) const;
  std::map< TypeInfo, Info > 
  get_missing_params(const boost::reflections::parameter_map &) const;
  bool is_valid() const;
  template<typename Derived, typename Params...> void set(Info) ;
};

Description

This class is a function object that returns new instances of type Interface, using factories that take parameters described in the variable length list Params...

adaptable_factory public construct/copy/destruct

  1. adaptable_factory();
  2. adaptable_factory(adaptable_factory< Interface > const & first);
  3. adaptable_factory& operator=(adaptable_factory< Interface > const & first);

adaptable_factory public member functions

  1. Interface * create(boost::reflections::parameter_map & map) const;

    Returns an instance of Interface (but does NOT retain ownership of the instance).

    Parameters:
    map

    A parameter map to search for the parameters for this function.

    Requires:

    is_valid() == true.

    Postconditions:

    None.

    Returns:

    An instance of Interface, if all of the needed parameters are found in map.

  2. function< Interface *()> 
    get_function(boost::reflections::parameter_map & map) const;
  3. std::map< TypeInfo, Info > 
    get_missing_params(const boost::reflections::parameter_map & map) const;

    Returns a map of the TypeInfo/Info pairs describing any parameters still needed before this function can be called.

    Parameters:
    map

    A parameter map to search for the parameters for this function.

    Requires:

    is_valid() == true.

    Postconditions:

    None.

    Returns:

    TypeInfo/Info pairs for any missing parameters.

  4. bool is_valid() const;

    Until set is called, a adaptable_factory cannot be used. This function can be used to determine if set has been called.

    Requires:

    None.

    Postconditions:

    None.

    Returns:

    True if the adaptable_factory is initialized (ie, set has been called).

  5. template<typename Derived, typename Params...> 
      void set(Info parameter_names...) ;

    This sets the factory function to the constructor for type D. It takes as arguments Info about each parameter in the constructor.

    Requires:

    None.

    Postconditions:

    None. Example: adaptable_factory<Base, int, int> f; f.set<Derived>();


PrevUpHomeNext