changeset 565:2e1b6c5e4f8f

linda API
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 22 Oct 2009 23:45:05 +0900
parents f7ec374fc093
children 006c4e9e6acb
files Renderer/Engine/SceneGraphRoot.cc Renderer/Engine/SceneGraphRoot.h Renderer/Engine/lindaapi.h Renderer/Engine/viewer.cc Renderer/Test/Makefile.macosx
diffstat 5 files changed, 69 insertions(+), 81 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraphRoot.cc	Thu Oct 22 23:07:16 2009 +0900
+++ b/Renderer/Engine/SceneGraphRoot.cc	Thu Oct 22 23:45:05 2009 +0900
@@ -72,18 +72,6 @@
 void
 SceneGraphRoot::registSceneGraph(SceneGraphPtr sg)
 {
-#if 0
-    for (int i = 0; i < SGLIST_LENGTH; i++) {
-		if (strcmp(sg->name, sglist_table[i]) == 0) {
-			sg->sgid = i;
-			sg_src[i] = sg;
-			return;
-		}
-    }
-
-    fprintf(stderr, "error: (%s:%3d) Can't find Scene \"%s\"\n",
-			__FUNCTION__, __LINE__, sg->name);
-#endif
 }
 
 void
--- a/Renderer/Engine/SceneGraphRoot.h	Thu Oct 22 23:07:16 2009 +0900
+++ b/Renderer/Engine/SceneGraphRoot.h	Thu Oct 22 23:45:05 2009 +0900
@@ -95,6 +95,11 @@
     void addSceneGraphList(TaskManager *manager, SceneGraphPtr tmp);
     void addNext(SceneGraphPtr sg);
     void allRemove(SceneGraphPtr list);
+
+    int getLast() {
+	return sglist->getLast()->id;
+    }
+
 };
 
 typedef SceneGraphRoot *SceneGraphRootPtr;
--- a/Renderer/Engine/lindaapi.h	Thu Oct 22 23:07:16 2009 +0900
+++ b/Renderer/Engine/lindaapi.h	Thu Oct 22 23:45:05 2009 +0900
@@ -1,8 +1,15 @@
-//  $Id: lindaapi.h,v 1.8 2005/12/21 07:29:38 yasumura Exp $
-//
+#ifndef _LINDAAPI_H
+
+#define _LINDAAPI_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*  $Id$ */
 
 /*----------------------------------------------------------------------
- ¥Þ¥¯¥íÄêµÁ
+  マクロ定義
 ----------------------------------------------------------------------*/
 
 #define FAIL            (-1)
@@ -13,8 +20,10 @@
 
 #define INT_SIZE    4     // Byte = sizeof(int)
 
+#define LDSERV_PORT     11511
+
 /*----------------------------------------------------------------------
- ¥Ñ¥±¥Ã¥È¥Õ¥©¡¼¥Þ¥Ã¥È
+ パケットフォーマット
  char     short  int    int
  Mode +   ID   + Seq  + Data_len + Padding + Data
  0        1      3      7          11        12
@@ -24,63 +33,65 @@
 #define LINDA_ID_OFFSET            1
 #define LINDA_SEQ_OFFSET           3
 #define LINDA_DATA_LENGTH_OFFSET   7
-#define LINDA_TID_OFFSET           11
 #define LINDA_HEADER_SIZE          12
 
 /*----------------------------------------------------------------------
- ¹½Â¤ÂÎÄêµÁ
+  構造体定義
 ----------------------------------------------------------------------*/
 typedef struct psx_reply{
     unsigned char *answer;
     unsigned int seq;
     struct psx_reply *next;
     char mode;
-    void(*callback)(char * tuple, void * obj);
+    void(*callback)(unsigned char * tuple, void * obj);
     void * obj;
-} REPLY, *REPLY_PTR;
-
+} REPLY;
+          
 typedef struct command_queue{
+    struct command_queue *next;
+    unsigned int tspace_id;        /* ID of destination Tuple Space */
+    unsigned int size;
     unsigned char *command;
-    struct command_queue *next;
-    unsigned int size;
-} COMMAND, *COMMAND_PTR;
+} COMMAND;
+
 
 /*----------------------------------------------------------------------
- ÀÅŪ´Ø¿ô¥Æ¥ó¥×¥ì¡¼¥È
+  Linda API
 ----------------------------------------------------------------------*/
 
-int start_linda(char *hostname);
-void unix_chkserv();
-extern void psx_free(char *tuple);
+extern void init_linda(void);
+extern int open_linda(char *hostname, int port);
+extern int open_linda_java(char *hostname, int port);
+extern int close_linda(int tspace_id);
 
-int psx_out(unsigned int id, unsigned char *data, unsigned int size);
-int psx_ld(unsigned int id, char mode, void(*callback)(char *,void *),void * obj);
+extern void psx_free(void*);
 
-#define psx_in(id)      psx_ld(id, 'i', NULL, NULL)
-#define psx_rd(id)      psx_ld(id, 'r', NULL, NULL)
-#define psx_ck(id)      psx_ld(id, 'c', NULL, NULL)
-#define psx_wait_rd(id) psx_ld(id, 'w', NULL, NULL)
-
-#define psx_callback_in(id,callback,obj)       psx_ld(id, 'i', callback, obj)
-#define psx_callback_rd(id,callback,obj)       psx_ld(id, 'r', callback, obj)
-#define psx_callback_ck(id,callback,obj)       psx_ld(id, 'c', callback, obj)
-#define psx_callback_wait_rd(id,callback,obj)  psx_ld(id, 'w', callback, obj)
+extern unsigned char *psx_reply(unsigned int seq);
+extern void psx_sync_n(void);
+extern unsigned int psx_get_datalength(unsigned char *);
+extern unsigned int psx_get_seq(unsigned char *);
+extern unsigned short psx_get_id(unsigned char *);
+extern unsigned char psx_get_mode(unsigned char *);
+extern unsigned char * psx_get_data(unsigned char *);
 
-unsigned char *psx_reply(int seq);
-void psx_sync_n();
-//void psx_free(unsigned char *);
-int psx_queue(unsigned int id, unsigned int size, unsigned char *data, char mode,
-              void(*callback)(char *,void *),void * obj);
-int psx_get_datalength(unsigned char *);
-unsigned char *psx_get_data(unsigned char *);
-int psx_get_seq(unsigned char *);
-short psx_get_id(unsigned char *);
-char psx_get_mode(unsigned char *);
+extern int psx_out(unsigned int tspace_id, unsigned int id,
+                   unsigned char *data, unsigned int size);
+extern int psx_ld(unsigned int tspace_id, unsigned int id,
+                  char mode, void(*callback)(unsigned char *,void *),void * obj);
+
+#define psx_in(tid, id)      psx_ld(tid, id, 'i', NULL, NULL)
+#define psx_rd(tid, id)      psx_ld(tid, id, 'r', NULL, NULL)
+#define psx_ck(tid, id)      psx_ld(tid, id, 'c', NULL, NULL)
+#define psx_wait_rd(tid, id) psx_ld(tid, id, 'w', NULL, NULL)
 
-int unix_open();                        /* UNIX ÄÌ¿®¤ò³«Àߤ¹¤ë */
-int unix_read(int,char *,unsigned int); /* UNIX ¤«¤éÆɤ߹þ¤à */
-int unix_read_w(int,char *,int);        /* UNIX ¤«¤éÆɤ߹þ¤à(non wait) */
-int unix_write(int,unsigned char *,unsigned int);/* UNIX ¤Ø½ñ¤­¹þ¤à */
-int unix_write_w(int,unsigned char *,unsigned int);/* UNIX ¤Ø½ñ¤­¹þ¤à(non wait) */
-int send_able();                        /* Æɤ߽ñ¤­¤Ç¤­¤ë¥Ñ¥±¥Ã¥È¿ô¤òµá¤á¤ë */
+#define psx_callback_in(tid, id,callback,obj)      psx_ld(tid, id, 'i', callback, obj)
+#define psx_callback_rd(tid, id,callback,obj)      psx_ld(tid, id, 'r', callback, obj)
+#define psx_callback_ck(tid, id,callback,obj)      psx_ld(tid, id, 'c', callback, obj)
+#define psx_callback_wait_rd(tid, id,callback,obj) psx_ld(tid, id, 'w', callback, obj)
+
 
+
+#ifdef __cplusplus
+};  // for extern "C"
+#endif
+#endif // _LINDAAPI_H
--- a/Renderer/Engine/viewer.cc	Thu Oct 22 23:07:16 2009 +0900
+++ b/Renderer/Engine/viewer.cc	Thu Oct 22 23:45:05 2009 +0900
@@ -90,31 +90,6 @@
     SDL_GL_SwapBuffers();
 }
 
-/*
-void 
-Viewer::createFromXMLfile(const char *file) 
-{
-    sgroot->createFromXMLfile(manager, file);
-}
-
-SceneGraph *
-Viewer::createSceneGraph(int id)
-{
-    return sgroot->createSceneGraph(id);
-}
-
-SceneGraph *
-Viewer::createSceneGraph()
-{
-    return sgroot->createSceneGraph();
-}
-
-void
-Viewer::setSceneData(SceneGraph *g)
-{
-    sgroot->setSceneData(g);
-}
- */
 
 void
 Viewer::run_init(TaskManager *manager, Application *app)
@@ -126,6 +101,7 @@
     frames     = 0;
 
     sgroot = new SceneGraphRoot(this->width, this->height);
+    sgroot->tmanger = this;
 
     MainLoop *mainloop = app->init(this, this->width, this->height);
 
--- a/Renderer/Test/Makefile.macosx	Thu Oct 22 23:07:16 2009 +0900
+++ b/Renderer/Test/Makefile.macosx	Thu Oct 22 23:45:05 2009 +0900
@@ -10,7 +10,7 @@
 .cc.o:
 	$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
 
-all: ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum
+all: ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum send_linda dynamic
 
 
 BALL_BOUND_OBJ = ball_bound.o
@@ -53,6 +53,14 @@
 vacuum : $(VACUUM_OBJ) 
 	$(CC) -o $@ $?    $(LIBS)
 
+DYNAMIC_OBJ = dynamic_create.o 
+dynamic : $(DYNAMIC_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
+SENDLINDA_OBJ = send_linda.o
+send_linda : $(SENDLINDA_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
 run: $(TARGET)
 	sudo ./$(TARGET) -width 576 -height 384 -bpp 32