GenericAttribute.cpp

From Giona

(Difference between revisions)
 
(3 intermediate revisions not shown)
Line 3: Line 3:
  * GenericAttribute.cpp
  * GenericAttribute.cpp
  * ====================
  * ====================
-
*
 
  * This class represents the implementation of a Generic Attribute.
  * This class represents the implementation of a Generic Attribute.
 +
* Author: Rosario Marino
  */
  */
-
#include "bool.h"
+
 
-
#include "mytypes.h"
+
#include "GenericAttribute.h"
#include "GenericAttribute.h"
Line 16: Line 15:
GenericAttribute::GenericAttribute()
GenericAttribute::GenericAttribute()
{
{
-
this->name = EMPTY_STRING;
+
Debug::debug("GenericAttribute::GenericAttribute()");
 +
this->name = EMPTY_STRING;
this->value = EMPTY_STRING;
this->value = EMPTY_STRING;
this->description = EMPTY_STRING;
this->description = EMPTY_STRING;
 +
this->lastError = ERROR_NO;
}
}
Line 26: Line 27:
GenericAttribute::~GenericAttribute()
GenericAttribute::~GenericAttribute()
{
{
 +
Debug::debug("GenericAttribute::~GenericAttribute()");
 +
}
 +
 +
/*
 +
* Returns last error code
 +
*/
 +
int GenericAttribute::getLastError()
 +
{
 +
Debug::debug("int GenericAttribute::getLastError()");
 +
return this->lastError;
}
}
/*
/*
  * Sets the name of the attribute
  * Sets the name of the attribute
 +
* Returns false in case of error
  */
  */
-
void GenericAttribute::setName(STRING name)
+
bool GenericAttribute::setName(STRING name)
{
{
 +
Debug::debug("bool GenericAttribute::setName(STRING name)");
 +
if(name==NULL)
 +
{
 +
Debug::debug("ERROR: ERROR_NULL_PARAMETER");
 +
this->lastError=ERROR_NULL_PARAMETER;
 +
return false;
 +
}
 +
if(strcmp(name, EMPTY_STRING)==0)
 +
{
 +
Debug::debug("ERROR: ERROR_EMPTY_STRING");
 +
this->lastError=ERROR_EMPTY_STRING;
 +
return false;
 +
}
 +
this->name = name;
this->name = name;
 +
return true;
}
}
Line 41: Line 68:
STRING GenericAttribute::getName()
STRING GenericAttribute::getName()
{
{
 +
Debug::debug("STRING GenericAttribute::getName()");
return this->name;
return this->name;
}
}
Line 47: Line 75:
  * Sets the value of the attribute
  * Sets the value of the attribute
  */
  */
-
void GenericAttribute::setValue(STRING value)
+
bool GenericAttribute::setValue(STRING value)
{
{
 +
Debug::debug("bool GenericAttribute::setValue(STRING value)");
 +
if(value==NULL)
 +
{
 +
Debug::debug("ERROR: ERROR_NULL_PARAMETER");
 +
this->lastError=ERROR_NULL_PARAMETER;
 +
return false;
 +
}
 +
if(strcmp(value, EMPTY_STRING)==0)
 +
{
 +
Debug::debug("ERROR: ERROR_EMPTY_STRING");
 +
this->lastError=ERROR_EMPTY_STRING;
 +
return false;
 +
}
 +
this->value = value;
this->value = value;
 +
return true;
}
}
Line 57: Line 100:
STRING GenericAttribute::getValue()
STRING GenericAttribute::getValue()
{
{
 +
Debug::debug("STRING GenericAttribute::getValue()");
return this->value;
return this->value;
}
}
Line 63: Line 107:
  * Sets the description of the attribute
  * Sets the description of the attribute
  */
  */
