Some cleanup.
authorSashi Penta <sashi.kumar.penta@intel.com>
Wed, 23 Jul 2014 00:22:05 +0000 (17:22 -0700)
committerSashi Penta <sashi.kumar.penta@intel.com>
Wed, 23 Jul 2014 00:22:05 +0000 (17:22 -0700)
22 files changed:
Makefile
OCLib/InProcServerWrapper.cpp
examples/Makefile
examples/old_tests/MyMultiResourceHandler.cpp [moved from examples/client/MyMultiResourceHandler.cpp with 100% similarity]
examples/old_tests/MyMultiResourceHandler.h [moved from examples/client/MyMultiResourceHandler.h with 100% similarity]
examples/old_tests/MyObserverHandler.cpp [moved from examples/client/MyObserverHandler.cpp with 100% similarity]
examples/old_tests/MyObserverHandler.h [moved from examples/client/MyObserverHandler.h with 100% similarity]
examples/old_tests/MyResourceHandler.cpp [moved from examples/client/MyResourceHandler.cpp with 100% similarity]
examples/old_tests/MyResourceHandler.h [moved from examples/client/MyResourceHandler.h with 100% similarity]
examples/old_tests/OCWrapper/Makefile [moved from examples/OCWrapper/Makefile with 100% similarity]
examples/old_tests/OCWrapper/parsetest.cpp [moved from examples/OCWrapper/parsetest.cpp with 100% similarity]
examples/old_tests/OCWrapper/testClient.cpp [moved from examples/OCWrapper/testClient.cpp with 100% similarity]
examples/old_tests/OCWrapper/testServer.cpp [moved from examples/OCWrapper/testServer.cpp with 100% similarity]
examples/old_tests/OCWrapper/testServerApp.cpp [moved from examples/OCWrapper/testServerApp.cpp with 100% similarity]
examples/old_tests/multiple_resources.cpp [moved from examples/server/multiple_resources.cpp with 100% similarity]
examples/reflect/test_OCClient.cpp [moved from examples/test_OCClient.cpp with 100% similarity]
examples/reflect/test_OCReflect.cpp [moved from examples/test_OCReflect.cpp with 100% similarity]
examples/reflect/test_properties.cpp [moved from examples/test_properties.cpp with 100% similarity]
examples/simpleclient.cpp [moved from examples/client/OCClient.cpp with 97% similarity]
examples/simpleserver.cpp [moved from examples/server/single_resource.cpp with 83% similarity]
include/IServerWrapper.h
include/InProcServerWrapper.h

index f2156b2..f538e35 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ CXX_FLAGS=-std=c++11 -Wall -pthread -ggdb
 CXX_INC=-I./include/ -I./csdk/stack/include -I./csdk/ocsocket/include -I./csdk/ocrandom/include -I./csdk/logger/include
 
 # Force metatargets to build:
-.PHONY: c_sdk single_resource client examples
+.PHONY: c_sdk simpleserver simpleclient examples
 
 all: .PHONY
 
@@ -15,11 +15,11 @@ c_sdk:
 examples:
        cd examples && $(MAKE)
 
-single_resource: OCLib.a single_resource.o
-       $(CXX) $(CXX_FLAGS) -o single_resource single_resource.o OCLib.a csdk/liboctbstack.a 
+simpleserver: OCLib.a simpleserver.o
+       $(CXX) $(CXX_FLAGS) -o simpleserver simpleserver.o OCLib.a csdk/liboctbstack.a 
 
-client: OCLib.a OCClient.o
-       $(CXX) $(CXX_FLAGS) -o client OCClient.o OCLib.a csdk/liboctbstack.a 
+simpleclient: OCLib.a simpleclient.o
+       $(CXX) $(CXX_FLAGS) -o simpleclient simpleclient.o OCLib.a csdk/liboctbstack.a 
 
 OCLib.a: OCPlatform.o OCResource.o OCReflect.o InProcServerWrapper.o InProcClientWrapper.o  
        ar -cvq OCLib.a OCPlatform.o OCResource.o OCReflect.o InProcServerWrapper.o InProcClientWrapper.o 
@@ -39,63 +39,14 @@ InProcServerWrapper.o: OCLib/InProcServerWrapper.cpp
 InProcClientWrapper.o: OCLib/InProcClientWrapper.cpp
        $(CXX) $(CXX_FLAGS) -c OCLib/InProcClientWrapper.cpp $(CXX_INC)
 
-single_resource.o : examples/server/single_resource.cpp
-       $(CXX) $(CXX_FLAGS) -c examples/server/single_resource.cpp $(CXX_INC)
+simpleserver.o : examples/simpleserver.cpp
+       $(CXX) $(CXX_FLAGS) -c examples/simpleserver.cpp $(CXX_INC)
 
-OCClient.o : examples/client/OCClient.cpp
-       $(CXX) $(CXX_FLAGS) -c examples/client/OCClient.cpp $(CXX_INC)
+simpleclient.o : examples/simpleclient.cpp
+       $(CXX) $(CXX_FLAGS) -c examples/simpleclient.cpp $(CXX_INC)
 
 clean: 
