Kaydet (Commit) 97ae05a4 authored tarafından Joseph Powers's avatar Joseph Powers

Rename List -> NodeList

List was defined as std::vector< Node* >; but calling it List is confusing
since you don't know what type of list it is. Also it's just asking for
compile issues since we also use std::List, a custom List<>, & a class List.

I also removed Node::Children() since it wasn't used.
üst 9097947b
...@@ -29,9 +29,6 @@ ...@@ -29,9 +29,6 @@
#ifndef ADC_DISPLAY_OUT_NODE_HXX #ifndef ADC_DISPLAY_OUT_NODE_HXX
#define ADC_DISPLAY_OUT_NODE_HXX #define ADC_DISPLAY_OUT_NODE_HXX
namespace output namespace output
{ {
...@@ -45,87 +42,84 @@ namespace output ...@@ -45,87 +42,84 @@ namespace output
*/ */
class Node class Node
{ {
public: public:
typedef std::vector< Node* > List; typedef std::vector< Node* > NodeList;
typedef UINT32 relative_id; typedef UINT32 relative_id;
// LIFECYCLE // LIFECYCLE
enum E_NullObject { null_object }; enum E_NullObject { null_object };
Node(); Node();
explicit Node( explicit Node( E_NullObject );
E_NullObject ); ~Node();
~Node();
// OPERATORS
// OPERATORS bool operator==( const Node& i_node ) const
bool operator==( { return pParent == i_node.pParent AND sName == i_node.sName; }
const Node & i_node ) const
{ return pParent == i_node.pParent AND sName == i_node.sName; } bool operator!=( const Node& i_node ) const
bool operator!=( { return NOT operator==(i_node); }
const Node & i_node ) const
{ return NOT operator==(i_node); } // OPERATIONS
/// Seek, and if not existent, create.
// OPERATIONS Node& Provide_Child( const String& i_name );
/// Seek, and if not existent, create.
Node & Provide_Child( /// Seek, and if not existent, create.
const String & i_name ); Node& Provide_Child( const StringVector& i_path )
/// Seek, and if not existent, create. { return provide_Child(i_path.begin(), i_path.end()); }
Node & Provide_Child(
const StringVector &
i_path )
{ return provide_Child(i_path.begin(), i_path.end()); }
// INQUIRY // INQUIRY
intt Depth() const { return nDepth; } intt Depth() const { return nDepth; }
const String & Name() const { return sName; } const String & Name() const { return sName; }
/// @return Id of a namespace or class etc. this directory represents. /// @return Id of a namespace or class etc. this directory represents.
relative_id RelatedNameRoom() const { return nNameRoomId; } relative_id RelatedNameRoom() const { return nNameRoomId; }
/// @return No delimiter at start, with delimiter at end. /// @return No delimiter at start, with delimiter at end.
void Get_Path( void Get_Path(
StreamStr & o_result, StreamStr & o_result,
intt i_maxDepth = -1 ) const; intt i_maxDepth = -1
) const;
void Get_Chain( void Get_Chain(
StringVector & o_result, StringVector & o_result,
intt i_maxDepth = -1 ) const; intt i_maxDepth = -1
) const;
// ACCESS // ACCESS
void Set_RelatedNameRoom( void Set_RelatedNameRoom( relative_id i_nNameRoomId )
relative_id i_nNameRoomId ) { nNameRoomId = i_nNameRoomId; }
{ nNameRoomId = i_nNameRoomId; }
Node * Parent() { return pParent; } Node* Parent() { return pParent; }
Node * Child( Node* Child( const String& i_name )
const String & i_name ) { return find_Child(i_name); }
{ return find_Child(i_name); }
List & Children() { return aChildren; }
/// @return a reference to a Node with Depth() == -1. /// @return a reference to a Node with Depth() == -1.
static Node & Null_(); static Node& Null_();
private: private:
// Local // Local
Node( Node(
const String & i_name, const String& i_name,
Node & i_parent ); Node& i_parent
);
Node * find_Child(
const String & i_name ); Node* find_Child( const String& i_name );
Node & add_Child(
const String & i_name ); Node& add_Child( const String& i_name );
Node & provide_Child(
StringVector::const_iterator Node& provide_Child(
i_next, StringVector::const_iterator i_next,
StringVector::const_iterator StringVector::const_iterator i_end
i_end ); );
// Data // Data
String sName; String sName;
Node * pParent; Node* pParent;
List aChildren; NodeList aChildren;
intt nDepth; intt nDepth;
relative_id nNameRoomId; relative_id nNameRoomId;
}; };
} // namespace output } // namespace output
#endif #endif
......
...@@ -63,35 +63,37 @@ Node C_aNullNode(Node::null_object); ...@@ -63,35 +63,37 @@ Node C_aNullNode(Node::null_object);
Node::Node() Node::Node()
: sName(), : sName(),
pParent(0), pParent(0),
aChildren(), aChildren(),
nDepth(0), nDepth(0),
nNameRoomId(0) nNameRoomId(0)
{ {
} }
Node::Node( E_NullObject ) Node::Node( E_NullObject )
: sName(), : sName(),
pParent(0), pParent(0),
aChildren(), aChildren(),
nDepth(-1), nDepth(-1),
nNameRoomId(0) nNameRoomId(0)
{ {
} }
Node::Node( const String & i_name, Node::Node(
Node & i_parent ) const String & i_name,
: sName(i_name), Node & i_parent
pParent(&i_parent), ) :
aChildren(), sName(i_name),
nDepth(i_parent.Depth()+1), pParent(&i_parent),
nNameRoomId(0) aChildren(),
nDepth(i_parent.Depth()+1),
nNameRoomId(0)
{ {
} }
Node::~Node() Node::~Node()
{ {
for ( List::iterator it = aChildren.begin(); for ( NodeList::iterator it = aChildren.begin();
it != aChildren.end(); it != aChildren.end();
++it ) ++it )
{ {
...@@ -99,19 +101,18 @@ Node::~Node() ...@@ -99,19 +101,18 @@ Node::~Node()
} }
} }
Node & Node& Node::Provide_Child( const String & i_name )
Node::Provide_Child( const String & i_name )
{ {
Node * Node* ret = find_Child(i_name);
ret = find_Child(i_name);
if (ret != 0) if (ret != 0)
return *ret; return *ret;
return add_Child(i_name); return add_Child(i_name);
} }
void void Node::Get_Path(
Node::Get_Path( StreamStr & o_result, StreamStr& o_result,
intt i_maxDepth ) const intt i_maxDepth
) const
{ {
// Intentionally 'i_maxDepth != 0', so max_Depth == -1 sets no limit: // Intentionally 'i_maxDepth != 0', so max_Depth == -1 sets no limit:
if (i_maxDepth != 0) if (i_maxDepth != 0)
...@@ -122,9 +123,10 @@ Node::Get_Path( StreamStr & o_result, ...@@ -122,9 +123,10 @@ Node::Get_Path( StreamStr & o_result,
} }
} }
void void Node::Get_Chain(
Node::Get_Chain( StringVector & o_result, StringVector & o_result,
intt i_maxDepth ) const intt i_maxDepth
) const
{ {
if (i_maxDepth != 0) if (i_maxDepth != 0)
{ {
...@@ -138,13 +140,12 @@ Node::Get_Chain( StringVector & o_result, ...@@ -138,13 +140,12 @@ Node::Get_Chain( StringVector & o_result,
} }
} }
Node * Node* Node::find_Child( const String & i_name )
Node::find_Child( const String & i_name )
{ {
Node aSearch; Node aSearch;
aSearch.sName = i_name; aSearch.sName = i_name;
List::const_iterator NodeList::const_iterator
ret = std::lower_bound( aChildren.begin(), ret = std::lower_bound( aChildren.begin(),
aChildren.end(), aChildren.end(),
&aSearch, &aSearch,
...@@ -155,11 +156,9 @@ Node::find_Child( const String & i_name ) ...@@ -155,11 +156,9 @@ Node::find_Child( const String & i_name )
return 0; return 0;
} }
Node & Node& Node::add_Child( const String & i_name )
Node::add_Child( const String & i_name )
{ {
DYN Node * DYN Node* pNew = new Node(i_name,*this);
pNew = new Node(i_name,*this);
aChildren.insert( std::lower_bound( aChildren.begin(), aChildren.insert( std::lower_bound( aChildren.begin(),
aChildren.end(), aChildren.end(),
pNew, pNew,
...@@ -168,9 +167,10 @@ Node::add_Child( const String & i_name ) ...@@ -168,9 +167,10 @@ Node::add_Child( const String & i_name )
return *pNew; return *pNew;
} }
Node & Node& Node::provide_Child(
Node::provide_Child( StringVector::const_iterator i_next, StringVector::const_iterator i_next,
StringVector::const_iterator i_end ) StringVector::const_iterator i_end
)
{ {
if (i_next == i_end) if (i_next == i_end)
return *this; return *this;
...@@ -180,8 +180,7 @@ Node::provide_Child( StringVector::const_iterator i_next, ...@@ -180,8 +180,7 @@ Node::provide_Child( StringVector::const_iterator i_next,
Node & Node& Node::Null_()
Node::Null_()
{ {
return C_aNullNode; return C_aNullNode;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment