source: trunk/loci/jvmlink/cpp/JVMLinkClient.h @ 3834

Revision 3834, 3.0 KB checked in by curtis, 12 years ago (diff)

Add support for nulls.

Line 
1//
2// JVMLinkClient.h
3//
4
5/*
6JVMLink client/server architecture for communicating between Java and
7non-Java programs using sockets.
8Copyright (c) 2008 Hidayath Ansari and Curtis Rueden. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12  * Redistributions of source code must retain the above copyright
13    notice, this list of conditions and the following disclaimer.
14  * Redistributions in binary form must reproduce the above copyright
15    notice, this list of conditions and the following disclaimer in the
16    documentation and/or other materials provided with the distribution.
17  * Neither the name of the UW-Madison LOCI nor the names of its
18    contributors may be used to endorse or promote products derived from
19    this software without specific prior written permission.
20
21THIS SOFTWARE IS PROVIDED BY THE UW-MADISON LOCI ``AS IS'' AND ANY
22EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
25DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31*/
32
33#pragma once
34#include "JVMLinkObject.h"
35
36// NB: Toggle comments to control debugging output for the client.
37#define debug(msg) ((void)0)
38//#define debug(msg) std::cout << "JVMLinkClient: " << msg << std::endl
39
40class JVMLinkClient
41{
42private:
43        int port;
44        SOCKET conn;
45
46        void sendMessage(CString);
47        void* readMessage(int);
48        void sendInt(int);
49        int readInt();
50        CString* readString();
51
52public:
53        enum ConnectionCode {
54                CONNECTION_SUCCESS = 0,
55                WINSOCK_ERR,
56                SOCKET_ERR,
57                RESOLVE_ERR,
58                RESPONSE_ERR
59        };
60
61        JVMLinkClient();
62        void startJava(int, CString);
63        void shutJava();
64        ConnectionCode establishConnection();
65        int closeConnection();
66        JVMLinkObject* getVar(CString);
67        void setVar(JVMLinkObject*);
68        void setVar(CString, int);
69        void setVar(CString, int*, int);
70        void setVar(CString, CString*);
71        void setVar(CString, CString*, int);
72        void setVar(CString, char);
73        void setVar(CString, char*, int);
74        void setVar(CString, Byte);
75        void setVar(CString, Byte*, int);
76        void setVar(CString, float);
77        void setVar(CString, float*, int);
78        void setVar(CString, bool);
79        void setVar(CString, bool*, int);
80        void setVar(CString, double);
81        void setVar(CString, double*, int);
82        void setVar(CString, long long);
83        void setVar(CString, long long*, int);
84        void setVar(CString, short);
85        void setVar(CString, short*, int);
86        void setVarNull(CString);
87        void exec(CString);
88
89        ~JVMLinkClient(void);
90};
Note: See TracBrowser for help on using the repository browser.