diff options
Diffstat (limited to 'CommonAPI-Examples/e02Attributes/src/e02AttributesService.cpp')
-rw-r--r-- | CommonAPI-Examples/e02Attributes/src/e02AttributesService.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/CommonAPI-Examples/e02Attributes/src/e02AttributesService.cpp b/CommonAPI-Examples/e02Attributes/src/e02AttributesService.cpp new file mode 100644 index 0000000..8636a6e --- /dev/null +++ b/CommonAPI-Examples/e02Attributes/src/e02AttributesService.cpp @@ -0,0 +1,30 @@ +/* Copyright (C) 2014 BMW Group + * Author: Manfred Bathelt (manfred.bathelt@bmw.de) + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <thread> +#include <iostream> + +#include <CommonAPI/CommonAPI.h> +#include "E02AttributesStubImpl.h" + +int main() { + std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load(); + std::shared_ptr<CommonAPI::Factory> factory = runtime->createFactory(); + std::shared_ptr<CommonAPI::ServicePublisher> servicePublisher = runtime->getServicePublisher(); + + const std::string& serviceAddress = "local:commonapi.examples.Attributes:commonapi.examples.Attributes"; + std::shared_ptr<E02AttributesStubImpl> myService = std::make_shared<E02AttributesStubImpl>(); + servicePublisher->registerService(myService, serviceAddress, factory); + + while (true) { + myService->incCounter(); // Change value of attribute, see stub implementation + std::cout << "Waiting for calls... (Abort with CTRL+C)" << std::endl; + std::this_thread::sleep_for(std::chrono::seconds(2)); + } + + return 0; +} |