Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes
Typelib::Container Class Reference

#include <typemodel.hh>

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

List of all members.

Classes

struct  DeleteIfPredicate
struct  PredicateWrapper

Public Types

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

Public Member Functions

virtual void clear (void *ptr) const =0
virtual bool compare (void *ptr, void *other) const =0
 Container (std::string const &kind, std::string const &name, size_t size, Type const &of)
virtual void copy (void *dst, void *src) const =0
template<typename Pred >
void delete_if (void *ptr, Pred pred) const
virtual void destroy (void *ptr) const =0
virtual MarshalOps::const_iterator dump (void const *container_ptr, size_t element_count, OutputStream &stream, MarshalOps::const_iterator const begin, MarshalOps::const_iterator const end) const =0
virtual bool erase (void *ptr, Value v) const =0
virtual Typelib::Value getElement (void *ptr, int idx) const
virtual size_t getElementCount (void const *ptr) const =0
virtual long getNaturalSize () const =0
virtual void init (void *ptr) const =0
virtual bool isRandomAccess () const
std::string kind () const
virtual MarshalOps::const_iterator load (void *container_ptr, size_t element_count, InputStream &stream, MarshalOps::const_iterator const begin, MarshalOps::const_iterator const end) const =0
virtual void push (void *ptr, Value v) const =0
virtual void setElement (void *ptr, int idx, Typelib::Value value) const
virtual bool visit (void *ptr, ValueVisitor &visitor) const =0

Static Public Member Functions

static AvailableContainers availableContainers ()
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)
static void registerContainer (std::string const &name, ContainerFactory factory)

Protected Member Functions

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

Private Attributes

std::string m_kind

Static Private Attributes

static AvailableContainerss_available_containers

Detailed Description

Base type for variable-length sets

Definition at line 423 of file typemodel.hh.


Member Typedef Documentation

Definition at line 574 of file typemodel.hh.

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

Definition at line 573 of file typemodel.hh.

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

Definition at line 453 of file typemodel.hh.


Constructor & Destructor Documentation

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

Definition at line 465 of file typemodel.cc.


Member Function Documentation

Definition at line 472 of file typemodel.cc.

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

Removes all elements from this container

Implemented in String, and Vector.

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

Implemented in String, and Vector.

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.

Implemented in String, and Vector.

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

Definition at line 485 of file typemodel.cc.

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

Definition at line 491 of file typemodel.cc.

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

Definition at line 522 of file typemodel.hh.

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

Implemented in String, and Vector.

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

Implemented in String, and Vector.

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

Reimplemented from Typelib::Indirect.

Definition at line 499 of file typemodel.cc.

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

Called by Type::merge when the type does not exist in registry already. This method has to create a new type in registry that matches the type definition of *this.

All types referenced by *this must be moved to their equivalent in registry.

Implements Typelib::Type.

Definition at line 508 of file typemodel.cc.

virtual MarshalOps::const_iterator Typelib::Container::dump ( void const *  container_ptr,
size_t  element_count,
OutputStream stream,
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 [64 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.
  • stream the stream that will be used to dump the data
  • 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)

Implemented in String, and Vector.

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.

Implemented in String, and Vector.

Typelib::Value Typelib::Container::getElement ( void *  ptr,
int  idx 
) const [virtual]

On random access containers, allows to access elements by their index

Random access containers are containers for which isRandomAccess() returns true.

Throws std::logic_error on containers that are not random access

Reimplemented in Vector.

Definition at line 523 of file typemodel.cc.

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

Implemented in String, and Vector.

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

Implemented in String, and Vector.

virtual long Typelib::Container::getNaturalSize ( ) const [pure virtual]

Called to return the natural size of the container, i.e. the size it has on this particular machine. This can be different than getSize() in case of registries generated on other machines.

Implemented in String, and Vector.

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

Implemented in String, and Vector.

bool Typelib::Container::isRandomAccess ( ) const [virtual]

If true, this is a random access container and both the getElement(int) and setElement(int) methods can be used

Containers are not random-access by default

Reimplemented in Vector.

Definition at line 520 of file typemodel.cc.

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

Definition at line 469 of file typemodel.cc.

virtual MarshalOps::const_iterator Typelib::Container::load ( void *  container_ptr,
size_t  element_count,
InputStream stream,
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 [64 bits]> <elements>

  • container_ptr the pointer to the container data
  • element_count the count of elements in the container, loaded from the stream.
  • stream the stream from which the data will be read
  • 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

Implemented in String, and Vector.

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

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

Implemented in String, and Vector.

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

Definition at line 478 of file typemodel.cc.

void Typelib::Container::setElement ( void *  ptr,
int  idx,
Typelib::Value  value 
) const [virtual]

On random access containers, allows to set an element's value by its index

Random access containers are containers for which isRandomAccess() returns true.

Throws std::logic_error on containers that are not random access

Reimplemented in Vector.

Definition at line 521 of file typemodel.cc.

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

Implemented in String, and Vector.


Member Data Documentation

std::string Typelib::Container::m_kind [private]

Definition at line 425 of file typemodel.hh.

Definition at line 587 of file typemodel.hh.


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


typelib
Author(s): Sylvain Joyeux/sylvain.joyeux@m4x.org
autogenerated on Mon Oct 6 2014 03:17:12