hgl 0.5.25
A compiler/interpreter suite for developing images
Public Member Functions | Protected Member Functions | List of all members
HGL::Type::TypeBase Class Referenceabstract

This class provides the default implementation for most types. More...

#include "typebase.h"

Inheritance diagram for HGL::Type::TypeBase:
[legend]

Public Member Functions

ITypeattachType (IType *type, bool check=true) throw (Exception::AttachException)
 Attach child objects to the IType at end of list. More...
 
virtual IType::iterator begin ()
 Gets the iterator to the begin over this type's attached types. More...
 
virtual void detachType (IType *type)
 Detaches a child from the IType. More...
 
virtual IType::iterator end ()
 Gets the iterator to the end over this type's attached types. More...
 
virtual const TYPELISTgetAttachedTypes () const
 Returns all attached IType instances. More...
 
virtual BOUNDINGBOX getBoundingBox () const
 Gets the bounding box of the type. More...
 
virtual const std::string & getId () const
 Gets the identifier. More...
 
virtual ITypegetParent () const
 Returns the parent IType. More...
 
virtual bool isNull () const
 Checks if the type is null type. More...
 
virtual void setDescription (const std::string &desc)
 Sets the description of the type. More...
 
virtual void setId (const std::string &id)
 Sets the identifier. More...
 
- Public Member Functions inherited from HGL::IType
virtual operator iterator ()=0
 Gets the iterator over this type's attached types. More...
 
virtual SERIALID getSerialID () const =0
 Gets the serialization ID of the object. More...
 

Protected Member Functions

virtual ITypeattachType (IType *type, const TYPELIST::iterator &before, bool check=true) throw (Exception::AttachException)
 Attaches a child at the position before. More...
 
virtual IType::Ptr clone () const throw (Exception::CloneNotSupportedException)
 Creates a clone of the type. More...
 
virtual const std::string & getDescription () const
 Gets the description of the type. More...
 
virtual const ITypegetRoot (const IType &type) const
 Get the root of a type. More...
 
virtual std::string getTypeName () const
 Displayable name of the IType. More...
 
virtual bool isValid () const
 Checks if the type is valid. More...
 
virtual operator float () const throw (Exception::ReferenceException, Exception::InvalidExpressionException)
 Converts the type into a float More...
 
virtual ITyperesolve (const std::string &id) const
 Resolves a type by its ID. More...
 
virtual void setParent (IType *parent)
 Set parent of the type. More...
 

Detailed Description

This class provides the default implementation for most types.

Author
Heiko Schäfer heiko.nosp@m.@hgl.nosp@m..rang.nosp@m.un.d.nosp@m.e

Member Function Documentation

HGL::IType * TypeBase::attachType ( IType type,
bool  check = true 
)
throw (Exception::AttachException
)
virtual

Attach child objects to the IType at end of list.

Parameters
typethe IType to attach as child
checktrue (default), if validity checks should be performed
Exceptions
Exception::AttachExceptionif a disallowed type gets attached. See Types for more.
Returns
the attached type

Implements HGL::IType.

Referenced by HGL::Type::RenderCallback::attachType(), HGL::Type::Poly::attachType(), HGL::Type::Line::attachType(), and HGL::Type::Point::attachType().

HGL::IType * TypeBase::attachType ( HGL::IType type,
const TYPELIST::iterator &  before,
bool  check = true 
)
throw (Exception::AttachException
)
protectedvirtual

Attaches a child at the position before.

It updates the parent of the attached type to this type as well.

Parameters
typethe IType to attach as child
beforethe type will be attached before the type referenced by before
checktrue (default), if validity checks should be performed
typethe IType to attach as child
checktrue (default), if validity checks should be performed
Exceptions
Exception::AttachExceptionif a disallowed type gets attached. See Types for more.
Returns
the attached type

Reimplemented in HGL::Type::Point, HGL::Type::Line, HGL::Type::AssignmentOperator, HGL::Type::Curve, HGL::Type::RenderCallback, and HGL::Type::VirtualGroup.

HGL::IType::iterator TypeBase::begin ( )
virtual

Gets the iterator to the begin over this type's attached types.

Returns
the iterator to the begin over this type's attached types

Implements HGL::IType.

HGL::IType::Ptr TypeBase::clone ( ) const
throw (Exception::CloneNotSupportedException
)
protectedvirtual

Creates a clone of the type.

Returns
a smart pointer to the cloned type

Implements HGL::IType.

Reimplemented in HGL::Type::FloatParam.

void TypeBase::detachType ( IType type)
virtual

Detaches a child from the IType.

