lxcpp skeleton 13/44613/8
authorMateusz Malicki <m.malicki2@samsung.com>
Thu, 23 Jul 2015 13:48:09 +0000 (15:48 +0200)
committerJan Olszak <j.olszak@samsung.com>
Mon, 27 Jul 2015 12:38:10 +0000 (05:38 -0700)
[Feature]       N/A
[Cause]         N/A
[Solution]      N/A
[Verification]  N/A

Change-Id: I1950967edc720ad9b81301daa4e1b60ff8c3b41d

CMakeLists.txt
libs/lxcpp/CMakeLists.txt [new file with mode: 0644]
libs/lxcpp/container-impl.cpp [new file with mode: 0644]
libs/lxcpp/container-impl.hpp [new file with mode: 0644]
libs/lxcpp/container.hpp [new file with mode: 0644]
libs/lxcpp/exception.hpp [new file with mode: 0644]
libs/lxcpp/liblxcpp.pc.in [new file with mode: 0644]
libs/lxcpp/lxcpp.cpp [new file with mode: 0644]
libs/lxcpp/lxcpp.hpp [new file with mode: 0644]
packaging/vasum.spec

index 76a2344..4e9e4d4 100644 (file)
@@ -145,6 +145,7 @@ ENDIF(NOT DEFINED PYTHON_SITELIB)
 SET(COMMON_FOLDER ${PROJECT_SOURCE_DIR}/common)
 SET(LIBS_FOLDER ${PROJECT_SOURCE_DIR}/libs)
 SET(LOGGER_FOLDER ${PROJECT_SOURCE_DIR}/libs/logger)
+SET(LXCPP_FOLDER ${PROJECT_SOURCE_DIR}/libs/lxcpp)
 SET(DBUS_FOLDER ${PROJECT_SOURCE_DIR}/libs/dbus)
 SET(CONFIG_FOLDER ${PROJECT_SOURCE_DIR}/libs/config)
 SET(IPC_FOLDER ${PROJECT_SOURCE_DIR}/libs/ipc)
@@ -190,6 +191,7 @@ SET(VSM_SERVER_IPC_SOCKET_PATH ${RUN_DIR}/vasum.socket)
 SET(VSM_UNIT_TESTS_IPC_SOCKET_PATH ${RUN_DIR}/vasum-ipc-unit-tests.socket)
 
 ADD_SUBDIRECTORY(${LOGGER_FOLDER})
+ADD_SUBDIRECTORY(${LXCPP_FOLDER})
 ADD_SUBDIRECTORY(${DBUS_FOLDER})
 ADD_SUBDIRECTORY(${CONFIG_FOLDER})
 ADD_SUBDIRECTORY(${IPC_FOLDER})
