diff options
author | François Gaffie <francois.gaffie@intel.com> | 2016-02-17 07:54:16 +0100 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2016-03-04 17:47:11 -0800 |
commit | 221a25e58e92ebc450c7eaba5f3ba8153a2308ae (patch) | |
tree | 21fba4d16e7be1fc91e2e8b85b12ad3950c209a1 /upstream/skeleton-subsystem | |
parent | 9368eea42a1afb01dd44110582f997115b50e742 (diff) | |
download | parameter-framework-221a25e58e92ebc450c7eaba5f3ba8153a2308ae.tar.gz |
parameter-framework: move github upstream code to upstream folder
Change-Id: I3aa6e8f8fccfcf80fdc2a4e00c17d8b10b45e9dd
Signed-off-by: François Gaffie <francois.gaffie@intel.com>
Bug: 22887211
Diffstat (limited to 'upstream/skeleton-subsystem')
-rw-r--r-- | upstream/skeleton-subsystem/CMakeLists.txt | 77 | ||||
-rw-r--r-- | upstream/skeleton-subsystem/README.md | 13 | ||||
-rw-r--r-- | upstream/skeleton-subsystem/SkeletonMappingKeys.h | 40 | ||||
-rw-r--r-- | upstream/skeleton-subsystem/SkeletonSubsystem.cpp | 49 | ||||
-rw-r--r-- | upstream/skeleton-subsystem/SkeletonSubsystem.h | 38 | ||||
-rw-r--r-- | upstream/skeleton-subsystem/SkeletonSubsystemBuilder.cpp | 39 | ||||
-rw-r--r-- | upstream/skeleton-subsystem/SkeletonSubsystemObject.cpp | 121 | ||||
-rw-r--r-- | upstream/skeleton-subsystem/SkeletonSubsystemObject.h | 60 | ||||
-rw-r--r-- | upstream/skeleton-subsystem/test/CMakeLists.txt | 39 | ||||
-rw-r--r-- | upstream/skeleton-subsystem/test/main.cpp | 55 | ||||
-rw-r--r-- | upstream/skeleton-subsystem/test/structure.xml | 9 | ||||
-rw-r--r-- | upstream/skeleton-subsystem/test/toplevel.xml | 9 |
12 files changed, 549 insertions, 0 deletions
diff --git a/upstream/skeleton-subsystem/CMakeLists.txt b/upstream/skeleton-subsystem/CMakeLists.txt new file mode 100644 index 0000000..1ec822d --- /dev/null +++ b/upstream/skeleton-subsystem/CMakeLists.txt @@ -0,0 +1,77 @@ +# Copyright (c) 2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# working on 2.8.12 - broken on older versions +cmake_minimum_required(VERSION 2.8.12) + +project(parameter-framework-plugins-skeleton) + +if(WIN32) + # Force include iso646.h to support alternative operator form (and, or, not...) + # Such support is require by the standard and can be enabled with /Za + # but doing so breaks compilation of windows headers... + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /FIiso646.h") +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -Wextra -Wconversion") +endif() + +# Hide symbols by default, then exposed symbols are the same in linux and windows +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN true) + +# Force libs and executable to all be at a known place - simplifies a lot of +# things, expecially setting the test environment +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) + +# +# Find PFW libraries and include directories +# +find_path(PFW_INCLUDE_ROOT NAMES parameter/plugin/Plugin.h) + +find_library(PFW_CORE_LIBRARY NAMES parameter) + +set(PFW_INCLUDE_DIRS + ${PFW_INCLUDE_ROOT}/parameter/plugin + ${PFW_INCLUDE_ROOT}/xmlserializer + ${PFW_INCLUDE_ROOT}/utility) + +add_library(skeleton-subsystem MODULE +SkeletonSubsystemBuilder.cpp +SkeletonSubsystem.cpp +SkeletonSubsystemObject.cpp) + +target_include_directories(skeleton-subsystem PRIVATE ${PFW_INCLUDE_DIRS}) +target_link_libraries(skeleton-subsystem ${PFW_CORE_LIBRARY}) + +install(TARGETS skeleton-subsystem + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin) + +include(../ctest/CMakeLists.txt) +add_subdirectory(test) diff --git a/upstream/skeleton-subsystem/README.md b/upstream/skeleton-subsystem/README.md new file mode 100644 index 0000000..e5ee0b2 --- /dev/null +++ b/upstream/skeleton-subsystem/README.md @@ -0,0 +1,13 @@ +# Skeleton plugin + +This is a skeleton plugin i.e. the minimal plugin boilerplate. + +It adds an `owner` and `message` mapping key and print it when reading or +writing the parameter. + +## Usage + +It has no purpose: it only serves as a template and the `make install` target +does not install it. If you want to see a real-life plugin and makefiles, see +<https://github.com/01org/parameter-framework-plugins-alsa> or +<https://github.com/01org/parameter-framework-plugins-filesystem> instead. diff --git a/upstream/skeleton-subsystem/SkeletonMappingKeys.h b/upstream/skeleton-subsystem/SkeletonMappingKeys.h new file mode 100644 index 0000000..f1b0962 --- /dev/null +++ b/upstream/skeleton-subsystem/SkeletonMappingKeys.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2011-2014, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#pragma once + +// Mapping item types +enum SkeletonItemType +{ + ESkeletonOwner, + EAmend1, + EAmend2, + EAmendEnd = EAmend2, + ENbSkeletonItemTypes +}; diff --git a/upstream/skeleton-subsystem/SkeletonSubsystem.cpp b/upstream/skeleton-subsystem/SkeletonSubsystem.cpp new file mode 100644 index 0000000..227d71a --- /dev/null +++ b/upstream/skeleton-subsystem/SkeletonSubsystem.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2011-2015, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "SkeletonSubsystem.h" +#include "SkeletonMappingKeys.h" +#include "SubsystemObjectFactory.h" +#include "SkeletonSubsystemObject.h" + +#define base CSubsystem + +// Implementation +CSkeletonSubsystem::CSkeletonSubsystem(const std::string &strName, core::log::Logger &logger) + : base(strName, logger) +{ + // Provide mapping keys to upper layer + addContextMappingKey("Owner"); + addContextMappingKey("Amend1"); + addContextMappingKey("Amend2"); + + // Provide creators to upper layer + addSubsystemObjectFactory( + new TSubsystemObjectFactory<CSkeletonSubsystemObject>("Message", 1 << ESkeletonOwner)); +} diff --git a/upstream/skeleton-subsystem/SkeletonSubsystem.h b/upstream/skeleton-subsystem/SkeletonSubsystem.h new file mode 100644 index 0000000..276562e --- /dev/null +++ b/upstream/skeleton-subsystem/SkeletonSubsystem.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2011-2015, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#pragma once + +#include "Subsystem.h" + +class CSkeletonSubsystem : public CSubsystem +{ +public: + CSkeletonSubsystem(const std::string &strName, core::log::Logger &logger); +}; diff --git a/upstream/skeleton-subsystem/SkeletonSubsystemBuilder.cpp b/upstream/skeleton-subsystem/SkeletonSubsystemBuilder.cpp new file mode 100644 index 0000000..5a8647e --- /dev/null +++ b/upstream/skeleton-subsystem/SkeletonSubsystemBuilder.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2011-2015, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "Plugin.h" +#include "LoggingElementBuilderTemplate.h" +#include "SkeletonSubsystem.h" + +void PARAMETER_FRAMEWORK_PLUGIN_ENTRYPOINT_V1(CSubsystemLibrary *pSubsystemLibrary, + core::log::Logger &logger) +{ + pSubsystemLibrary->addElementBuilder( + "Skeleton", new TLoggingElementBuilderTemplate<CSkeletonSubsystem>(logger)); +} diff --git a/upstream/skeleton-subsystem/SkeletonSubsystemObject.cpp b/upstream/skeleton-subsystem/SkeletonSubsystemObject.cpp new file mode 100644 index 0000000..8f696a0 --- /dev/null +++ b/upstream/skeleton-subsystem/SkeletonSubsystemObject.cpp @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2011-2015, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include <fstream> +#include <string> +#include <sstream> +#include <cstdlib> +#include <cassert> +#include <iostream> +#include "ParameterType.h" +#include "MappingContext.h" +#include "SkeletonMappingKeys.h" +#include "InstanceConfigurableElement.h" +#include "SkeletonSubsystemObject.h" + +#define STR_FORMAT_LENGTH 32 + +#define base CFormattedSubsystemObject + +using std::string; + +CSkeletonSubsystemObject::CSkeletonSubsystemObject( + const string &strMappingValue, CInstanceConfigurableElement *pInstanceConfigurableElement, + const CMappingContext &context, core::log::Logger &logger) + : base(pInstanceConfigurableElement, logger, strMappingValue, EAmend1, EAmendEnd - EAmend1 + 1, + context), + _bWrongElementTypeError(false) +{ + // Get actual element type + const CParameterType *pParameterType = + static_cast<const CParameterType *>(pInstanceConfigurableElement->getTypeElement()); + + // Retrieve sizes + _scalarSize = pParameterType->getSize(); + _arraySize = pInstanceConfigurableElement->getFootPrint() / _scalarSize; + + // Construct message + _strMessage = context.getItem(ESkeletonOwner) + ":" + strMappingValue; + + // Handle types + // Check we are able to handle elements (no exception support, defer the error) + switch (pInstanceConfigurableElement->getType()) { + + case CInstanceConfigurableElement::EParameter: + break; + default: + _bWrongElementTypeError = true; + break; + } +} +// Sync to/from HW +bool CSkeletonSubsystemObject::accessHW(bool bReceive, string &strError) +{ + // Check parameter type is ok (deferred error, no exceptions available :-() + if (_bWrongElementTypeError) { + + strError = "Unsupported parameter type"; + + return false; + } + + return base::accessHW(bReceive, strError); +} + +bool CSkeletonSubsystemObject::sendToHW(string & /*strError*/) +{ + void *pvValue = alloca(_scalarSize); + + for (size_t index = 0; index < _arraySize; index++) { + + // Read Value in BlackBoard + blackboardRead(pvValue, _scalarSize); + + // Send here the value + std::cout << "Sending to HW: " << _strMessage << std::endl; + } + + return true; +} + +bool CSkeletonSubsystemObject::receiveFromHW(string & /*strError*/) +{ + void *pvValue = alloca(_scalarSize); + + for (size_t index = 0; index < _arraySize; index++) { + + // Retreive here the value + std::cout << "Retreive from HW: " << _strMessage << std::endl; + + // Write Value in Blackboard + blackboardWrite(pvValue, _scalarSize); + } + + return true; +} diff --git a/upstream/skeleton-subsystem/SkeletonSubsystemObject.h b/upstream/skeleton-subsystem/SkeletonSubsystemObject.h new file mode 100644 index 0000000..f4c09c9 --- /dev/null +++ b/upstream/skeleton-subsystem/SkeletonSubsystemObject.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2011-2015, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#pragma once + +#include "FormattedSubsystemObject.h" + +class CMappingContext; + +class CSkeletonSubsystemObject : public CFormattedSubsystemObject +{ +public: + CSkeletonSubsystemObject(const std::string &strMappingValue, + CInstanceConfigurableElement *pInstanceConfigurableElement, + const CMappingContext &context, core::log::Logger &logger); + +protected: + // from CSubsystemObject + // Sync to/from HW + virtual bool sendToHW(std::string &strError); + virtual bool receiveFromHW(std::string &strError); + +private: + // Sync to/from HW + virtual bool accessHW(bool bReceive, std::string &strError); + +protected: + // Scalar parameter size for elementary access + size_t _scalarSize; + size_t _arraySize; + std::string _strMessage; + // Delayed error about supported parameter types (always false in this example) + bool _bWrongElementTypeError; +}; diff --git a/upstream/skeleton-subsystem/test/CMakeLists.txt b/upstream/skeleton-subsystem/test/CMakeLists.txt new file mode 100644 index 0000000..46cb669 --- /dev/null +++ b/upstream/skeleton-subsystem/test/CMakeLists.txt @@ -0,0 +1,39 @@ +# Copyright (c) 2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +configure_file(structure.xml "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY) +configure_file(toplevel.xml "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY) + +add_executable(skeleton-test main.cpp) +target_include_directories(skeleton-test PRIVATE "${PFW_INCLUDE_ROOT}/parameter/client") +target_link_libraries(skeleton-test "${PFW_CORE_LIBRARY}") + +add_test(NAME skeleton-test + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + COMMAND skeleton-test) +set_test_env(skeleton-test) diff --git a/upstream/skeleton-subsystem/test/main.cpp b/upstream/skeleton-subsystem/test/main.cpp new file mode 100644 index 0000000..43a9d6f --- /dev/null +++ b/upstream/skeleton-subsystem/test/main.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2015, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include <ParameterMgrFullConnector.h> + +#include <iostream> + +class MyLogger final : public CParameterMgrFullConnector::ILogger +{ +public: + void info(const std::string &log) override { std::cout << "Info: " << log << std::endl; } + + void warning(const std::string &log) override { std::cerr << "Warning: " << log << std::endl; } +}; + +int main(void) +{ + MyLogger logger; + CParameterMgrFullConnector instance("toplevel.xml"); + instance.setLogger(&logger); + + std::string errorMsg; + if (not instance.start(errorMsg)) { + std::cout << "Failed to start: " << errorMsg << std::endl; + return 1; + } + + return 0; +} diff --git a/upstream/skeleton-subsystem/test/structure.xml b/upstream/skeleton-subsystem/test/structure.xml new file mode 100644 index 0000000..58e15c3 --- /dev/null +++ b/upstream/skeleton-subsystem/test/structure.xml @@ -0,0 +1,9 @@ +<SystemClass Name="class"> + <Subsystem Name="subsystem" Type="Skeleton"> + <ComponentLibrary> + </ComponentLibrary> + <InstanceDefinition> + <BooleanParameter Name="parameter"/> + </InstanceDefinition> + </Subsystem> +</SystemClass> diff --git a/upstream/skeleton-subsystem/test/toplevel.xml b/upstream/skeleton-subsystem/test/toplevel.xml new file mode 100644 index 0000000..b15d4b0 --- /dev/null +++ b/upstream/skeleton-subsystem/test/toplevel.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ParameterFrameworkConfiguration SystemClassName="class" ServerPort="1" TuningAllowed="false"> + <SubsystemPlugins> + <Location Folder=""> + <Plugin Name="skeleton-subsystem"/> + </Location> + </SubsystemPlugins> + <StructureDescriptionFileLocation Path="structure.xml"/> +</ParameterFrameworkConfiguration> |