Typelib::Container Class Reference

#include <typelib/typemodel.hh>

Inheritance diagram for Typelib::Container:

Inheritance graph
[legend]
Collaboration diagram for Typelib::Container:

Collaboration graph
[legend]

List of all members.

Public Types

typedef std::vector< size_t > MarshalOps
typedef Container const &(* ContainerFactory )(Registry &r, std::list< Type const * > const &base_type)
typedef std::map< std::string,
ContainerFactory
AvailableContainers

Public Member Functions

 Container (std::string const &kind, std::string const &name, size_t size, Type const &of)
std::string kind () const
virtual void init (void *ptr) const =0
virtual void destroy (void *ptr) const =0
virtual bool visit (void *ptr, ValueVisitor &visitor) const =0
virtual void insert (void *ptr, Value v) const =0
virtual bool erase (void *ptr, Value v) const =0
virtual bool compare (void *ptr, void *other) const =0
virtual void copy (void *dst, void *src) const =0
template<typename Pred>
void delete_if (void *ptr, Pred pred) const
virtual size_t getElementCount (void *ptr) const =0
virtual MarshalOps::const_iterator dump (void *container_ptr, size_t element_count, std::vector< uint8_t > &buffer, MarshalOps::const_iterator const begin, MarshalOps::const_iterator const end) const =0
virtual boost::tuple< size_t,
MarshalOps::const_iterator > 
load (void *container_ptr, size_t element_count, std::vector< uint8_t > const &buffer, size_t in_offset, MarshalOps::const_iterator const begin, MarshalOps::const_iterator const end) const =0

Static Public Member Functions

static AvailableContainers availableContainers ()
static void registerContainer (std::string const &name, ContainerFactory factory)
static Container const & createContainer (Registry &r, std::string const &name, Type const &on)
static Container const & createContainer (Registry &r, std::string const &name, std::list< Type const * > const &on)

Protected Member Functions

virtual void delete_if_impl (void *ptr, DeleteIfPredicate &pred) const =0
virtual bool do_isSame (Type const &other, RecursionStack &stack) const
virtual ContainerFactory getFactory () const =0
Typedo_merge (Registry &registry, RecursionStack &stack) const

Classes

struct  DeleteIfPredicate
struct  PredicateWrapper


Detailed Description

Base type for variable-length sets

Member Typedef Documentation

typedef std::vector<size_t> Typelib::Container::MarshalOps

typedef Container const&(* Typelib::Container::ContainerFactory)(Registry &r, std::list< Type const * > const &base_type)


Constructor & Destructor Documentation

Typelib::Container::Container ( std::string const &  kind,
std::string const &  name,
size_t  size,
Type const &  of 
)


Member Function Documentation

virtual void Typelib::Container::delete_if_impl ( void *  ptr,
DeleteIfPredicate pred 
) const [protected, pure virtual]

Referenced by delete_if().

std::string Typelib::Container::kind (  )  const

virtual void Typelib::Container::init ( void *  ptr  )  const [pure virtual]

virtual void Typelib::Container::destroy ( void *  ptr  )  const [pure virtual]

virtual bool Typelib::Container::visit ( void *  ptr,
ValueVisitor visitor 
) const [pure virtual]

virtual void Typelib::Container::insert ( void *  ptr,
Value  v 
) const [pure virtual]

Insert the given element v into the container at +ptr+

virtual bool Typelib::Container::erase ( void *  ptr,
Value  v 
) const [pure virtual]

Removes the element equal to in ptr.

Returns:
true if has been found in ptr, false otherwise.

virtual bool Typelib::Container::compare ( void *  ptr,
void *  other 
) const [pure virtual]

Called to check if +ptr+ and +other+, which are containers of the same type, actually contain the same data

Returns:
true if the two containers have the same data, false otherwise

Referenced by Typelib::ValueOps::compare().

virtual void Typelib::Container::copy ( void *  dst,
void *  src 
) const [pure virtual]

Called to copy the contents of +src+ into +dst+, which are both containers of the same type.

Referenced by Typelib::ValueOps::copy().

template<typename Pred>
void Typelib::Container::delete_if ( void *  ptr,
Pred  pred 
) const [inline]

References delete_if_impl().

virtual size_t Typelib::Container::getElementCount ( void *  ptr  )  const [pure virtual]

Referenced by Typelib::ValueOps::dump().

virtual MarshalOps::const_iterator Typelib::Container::dump ( void *  container_ptr,
size_t  element_count,
std::vector< uint8_t > &  buffer,
MarshalOps::const_iterator const   begin,
MarshalOps::const_iterator const   end 
) const [pure virtual]

The marshalling process calls this method so that the contents of the container are dumped into the provided buffer.

In the marshalled stream, all containers are dumped as <element-count [65 bits]> <elements>

  • container_ptr the pointer to the container data
  • element_count the count of elements in the container. This is passed here to avoid costly computations: getElementCount is already called by the marshalling code itself.
  • buffer the memory buffer to which the elements should be appended
  • begin the marshalling code that describes the marshalling process for one element
  • end end of the marshalling code that describes the marshalling process for one element
    Returns:
    the marshalling process should end at the first FLAG_END found in [begin, end) (with nesting taken into account). The returned value is the iterator on this FLAG_END element (i.e. *retval == FLAG_END is a postcondition of this method)

Referenced by Typelib::ValueOps::dump().

virtual boost::tuple<size_t, MarshalOps::const_iterator> Typelib::Container::load ( void *  container_ptr,
size_t  element_count,
std::vector< uint8_t > const &  buffer,
size_t  in_offset,
MarshalOps::const_iterator const   begin,
MarshalOps::const_iterator const   end 
) const [pure virtual]

The marshalling process calls this method so that the contents of the container are loaded from the provided buffer.

In the marshalled stream, all containers are dumped as <element-count [65 bits]> <elements>

  • container_ptr the pointer to the container data
  • element_count the count of elements in the container, loaded from the stream.
  • buffer the memory buffer from which the elements should be loaded
  • in_offset the offset in buffer of the first element of the container
  • begin the marshalling code that describes the loading process for one element
  • end end of the marshalling code that describes the loading process for one element
    Returns:
    the marshalling process should end at the first FLAG_END found in [begin, end) (with nesting taken into account). The first element of the returned value is the iterator on this FLAG_END element (i.e. *retval == FLAG_END is a postcondition of this method). The second element is the new value of in_offset

Referenced by Typelib::ValueOps::load().

Container::AvailableContainers Typelib::Container::availableContainers (  )  [static]

void Typelib::Container::registerContainer ( std::string const &  name,
ContainerFactory  factory 
) [static]

Container const & Typelib::Container::createContainer ( Registry r,
std::string const &  name,
Type const &  on 
) [static]

Container const & Typelib::Container::createContainer ( Registry r,
std::string const &  name,
std::list< Type const * > const &  on 
) [static]

bool Typelib::Container::do_isSame ( Type const &  other,
RecursionStack stack 
) const [protected, virtual]

virtual ContainerFactory Typelib::Container::getFactory (  )  const [protected, pure virtual]

Referenced by do_isSame(), and do_merge().

Type * Typelib::Container::do_merge ( Registry registry,
RecursionStack stack 
) const [protected]


The documentation for this class was generated from the following files:

Generated on Thu Jan 22 16:38:05 2009 for typeLib by doxygen 1.5.6
SourceForge.net Project Page