Testing for list/vector data types
authorrtrimana <rtrimana@uci.edu>
Mon, 28 Nov 2016 23:27:30 +0000 (15:27 -0800)
committerrtrimana <rtrimana@uci.edu>
Mon, 28 Nov 2016 23:27:30 +0000 (15:27 -0800)
config/iotpolicy/testclasspolicy.pol
iotjava/iotrmi/C++/IoTRMIUtil.hpp
iotjava/iotrmi/C++/basics/TestClass.hpp
iotjava/iotrmi/C++/basics/TestClass_Stub.cpp
iotjava/iotrmi/Java/basics/TestClass.java
iotjava/iotrmi/Java/basics/TestClass_Stub.java

index e2b70cc..36ded08 100644 (file)
@@ -16,6 +16,14 @@ public interface TestClassInterface {
        public boolean[] getBooleanArray(boolean in[]);
        public char[] getCharArray(char in[]);
 
+       public List<Byte> getByteList(List<Byte> in);
+       public List<Short> getShortList(List<Short> in);
+       public List<Long> getLongList(List<Long> in);
+       public List<Float> getFloatList(List<Float> in);
+       public List<Double> getDoubleList(List<Double> in);
+       public List<Boolean> getBooleanList(List<Boolean> in);
+       public List<Character> getCharList(List<Character> in);
+
        public int getA();
        public void setA(int _int);
        public void setB(float _float);
@@ -40,6 +48,13 @@ public interface TestClassInterface {
                method = "getDoubleArray(double in[])";
                method = "getBooleanArray(boolean in[])";
                method = "getCharArray(char in[])";
+               method = "getByteList(List<Byte> in)";
+               method = "getShortList(List<Short> in)";
+               method = "getLongList(List<Long> in)";
+               method = "getFloatList(List<Float> in)";
+               method = "getDoubleList(List<Double> in)";
+               method = "getBooleanList(List<Boolean> in)";
+               method = "getCharList(List<Character> in)";
                method = "getA()";
                method = "setA(int _int)";
                method = "setB(float _float)";
index 5da411c..2c3be17 100644 (file)
@@ -300,6 +300,10 @@ void* IoTRMIUtil::getParamObject(void* retObj, const char* type, char* paramByte
        } else if ( string(type).find("*") != string::npos) {
                // This is an array type, i.e. vector
                retObj = getArrayParamObject(retObj, type, paramBytes, len);
+       } else if ( (string(type).find("<") != string::npos) &&
+                               (string(type).find(">") != string::npos)) {
+               // This is a vector/list type
+               retObj = getArrayParamObject(retObj, type, paramBytes, len);
        } else {
                cerr << "IoTRMIUtil: Unrecognizable type: " << type << endl;
                exit(-1);
@@ -389,6 +393,10 @@ char* IoTRMIUtil::getObjectBytes(char* retObjBytes, void* obj, const char* type)
        } else if ( string(type).find("*") != string::npos) {
        // This is an array type, i.e. vector
                retObjBytes = getArrayObjectBytes(retObjBytes, obj, type);
+       } else if ( (string(type).find("<") != string::npos) &&
+                               (string(type).find(">") != string::npos)) {
+       // This is a vector/list type
+               retObjBytes = getArrayObjectBytes(retObjBytes, obj, type);
        } else {
                cerr << "IoTRMIUtil: Unrecognizable type: " << type << endl;
                exit(-1);
index 24fe1ac..fe758d7 100644 (file)
@@ -29,6 +29,14 @@ class TestClass : public TestClassInterface {
                vector<bool>            getBooleanArray(vector<bool> in);
                vector<char>            getCharArray(vector<char> in);
 
+               vector<char>            getByteList(vector<char> in);
+               vector<short>           getShortList(vector<short> in);
+               vector<int64_t>         getLongList(vector<int64_t> in);
+               vector<float>           getFloatList(vector<float> in);
+               vector<double>          getDoubleList(vector<double> in);
+               vector<bool>            getBooleanList(vector<bool> in);
+               vector<char>            getCharList(vector<char> in);
+
                int                                     getA();
                void                            setA(int _int);
                void                            setB(float _float);
@@ -147,6 +155,48 @@ vector<char> TestClass::getCharArray(vector<char> in) {
        return in;
 }
 
+// List
+vector<char> TestClass::getByteList(vector<char> in) {
+
+       return in;
+}
+
+
+vector<short> TestClass::getShortList(vector<short> in) {
+
+       return in;
+}
+
+
+vector<int64_t> TestClass::getLongList(vector<int64_t> in) {
+
+       return in;
+}
+
+
+vector<float> TestClass::getFloatList(vector<float> in) {
+
+       return in;
+}
+
+
+vector<double> TestClass::getDoubleList(vector<double> in) {
+
+       return in;
+}
+
+
+vector<bool> TestClass::getBooleanList(vector<bool> in) {
+
+       return in;
+}
+
+
+vector<char> TestClass::getCharList(vector<char> in) {
+
+       return in;
+}
+
 
 int TestClass::getA() {
 
index 1d8ad91..bac2b0e 100644 (file)
@@ -53,6 +53,35 @@ int main(int argc, char *argv[])
        in7.push_back('c');
        in7.push_back('e');
        cout << "Return value: " << tcStub->getCharArray(in7)[0] << ", "  << tcStub->getCharArray(in7)[1] << endl;
+       cout << "==== VECTOR/LIST ====" << endl;
+       vector<char> inl1;
+       inl1.push_back(68);
+       inl1.push_back(69);
+       cout << "Return value: " << tcStub->getByteList(inl1)[0] << ", " << tcStub->getByteList(inl1)[1] << endl;
+       vector<short> inl2;
+       inl2.push_back(1234);
+       inl2.push_back(1235);
+       cout << "Return value: " << tcStub->getShortList(inl2)[0] << ", "  << tcStub->getShortList(inl2)[1] << endl;
+       vector<int64_t> inl3;
+       inl3.push_back(12345678);
+       inl3.push_back(12356782);
+       cout << "Return value: " << tcStub->getLongList(inl3)[0] << ", "  << tcStub->getLongList(inl3)[1] << endl;
+       vector<float> inl4;
+       inl4.push_back(12.345);
+       inl4.push_back(12.346);
+       cout << "Return value: " << tcStub->getFloatList(inl4)[0] << ", "  << tcStub->getFloatList(inl4)[1] << endl;
+       vector<double> inl5;
+       inl5.push_back(12345.678);
+       inl5.push_back(12345.543);
+       cout << "Return value: " << tcStub->getDoubleList(inl5)[0] << ", "  << tcStub->getDoubleList(inl5)[1] << endl;
+       vector<bool> inl6;
+       inl6.push_back(true);
+       inl6.push_back(false);
+       cout << "Return value: " << tcStub->getBooleanList(inl6)[0] << ", "  << tcStub->getBooleanList(inl6)[1] << endl;
+       vector<char> inl7;
+       inl7.push_back('c');
+       inl7.push_back('e');
+       cout << "Return value: " << tcStub->getCharList(inl7)[0] << ", "  << tcStub->getCharList(inl7)[1] << endl;
        cout << "==== OTHERS ====" << endl;
        cout << "Return value: " << tcStub->getA() << endl;
        cout << "Return value: " << tcStub->setAndGetA(123) << endl;
index 4f55242..6373238 100644 (file)
@@ -116,6 +116,49 @@ public class TestClass implements TestClassInterface {
        }
 
 
+       // Lists
+       public List<Byte> getByteList(List<Byte> in) {
+
+               return in;
+       }
+
+
+       public List<Short> getShortList(List<Short> in) {
+
+               return in;
+       }
+
+
+       public List<Long> getLongList(List<Long> in) {
+
+               return in;
+       }
+
+
+       public List<Float> getFloatList(List<Float> in) {
+
+               return in;
+       }
+
+
+       public List<Double> getDoubleList(List<Double> in) {
+
+               return in;
+       }
+
+
+       public List<Boolean> getBooleanList(List<Boolean> in) {
+
+               return in;
+       }
+
+
+       public List<Character> getCharList(List<Character> in) {
+
+               return in;
+       }
+
+
        // Other functions
        public int getA() {
 
index 01b1bdd..67b69dc 100644 (file)
@@ -1,4 +1,6 @@
 import java.util.Arrays;
+import java.util.List;
+import java.util.ArrayList;
 import iotruntime.master.CommunicationHandler;
 
 public class TestClass_Stub {
@@ -42,6 +44,22 @@ public class TestClass_Stub {
                char[] in7 = { 'c', 'e' };
                System.out.println("Return value: " + Arrays.toString(tcstub.getCharArray(in7)));
 
+               System.out.println("==== LIST ====");
+               List<Byte> inl1 = Arrays.asList(new Byte[] { 68, 69 });
+               System.out.println("Return value: " + tcstub.getByteList(inl1));
+               List<Short> inl2 = Arrays.asList(new Short[] { (short)1234, (short)1235 });
+               System.out.println("Return value: " + tcstub.getShortList(inl2));
+               List<Long> inl3 = Arrays.asList(new Long[] { 12345678l, 12356782l });
+               System.out.println("Return value: " + tcstub.getLongList(inl3));
+               List<Float> inl4 = Arrays.asList(new Float[] { 12.345f, 12.346f });
+               System.out.println("Return value: " + tcstub.getFloatList(inl4));
+               List<Double> inl5 = Arrays.asList(new Double[] { 12345.678, 12345.543 });
+               System.out.println("Return value: " + tcstub.getDoubleList(inl5));
+               List<Boolean> inl6 = Arrays.asList(new Boolean[] { true, false });
+               System.out.println("Return value: " + tcstub.getBooleanList(inl6));
+               List<Character> inl7 = Arrays.asList(new Character[] { 'c', 'e' });
+               System.out.println("Return value: " + tcstub.getCharList(inl7));
+
                System.out.println("==== OTHERS ====");
                System.out.println("Return value: " + tcstub.getA());
                System.out.println("Return value: " + tcstub.setAndGetA(123));