mudbox::AttributePointer< type > Class Template Reference

#include <node.h>

Inheritance diagram for mudbox::AttributePointer< type >:

Inheritance graph
[legend]
List of all members.

Detailed Description

template<typename type>
class mudbox::AttributePointer< type >

This class can be used instead of standard pointers, when the pointer target class is derived from the Node class.

This object has the following advantages over a plain pointer:


Public Member Functions

  AttributePointer (Node *pOwner=NULL, const QString &sID="")
  AttributePointer (Node *pOwner, const QString &sID, bool bInstall)
QString  AsString (void) const
void  SetFromString (const QString &)
void  SetValidator (validator *pValidator)
  Register a function as the validator for this pointer. This function will be called each time a new value has to be assigned to the pointer. If this function returns false the value wont be assigned to the pointer.
void  SetPointerValue (Node *pNode, bool bLink=true)
void  SetValue (type *cValue, bool bX=false)
void  AddTarget (Attribute &cTarget)
void  DeleteTarget (void)
  Deletes the object what is referred in this pointer.
void  Serialize (Stream &s)
  Serializes the pointer value to a stream.
void  StartEvent (NodeEventType cType) const
Attribute::AttributeType  Type (void) const
  PTROPERATORS (type)
template<>
AttributeWidget CreateEditorWidget (QWidget *pParent, int iWidth)

Public Attributes

QString  m_sNullString
bool  m_bAllowNull

Friends

class  Node
class  AttributeThisPointer
struct  Attribute

Constructor & Destructor Documentation

template<typename type>
mudbox::AttributePointer< type >::AttributePointer Node pOwner = NULL,
const QString &  sID = ""
[inline]
 
00566 :
    AttributePointer( Node *pOwner=NULL, const QString &sID = "") : AttributeInstance<type *>( pOwner, sID ) { SetValue( 0, true ); m_pValidator = 0; m_sNullString = "NULL"; m_bAllowNull = true; };
template<typename type>
mudbox::AttributePointer< type >::AttributePointer Node pOwner,
const QString &  sID,
bool  bInstall
[inline]
 
00566 :
    AttributePointer( Node *pOwner=NULL, const QString &sID = "") : AttributeInstance<type *>( pOwner, sID ) { SetValue( 0, true ); m_pValidator = 0; m_sNullString = "NULL"; m_bAllowNull = true; };

Member Function Documentation

template<typename type>
QString mudbox::AttributePointer< type >::AsString void   )  const [inline, virtual]
 

Reimplemented from mudbox::AttributeInstance< type * >.

00566 :
    AttributePointer( Node *pOwner=NULL, const QString &sID = "") : AttributeInstance<type *>( pOwner, sID ) { SetValue( 0, true ); m_pValidator = 0; m_sNullString = "NULL"; m_bAllowNull = true; };
template<typename type>
void mudbox::AttributePointer< type >::SetFromString const QString &   )  [inline, virtual]
 

Reimplemented from mudbox::AttributeInstance< type * >.

00566 :
    AttributePointer( Node *pOwner=NULL, const QString &sID = "") : AttributeInstance<type *>( pOwner, sID ) { SetValue( 0, true ); m_pValidator = 0; m_sNullString = "NULL"; m_bAllowNull = true; };
template<typename type>
void mudbox::AttributePointer< type >::SetValidator validator *  pValidator  )  [inline]
 

Register a function as the validator for this pointer. This function will be called each time a new value has to be assigned to the pointer. If this function returns false the value wont be assigned to the pointer.

00568 : AttributeInstance<type *>( pOwner, sID, bInstall ) { SetValue( 0, true ); m_pValidator = 0; m_sNullString = "NULL"; m_bAllowNull = true; };
template<typename type>
void mudbox::AttributePointer< type >::SetPointerValue Node pNode,
bool  bLink = true
[inline, virtual]
 

Reimplemented from mudbox::Attribute.

00569                                    { if ( PointerValue() ) return PointerValue()->Name(); else return m_sNullString; };
00570     void SetFromString( const QString & /*sValue*/ ) { SetPointerValue( 0 ); };
00572     inline void SetValidator( validator *pValidator ) { m_pValidator = pValidator; };
00573     void SetPointerValue( Node *pNode, bool bLink = true ) 
00574     {
00575         // always accept 0 pointer, the target may be destroyed
00576         if ( pNode && m_pValidator && !m_pValidator( dynamic_cast<type *>( pNode ) ) )
00577             return;
00578         if ( bLink )
template<typename type>
void mudbox::AttributePointer< type >::SetValue type *  cValue,
bool  bX = false
[inline, virtual]
 

Reimplemented from mudbox::AttributeInstance< type * >.

00584     {
00585         if ( cValue == AttributePointer<type>::Value() )
00586             return;
template<typename type>
void mudbox::AttributePointer< type >::AddTarget Attribute cTarget  )  [inline, virtual]
 

Reimplemented from mudbox::AttributeInstance< type * >.

00592     {
00593         Attribute::AddTarget( cTarget );
00594         if ( cTarget.Size() )
00595         {
template<typename type>
void mudbox::AttributePointer< type >::DeleteTarget void   )  [inline]
 

Deletes the object what is referred in this pointer.

00602     {
template<typename type>
void mudbox::AttributePointer< type >::Serialize Stream s  )  [inline, virtual]
 

Serializes the pointer value to a stream.

The following two lines are doing the same:

        s == m_pMyPointer;
        m_pMyPointer.Serialize( s );
The stream has an internal list of the nodes it contains. This list is empty when the stream is opened, and keeps growing as more and more nodes are serialized. If the stream is writing data to a file and a pointers Serialize function is called, the stream checks the list if the target of the pointer is there or not. If its there, it will only write the index of the node into the stream. Otherwise it will serialize the target node and append it to the end of the list. You don't have to know about this mechanism, but be carefull because if you serialize pointers in your nodes then it might lead to a huge stream file containing lots of nodes. For example if you have a pointer to a mesh object, and you serialize that pointer, then the whole scene graph will be serialized to the file, since the mesh node will also serialize some pointers and so on.

Reimplemented from mudbox::AttributeInstance< type * >.

00308 {
00309     if ( s.IsStoring() )
00310         s.WritePointer( AttributeInstance<type *>::Value() );
00311     else
00312         SetValue( dynamic_cast<type *>( s.ReadPointer() ) );
00313 };
template<typename type>
void mudbox::AttributePointer< type >::StartEvent NodeEventType  cType  )  const [inline, virtual]
 

Reimplemented from mudbox::Attribute.

00622     {
00623         AttributeInstance<type *>::StartEvent( cType );
template<typename type>
Attribute::AttributeType mudbox::AttributePointer< type >::Type void   )  const [inline, virtual]
 

Reimplemented from mudbox::AttributeInstance< type * >.

template<typename type>
mudbox::AttributePointer< type >::PTROPERATORS type   ) 
 
template<>
AttributeWidget * mudbox::AttributePointer< Image >::CreateEditorWidget QWidget *  pParent,
int  iWidth
[inline, virtual]
 

Reimplemented from mudbox::AttributeInstance< type * >.

02118 { return CreateNewImageWidget( pParent, iWidth, this ); };

Friends And Related Function Documentation

template<typename type>
friend class Node [friend]
 

Reimplemented from mudbox::Attribute.

template<typename type>
friend class AttributeThisPointer [friend]
 
template<typename type>
friend struct Attribute [friend]
 

Member Data Documentation

template<typename type>
QString mudbox::AttributePointer< type >::m_sNullString
 
template<typename type>
bool mudbox::AttributePointer< type >::m_bAllowNull