-       rm -f -v OCLib.a *.o single_resource client
-       cd examples && $(MAKE) clean
-
-       cd csdk && $(MAKE) clean
-       cd csdk && $(MAKE) deepclean
-
-
-# Force metatargets to build:
-.PHONY: c_sdk single_resource client examples
-
-all: .PHONY
-
-c_sdk:
-       cd csdk && $(MAKE)
-
-examples:
-       cd examples && $(MAKE)
-
-single_resource: OCLib.a single_resource.o
-       $(CXX) $(CXX_FLAGS) -o single_resource single_resource.o OCLib.a csdk/liboctbstack.a 
-
-client: OCLib.a OCClient.o
-       $(CXX) $(CXX_FLAGS) -o client OCClient.o OCLib.a csdk/liboctbstack.a 
-
-OCLib.a: OCPlatform.o OCResource.o OCReflect.o InProcServerWrapper.o InProcClientWrapper.o  
-       ar -cvq OCLib.a OCPlatform.o OCResource.o OCReflect.o InProcServerWrapper.o InProcClientWrapper.o 
-
-OCReflect.o: OCLib/OCReflect.cpp
-       $(CXX) $(CXX_FLAGS) -c OCLib/OCReflect.cpp $(CXX_INC)
-
-OCPlatform.o: OCLib/OCPlatform.cpp
-       $(CXX) $(CXX_FLAGS) -c OCLib/OCPlatform.cpp $(CXX_INC)
-OCResource.o: OCLib/OCResource.cpp
-       $(CXX) $(CXX_FLAGS) -c OCLib/OCResource.cpp $(CXX_INC)
-       
-InProcServerWrapper.o: OCLib/InProcServerWrapper.cpp
-       $(CXX) $(CXX_FLAGS) -c OCLib/InProcServerWrapper.cpp $(CXX_INC)
-
-InProcClientWrapper.o: OCLib/InProcClientWrapper.cpp
-       $(CXX) $(CXX_FLAGS) -c OCLib/InProcClientWrapper.cpp $(CXX_INC)
-
-single_resource.o : examples/server/single_resource.cpp
-       $(CXX) $(CXX_FLAGS) -c examples/server/single_resource.cpp $(CXX_INC)
-
-OCClient.o : examples/client/OCClient.cpp
-       $(CXX) $(CXX_FLAGS) -c examples/client/OCClient.cpp $(CXX_INC)
-
-clean: 
-       rm -f -v OCLib.a *.o single_resource client
+       rm -f -v OCLib.a *.o simpleserver simpleclient
        cd examples && $(MAKE) clean
 
        cd csdk && $(MAKE) clean
