sercani
7/24/2015 - 7:45 PM

C++ Setter Getter Macros

C++ Setter Getter Macros

//--------------------------------------------------
#define SetMacro(name,type)								\
void Set##name (type _arg)								\
{														\
  if (this->name != _arg)								\
	{													\
		this->name = _arg;								\
	}													\
} 
//--------------------------------------------------
#define GetMacro(name,type)								\
type Get##name ()const									\
{														\
	return this->name;									\
} 
//--------------------------------------------------
#define SetGetMacro(name,type)							\
void Set##name (type _arg)								\
{														\
  if (this->name != _arg)								\
	{													\
		this->name = _arg;								\
	}													\
}														\
type Get##name ()const									\
{														\
	return this->name;									\
}
//--------------------------------------------------
#define BooleanMacro(name,type)							\
void name##On ()										\
{														\
	if(this->name != static_cast<type>(1))				\
	{													\
		this->name = static_cast<type>(1);				\
	}													\
}														\
void name##Off ()										\
{														\
	if(this->name != static_cast<type>(0))				\
	{													\
		this->name = static_cast<type>(0);				\
	}													\
}														\
type Is##name##On()										\
{														\
	return this->name;									\
}
//--------------------------------------------------
#define BooleanSetGetMacro(name,type)					\
void Set##name (type _arg)								\
{														\
  if (this->name != _arg)								\
	{													\
		this->name = _arg;								\
	}													\
}														\
type Get##name ()const									\
{														\
	return this->name;									\
}														\
void name##On ()										\
{														\
	if(this->name != static_cast<type>(1))				\
	{													\
		this->name = static_cast<type>(1);				\
	}													\
}														\
void name##Off ()										\
{														\
	if(this->name != static_cast<type>(0))				\
	{													\
		this->name = static_cast<type>(0);				\
	}													\
}														\
type Is##name##On()										\
{														\
	return this->name;									\
}