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 e2b70ccd8b0f9980ed1635572ebf29924849c27d..36ded083b60c9899e6fe5fee633f2c2566af14db 100644 (file)
@@ -16,6 +16,14 @@ public interface TestClassInterface {
        public boolean[] getBooleanArray(boolean in[]);
        public char[] getCharArray(char in[]);
 
        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);
        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 = "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)";
                method = "getA()";
                method = "setA(int _int)";
                method = "setB(float _float)";
index 5da411cfd4d85179bd5e1a6291766aef4454f8ac..2c3be17cfc9aab7372d1b647cf175257cf3681f1 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) {
                // 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);
        } 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) {
        // 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);
        } else {
                cerr << "IoTRMIUtil: Unrecognizable type: " << type << endl;
                exit(-1);
index 24fe1acc0ebc24480e91451033eb016ca6d60703..fe758d728932b5f601a38ae98e193af516c6b69d 100644 (file)
@@ -29,6 +29,14 @@ class TestClass : public TestClassInterface {
                vector<bool>            getBooleanArray(vector<bool> in);
                vector<char>            getCharArray(vector<char> in);
 
                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);
                int                                     getA();
                void                            setA(int _int);
                void                            setB(float _float);
@@ -147,6 +155,48 @@ vector<char> TestClass::getCharArray(vector<char> in) {
        return 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() {
 
 
 int TestClass::getA() {
 
index 1d8ad91ab11f4a5fd5807e2abd1f1972038b5ff7..bac2b0e7b60ae35ec13d13cb223e1ff2260f56d1 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;
        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;
        cout << "==== OTHERS ====" << endl;
        cout << "Return value: " << tcStub->getA() << endl;
        cout << "Return value: " << tcStub->setAndGetA(123) << endl;
index 4f55242262671680c94b66a16338884a9c240c31..6373238874d12ff8784608bd284c0e812cb2db18 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() {
 
        // Other functions
        public int getA() {
 
index 01b1bddf1690ab9845e50b7273f96a37b56dfb47..67b69dc476892adeed4dc8fb56236d5c0a60808f 100644 (file)
@@ -1,4 +1,6 @@
 import java.util.Arrays;
 import java.util.Arrays;
+import java.util.List;
+import java.util.ArrayList;
 import iotruntime.master.CommunicationHandler;
 
 public class TestClass_Stub {
 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)));
 
                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));
                System.out.println("==== OTHERS ====");
                System.out.println("Return value: " + tcstub.getA());
                System.out.println("Return value: " + tcstub.setAndGetA(123));