index db49a6a..7e70361 100644 (file)
@@ -65,7 +65,7 @@ namespace OC
 
     void InProcServerWrapper::registerResource(const std::string& resourceURI,
                                 const std::string& resourceTypeName,
-                                named_property_binding_vector properties)
+                                named_property_binding_vector& properties)
     {
         using OC::OCReflect::property_type;
         using OC::OCReflect::named_property_binding;
@@ -73,25 +73,20 @@ namespace OC
 
         std::vector<std::string> reps { convert(properties) };
 
-        for(const auto& r : reps)
-            std::cout << r << '\n';
+        char *resourceTypeRepresentation = flatten(reps);
 
-        char *resourTypeRepresentation = flatten(reps);
-
-        std::cout << resourTypeRepresentation << "\n";
+        std::cout << "Resource type representation: " << resourceTypeRepresentation << "\n";
 
         OCResourceHandle resourceHandle;
 
                {
                        std::lock_guard<std::mutex> lock(m_csdkLock);
 
-            cout << "Creating a resource" << endl;
-
                        OCStackResult  result;
 
                        result = OCCreateResource(&resourceHandle, // OCResourceHandle *handl
                                                        resourceTypeName.c_str(), // const char * resourceTypeName
-                                                       resourTypeRepresentation, //const char * resourceTypeRepresentation
+                                                       resourceTypeRepresentation, //const char * resourceTypeRepresentation
                                                        "core.rw", //const char * resourceInterfaceName
                                                        OC_REST_GET | OC_REST_PUT, // uint8_t allowedMethods
                                                        resourceURI.c_str(), // const char * uri
index b0ffea0..342875d 100644 (file)
@@ -6,30 +6,23 @@ CXX_FLAGS=-std=c++11 -Wall -pthread
 
 CXX_INC=-I../include/ -I./client/ -I../csdk/stack/include -I../csdk/ocsocket/include -I../csdk/ocrandom/include -I../csdk/logger/include
 
-LIB_SRC0=../OCLib/OCReflect.cpp ../OCLib/OCProperties.cpp ../OCLib/OCObserver.cpp ../OCLib/OCResource.cpp ./client/MyObserverHandler.cpp 
+LIB_SRC0=../OCLib/OCReflect.cpp ../OCLib/OCProperties.cpp ../OCLib/OCObserver.cpp ../OCLib/OCResource.cpp 
+
 LIB_SRC1=../OCLib/OCReflect.cpp ../OCLib/OCObserver.cpp ./client/MyObserverHandler.cpp ../OCLib/OCResource.cpp ../OCLib/OCSecurityModel.cpp ../OCLib/InProcClientWrapper.cpp ../OCLib/OCPlatform.cpp ../OCLib/InProcServerWrapper.cpp ../csdk/liboctbstack.a
 
-all: ocreflect resources
+all: ocreflect 
 
 ocreflect: test_properties test_OCClient
 
 test_properties:
-       $(CXX) $(CXX_FLAGS) -o test_properties test_properties.cpp $(LIB_SRC0) $(CXX_INC)
+       $(CXX) $(CXX_FLAGS) -o test_properties reflect/test_properties.cpp $(LIB_SRC0) $(CXX_INC)
 
 test_OCReflect:
-       $(CXX) $(CXX_FLAGS) -o test_OCReflect test_OCReflect.cpp ../OCLib/OCReflect.cpp ../OCLib/OCProperties.cpp  $(CXX_INC)
+       $(CXX) $(CXX_FLAGS) -o test_OCReflect reflect/test_OCReflect.cpp ../OCLib/OCReflect.cpp ../OCLib/OCProperties.cpp  $(CXX_INC)
 
 test_OCClient:
-       $(CXX) $(CXX_FLAGS) -o test_OCClient test_OCClient.cpp $(LIB_SRC0) $(CXX_INC)
-
-resources: single_resource multiple_resources
-
-single_resource:
-       $(CXX) $(CXX_FLAGS) -o single_resource ./server/single_resource.cpp $(LIB_SRC1) $(CXX_INC)
-
-multiple_resources:
-       #$(CXX) $(CXX_FLAGS) -o multiple_resources ./server/multiple_resources.cpp $(LIB_SRC1) $(CXX_INC)
+       $(CXX) $(CXX_FLAGS) -o test_OCClient reflect/test_OCClient.cpp $(LIB_SRC0) $(CXX_INC)
 
 clean:
-       rm -f -v test_properties test_OCReflect test_OCClient single_resource multiple_resources
+       rm -f -v test_properties test_OCReflect test_OCClient 
 
similarity index 97%
rename from examples/client/OCClient.cpp
rename to examples/simpleclient.cpp
index 8dc790c..cc75aa3 100644 (file)
@@ -45,7 +45,7 @@ int main()
        // Create PlatformConfig object
 
        PlatformConfig cfg;
-       cfg.ipAddress = "134.134.161.166";
+       cfg.ipAddress = "134.134.161.33";
        cfg.port = 5683;
        cfg.mode = ModeType::Client;
        cfg.serviceType = ServiceType::InProc;
similarity index 83%
rename from examples/server/single_resource.cpp
rename to examples/simpleserver.cpp
index 7ea1779..a3a609b 100644 (file)
@@ -65,13 +65,21 @@ public:
        /// This function binds the properties and methods to the server. 
        void createResourceWithPropeties(OC::OCPlatform& platform)
        {
-               using OC::OCReflect::property_type;
-               using OC::OCReflect::named_property_binding;
-
-               named_property_binding_vector properties {
-                       named_property_binding("state", property_type::boolean),
-                       named_property_binding("power", property_type::integer)
+        /*
+        We could typedef to simpler namers! :)
+        typedef named_property_binding_vector OCPropertyBindings;
+        typedef named_property_binding OCPropertyBinding;
+
+        OCPropertyBindings properties {
+                       OCPropertyBinding("state", property_type::boolean),
+                       OCPropertyBidning("power", property_type::integer)
                };
+        */
+
+        auto properties {
+                       named_property_binding{"state", property_type::boolean},
+                       named_property_binding{"power", property_type::integer}
+        };
 
                std::string resourceURI = "/a/light";
                std::string resourceTypeName = "light";
@@ -89,7 +97,7 @@ int main()
 
        PlatformConfig cfg;
        //cfg.ipAddress = "192.168.1.5";
-       cfg.ipAddress = "134.134.161.166";
+       cfg.ipAddress = "134.134.161.33";
        cfg.port = 5683;
        cfg.mode = ModeType::Server;
        cfg.serviceType = ServiceType::InProc;
index 4c64311..bc20900 100644 (file)
@@ -22,10 +22,9 @@ namespace OC
 
         virtual ~IServerWrapper(){};
 
-        // TODO: SASHI : parameters by reference???
         virtual void registerResource(  const std::string& resourceURI, 
                                 const std::string& resourceTypeName,
-                                named_property_binding_vector properties) = 0; 
+                                named_property_binding_vector& properties) = 0; 
     };
 }
 
index 9f8709e..19c7c8d 100644 (file)
@@ -25,7 +25,7 @@ namespace OC
 
         void registerResource(  const std::string& resourceURI, 
                                 const std::string& resourceTypeName,
-                                named_property_binding_vector properties); 
+                                named_property_binding_vector& properties); 
                                                                
        private:
                void processFunc();