diff --git a/libs/lxcpp/CMakeLists.txt b/libs/lxcpp/CMakeLists.txt
new file mode 100644 (file)
index 0000000..fa63074
--- /dev/null
@@ -0,0 +1,53 @@
+# Copyright (c) 2015 Samsung Electronics Co., Ltd 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.
+#
+#
+# @file   CMakeLists.txt
+# @author Mateusz Malicki (m.malicki2@samsung.com)
+#
+
+PROJECT(lxcpp)
+
+MESSAGE(STATUS "")
+MESSAGE(STATUS "Generating makefile for the liblxcpp...")
+FILE(GLOB HEADERS       *.hpp)
+FILE(GLOB SRCS          *.cpp *.hpp)
+
+SET(_LIB_VERSION_ "${VERSION}")
+SET(_LIB_SOVERSION_ "0")
+SET(PC_FILE "lib${PROJECT_NAME}.pc")
+
+## Setup target ################################################################
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
+    SOVERSION   ${_LIB_SOVERSION_}
+    VERSION     ${_LIB_VERSION_}
+)
+
+## Link libraries ##############################################################
+INCLUDE_DIRECTORIES(${LIBS_FOLDER})
+
+## Generate the pc file ########################################################
+CONFIGURE_FILE(${PC_FILE}.in ${CMAKE_CURRENT_BINARY_DIR}/${PC_FILE} @ONLY)
+
+## Install #####################################################################
+INSTALL(FILES       ${CMAKE_CURRENT_BINARY_DIR}/${PC_FILE}
+        DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+
+INSTALL(TARGETS     ${PROJECT_NAME}
+        DESTINATION ${LIB_INSTALL_DIR}
+        COMPONENT   RuntimeLibraries)
+
+INSTALL(FILES       ${HEADERS}
+        DESTINATION ${INCLUDE_INSTALL_DIR}/lxcpp)
diff --git a/libs/lxcpp/container-impl.cpp b/libs/lxcpp/container-impl.cpp
new file mode 100644 (file)
index 0000000..c0fd907
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Contact: Mateusz Malicki <m.malicki2@samsung.com>
+ *
+ *  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
+ */
+
+/**
+ * @file
+ * @author  Mateusz Malicki (m.malicki2@samsung.com)
+ * @brief   ContainerImpl definition
+ */
+
+#include <lxcpp/container-impl.hpp>
+#include <lxcpp/exception.hpp>
+
+namespace lxcpp {
+
+ContainerImpl::ContainerImpl()
+{
+}
+
+ContainerImpl::~ContainerImpl()
+{
+}
+
+std::string ContainerImpl::getName()
+{
+    throw NotImplemented();
+}
+
+void ContainerImpl::setName(const std::string& /* name */)
+{
+    throw NotImplemented();
+}
+
+void ContainerImpl::start()
+{
+    throw NotImplemented();
+}
+
+void ContainerImpl::stop()
+{
+    throw NotImplemented();
+}
+
+void ContainerImpl::freeze()
+{
+    throw NotImplemented();
+}
+
+void ContainerImpl::unfreeze()
+{
+    throw NotImplemented();
+}
+
+void ContainerImpl::reboot()
+{
+    throw NotImplemented();
+}
+
+int ContainerImpl::getInitPid()
+{
+    throw NotImplemented();
+}
+
+void ContainerImpl::create()
+{
+    throw NotImplemented();
+}
+
+void ContainerImpl::destroy()
+{
+    throw NotImplemented();
+}
+
+void ContainerImpl::setRootPath(const std::string& /* path */)
+{
+    throw NotImplemented();
+}
+
+std::string getRootPath()
+{
+    throw NotImplemented();
+}
+
+} // namespace lxcpp
diff --git a/libs/lxcpp/container-impl.hpp b/libs/lxcpp/container-impl.hpp
new file mode 100644 (file)
index 0000000..e53684e
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Contact: Mateusz Malicki <m.malicki2@samsung.com>
+ *
+ *  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
+ */
+
+/**
+ * @file
+ * @author  Mateusz Malicki (m.malicki2@samsung.com)
+ * @brief   ContainerImpl main class
+ */
+
+#ifndef LXCPP_CONTAINER_IMPL_HPP
+#define LXCPP_CONTAINER_IMPL_HPP
+
+#include <lxcpp/container.hpp>
+
+namespace lxcpp {
+
+class ContainerImpl : public virtual Container {
+public:
+    ContainerImpl();
+    ~ContainerImpl();
+
+    std::string getName();
+    void setName(const std::string& name);
+
+    //Execution actions
+    void start();
+    void stop();
+    void freeze();
+    void unfreeze();
+    void reboot();
+    int getInitPid();
+
+    //Filesystem actions
+    void create();
+    void destroy();
+    void setRootPath(const std::string& path);
+    std::string getRootPath();
+};
+
+} // namespace lxcpp
+
+#endif // LXCPP_CONTAINER_IMPL_HPP
diff --git a/libs/lxcpp/container.hpp b/libs/lxcpp/container.hpp
new file mode 100644 (file)
index 0000000..b3ce50a
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Contact: Mateusz Malicki <m.malicki2@samsung.com>
+ *
+ *  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
+ */
+
+/**
+ * @file
+ * @author  Mateusz Malicki (m.malicki2@samsung.com)
+ * @brief   Container interface
+ */
+
+#ifndef LXCPP_CONTAINER_HPP
+#define LXCPP_CONTAINER_HPP
+
+#include <string>
+
+namespace lxcpp {
+
+class Container {
+public:
+    virtual ~Container();
+
+    virtual std::string getName() = 0;
+    virtual void setName(const std::string& name) = 0;
+
+    //Execution actions
+    virtual void start() = 0;
+    virtual void stop() = 0;
+    virtual void freeze() = 0;
+    virtual void unfreeze() = 0;
+    virtual void reboot() = 0;
+    virtual int getInitPid() = 0;
+
+    //Filesystem actions
+    virtual void create() = 0;
+    virtual void destroy() = 0;
+    virtual void setRootPath(const std::string& path) = 0;
+    virtual std::string getRootPath() = 0;
+};
+
+} // namespace lxcpp
+
+#endif // LXCPP_CONTAINER_HPP
diff --git a/libs/lxcpp/exception.hpp b/libs/lxcpp/exception.hpp
new file mode 100644 (file)
index 0000000..e841c0b
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Contact: Mateusz Malicki <m.malicki2@samsung.com>
+ *
+ *  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
+ */
+
+/**
+ * @file
+ * @author  Mateusz Malicki (m.malicki2@samsung.com)
+ * @brief   lxcpp's exceptions definitions
+ */
+
+#ifndef LXCPP_EXCEPTION_HPP
+#define LXCPP_EXCEPTION_HPP
+
+#include <stdexcept>
+
+namespace lxcpp {
+
+class ContainerException : std::runtime_error
+{
+public:
+    ContainerException(const std::string& what) : std::runtime_error(what) {}
+};
+
+class NotImplemented : ContainerException
+{
+public:
+    NotImplemented() : ContainerException(std::string()) {}
+};
+
+} // namespace lxcpp
+
+#endif // LXCPP_EXCEPTION_HPP
diff --git a/libs/lxcpp/liblxcpp.pc.in b/libs/lxcpp/liblxcpp.pc.in
new file mode 100644 (file)
index 0000000..812e495
--- /dev/null
@@ -0,0 +1,12 @@
+# Package Information for pkg-config
+
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+includedir=@INCLUDE_INSTALL_DIR@
+
+Name: liblxcpp
+Description: Lxc library
+Version: @_LIB_VERSION_@
+Libs: -L${libdir} -llxcpp
+Cflags: -I${includedir}
diff --git a/libs/lxcpp/lxcpp.cpp b/libs/lxcpp/lxcpp.cpp
new file mode 100644 (file)
index 0000000..a81f8f9
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Contact: Mateusz Malicki <m.malicki2@samsung.com>
+ *
+ *  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
+ */
+
+/**
+ * @file
+ * @author  Mateusz Malicki (m.malicki2@samsung.com)
+ * @brief   lxcpp container factory definition
+ */
+
+#include <lxcpp/container-impl.hpp>
+
+namespace lxcpp {
+
+Container* createContainer()
+{
+    return new ContainerImpl();
+}
+
+} // namespace lxcpp
diff --git a/libs/lxcpp/lxcpp.hpp b/libs/lxcpp/lxcpp.hpp
new file mode 100644 (file)
index 0000000..a6b8437
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Contact: Mateusz Malicki <m.malicki2@samsung.com>
+ *
+ *  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
+ */
+
+/**
+ * @file
+ * @author  Mateusz Malicki (m.malicki2@samsung.com)
+ * @brief   LXCpp factory declaration
+ */
+
+#ifndef LXCPP_LXCPP_HPP
+#define LXCPP_LXCPP_HPP
+
+#include <lxcpp/container.hpp>
+
+namespace lxcpp {
+
+Container* createContainer();
+
+} // namespace lxcpp
+
+#endif // LXCPP_LXCPP_HPP
index acb7ada..f1991d4 100644 (file)
@@ -433,3 +433,36 @@ The package provides libIpc development tools and libs.
 %{_libdir}/libIpc.so
 %{_includedir}/vasum-tools/ipc
 %{_libdir}/pkgconfig/libIpc.pc
+
+## liblxcpp Package ###########################################################
+%package -n liblxcpp
+Summary:            lxcpp library
+Group:              Security/Other
+Requires(post):     /sbin/ldconfig
+Requires(postun):   /sbin/ldconfig
+
+%description -n liblxcpp
+The package provides liblxcpp library.
+
+%post -n liblxcpp -p /sbin/ldconfig
+
+%postun -n liblxcpp -p /sbin/ldconfig
+
+%files -n liblxcpp
+%defattr(644,root,root,755)
+%{_libdir}/liblxcpp.so.0
+%attr(755,root,root) %{_libdir}/liblxcpp.so.%{version}
+
+%package -n liblxcpp-devel
+Summary:        Development lxcpp library
+Group:          Development/Libraries
+Requires:       liblxcpp = %{epoch}:%{version}-%{release}
+
+%description -n liblxcpp-devel
+The package provides liblxcpp development tools and libs.
+
+%files -n liblxcpp-devel
+%defattr(644,root,root,755)
+%{_libdir}/liblxcpp.so
+%{_includedir}/lxcpp
+%{_libdir}/pkgconfig/liblxcpp.pc