GenericListNode.cpp

From Giona

(Difference between revisions)
 
Line 1: Line 1:
<pre>
<pre>
-
 
/****************************************************************************
/****************************************************************************
  *Generic List Node for a Linked List.
  *Generic List Node for a Linked List.
 +
* --------------------------------------------------------------------------
  *Author: Rosario Marino
  *Author: Rosario Marino
  ***************************************************************************/
  ***************************************************************************/
Line 27: Line 27:
     if(this->elem)
     if(this->elem)
     if(!notAnObject)
     if(!notAnObject)
 +
    {
 +
    Debug::debug("GenericListNode::~GenericListNode() is deleting node element");
     delete(this->elem);
     delete(this->elem);
 +
    }
}
}
Line 76: Line 79:
return this->next;
return this->next;
}
}
 +
</pre>
</pre>

Current revision as of 17:37, 17 December 2007

/****************************************************************************
 *Generic List Node for a Linked List.
 * --------------------------------------------------------------------------
 *Author: Rosario Marino
 ***************************************************************************/

#include "GenericListNode.h"

/*
 * Constructor
 */
GenericListNode::GenericListNode()
{
	Debug::debug("GenericListNode::GenericListNode()");
	this->next = NULL;
	this->elem = NULL;
	this->notAnObject=false;
}

/*
 * Destructor
 */
GenericListNode::~GenericListNode()
{
	Debug::debug("GenericListNode::~GenericListNode()");
    if(this->elem)
    	if(!notAnObject)
    	{
    		Debug::debug("GenericListNode::~GenericListNode() is deleting node element");
    		delete(this->elem);
    	}
}

/*
 * 	This method must be called if the element of the node
 * 	is not an object created by a new() statement (so that
 *  the delete statement will ignore it)
 */
void GenericListNode::setNotAnObject()
{
	Debug::debug("void GenericListNode::setNotAnObject()");
	this->notAnObject=true;
}

/*
 * Sets the element of the node
 */
void GenericListNode::setElem(genericListElemT elem)
{
	Debug::debug("void GenericListNode::setElem(genericListElemT elem)");
	this->elem = elem;
}

/*
 * Returns the element of the node
 */
genericListElemT GenericListNode::getElem()
{
	Debug::debug("genericListElemT GenericListNode::getElem()");
	return this->elem;
}

/*
 * Sets next node in the list
 */
void GenericListNode::setNext(GenericListNode *next)
{
	Debug::debug("void GenericListNode::setNext(GenericListNode *next)");
	this->next = next;
}

/*
 * Returns next node in the list
 */
GenericListNode* GenericListNode::getNext()
{
	Debug::debug("GenericListNode* GenericListNode::getNext()");
	return this->next;
}


BACK

Personal tools