Typelib::Registry Class Reference

#include <typelib/registry.hh>

Collaboration diagram for Typelib::Registry:

Collaboration graph
[legend]

List of all members.

Public Types

enum  DumpMode { NameOnly = 0, AllType = 1, WithSourceId = 2, RecursiveTypeDump = 4 }
typedef RegistryIterator Iterator

Public Member Functions

 Registry ()
 ~Registry ()
void importNamespace (const std::string &name, bool erase_existing=false)
bool setDefaultNamespace (const std::string &name)
std::string getDefaultNamespace () const
bool has (const std::string &name, bool build=true) const
std::string source (Type const *type) const
Type const * build (const std::string &name)
Type const * get (const std::string &name) const
void add (Type *type, std::string const &source_id="")
void alias (std::string const &base, std::string const &alias, std::string const &source_id="")
size_t size () const
void clear ()
std::string getFullName (const std::string &name) const
RegistryIterator begin () const
RegistryIterator end () const
void merge (Registry const &registry)
Registryminimal (Registry const &auto_types) const
bool isSame (Registry const &other) const
void dump (std::ostream &stream, int dumpmode=AllType, const std::string &source_filter="*") const

Static Public Member Functions

static Type const & null ()

Friends

class RegistryIterator

Classes

struct  RegistryType


Detailed Description

Manipulation of a set of types Any complex type in a Registry object can only reference types in the same registry. No duplicates are allowed.

Registry objects provide the following services:


Member Typedef Documentation


Member Enumeration Documentation

Enumerator:
NameOnly 
AllType 
WithSourceId 
RecursiveTypeDump 


Constructor & Destructor Documentation

Typelib::Registry::Registry (  ) 

References setDefaultNamespace().

Typelib::Registry::~Registry (  ) 

References clear().


Member Function Documentation

void Typelib::Registry::importNamespace ( const std::string &  name,
bool  erase_existing = false 
)

Import the name namespace into the current namespace.

  • erase_existing controls the behaviour in case of name collision. If true, the type from the namespace being imported will have priority. If false, an already imported type will have priority.

References Typelib::getNormalizedNamespace(), and Typelib::isInNamespace().

Referenced by setDefaultNamespace().

bool Typelib::Registry::setDefaultNamespace ( const std::string &  name  ) 

Sets the default namespace. This removes all namespace import and imports name in the current namespace

References Typelib::getNormalizedNamespace(), importNamespace(), Typelib::isValidNamespace(), and Typelib::NamespaceMarkString.

Referenced by Registry().

std::string Typelib::Registry::getDefaultNamespace (  )  const

Get the default namespace (if any). Returns '/' (i.e. the root) if no default namespace have been set

bool Typelib::Registry::has ( const std::string &  name,
bool  build = true 
) const

Checks for the availability of a particular type

  • name the type name
  • build if true, the method returns true if name is a derived version (pointer or array) of a known type
Returns:
true if the Type exists, or if it is a derived type and build is true, false otherwise

References Typelib::TypeBuilder::getBaseType(), and getFullName().

Referenced by minimal().

std::string Typelib::Registry::source ( Type const *  type  )  const

Get the source ID of type. Throws Undefined if type is not a registered type

const Type * Typelib::Registry::build ( const std::string &  name  ) 

Build a derived type from its canonical name

References getFullName().

Referenced by Typelib::TypeBuilder::TypeBuilder().

const Type * Typelib::Registry::get ( const std::string &  name  )  const

Gets a Type object

  • name the type name
    Returns:
    the type object if it exists, 0 otherwise

Referenced by Typelib::TypeBuilder::addArrayMajor(), Typelib::TypeBuilder::addPointer(), and Typelib::Type::try_merge().

void Typelib::Registry::add ( Type type,
std::string const &  source_id = "" 
)

Adds a new type

Returns:
true on success, false if the type was already defined in the registry

References Typelib::Type::getName().

void Typelib::Registry::alias ( std::string const &  base,
std::string const &  alias,
std::string const &  source_id = "" 
)

Creates an alias While base can be a derived type, all aliases are considered persistent since they can be referenced by their name in other types

  • base the base type
  • alias the alias name
  • source_id a source ID for the newly created type

References Typelib::isValidTypename().

Referenced by merge().

size_t Typelib::Registry::size (  )  const

Returns the count of types defined in this registry, including non-persistent and aliases

Referenced by Typelib::make_std_numeric(), and Typelib::Exporter::save().

void Typelib::Registry::clear (  ) 

Remove all types

Referenced by ~Registry().

std::string Typelib::Registry::getFullName ( const std::string &  name  )  const

Get the absolute type name of name, taking the default namespace into account

See also:
setDefaultNamespace getDefaultNamespace

References Typelib::isAbsoluteName().

Referenced by build(), and has().

RegistryIterator Typelib::Registry::begin (  )  const

Iterator pointing on the first type of the registry

References RegistryIterator.

Referenced by merge(), minimal(), and Typelib::Exporter::save().

RegistryIterator Typelib::Registry::end (  )  const

Past-the-end iterator on the registry

References RegistryIterator.

Referenced by merge(), minimal(), and Typelib::Exporter::save().

Type const & Typelib::Registry::null (  )  [static]

Returns a null type

void Typelib::Registry::merge ( Registry const &  registry  ) 

Merges the content of registry into this object

References alias(), begin(), end(), and Typelib::Type::isSame().

Registry * Typelib::Registry::minimal ( Registry const &  auto_types  )  const

Returns a registry containing the minimal set of types needed to define the types that are in this and not in auto_types

References begin(), end(), has(), and Typelib::Type::isSame().

bool Typelib::Registry::isSame ( Registry const &  other  )  const

Compares the two registries. Returns true if they contain the same set of types, referenced under the same name

Note that for now, if this contains a type 'A' aliased to 'B' and other contains the same type but named 'B' and aliased to 'A', the method will return false.

References m_global.

void Typelib::Registry::dump ( std::ostream &  stream,
int  dumpmode = AllType,
const std::string &  source_filter = "*" 
) const


Friends And Related Function Documentation

friend class RegistryIterator [friend]

Referenced by begin(), and end().


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

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