From 42652d235f20e3bbb6d42bbf96db2d02c5d94b2c Mon Sep 17 00:00:00 2001 From: Sakthivel Samidurai Date: Fri, 3 Apr 2015 14:49:28 -0700 Subject: [PATCH] Removed old_tests folder The old_tests folder is not used. Change-Id: I194ba0d7a11b38b682d62f3a95cd86406955f1fb Signed-off-by: Sakthivel Samidurai Reviewed-on: https://gerrit.iotivity.org/gerrit/645 Tested-by: jenkins-iotivity Reviewed-by: Erich Keane --- .../examples/old_tests/MyMultiResourceHandler.cpp | 158 ------------ .../examples/old_tests/MyMultiResourceHandler.h | 45 ---- resource/examples/old_tests/MyObserverHandler.cpp | 26 -- resource/examples/old_tests/MyObserverHandler.h | 33 --- resource/examples/old_tests/MyResourceHandler.cpp | 107 --------- resource/examples/old_tests/MyResourceHandler.h | 41 ---- resource/examples/old_tests/OCWrapper/makefile | 64 ----- .../examples/old_tests/OCWrapper/parsetest.cpp | 120 ---------- .../examples/old_tests/OCWrapper/testClient.cpp | 44 ---- .../examples/old_tests/OCWrapper/testServer.cpp | 97 -------- .../examples/old_tests/OCWrapper/testServerApp.cpp | 131 ---------- resource/examples/old_tests/multiple_resources.cpp | 264 --------------------- 12 files changed, 1130 deletions(-) delete mode 100644 resource/examples/old_tests/MyMultiResourceHandler.cpp delete mode 100644 resource/examples/old_tests/MyMultiResourceHandler.h delete mode 100644 resource/examples/old_tests/MyObserverHandler.cpp delete mode 100644 resource/examples/old_tests/MyObserverHandler.h delete mode 100644 resource/examples/old_tests/MyResourceHandler.cpp delete mode 100644 resource/examples/old_tests/MyResourceHandler.h delete mode 100644 resource/examples/old_tests/OCWrapper/makefile delete mode 100644 resource/examples/old_tests/OCWrapper/parsetest.cpp delete mode 100644 resource/examples/old_tests/OCWrapper/testClient.cpp delete mode 100644 resource/examples/old_tests/OCWrapper/testServer.cpp delete mode 100644 resource/examples/old_tests/OCWrapper/testServerApp.cpp delete mode 100644 resource/examples/old_tests/multiple_resources.cpp diff --git a/resource/examples/old_tests/MyMultiResourceHandler.cpp b/resource/examples/old_tests/MyMultiResourceHandler.cpp deleted file mode 100644 index 76b5f4e..0000000 --- a/resource/examples/old_tests/MyMultiResourceHandler.cpp +++ /dev/null @@ -1,158 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -#include - -#include "ocapi.h" -#include "OCReflect.h" -#include "OCObserver.h" -#include "OCException.h" -#include "MyMultiResourceHandler.h" - -namespace { - -void log(const std::string& msg) -{ - std::cerr << msg << '\n'; -} - -} // namespace - -void OC::MyMultiResourceHandler::onFoundResource(OCResourceResult *update, void *params){ - - //Step1: Find a specific resource that also contains OCReflect byte stream of methods and properties - for( auto &resource : update->resources ) - { - if(resource.getURI() == "/garage/dimmer/a") - { - performDimmerOperations(resource, update); - } - else if(resource.getURI() == "/garage/door/a") - { - performDoorOperations(resource, update); - } - } -} - -void OC::MyMultiResourceHandler::performDimmerOperations(OC::OCResource myResource, OC::OCResourceResult *update) -{ - using OC::OCReflect::entity; - using OC::OCReflect::method; - using OC::OCReflect::remote_resource; - - using OC::bind_observer; - using OC::unbind_observer; - - try - { - // Perform resource operation - // Note that this resource dimmer has - // 'manufacturer' as a property - // 'powerState' as a observable property - // 'setPowered' as a method - // 'getPowered' as a method - - //Step1: Find a specific method and invoke it. or Find a specific property and use it. - - // Canonical one-step approach to get a callable function object: - // OCReflect::method throw OC::OCReflect::reflect_exception if there is no setLevel method in the myResource - auto setPowered = OCReflect::method(myResource, "setPowered"); - - // invoke the remote method, - // invalid arguments return as an OC::OCReflect::reflect_exception - setPowered(true); - - // Canonical one-step approach to get a callable function object: - // OCReflect::method throw OC::OCReflect::reflect_exception if there is no setLevel method in the myResource - auto getPowered = OCReflect::method(myResource, "getPowered"); - - // invoke the remote method, - // invalid arguments return as an OC::OCReflect::reflect_exception - // bool power = getPowered(); // Use power variable to do other operations - - // Canonical one-step approach to access a property: - std::string manufacturer = update->property("manufacturer"); - - //Example to observe a property - bind_observer(&myObserverHandler, myResource, "powerState"); - - //Example to unobserve a property - unbind_observer(&myObserverHandler, myResource, "powerState"); - } - catch(OC::reflection_exception& e) - { - log(e.what()); - } - catch(std::exception& e) - { - log(e.what()); - } -} - -void OC::MyMultiResourceHandler::performDoorOperations(OC::OCResource myResource, OC::OCResourceResult *update) -{ - // Perform resource operation - // Note that this resource door has - // 'manufacturer' as a property - // 'setLockState' as a method - // 'getLockState' as a method - - try - { - // Step1: Find a specific method and invoke it or find a specific property and use it. - - // Canonical one-step approach to get a callable function object: - // OCReflect::method throw OC::OCReflect::reflect_exception if there is no setLevel method in the myResource - auto setLockState = OCReflect::method(myResource, "setLockState"); - - // invoke the remote method, - // invalid arguments return as an OC::OCReflect::reflect_exception - setLockState(true); - - // Canonical one-step approach to get a callable function object: - // OCReflect::method throw OC::OCReflect::reflect_exception if there is no setLevel method in the myResource - auto getLockState = OCReflect::method(myResource, "getLockState"); - - // invoke the remote method, - // invalid arguments return as an OC::OCReflect::reflect_exception - // bool lockState = getLockState(); // use lockState variable for any other operations - - // Canonical one-step approach to access a property - std::string manufacturer = update->property("manufacturer"); - } - catch(OC::reflection_exception& e) - { - log(e.what()); - } - catch(std::exception& e) - { - log(e.what()); - } -} - -void OC::MyMultiResourceHandler::MyMultiResourceHandler::onCompleted() -{ - -} - -void OC::MyMultiResourceHandler::MyMultiResourceHandler::onFailed() -{ - -} diff --git a/resource/examples/old_tests/MyMultiResourceHandler.h b/resource/examples/old_tests/MyMultiResourceHandler.h deleted file mode 100644 index c0695b7..0000000 --- a/resource/examples/old_tests/MyMultiResourceHandler.h +++ /dev/null @@ -1,45 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -#include "ocapi.h" -#include "OCResourceHandler.h" -#include "MyObserverHandler.h" - -namespace OC { - -class MyMultiResourceHandler : - public OCResourceHandler -{ -public: - void onFoundResource(OCResourceResult *update, void *params); - void onCompleted(); - void onFailed(); - -private: - MyObserverHandler myObserverHandler; - - /// This is a private function to perform operations related to dimmer resource - void performDimmerOperations(OCResource myResource, OCResourceResult *update); - - /// This is a private function to perform operations related to door resource - void performDoorOperations(OCResource myResource, OCResourceResult *update); -}; - -} // namespace OC diff --git a/resource/examples/old_tests/MyObserverHandler.cpp b/resource/examples/old_tests/MyObserverHandler.cpp deleted file mode 100644 index ee090ce..0000000 --- a/resource/examples/old_tests/MyObserverHandler.cpp +++ /dev/null @@ -1,26 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -#include "MyObserverHandler.h" - -void OC::MyObserverHandler::onObserverUpdate(std::string propertyName, void *value) -{ - -} diff --git a/resource/examples/old_tests/MyObserverHandler.h b/resource/examples/old_tests/MyObserverHandler.h deleted file mode 100644 index 25d6991..0000000 --- a/resource/examples/old_tests/MyObserverHandler.h +++ /dev/null @@ -1,33 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -#include "OCApi.h" -#include "OCObserverHandler.h" - -namespace OC { - -class MyObserverHandler : - public OC::OCObserverHandler -{ -public: - void onObserverUpdate(std::string propertyName, void *value); -}; - -} // namespace OC diff --git a/resource/examples/old_tests/MyResourceHandler.cpp b/resource/examples/old_tests/MyResourceHandler.cpp deleted file mode 100644 index cd6a511..0000000 --- a/resource/examples/old_tests/MyResourceHandler.cpp +++ /dev/null @@ -1,107 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - - -#include - -#include "ocapi.h" -#include "OCReflect.h" -#include "OCObserver.h" -#include "OCException.h" -#include "MyResourceHandler.h" - -void log(const std::string& msg) -{ - std::cerr << msg << '\n'; -} - -MyResourceHandler::MyResourceHandler(void) -{ -} - - -MyResourceHandler::~MyResourceHandler(void) -{ -} - -void MyResourceHandler::onFoundResource(OCResourceResult *update, void *params){ - using OC::OCReflect::entity; - using OC::OCReflect::method; - using OC::OCReflect::remote_resource; - - using OC::bind_observer; - using OC::unbind_observer; - - try - { - //Step1: Find a specific resource that also contains OCReflect byte stream of methods and properties - OCResource myResource; - for ( auto &resource : update->resources ) { - if(resource.getURI() == "/light/a"){ - myResource = resource; - break; - } - } - - //Step2: Find a specific method and invoke it. or Find a specific property and use it. - - // Canonical one-step approach to get a callable function object: - // OCReflect::method throw OC::OCReflect::reflect_exception if there is no setLevel method in the myResource - auto setLevel = OC::OCReflect::method(myResource, "setLevel"); - - setLevel(75, 255); - - // Individual steps-- each may throw on failure: - remote_resource myLight(myResource, "lights/a"); // JFW: this may be subsumed by type OCResource - - entity e_setPowered = myLight("setPowered"); - - method setPowered = OC::OCReflect::narrow(e_setPowered); - - setPowered(true); - - // Canonical one-step approach to access a property: - std::string manufacturer = update->property("manufacturer"); - - // Individual steps: - entity e_manufacturer = myResource.property("manufacturer"); - std::string manufacturer_2 = OC::OCReflect::narrow(e_manufacturer); - - //Example to observe a property - bind_observer(&myObserverHandler, myResource, "PowerState"); - - //Example to unobserve a property - unbind_observer(&myObserverHandler, myResource, "PowerState"); - } - catch(OC::reflection_exception& e) - { - log(e.what()); - } - catch(std::exception& e) - { - log(e.what()); - } -} - -void MyResourceHandler::onCompleted(){ -} - -void MyResourceHandler::onFailed(){ -} diff --git a/resource/examples/old_tests/MyResourceHandler.h b/resource/examples/old_tests/MyResourceHandler.h deleted file mode 100644 index 28b9e88..0000000 --- a/resource/examples/old_tests/MyResourceHandler.h +++ /dev/null @@ -1,41 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -#include "ocapi.h" -#include "OCResourceHandler.h" -#include "MyObserverHandler.h" - -using namespace OC; - -class MyResourceHandler : - public OCResourceHandler -{ -public: - MyResourceHandler(void); - virtual ~MyResourceHandler(void); - void onFoundResource(OCResourceResult *update, void *params); - void onCompleted(); - void onFailed(); - -private: - MyObserverHandler myObserverHandler; - -}; - diff --git a/resource/examples/old_tests/OCWrapper/makefile b/resource/examples/old_tests/OCWrapper/makefile deleted file mode 100644 index e0b44e4..0000000 --- a/resource/examples/old_tests/OCWrapper/makefile +++ /dev/null @@ -1,64 +0,0 @@ -# //****************************************************************** -# // -# // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved. -# // -# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -# // -# // Licensed under the Apache License, Version 2.0 (the "License"); -# // you may not use this file except in compliance with the License. -# // You may obtain a copy of the License at -# // -# // http://www.apache.org/licenses/LICENSE-2.0 -# // -# // Unless required by applicable law or agreed to in writing, software -# // distributed under the License is distributed on an "AS IS" BASIS, -# // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# // See the License for the specific language governing permissions and -# // limitations under the License. -# // -# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -# -CXX=g++ -CXX_FLAGS=-std=c++0x -Wall -pthread - -final: server client serverApp - -serverApp: InProcServerWrapper.o testServerApp.o ocstack_stub.o OCResource.o InProcClientWrapper.o OCReflect.o OCPlatform.o - $(CXX) $(CXX_FLAGS) -o serverApp InProcServerWrapper.o testServerApp.o ocstack_stub.o OCResource.o InProcClientWrapper.o OCReflect.o OCPlatform.o - -server: InProcServerWrapper.o testServer.o ocstack_stub.o OCResource.o InProcClientWrapper.o OCReflect.o - $(CXX) $(CXX_FLAGS) -o server InProcServerWrapper.o testServer.o ocstack_stub.o OCResource.o InProcClientWrapper.o OCReflect.o - -client: InProcServerWrapper.o testClient.o ocstack_stub.o OCResource.o InProcClientWrapper.o OCReflect.o - $(CXX) $(CXX_FLAGS) -o client InProcServerWrapper.o testClient.o ocstack_stub.o OCResource.o InProcClientWrapper.o OCReflect.o - -OCReflect.o: ../../../OCLib/OCReflect.cpp - $(CXX) $(CXX_FLAGS) -c ../../../OCLib/OCReflect.cpp -I../../../csdk/ -I../../../include -I../ - -OCPlatform.o: ../../../OCLib/OCPlatform.cpp - $(CXX) $(CXX_FLAGS) -c ../../../OCLib/OCPlatform.cpp -I../../../csdk/ -I../../../include/ -I../ -I../client/ -I../server/ - -OCResource.o: ../../../OCLib/OCResource.cpp - $(CXX) $(CXX_FLAGS) -c ../../../OCLib/OCResource.cpp -I../../../csdk/ -I../../../include/ -I../ -I../client/ -I../server/ - -ocstack_stub.o : ../../../csdk/ocstack_stub.c - gcc -c ../../../csdk/ocstack_stub.c -I../../../csdk/ - -InProcServerWrapper.o: ../server/InProcServerWrapper.cpp - $(CXX) $(CXX_FLAGS) -c ../server/InProcServerWrapper.cpp -I../../../csdk/ -I../../../include -I../ - -InProcClientWrapper.o: ../client/InProcClientWrapper.cpp - $(CXX) $(CXX_FLAGS) -c ../client/InProcClientWrapper.cpp -I../../../csdk/ -I../../../include -I../ - -testServer.o : testServer.cpp - $(CXX) $(CXX_FLAGS) -c testServer.cpp -I../../../csdk/ -I../../../include -I../ -I../client/ -I../server/ - -testServerApp.o : testServerApp.cpp - $(CXX) $(CXX_FLAGS) -c testServerApp.cpp -I../../../csdk/ -I../../../include -I../ -I../client/ -I../server/ - -testClient.o : testClient.cpp - $(CXX) $(CXX_FLAGS) -c testClient.cpp -I../../../csdk/ -I../../../include -I../ -I../client/ -I../server/ - -clean: - rm *.o server client serverApp - diff --git a/resource/examples/old_tests/OCWrapper/parsetest.cpp b/resource/examples/old_tests/OCWrapper/parsetest.cpp deleted file mode 100644 index 9eb71da..0000000 --- a/resource/examples/old_tests/OCWrapper/parsetest.cpp +++ /dev/null @@ -1,120 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -#include -#include -#include - -using namespace std; -using namespace boost::property_tree; - -void parseResource(ptree resource) -{ - cout<<"\t\tParsing Resource with "<< resource.size() <<" facts:"<("href", "") <("obs",0)==1)<() < -#include -#include -#include - -using namespace OC; - -void testClient() -{ - PlatformConfig cfg; - cfg.ipAddress = "192.168.1.5"; - cfg.port = 8080; - cfg.mode = ModeType::Client; - cfg.serviceType = ServiceType::InProc; - - IWrapperFactory::Ptr pFactory = std::make_shared(); - IClientWrapper::Ptr pWrapper = pFactory->CreateClientWrapper(cfg); -} - -int main() -{ - testClient(); -} diff --git a/resource/examples/old_tests/OCWrapper/testServer.cpp b/resource/examples/old_tests/OCWrapper/testServer.cpp deleted file mode 100644 index 986c3a4..0000000 --- a/resource/examples/old_tests/OCWrapper/testServer.cpp +++ /dev/null @@ -1,97 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - - -#include -#include -#include -#include -#include - -#include -#include -#include - -using namespace OC; -using namespace OC::OCReflect; - -// Demo of how to generate OCStack stuff: -void rep_test() -{ - using OC::OCReflect::property_type; - using OC::OCReflect::named_property_binding; - - named_property_binding_vector sigs { - named_property_binding("state", property_type::boolean), - named_property_binding("power", property_type::integer), - }; - - using namespace OC::OCReflect::OCStack; - - std::vector reps { convert(sigs) }; - - for(const auto& r : reps) - std::cout << r << '\n'; - - char **LEDrep = convert(reps); - - std::for_each(LEDrep, LEDrep + length(LEDrep), [](const char *s) { std::cout << s << '\n'; }); - - - - - OCEntityHandler entityHandler; - OCResourceHandle resourceHandle; - - OCCreateResource( &resourceHandle, // OCResourceHandle *handl - "core.led", // const char * resourceTypeName - "state:oc.bt.b;power:oc.bt.i", //const char * resourceTypeRepresentation - "core.rw", //const char * resourceInterfaceName - OC_REST_GET | OC_REST_PUT, // uint8_t allowedMethods - "/a/led", // const char * uri - entityHandler, // OCEntityHandler entityHandler - OC_DISCOVERABLE | OC_OBSERVABLE // uint8_t resourceProperties - ); - - - - release(LEDrep); -} - -void testServer() -{ - PlatformConfig cfg; - cfg.ipAddress = "192.168.1.5"; - cfg.port = 8080; - cfg.mode = ModeType::Server; - cfg.serviceType = ServiceType::InProc; - - IWrapperFactory::Ptr pFactory= std::make_shared(); - - IServerWrapper::Ptr pServer = pFactory->CreateServerWrapper(cfg); - - //pServer->bindTo -} - -int main() -{ - rep_test(); - testServer(); -} diff --git a/resource/examples/old_tests/OCWrapper/testServerApp.cpp b/resource/examples/old_tests/OCWrapper/testServerApp.cpp deleted file mode 100644 index 3db9871..0000000 --- a/resource/examples/old_tests/OCWrapper/testServerApp.cpp +++ /dev/null @@ -1,131 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -/// -/// This sample provides steps to define an interface for a resource -/// (properties and methods) and host this resource on the server. -/// - -#include - -#include -#include -#include -#include -#include - -using namespace std; - -using namespace OC; -using namespace OC::OCReflect; - -/// This class represents a single resource named 'light'. This resource has -/// two simple properties named 'state' and 'power' and they have respective setter -/// and getter methods. - -class light -{ -private: - /// Access this property from a TB client - bool m_state; - int m_power; - -public: - light() - : m_power(0), - m_state(false) - {} - -public: - /// Setter method for the setting the power of this light resource - void setPower(int powerValue) - { - m_power = powerValue; - } - - /// Getter method for the getting the power of this light resource - int getPower() const - { - return m_power; - } - - /// Setter method for the setting the state of this light resource - void setState(bool state) - { - m_state = state; - } - - /// Getter method for the getting the state of this light resource - bool getState() const - { - return m_state; - } - -public: - /* Note that this does not need to be a member function: for classes you do not have - access to, you can accomplish this with a free function: */ - - /// This function binds the properties and methods to the server. - void bindTo(OC::OCPlatform& platform) - { - using OC::OCReflect::property_type; - using OC::OCReflect::property_binding; - - property_binding_vector properties { - property_binding("state", property_type::boolean), - property_binding("power", property_type::integer) - }; - - std::string resourceURI = "/a/light"; - std::string resourceTypeName = "light"; - platform.registerResource(resourceURI, resourceTypeName, properties); - } -}; - -int main() -{ - // Step1: Create a OCPlatform instance. - // Step1.1: The constructor of OCPlatform class takes PlatformConfig object. - // Note: Platform creation is synchronous call. - - PlatformConfig cfg; - cfg.ipAddress = "192.168.1.5"; - cfg.port = 8080; - cfg.mode = ModeType::Server; - cfg.serviceType = ServiceType::InProc; - - cout << "Creating OCPlatform .. \n"; - - OCPlatform platform(cfg); - - // Step2: Create the instance of the resource class (in this case instance of class 'light'). - // Step2.1: Invoke bindTo function of class light. - - light myLight; - myLight.bindTo(platform); - - while(true) - { - //some tasks - } - - // No explicit call to stop the platform. - // When OCPlatform destructor is invoked, internally we do platform cleanup -} diff --git a/resource/examples/old_tests/multiple_resources.cpp b/resource/examples/old_tests/multiple_resources.cpp deleted file mode 100644 index f0fc986..0000000 --- a/resource/examples/old_tests/multiple_resources.cpp +++ /dev/null @@ -1,264 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -/// -/// This sample provides steps to define an interface for multiple resources -/// (properties and methods) and host these resources on the server. -/// -#include - -#include "OCServer.h" -#include "OCReflect.h" - -using namespace OC::OCReflect; - -class dimmer -{ -private: - int m_level; - int m_color; - -public: - bool m_powered; // This is an observable property - std::string manufacturer; // This is a non-observable property - -public: - dimmer() - : m_level(0), - m_color(0), - m_powered(false), - manufacturer("Integrated Electronics") - {} - -public: - /// Setter method for the setting the power state of this dimmer resource - void setPowered(const bool newState) - { - m_powered = newState; - } - - /// Getter method for the setting the power state of this dimmer resource - bool getPowered() const - { - return m_powered; - } - - /// Setter method for the setting the intensity level of this dimmer resource - /// Along with above basic method, this method takes two arguments - /// with first argument as intensity level and second level as color. - void setLevel(const int newLevel, int color) - { - m_level = newLevel; - m_color = color; - } - - /// Getter method for getting the intensity level of the dimmer resoruce - int getLevel() const - { - return m_level; - } - - /// Note that this does not need to be a member function: for classes you do not have - /// access to, you can accomplish this with a free function: -public: - void bindTo(OC::OCServer& server, const std::string& base_URI) - { - /*using OC::OCReflect::method_signature; - using OC::OCReflect::method_binding; - using OC::OCReflect::property_signature; - using OC::OCReflect::property_binding; - using OC::OCReflect::bind_service; - using OC::OCReflect::bind_property; - - using OC::OCReflect::property_type;*/ - - // Register the URI with the server - server.registerResource(this, base_URI); - - // Steps to map the property - - // The canonical way to bind a property to a server in one step: - bind_property( - server, // server to bind to - this->manufacturer, // pointer to property - "manufacturer", // property binding name - OC::OCReflect::property_type::string, // property - OC::OCReflect::property_attribute::r // type decoration - ); - - // The canonical way to bind a property to a server in one step: - bind_property( - server, // server to bind to - this->m_powered, // pointer to property - "powerState", // property binding name - OC::OCReflect::property_type::boolean, // property - OC::OCReflect::property_attribute::r // type decoration - ); - - // Steps to map the methods - - // Example to map getPowered method using the canonical way in one step: - bind_service(server, // server to bind to - this, // instance (ourself) to bind - &dimmer::getPowered, // address of the method to bind - "getPowered", // name to bind with service URL - property_type::boolean); // return type of the method - - // Example to map setPowered method using the canonical way in one step: - bind_service(server, // server to bind to - this, // instance (ourself) to bind - &dimmer::setPowered, // address of the method to bind - "setPowered", // name to bind with service URL - property_type::nil, // return type of the method - property_type::boolean); // parameter type for setPowered method - - // Example to map setLevel method using the canonical way in one step: - bind_service( - server, // server to bind with - this, // instance to bind - &dimmer::setLevel, // method to bind - "setLevel", // service name - property_type::nil, // input type - property_type::integer, // parameter list starts (parameter type for level) - property_type::integer); // parameter list (parameter type for color) - - // Example to map getLevel method using the canonical way in one step: - bind_service(server, this, &dimmer::getLevel, "getLevel", property_type::integer); - } -}; - -class door -{ - bool m_locked; - -public: - std::string manufacturer; - -public: - door() - : m_locked(true), - manufacturer("Integrated Electronics") - {} - -public: - /// Setter method for the setting the lock state of this door resource - void setLockState(const bool lockState) - { - m_locked = lockState; - } - - /// Getter method for the setting the lock state of this door resource - bool getLockState() const - { - return m_locked; - } - - /* Note that this does not need to be a member function: for classes you do not have - access to, you can accomplish this with a free function: */ -public: - void bindTo(OC::OCServer& server, const std::string& base_URI) - { - /*using OC::OCReflect::method_signature; - using OC::OCReflect::method_binding; - using OC::OCReflect::property_signature; - using OC::OCReflect::property_binding; - using OC::OCReflect::bind_service; - using OC::OCReflect::bind_property; - - using OC::OCReflect::property_type;*/ - - // Register the URI with the server - server.registerResource(this, base_URI); - - // Steps to map the property - - // The canonical way to bind a property to a server in one step: - bind_property( - server, // server to bind to - this->manufacturer, // pointer to property - "manufacturer", // property binding name - OC::OCReflect::property_type::string, // property - OC::OCReflect::property_attribute::r // type decoration - ); - - // Steps to map the methods - - // Example to map getPowered method using the canonical way in one step: - bind_service(server, // server to bind to - this, // instance (ourself) to bind - &door::getLockState, // address of the method to bind - "getLockState", // name to bind with service URL - property_type::boolean); // return type of the method - - // Example to map setPowered method using the canonical way in one step: - bind_service(server, // server to bind to - this, // instance (ourself) to bind - &door::setLockState, // address of the method to bind - "setLockState", // name to bind with service URL - property_type::nil, // return type of the method - property_type::boolean); // parameter type for setPowered method - } -}; - -class garage -{ -private: - dimmer myDimmer; - door myDoor; - -public: - void bindTo(OC::OCServer& server, const std::string& base_URI) - { - // Register the URI with the server - server.registerResource(this, base_URI); - - // Bind child resource 'dimmer' to the server - myDimmer.bindTo(server, base_URI + "/dimmer/a"); - - // Bind child resource 'door' to the server - myDoor.bindTo(server, base_URI + "/door/a"); - } -}; - -int main() -{ - //Step1: create a server - OC::OCSecurityModel securityModel; - OC::OCServer server; - server.setSecurityModel(securityModel); - - //Step2: Create a Garage resource - garage myGarage; - - //Step3: Bind garage resource to the server - //Note: Garage resource has child resources -- dimmer and door. - myGarage.bindTo(server, "/garage/"); - - //Step4: Start the server - server.start(); - - while(true) - { - //do something here - } - - //Step4: Stop the server - server.stop(); -} -- 2.7.4