From 80e2acb01c9e9d5ca71bce9f43b2b6a44074b04a Mon Sep 17 00:00:00 2001
From: meini <meini@meini-desktop.ARBEITSGRUPPE>
Date: Mon, 16 Mar 2009 06:53:49 +0100
Subject: TestMedul for remoteConfig

---
 src/testmodul.cc |  103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/testmodul.h  |   44 +++++++++++++++++++++++
 2 files changed, 147 insertions(+), 0 deletions(-)
 create mode 100644 src/testmodul.cc
 create mode 100644 src/testmodul.h

diff --git a/src/testmodul.cc b/src/testmodul.cc
new file mode 100644
index 0000000000000000000000000000000000000000..cde54039725e318f838f50de037f9e10a4efbb86
--- /dev/null
+++ b/src/testmodul.cc
@@ -0,0 +1,103 @@
+
+#include <gea/API.h>
+#include <gea/gea_main.h>
+#include <gea/ObjRepository.h>
+#include <SPP2.h>
+
+#include "testmodul.h"
+#include "remoteConfig.h"
+using namespace std;
+using namespace awds;
+
+
+RemoteConfigTestModule::RemoteConfigTestModule()
+{
+	REP_MAP_OBJ(RemoteConfig *,remoteConfig);
+
+	this->testint=21;
+	this->testdouble=1982;
+	this->testfloat=1;
+	this->testchar=new char[16];
+	memset(this->testchar,0,16);
+	memcpy(this->testchar,"Hallo du!!",16);
+	this->testbool=false;
+
+	//ConfigVariableInt(const char* name, const int value, variableGetHandler vgh,variableSetHandler vsh,void* classref):
+	remoteConfig->remoteConfigAnnounce((char*)"testint",new ConfigVariableInt("testint",10,getint,setint,this));
+
+}
+
+//typedef int (*variableSetHandler) (const void* value, void* thisref);
+//typedef int (*variableGetHandler) (void* value, void* thisref);
+
+static const char *config_cmd_usage =
+    "remoteConfig [node1,node2,...] <module>.<variable> <value>  \n"
+    " with <nodeN>		hostname	or\n"
+		" with [..]				for all nodes in network\n"
+    " with <module>		the module containing the configuration variable\n"
+    " with <value>		the value to be assigned to the variable\n";
+
+int RemoteConfigTestModule::addRemoteConfigTestModulCmd()
+{
+
+    ObjRepository& rep = ObjRepository::instance();
+
+    Shell *shell = static_cast<Shell *>(rep.getObj("shell"));
+
+    if (!shell)
+	return -1;
+
+    shell->add_command("rct", remoteconfigTestModule_command_fn, NULL,
+		       "remote configuration per (tiny)RPC",
+		       config_cmd_usage);
+
+    return 0;
+}
+void RemoteConfigTestModule::print()
+{
+	printf("test3!!\n");fflush(stdout);
+	
+	GEA.dbg() << "testdouble" <<testdouble<<"\n"; 
+	if(testbool==true)
+	{
+	GEA.dbg() << "testdouble2" <<testdouble<<"\n"; 
+		printf("testint: %li testdouble: %lf testfloat: %f testchar:<%s> testbool: true\n",testint,testdouble,testfloat,this->testchar);
+	}
+	else
+	{
+		printf("testint: %li testdouble: %lf testfloat: %f testchar:<%s> testbool: false\n",testint,testdouble,testfloat,this->testchar);
+	}
+}
+int RemoteConfigTestModule::remoteconfigTestModule_command_fn(ShellClient &sc, void *data, int argc, char **argv)
+{
+	REP_MAP_OBJ(RemoteConfigTestModule *,remoteConfigTestModule);
+	int cmd=0;
+	if ( (argc >= 2) && !strcmp(argv[1], "print"))
+	{
+			cmd = 1;
+	}
+	else
+	{
+		*sc.sockout << "print!!!" << endl;
+		return 0;
+	}
+	if(cmd==1)
+	{
+		printf("test!!\n");fflush(stdout);
+		remoteConfigTestModule->print();
+		printf("test2!!\n");fflush(stdout);
+	}
+    return 0;
+}
+
+GEA_MAIN(argc, argv)
+{
+
+	RemoteConfigTestModule *remoteConfigTest = new RemoteConfigTestModule();
+	REP_INSERT_OBJ(RemoteConfigTestModule *, remoteConfigTest, remoteConfigTest);
+	if (!remoteConfigTest)//TODO hier eher nen fehler abfangen als NULL checken weil evtl wirds net NULL gesetzt
+	{
+			GEA.dbg() << "RemoteConfigTest Module not found :( " << endl;
+	}
+	else remoteConfigTest->addRemoteConfigTestModulCmd();
+}
\ No newline at end of file
diff --git a/src/testmodul.h b/src/testmodul.h
new file mode 100644
index 0000000000000000000000000000000000000000..464dbca121bf51f1f10d21d598e507797bf28453
--- /dev/null
+++ b/src/testmodul.h
@@ -0,0 +1,44 @@
+#ifndef _REMOTECONFIGTEST_H__
+#define _REMOTECONFIGTEST_H__
+
+
+
+#include "remoteConfig.h"
+#include "configVariable.h"
+
+class RemoteConfigTestModule
+{
+
+private:
+int	testint;
+double	testdouble;
+float	testfloat;
+char*	testchar;
+bool	testbool;
+
+
+protected:
+
+public:
+	RemoteConfigTestModule();
+
+	int  addRemoteConfigTestModulCmd();
+	void print();
+	
+	static int remoteconfigTestModule_command_fn(ShellClient &sc, void *data, int argc, char **argv);
+
+	static int setint( void* thisref,const void* value)
+	{
+		((RemoteConfigTestModule*)thisref)->testint=*((int*)value);
+		return CONFIG_VARIABLE_SUCCESS;
+	}
+	static int getint (void* thisref,void* value)
+	{
+		*((int*)value)=((RemoteConfigTestModule*)thisref)->testint;
+		return CONFIG_VARIABLE_SUCCESS;
+	}
+
+
+};
+
+#endif
\ No newline at end of file
-- 
1.6.2.1


