treenode.h

Go to the documentation of this file.
00001 
00002 
00003 //**************************************************************************/
00004 
00005 // Copyright (c) 2008 Autodesk, Inc.
00006 
00007 // All rights reserved.
00008 
00009 //
00010 
00011 // Use of this software is subject to the terms of the Autodesk license
00012 
00013 // agreement provided at the time of installation or download, or which
00014 
00015 // otherwise accompanies this software in either electronic or hard copy form.
00016 
00017 //
00018 
00019 //**************************************************************************/
00020 
00021 // DESCRIPTION:
00022 
00023 // CREATED: October 2008
00024 
00025 //**************************************************************************/
00026 
00027 
00028 
00029 namespace mudbox {
00030 
00031 
00032 
00034 
00035 class MBDLL_DECL TreeNode : virtual public Node
00036 
00037 {
00038 
00039 public:
00040 
00041     DECLARE_CLASS;
00042 
00043 
00044 
00045     TreeNode( void );
00046 
00047     ~TreeNode( void );
00048 
00049     virtual void Serialize( Stream &s );
00050 
00051 
00052 
00054 
00055     virtual void AddChild( TreeNode *pChild, bool bFirst = false ) const;
00056 
00058 
00059     virtual void RemoveChild( TreeNode *pChild ) const;
00060 
00062 
00063     virtual TreeNode *FirstChild( void ) const;
00064 
00066 
00067     virtual TreeNode *Parent( void ) const;
00068 
00070 
00071     virtual TreeNode *NextSibling( void ) const;
00072 
00074 
00075     virtual TreeNode *PrevSibling( void ) const;
00076 
00077 
00078 
00080 
00081     virtual TreeNode *ChildByClass( const ClassDesc *pClass, bool bAutoCreate = true ) const;
00082 
00084 
00085     template < typename type >
00086 
00087     inline type *ChildByClass( bool bAutoCreate = true ) const { return dynamic_cast<type *>( ChildByClass( type::StaticClass(), bAutoCreate ) ); };
00088 
00090 
00091     virtual TreeNode *ChildByClass( const ClassDesc *pClass, unsigned int iIndex = 0 ) const;
00092 
00094 
00095     template < typename type >
00096 
00097     inline type *ChildByClass( unsigned int iIndex = 0 ) const { return dynamic_cast<type *>( ChildByClass( type::StaticClass(), iIndex ) ); };
00098 
00100 
00101     virtual void DeleteChildByClass( const ClassDesc *pClass );
00102 
00103 
00104 
00106 
00107     virtual QString Info( void ) const;
00108 
00110 
00111     virtual bool Visible( void ) const;
00112 
00114 
00115     virtual void SetVisible( bool b );
00116 
00118 
00119     virtual bool Locked( void ) const;
00120 
00122 
00123     virtual void SetLocked( bool b );
00124 
00125 
00126 
00128 
00129     virtual void OnLinked( const TreeNode *pOldParent );
00130 
00131 
00132 
00134 
00135     virtual void CheckValidity( Node::DiagnosticLevel iLevel ) const;
00136 
00137 
00138 
00140 
00141     QString UniqueChildName( 
00142 
00143         const TreeNode* pChild,         
00144 
00145         const QString& sPrefix = ""     
00146 
00147         ) const;
00148 
00149 
00150 
00152 
00153     virtual void SetName( const QString &sName );
00154 
00155 
00156 
00157 private:
00158 
00159     mutable aptr<TreeNode> m_pNext;
00160 
00161     mutable aptr<TreeNode> m_pPrev;
00162 
00163     mutable aptr<TreeNode> m_pParent;
00164 
00165     mutable aptr<TreeNode> m_pChildren;
00166 
00167     abool m_bVisible, m_bLocked;
00168 
00169 };
00170 
00171 
00172 
00173 }; // end of namespace mudbox
00174