Parameters
typethe IType to detach
Since
0.5.21

Implements HGL::IType.

Reimplemented in HGL::Type::Poly, and HGL::Type::RenderCallback.

Referenced by HGL::Type::Poly::detachType().

HGL::IType::iterator TypeBase::end ( )
virtual

Gets the iterator to the end over this type's attached types.

Returns
the iterator to the end over this type's attached types

Implements HGL::IType.

Referenced by HGL::Type::Ellipse::isValid(), and HGL::Type::Text::isValid().

const HGL::IType::TYPELIST & TypeBase::getAttachedTypes ( ) const
virtual
HGL::IType::BOUNDINGBOX TypeBase::getBoundingBox ( ) const
virtual

Gets the bounding box of the type.

Returns
the bounding box of the type

Implements HGL::IType.

Reimplemented in HGL::Type::Point, HGL::Type::Line, HGL::Type::Vector2D, HGL::Type::Fill, HGL::Type::ParamBase, and HGL::Type::Text.

References getAttachedTypes(), and BOUNDINGBOX::isDefined().

Referenced by HGL::Type::Line::getBoundingBox().

const std::string & TypeBase::getDescription ( ) const
protectedvirtual

Gets the description of the type.

Returns
the description of the type

Implements HGL::IType.

const std::string & TypeBase::getId ( ) const
virtual

Gets the identifier.

Returns
the identifier

Implements HGL::IType.

Reimplemented in HGL::Type::NamedParam, and HGL::Type::Procedure.

Referenced by HGL::Type::Procedure::getId().

HGL::IType * TypeBase::getParent ( ) const
virtual

Returns the parent IType.

Returns
the parent IType or NULL if there is no parent

Implements HGL::IType.

Referenced by HGL::Type::FloatParam::clone().

const HGL::IType * TypeBase::getRoot ( const IType type) const
protectedvirtual

Get the root of a type.

Parameters
typethe type to get the root of
Returns
the the root of a type

Implements HGL::IType.

References HGL::IType::getRoot().

std::string TypeBase::getTypeName ( ) const
protectedvirtual

Displayable name of the IType.

Returns
the displayable name of the IType

Reimplemented in HGL::Type::ExpressionParam, and HGL::Type::NamedParam.

References HGL::IType::getSerialID().

Referenced by HGL::Type::NamedParam::getTypeName(), and HGL::Type::ExpressionParam::getTypeName().

bool TypeBase::isNull ( ) const
virtual

Checks if the type is null type.

See Also
IReferenceHolder::findReference
Returns
true if the type is null type, false otherwise

Implements HGL::IType.

bool TypeBase::isValid ( ) const
protectedvirtual

Checks if the type is valid.

A type is valid

  1. if all attached types are allowed for this type, if not the type is invalid
  2. if all attached types itself are valid, if not the type is invalid

Subclasses can add more checks if neccessary.

Returns
true if the type is valid, false otherwise

Implements HGL::IType.

Reimplemented in HGL::Type::Point, HGL::Type::Curve, HGL::Type::Text, HGL::Type::Ellipse, HGL::Type::Project, HGL::Type::Poly, HGL::Type::NonEmptyType, and HGL::Type::ReferenceHolderBase.

References getAttachedTypes(), and HGL::IType::isValid().

Referenced by HGL::Type::ReferenceHolderBase::isValid(), and HGL::Type::NonEmptyType::isValid().

TypeBase::operator float ( ) const
throw (Exception::ReferenceException,
Exception::InvalidExpressionException
)
protectedvirtual

Converts the type into a float

Returns
the type as float

Implements HGL::IType.

Reimplemented in HGL::Type::FloatParam, and HGL::Type::ReferenceParam.

HGL::IType * TypeBase::resolve ( const std::string &  id) const
protectedvirtual

Resolves a type by its ID.

Parameters
idthe id to resolve
Returns
the resolved type or 0L if no type could get resolved by that id

Implements HGL::IType.

Reimplemented in HGL::Type::AssignmentOperator.

References getAttachedTypes().

void TypeBase::setDescription ( const std::string &  desc)
virtual

Sets the description of the type.

Parameters
descthe description of the type

Implements HGL::IType.

void TypeBase::setId ( const std::string &  id)
virtual

Sets the identifier.

Parameters
idthe identifier

Implements HGL::IType.

Reimplemented in HGL::Type::NamedParam.

Referenced by HGL::Type::NamedParam::setId().

void TypeBase::setParent ( IType parent)
protectedvirtual

Set parent of the type.

Parameters
parentthe parent of the type

Implements HGL::IType.

Referenced by HGL::Type::FloatParam::clone().