Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions debug_cli/DbgCliNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#ifndef PLAT_DEBUG_CLI_DBGCLINODE_H_
#define PLAT_DEBUG_CLI_DBGCLINODE_H_

/**
* Composite Pattern: Abstract Node Class, acts as the Interface to the object tree.
*/
class DbgCli_Node
{
protected: // abstract class - constructor must not be accessible
Expand Down
15 changes: 15 additions & 0 deletions debug_cli/DbgCliTopic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ DbgCli_Topic* DbgCli_Topic::RootNode()

DbgCli_Topic::DbgCli_Topic(const char* parentPath, const char* nodeName, const char* helpText)
: DbgCli_Node(parentPath, nodeName, helpText)
, m_child(0)
, m_sibling(0)
{ }

DbgCli_Topic::~DbgCli_Topic()
Expand All @@ -27,6 +29,8 @@ DbgCli_Topic::~DbgCli_Topic()
void DbgCli_Topic::addNode(DbgCli_Node* node)
{
// TODO: search the parent node according to the provided parentPath given by the node object.
const char* parentPath = node->getParentPath();

}

DbgCli_Node* DbgCli_Topic::getNode(const char* cmdPath, unsigned int cmdPathStrLen)
Expand All @@ -40,3 +44,14 @@ void DbgCli_Topic::execute(unsigned int arg_cnt, char* args[], unsigned int idxT
// TODO: Finds its path according to the args array's tokens.
// TODO: Calls the execute method of the right child node if found, increments the index to the first parameter to handle accordingly.
}

void DbgCli_Topic::addChildNode(DbgCli_Node* node)
{
DbgCli_Topic* tmpTopic = m_child;
while (0 != tmpTopic)
{
tmpTopic = tmpTopic->m_sibling;
}
tmpTopic->addNode(node);
}

8 changes: 7 additions & 1 deletion debug_cli/DbgCliTopic.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <DbgCliNode.h>

/**
* This is the Compositum part of the Composite Pattern.
* This is the Composite part of the Composite Pattern.
*/
class DbgCli_Topic: public DbgCli_Node
{
Expand Down Expand Up @@ -44,9 +44,15 @@ class DbgCli_Topic: public DbgCli_Node
*/
virtual void execute(unsigned int argc, char* args[], unsigned int idxToFirstArgToHandle);

private:
void addChildNode(DbgCli_Node* node);
DbgCli_Node* getChildNode(const char* childNodeName);

private:
static DbgCli_Topic* s_rootNode;

DbgCli_Node* m_child;
DbgCli_Node* m_sibling;

private: // forbidden default functions
DbgCli_Topic& operator= (const DbgCli_Topic& src); // assignment operator
Expand Down