Adding object Id specification for stub/skeleton used in multiple applications.
[iot2.git] / iotjava / iotpolicy / IoTCompiler.java
index bdf6a416db89061f4f444483f4d151a56c7dc2e7..79e838cb97b0a59f78e1bf318beac6100355c881 100644 (file)
@@ -177,6 +177,17 @@ public class IoTCompiler {
                // Set object Id counter to 0 for each interface
                mapIntfaceObjId.put(origInt, countObjId++);
        }
+       
+       
+       /**
+        * setObjectId() updates the object Id. This option is useful
+        * when the stub/skeleton are also used in other apps, so that
+        * we can set a single object Id for the stub/skeleton.
+        */
+       private void setObjectId(String intface, String objectId) {
+
+               mapIntfaceObjId.put(intface, Integer.parseInt(objectId));
+       }
 
 
        /**
@@ -4516,6 +4527,9 @@ public class IoTCompiler {
                System.out.println("Options:");
                System.out.println("\t-cont\t<controller-class>\tSpecify controller class name");
                System.out.println("\t-drv\t<driver-class>\t\tSpecify driver class name");
+               System.out.println("\t\t(place this option right after a pair of .pol and .req files)");
+               System.out.println("\t-objid\t<object-id>\t\tSpecify object Id for stub/skeleton used in multiple apps");
+               System.out.println("\t\t(place this option right after -drv option)");
                System.out.println("\t-cplus\t<directory>\t\tGenerate C++ stub files");
                System.out.println("\t-java\t<directory>\t\tGenerate Java stub files\n");
                System.out.println("\t\tNote: The options -cont and -drv have to be defined before -cplus and -java");
@@ -4655,7 +4669,7 @@ public class IoTCompiler {
        // Basically the compiler needs to parse the policy (and requires) files for callback class first
        private int getNewIntfaceObjectId(String newIntface) {
 
-               int retObjId = mapNewIntfaceObjId.get(newIntface);
+               int retObjId = mapNewIntfaceObjId.get(newIntface);      
                return retObjId;
        }
 
@@ -5348,7 +5362,6 @@ public class IoTCompiler {
 
                        IoTCompiler comp = new IoTCompiler();
                        int i = 0;
-                       //boolean driverDefined = false;
                        boolean controllerDefined = false;
                        do {
                                if (!controllerDefined && args[i].equals("-cont")) {
@@ -5365,11 +5378,18 @@ public class IoTCompiler {
                            comp.setDataStructures(intface, pnPol, pnReq);
                            comp.getMethodsForIntface(intface);
                                i = i + 2;
+                               // Driver name
                                if (args[i].equals("-drv")) {
                                        comp.setDriverClass(intface, args[i+1]);
                                        i = i + 2;
                                } else
                                        throw new Error("IoTCompiler: ERROR - driver class name is needed for the interface: " + intface + "\n");
+                               // Object ID (for a stub/skeleton pair that is also used in other applications)
+                               if (args[i].equals("-objid")) {
+                                       comp.setObjectId(intface, args[i+1]);
+                                       i = i + 2;
+                               }
+
                        // 1) Check if this is the last option before "-java" or "-cplus"
                        // 2) Check if this is really the last option
                        } while(!args[i].equals("-java") &&