-
void GenericAttribute::setDescription(STRING description)
+
bool GenericAttribute::setDescription(STRING description)
{
{
 +
Debug::debug("bool GenericAttribute::setDescription(STRING description)");
 +
if(description==NULL)
 +
{
 +
Debug::debug("ERROR: ERROR_NULL_PARAMETER");
 +
this->lastError=ERROR_NULL_PARAMETER;
 +
return false;
 +
}
 +
this->description = description;
this->description = description;
 +
return true;
}
}
Line 73: Line 126:
STRING GenericAttribute::getDescription()
STRING GenericAttribute::getDescription()
{
{
 +
Debug::debug("STRING GenericAttribute::getDescription()");
return this->description;
return this->description;
}
}
-
 
</pre>
</pre>
 +
 +
[[Il database Object Oriented Generico|BACK]]
 +
[[Category:Codice Sorgente]]

Current revision as of 16:57, 13 December 2007

/*
 * GenericAttribute.cpp
 * ====================
 * This class represents the implementation of a Generic Attribute.
 * Author: Rosario Marino
 */


#include "GenericAttribute.h"

/*
 * Constructor
 */
GenericAttribute::GenericAttribute()
{
	Debug::debug("GenericAttribute::GenericAttribute()");
	this->name 	= EMPTY_STRING;
	this->value = EMPTY_STRING;
	this->description = EMPTY_STRING;
	this->lastError = ERROR_NO;
}

/*
 * Destructor
 */
GenericAttribute::~GenericAttribute()
{
	Debug::debug("GenericAttribute::~GenericAttribute()");
}

/*
 * 	Returns last error code
 */
int GenericAttribute::getLastError()
{
	Debug::debug("int GenericAttribute::getLastError()");
	return this->lastError;
}

/*
 * Sets the name of the attribute
 * Returns false in case of error
 */
bool GenericAttribute::setName(STRING name)
{
	Debug::debug("bool GenericAttribute::setName(STRING name)");
	if(name==NULL)
	{
		Debug::debug("ERROR: ERROR_NULL_PARAMETER");
		this->lastError=ERROR_NULL_PARAMETER;
		return false;
	}
	if(strcmp(name, EMPTY_STRING)==0)
	{
		Debug::debug("ERROR: ERROR_EMPTY_STRING");
		this->lastError=ERROR_EMPTY_STRING;
		return false;
	}
	
	this->name = name;
	return true;
}

/*
 * Returns the name of the attribute
 */
STRING GenericAttribute::getName()
{
	Debug::debug("STRING GenericAttribute::getName()");
	return this->name;
}

/*
 * Sets the value of the attribute
 */
bool GenericAttribute::setValue(STRING value)
{
	Debug::debug("bool GenericAttribute::setValue(STRING value)");
	if(value==NULL)
	{
		Debug::debug("ERROR: ERROR_NULL_PARAMETER");
		this->lastError=ERROR_NULL_PARAMETER;
		return false;
	}
	if(strcmp(value, EMPTY_STRING)==0)
	{
		Debug::debug("ERROR: ERROR_EMPTY_STRING");
		this->lastError=ERROR_EMPTY_STRING;
		return false;
	}
	
	this->value = value;
	return true;
}

/*
 * Returns the value of the attribute
 */
STRING GenericAttribute::getValue()
{
	Debug::debug("STRING GenericAttribute::getValue()");
	return this->value;
}

/*
 * Sets the description of the attribute
 */
bool GenericAttribute::setDescription(STRING description)
{
	Debug::debug("bool GenericAttribute::setDescription(STRING description)");
	if(description==NULL)
	{
		Debug::debug("ERROR: ERROR_NULL_PARAMETER");
		this->lastError=ERROR_NULL_PARAMETER;
		return false;
	}
	
	this->description = description;
	return true;
}

/*
 * Returns the description of the attribute
 */
STRING GenericAttribute::getDescription()
{
	Debug::debug("STRING GenericAttribute::getDescription()");
	return this->description;
}

BACK

Personal tools