source: trunk/legacy/jvmlink/src/main/c++/JVMLinkObject.h @ 7818

Revision 7818, 2.9 KB checked in by mario, 8 years ago (diff)

use again a bit stricter types, and use const reference for some JVMLinkObjects (instead of new and delete objects)

Line 
1//
2// JVMLinkObject.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
34#ifndef JVMLINKOBJECT_HH
35#define JVMLINKOBJECT_HH
36
37#include <string>
38#include <vector>
39
40
41enum Command {
42        BYTE_ORDER_CMD = 0,
43        SETVAR_CMD = 1,
44        GETVAR_CMD = 2,
45        EXEC_CMD = 3,
46        EXIT_CMD = 255
47};
48
49enum Type {
50        ARRAY_TYPE = 0,
51        INT_TYPE,
52        STRING_TYPE,
53        BYTE_TYPE,
54        CHAR_TYPE,
55        FLOAT_TYPE,
56        BOOL_TYPE,
57        DOUBLE_TYPE,
58        LONG_TYPE,
59        SHORT_TYPE,
60        NULL_TYPE = -1
61};
62
63struct Byte {
64        char data;
65};
66
67class JVMLinkObject {
68private:
69        int getSize(Type);
70
71public:
72        JVMLinkObject(const std::string&);
73        JVMLinkObject(const std::string&, Type, const void*);
74        JVMLinkObject(const std::string&, Type, int, const void*);
75
76        ~JVMLinkObject(void);
77
78        std::string name;
79        int size, length;
80        Type type, insideType;
81        const void* data;
82
83        int getDataAsInt();
84        int* getDataAsIntArray();
85        std::string* getDataAsString();
86        std::string* getDataAsStringArray();
87        char getDataAsChar();
88        char* getDataAsCharArray();
89        Byte getDataAsByte();
90        Byte* getDataAsByteArray();
91        float getDataAsFloat();
92        float* getDataAsFloatArray();
93        bool getDataAsBool();
94        bool* getDataAsBoolArray();
95        double getDataAsDouble();
96        double* getDataAsDoubleArray();
97        long long getDataAsLong();
98        long long* getDataAsLongArray();
99        short getDataAsShort();
100        short* getDataAsShortArray();
101        bool isDataNull();
102};
103
104#endif // JVMLINKOBJECT_HH
Note: See TracBrowser for help on using the repository browser.