00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #pragma once
00013
00015 #include "nvsgcommon.h"
00016
00017 #include "nvsg/Node.h"
00018
00019 namespace nvsg
00020 {
00022
00025 class Path : public nvutil::RCObject
00026 {
00027 public:
00029 NVSG_API Path( void );
00030
00032 NVSG_API Path( const Path& rhs );
00033
00035
00036 NVSG_API unsigned int getLength( void ) const;
00037
00039
00041 NVSG_API bool isEmpty( void ) const;
00042
00044
00045 NVSG_API const Node * getHead( void ) const;
00046
00048
00049 NVSG_API const Node * getTail( void ) const;
00050
00052
00054 NVSG_API const Node * getNodeFromHead( size_t i
00055 ) const;
00056
00058
00060 NVSG_API const Node * getNodeFromTail( size_t i
00061 ) const;
00062
00064 NVSG_API void pop( void );
00065
00067
00068 NVSG_API void push( const Node * pNode
00069 );
00070
00072
00073 NVSG_API void truncate( size_t start
00074 );
00075
00076 protected:
00078 NVSG_API virtual ~Path(void);
00079
00080 private:
00081 std::vector<const Node *> m_path;
00082 };
00083
00084
00085
00086
00087
00089 inline const Node * Path::getHead( void ) const
00090 {
00091 __TRACE();
00092 return( m_path.empty() ? NULL : m_path.front() );
00093 }
00094
00096 inline const Node * Path::getTail( void ) const
00097 {
00098 __TRACE();
00099 return( m_path.empty() ? NULL : m_path.back() );
00100 }
00101
00103 inline const Node * Path::getNodeFromHead( size_t i ) const
00104 {
00105 __TRACE();
00106 __ASSERT(0 <= i && i < m_path.size());
00107 return( m_path[i] );
00108 }
00109
00111 inline const Node * Path::getNodeFromTail( size_t i ) const
00112 {
00113 __TRACE();
00114 __ASSERT(0 <= i && i < m_path.size());
00115 return( m_path[m_path.size() - i-1] );
00116 }
00117
00118 inline unsigned int Path::getLength( void ) const
00119 {
00120 __TRACE();
00121 return (unsigned int) m_path.size();
00122 }
00123
00124 inline void Path::pop( void )
00125 {
00126 __TRACE();
00127 __ASSERT(getLength() > 0);
00128 m_path.back()->removeRef();
00129 m_path.pop_back();
00130 }
00131
00132 inline bool Path::isEmpty( void ) const
00133 {
00134 __TRACE();
00135 return m_path.empty();
00136 }
00137 }