#ifndef CODE_MESSAGETOOLS_CXX
#define CODE_MESSAGETOOLS_CXX

/*-----------------------------------------------------------------------
 * Xclasses code file
 * ($Id: message_tools.cxx,v 1.5 2000/05/18 14:11:58 schmitzj Exp $)
 * 
 * Copyright (C) 1998 Jürgen Schmitz
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA  02111-1307, USA.
 *-----------------------------------------------------------------------
 */

#include <math.h>
#include <Xclasses/types.h>
#include <Xclasses/message_tools.h>

// ===================================================================
// msg get Klassen
// -------------------------------------------------------------------

msgget_int::msgget_int(callable *c,int (callable::*f)(void)) : msg_get(c,(void (callable::*)(void))f)
{
}
msgget_int::msgget_int(callable *c,unsigned int (callable::*f)(void)) : msg_get(c,(void (callable::*)(void))f)
{
}
msgget_int::~msgget_int()
{
}
#include <Xclasses/slider.h>
void *msgget_int::get(void)
{
	static int v=0;
	v=(classptr->*(int (callable::*)(void))classfunc)();
	return &v;
}
// -------------------------------------------------------------------
msgget_char::msgget_char(callable *c,void (callable::*f)(char *),int size) : msg_get(c,(void (callable::*)(void))f)
{
	buf=new char[size+1];
}
msgget_char::~msgget_char()
{
	delete [] buf;
}
void *msgget_char::get(void)
{
	(classptr->*(void (callable::*)(char*))classfunc)(buf);
	return buf;
}
// -------------------------------------------------------------------

// ===================================================================
// msg set Klassen
// -------------------------------------------------------------------

msgset_int::msgset_int(callable *c,void (callable::*f)(int)) : msg_set(c,(void (callable::*)(void))f)
{
}
msgset_int::msgset_int(callable *c,void (callable::*f)(unsigned int)) : msg_set(c,(void (callable::*)(void))f)
{
}
msgset_int::~msgset_int()
{
}
void msgset_int::set(void *v)
{
	(classptr->*(void (callable::*)(int))classfunc)(*(int*)v);
}
// -------------------------------------------------------------------
msgset_char::msgset_char(callable *c,void (callable::*f)(char *)) : msg_set(c,(void (callable::*)(void))f)
{
}
msgset_char::~msgset_char()
{
}
void msgset_char::set(void *v)
{
	(classptr->*(void (callable::*)(char*))classfunc)((char*)v);
}
// -------------------------------------------------------------------

// ===================================================================
// msg conv Klassen
// -------------------------------------------------------------------

msgconv_int2char::msgconv_int2char() : msg_conv()
{
	buf=new char[300];
}
msgconv_int2char::~msgconv_int2char()
{
	if (buf) delete buf;
}
void *msgconv_int2char::conv(void *v)
{
	sprintf(buf,"%d",*(int*)v);
	return (void*)buf;
}
// -------------------------------------------------------------------
msgconv_char2int::msgconv_char2int() : msg_conv()
{
}
msgconv_char2int::~msgconv_char2int()
{
}
void *msgconv_char2int::conv(void *v)
{
	static int b=0;
	sscanf((char*)v,"%d",&b);
	return (void*)&b;
}
// -------------------------------------------------------------------


#endif
