Parcourir la source

DEVS implementation: initial commit

Eric Ramat il y a 10 ans
commit
65ff8d5aff

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+*~
+build/

+ 109 - 0
CMakeCPack.cmake

@@ -0,0 +1,109 @@
+INCLUDE(InstallRequiredSystemLibraries)
+
+IF (WIN32)
+  SET(CPACK_GENERATOR "NSIS")
+  SET(CPACK_SOURCE_GENERATOR "ZIP")
+ENDIF (WIN32)
+
+IF (UNIX)
+  SET(CPACK_GENERATOR "TGZ;DEB;RPM")
+  SET(CPACK_SOURCE_GENERATOR "ZIP;TGZ;TBZ2")
+ENDIF (UNIX)
+
+IF (APPLE)
+  SET(CPACK_GENERATOR "OSXX11")
+ENDIF (APPLE)
+
+SET(CPACK_STRIP_FILES "1")
+SET(CPACK_PACKAGE_NAME "VLE")
+SET(CPACK_PACKAGE_VENDOR "VLE Development Team")
+SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "VLE - Virtual Laboratory Environment")
+SET(CPACK_PACKAGE_CONTACT "Gauthier Quesnel <quesnel@users.sourceforge.net>")
+SET(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README")
+SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
+SET(CPACK_PACKAGE_FILE_NAME "${VLE_NAME_COMPLETE}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
+SET(CPACK_PACKAGE_VERSION_MAJOR "${VLE_MAJOR}")
+SET(CPACK_PACKAGE_VERSION_MINOR "${VLE_MINOR}")
+
+IF ("${VLE_EXTRA}" STREQUAL "")
+  SET(CPACK_PACKAGE_VERSION_PATCH "${VLE_PATCH}")
+ELSE ("${VLE_EXTRA}" STREQUAL "")
+  SET(CPACK_PACKAGE_VERSION_PATCH "${VLE_PATCH}-${VLE_EXTRA}")
+ENDIF ("${VLE_EXTRA}" STREQUAL "")
+
+SET(CPACK_PACKAGE_INSTALL_DIRECTORY ${VLE_NAME_COMPLETE})
+SET(CPACK_PACKAGE_EXECUTABLES "vle" "VLE" "oov" "OOV" "eov" "EOV" "gvle" "GVLE")
+
+# CPack source configuration
+SET(CPACK_SOURCE_PACKAGE_FILE_NAME ${VLE_NAME_COMPLETE})
+SET(CPACK_SOURCE_IGNORE_FILES "\\\\.swp$;/\\\\.gitignore;/build/;/\\\\.git/")
+
+# CPack DEB configuration
+SET(CPACK_DEBIAN_PACKAGE_NAME ${VLE_NAME}-${VLE_MAJOR}.${VLE_MINOR})
+SET(CPACK_DEBIAN_PACKAGE_VERSION ${VLE_COMPLETE})
+SET(CPACK_DEBIAN_PACKAGE_DEPENDS "")
+SET(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS "")
+SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Gauthier Quesnel <quesnel@users.sourceforge.net>")
+SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "VLE, a framework for multi-modeling, simulation and analysis of complex dynamical systems.")
+SET(CPACK_DEBIAN_PACKAGE_SECTION "libs")
+SET(CPACK_DEBIAN_PACKAGE_PRIORITY "extra")
+
+# CPack RPM configuration
+SET(CPACK_RPM_PACKAGE_SUMMARY "VLE, a framework for multi-modeling, simulation and analysis of complex dynamical systems.")
+SET(CPACK_RPM_PACKAGE_NAME ${VLE_NAME}-${VLE_MAJOR}.${VLE_MINOR})
+SET(CPACK_RPM_PACKAGE_VERSION ${VLE_MAJOR}.${VLE_MINOR}.${VLE_PATCH})
+SET(CPACK_RPM_PACKAGE_RELEASE "1")
+SET(CPACK_RPM_PACKAGE_VENDOR "Gauthier Quesnel <quesnel@users.sourceforge.net>")
+SET(CPACK_RPM_PACKAGE_LICENSE "GNU General Public License (GPL)")
+SET(CPACK_RPM_PACKAGE_DESCRIPTION "VLE, a framework for multi-modeling, simulation and analysis of complex dynamical systems.")
+
+# CPack NSIS configuration
+IF (CPACK_GENERATOR MATCHES "NSIS")
+  SET(CMAKE_MODULE_PATH "share")
+  SET(VLE_BOOST_INCLUDE_DIR CACHE PATH "Boost include directory")
+  SET(VLE_BOOST_LIBRARY_DIR CACHE PATH "Boost library directory")
+  SET(VLE_MINGW_PATH CACHE PATH "Mingw Boost directory")
+  SET(VLE_GTK_PATH CACHE PATH "Gtk directory")
+  SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/share)
+
+  INSTALL(DIRECTORY "${VLE_BOOST_INCLUDE_DIR}/" DESTINATION include)
+  INSTALL(DIRECTORY "${VLE_BOOST_LIBRARY_DIR}/" DESTINATION bin
+    FILES_MATCHING PATTERN "libboost*.dll")
+  INSTALL(DIRECTORY "${VLE_BOOST_LIBRARY_DIR}/" DESTINATION lib
+    FILES_MATCHING PATTERN "libboost*.a")
+
+  INSTALL(FILES "${VLE_MINGW_PATH}/bin\\\\mingwm10.dll" DESTINATION bin)
+
+  INSTALL(DIRECTORY "${VLE_GTK_PATH}/include/" DESTINATION include)
+  INSTALL(DIRECTORY "${VLE_GTK_PATH}/redist/" DESTINATION bin)
+
+  INSTALL(FILES "${VLE_GTK_PATH}/bin\\\\pkg-config.exe" DESTINATION bin)
+
+  INSTALL(DIRECTORY "${VLE_GTK_PATH}/lib/" DESTINATION lib
+    PATTERN "*.def" EXCLUDE
+    PATTERN "*.lib" EXCLUDE)
+
+  INSTALL(DIRECTORY "${VLE_GTK_PATH}/etc\\\\gtk-2.0" DESTINATION etc)
+  INSTALL(DIRECTORY "${VLE_GTK_PATH}/etc\\\\pango" DESTINATION etc)
+
+  INSTALL(DIRECTORY "${VLE_GTK_PATH}/share\\\\doc" DESTINATION share)
+  INSTALL(DIRECTORY "${VLE_GTK_PATH}/share\\\\locale" DESTINATION share)
+  INSTALL(DIRECTORY "${VLE_GTK_PATH}/share\\\\themes" DESTINATION share)
+
+  SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/share/pixmaps\\\\vle.ico")
+  SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/share/pixmaps\\\\vle.ico")
+  SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/share/pixmaps\\\\logo.bmp")
+  SET(CPACK_NSIS_MENU_LINKS "${VLE_SHARE_DIRS}/doc/vle.chm" "VLE API" "http://www.sourceforge.net/projects/vle" "VLE Web Site")
+  SET(CPACK_CREATE_DESKTOP_LINKS gvle)
+  SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\vle.exe")
+  SET(CPACK_NSIS_DISPLAY_NAME "VLE - Virtual Laboratory Environment")
+  SET(CPACK_NSIS_HELP_LINK "http://www.sourceforge.net/projects/vle")
+  SET(CPACK_NSIS_URL_INFO_ABOUT "http://www.sourceforge.net/projects/vle")
+  SET(CPACK_NSIS_CONTACT "Gauthier Quesnel <quesnel@users.sourceforge.net>")
+  SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME} ${VLE_VERSION_SHORT}.0")
+  SET(CPACK_NSIS_MODIFY_PATH ON)
+ENDIF (CPACK_GENERATOR MATCHES "NSIS")
+
+INCLUDE(CPack)
+
+# vim:tw=0:ts=8:tw=0:sw=2:sts=2

+ 196 - 0
CMakeLists.txt

@@ -0,0 +1,196 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(PARADEVS CXX C)
+ENABLE_TESTING()
+
+SET(PARADEVS_MAJOR 1)
+SET(PARADEVS_MINOR 0)
+SET(PARADEVS_PATCH 0)
+SET(PARADEVS_EXTRA "")
+SET(PARADEVS_VERSION "${PARADEVS_MAJOR}.${PARADEVS_MINOR}.${PARADEVS_PATCH}")
+SET(PARADEVS_VERSION_SHORT "${PARADEVS_MAJOR}.${PARADEVS_MINOR}")
+SET(PARADEVS_NAME "paradevs")
+SET(PARADEVS_NAME_VERSION "${PARADEVS_NAME}-${PARADEVS_VERSION}")
+SET(PARADEVS_LOCALE_NAME "${PARADEVS_NAME}-${PARADEVS_MAJOR}-${PARADEVS_MINOR}")
+IF ("${PARADEVS_EXTRA}" STREQUAL "")
+  SET(PARADEVS_COMPLETE "${PARADEVS_MAJOR}.${PARADEVS_MINOR}.${PARADEVS_PATCH}")
+ELSE ("${PARADEVS_EXTRA}" STREQUAL "")
+  SET(PARADEVS_COMPLETE "${PARADEVS_MAJOR}.${PARADEVS_MINOR}.${PARADEVS_PATCH}-${PARADEVS_EXTRA}")
+ENDIF ("${PARADEVS_EXTRA}" STREQUAL "")
+SET(PARADEVS_NAME_COMPLETE "${PARADEVS_NAME}-${PARADEVS_COMPLETE}")
+
+#
+ # Installation variables
+#
+
+SET(PARADEVS_LIBRARY_DIRS "lib/vle-${PARADEVS_VERSION_SHORT}")
+SET(PARADEVS_INCLUDE_DIRS "include/vle-${PARADEVS_VERSION_SHORT}/vle")
+SET(PARADEVS_INCLUDE_DIR "include/vle-${PARADEVS_VERSION_SHORT}")
+SET(PARADEVS_MANPAGE_PATH "share/man/man1")
+SET(PARADEVS_SHARE_DIRS "share/vle-${PARADEVS_VERSION_SHORT}")
+
+#
+ # Append the library version information to the library target
+ # properties.
+#
+
+SET (PARADEVS_LIBRARY_PROPERTIES VERSION 0)
+SET (PARADEVS_APP_PROPERTIES SOVERSION "${PARADEVS_MAJOR}.${PARADEVS_MINOR}"
+  VERSION "${PARADEVS_MAJOR}.${PARADEVS_MINOR}")
+
+#
+ # CPack configuration
+#
+
+INCLUDE(CMakeCPack.cmake)
+
+#
+ # Debug mode
+#
+
+IF (CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
+  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
+  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
+  IF (UNIX)
+    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic")
+    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
+  ENDIF (UNIX)
+ENDIF (CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
+
+if (CMAKE_BUILD_TYPE STREQUAL "")
+  SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build" FORCE)
+endif ()
+
+#
+ # Modules
+#
+
+INCLUDE(CheckIncludeFileCXX)
+INCLUDE(CheckIncludeFile)
+INCLUDE(CheckLibraryExists)
+INCLUDE(CMakeDetermineCCompiler)
+
+#
+ # Check libraries with pkgconfig
+#
+
+FIND_PACKAGE(PkgConfig REQUIRED)
+
+# FIXME use old-style link directories for now
+IF (COMMAND CMAKE_POLICY)
+  CMAKE_POLICY(SET CMP0003 OLD)
+ENDIF (COMMAND CMAKE_POLICY)
+
+PKG_CHECK_MODULES(GLIBMM REQUIRED glibmm-2.4)
+PKG_CHECK_MODULES(LIBXML REQUIRED libxml-2.0)
+#
+ # Test the libboost header and libboost-text library.
+#
+
+OPTION(WITH_TEST "use the libboost test unit library [default: on]" ON)
+SET(Boost_USE_MULTITHREADED ON)
+SET(Boost_USE_STATIC_LIBS OFF)
+SET(Boost_NO_SYSTEM_PATHS OFF)
+SET(Boost_USE_STATIC_RUNTIME ON)
+IF (WIN32)
+  SET(Boost_THREADAPI "win32")
+ENDIF (WIN32)
+SET(Boost_DETAILED_FAILURE_MSG FALSE)
+SET(Boost_DEBUG FALSE)
+
+FIND_PACKAGE(Boost COMPONENTS unit_test_framework serialization filesystem
+  system date_time regex thread)
+IF (NOT Boost_SERIALIZATION_FOUND)
+  MESSAGE(FATAL_ERROR "The boost serialization library is required")
+ENDIF (NOT Boost_SERIALIZATION_FOUND)
+IF (NOT Boost_FILESYSTEM_FOUND)
+  MESSAGE(FATAL_ERROR "The boost filesystem library is required")
+ENDIF (NOT Boost_FILESYSTEM_FOUND)
+IF (NOT Boost_REGEX_FOUND)
+  MESSAGE(FATAL_ERROR "The boost regex library is required")
+ENDIF (NOT Boost_REGEX_FOUND)
+IF (NOT Boost_DATE_TIME_FOUND)
+  MESSAGE(FATAL_ERROR "The boost date_time library is required")
+ENDIF (NOT Boost_DATE_TIME_FOUND)
+IF (NOT Boost_THREAD_FOUND)
+  MESSAGE(FATAL_ERROR "The boost thread library is required")
+ENDIF (NOT Boost_THREAD_FOUND)
+IF (Boost_MINOR_VERSION AND ${Boost_MINOR_VERSION} LESS "35")
+  SET(Boost_SYSTEM_LIBRARY "")
+ENDIF (Boost_MINOR_VERSION AND ${Boost_MINOR_VERSION} LESS "35")
+IF (Boost_MINOR_VERSION AND ${Boost_MINOR_VERSION} LESS "41")
+  SET(PARADEVS_HAVE_BOOST_SPIRIT2 0 CACHE INTERNAL "" FORCE)
+ELSE (Boost_MINOR_VERSION AND ${Boost_MINOR_VERSION} LESS "41")
+  SET(PARADEVS_HAVE_BOOST_SPIRIT2 1 CACHE INTERNAL "" FORCE)
+ENDIF (Boost_MINOR_VERSION AND ${Boost_MINOR_VERSION} LESS "41")
+IF (WITH_TEST)
+  IF (Boost_UNIT_TEST_FRAMEWORK_FOUND)
+    SET(HAVE_UNITTESTFRAMEWORK 1 CACHE INTERNAL "" FORCE)
+  ENDIF (Boost_UNIT_TEST_FRAMEWORK_FOUND)
+ENDIF (WITH_TEST)
+
+#
+ # Generate the config.h
+#
+
+CHECK_INCLUDE_FILE_CXX(cxxabi.h PARADEVS_HAVE_GCC_ABI_DEMANGLE)
+CHECK_INCLUDE_FILE_CXX(execinfo.h PARADEVS_HAVE_EXECINFO)
+CHECK_INCLUDE_FILE_CXX(signal.h PARADEVS_HAVE_SIGNAL)
+INCLUDE_DIRECTORIES(${PARADEVS_BINARY_DIR})
+
+#
+ # Generate the vle.pc pkg-config file.
+ # Build some variable to build a correct Win32 pkg config file with:
+ # prefix=/target to detect the DIRNAME
+ # cflag=-Iboost_1_34_1 for the directory
+#
+
+SET(PARADEVS_PKGCONFIG_PREFIXPATH "${CMAKE_INSTALL_PREFIX}")
+SET(PARADEVS_PKGCONFIG_BOOSTINCLUDE_DIRS "${Boost_INCLUDE_DIRS}")
+SET(PARADEVS_PKGCONFIG_LIBDIR "lib")
+
+CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/src/paradevs.pc.in
+  ${PARADEVS_BINARY_DIR}/paradevs-${PARADEVS_VERSION_SHORT}.pc @ONLY)
+INSTALL(FILES ${PARADEVS_BINARY_DIR}/paradevs-${PARADEVS_VERSION_SHORT}.pc
+  DESTINATION lib/pkgconfig)
+
+#
+ # Install the README
+#
+
+IF(UNIX)
+  INSTALL(FILES "README" DESTINATION "${PARADEVS_SHARE_DIRS}")
+  INSTALL(FILES "COPYING" DESTINATION "${PARADEVS_SHARE_DIRS}")
+ELSE(UNIX)
+  INSTALL(FILES "README" DESTINATION "${PARADEVS_SHARE_DIRS}" RENAME "Readme.txt")
+  INSTALL(FILES "COPYING" DESTINATION "${PARADEVS_SHARE_DIRS}" RENAME "CopyRight.txt")
+ENDIF(UNIX)
+
+#
+ # Browse the src subdirectory
+#
+
+ADD_SUBDIRECTORY(src)
+
+#
+ # Status
+#
+
+MESSAGE(STATUS "- - - -")
+MESSAGE(STATUS "${PARADEVS_NAME_COMPLETE} configured successfully")
+MESSAGE(STATUS "Using ${CMAKE_INSTALL_PREFIX} for installation")
+MESSAGE(STATUS "Build type ${CMAKE_BUILD_TYPE}")
+IF (PARADEVS_HAVE_GCC_ABI_DEMANGLE)
+  MESSAGE(STATUS "Build with GCC ABI Demangle...: yes")
+ENDIF (PARADEVS_HAVE_GCC_ABI_DEMANGLE)
+IF (PARADEVS_HAVE_EXECINFO)
+  MESSAGE(STATUS "Build with execinfo.h.........: yes")
+ENDIF (PARADEVS_HAVE_EXECINFO)
+IF (Boost_FOUND)
+  MESSAGE(STATUS "Build with boost..............: yes")
+ENDIF (Boost_FOUND)
+IF (HAVE_UNITTESTFRAMEWORK)
+  MESSAGE(STATUS "Build unit test...............: yes")
+ENDIF (HAVE_UNITTESTFRAMEWORK)
+MESSAGE(STATUS "- - - -")
+
+# vim:tw=0:ts=8:tw=0:sw=2:sts=2

+ 0 - 0
COPYING


+ 0 - 0
README


+ 3 - 0
src/CMakeLists.txt

@@ -0,0 +1,3 @@
+ADD_SUBDIRECTORY(devs)
+ADD_SUBDIRECTORY(apps)
+ADD_SUBDIRECTORY(examples)

+ 23 - 0
src/apps/CMakeLists.txt

@@ -0,0 +1,23 @@
+INCLUDE_DIRECTORIES(
+  ${PARADEVS_BINARY_DIR}/src
+  ${PARADEVS_SOURCE_DIR}/src
+  ${Boost_INCLUDE_DIRS}
+  ${GLIBMM_INCLUDE_DIRS}
+  ${LIBXML_INCLUDE_DIRS})
+
+LINK_DIRECTORIES(
+  ${GLIBMM_LIBRARY_DIRS}
+  ${LIBXML_LIBRARY_DIRS}
+  ${Boost_LIBRARY_DIRS})
+
+ADD_EXECUTABLE(paradevs main.cpp)
+SET_TARGET_PROPERTIES(paradevs PROPERTIES ${PARADEVS_APP_PROPERTIES})
+
+TARGET_LINK_LIBRARIES(paradevs
+  pdevs examples
+  ${GLIBMM_LIBRARIES}
+  ${LIBXML_LIBRARIES}
+  ${GTHREAD_LIBRARIES}
+  ${Boost_FILESYSTEM_LIBRARY})
+
+INSTALL(TARGETS paradevs DESTINATION bin)

+ 39 - 0
src/apps/main.cpp

@@ -0,0 +1,39 @@
+/**
+ * @file main.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <devs/RootCoordinator.hpp>
+#include <examples/Examples.hpp>
+
+using namespace paradevs;
+
+int main()
+{
+    MyBuilder builder;
+    paradevs::RootCoordinator rc(0, 10, builder);
+
+    rc.run();
+    return 0;
+}

+ 48 - 0
src/devs/Builder.hpp

@@ -0,0 +1,48 @@
+/**
+ * @file Builder.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef DEVS_BUILDER
+#define DEVS_BUILDER 1
+
+#include <devs/Coordinator.hpp>
+
+namespace paradevs {
+
+class Builder
+{
+public :
+    Builder()
+    { }
+
+    virtual ~Builder()
+    { }
+
+    virtual Coordinator* build() const =0;
+};
+
+} // namespace paradevs
+
+#endif

+ 36 - 0
src/devs/CMakeLists.txt

@@ -0,0 +1,36 @@
+INCLUDE_DIRECTORIES(
+  ${PARADEVS_BINARY_DIR}/src
+  ${PARADEVS_SOURCE_DIR}/src
+  ${Boost_INCLUDE_DIRS}
+  ${GLIBMM_INCLUDE_DIRS}
+  ${LIBXML_INCLUDE_DIRS})
+
+LINK_DIRECTORIES(
+  ${GLIBMM_LIBRARY_DIRS}
+  ${LIBXML_LIBRARY_DIR})
+
+SET(DEVS_CPP Coordinator.cpp Dynamics.cpp EventTable.cpp
+  InternalEvent.cpp Links.cpp Message.cpp Model.cpp Node.cpp RootCoordinator.cpp
+  Simulator.cpp)
+
+SET(DEVS_HPP Builder.hpp Coordinator.hpp Dynamics.hpp EventTable.hpp
+  InternalEvent.hpp Links.hpp Message.hpp Model.hpp Node.hpp RootCoordinator.hpp
+  Simulator.hpp Time.hpp)
+
+ADD_LIBRARY(pdevs SHARED ${DEVS_CPP};${DEVS_HPP})
+
+SET_TARGET_PROPERTIES(pdevs PROPERTIES ${PARADEVS_LIBRARY_PROPERTIES})
+SET_TARGET_PROPERTIES(pdevs PROPERTIES OUTPUT_NAME
+  "paradevs-pdevs-${PARADEVS_VERSION_SHORT}")
+
+TARGET_LINK_LIBRARIES(pdevs
+  ${GLIBMM_LIBRARIES}
+  ${LIBXML_LIBRARIES}
+  ${GTHREAD_LIBRARIES})
+
+INSTALL(TARGETS pdevs
+  RUNTIME DESTINATION bin
+  LIBRARY DESTINATION lib
+  ARCHIVE DESTINATION lib)
+
+INSTALL(FILES ${DEVS_HPP} DESTINATION ${PARADEVS_INCLUDE_DIRS}/devs)

+ 197 - 0
src/devs/Coordinator.cpp

@@ -0,0 +1,197 @@
+/**
+ * @file Coordinator.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <devs/Coordinator.hpp>
+
+#include <cassert>
+
+namespace paradevs {
+
+Coordinator::Coordinator(const std::string& name) : Model(name)
+{ }
+
+Coordinator::~Coordinator()
+{
+    for (unsigned int i = 0; i < _child_list.size(); i++)
+    { delete _child_list[i]; }
+}
+
+Time Coordinator::i_message(Time t)
+{
+
+    std::cout << "[" << get_name() << "] at " << t << ": BEFORE - i_message => "
+              << "tl = " << _tl << " ; tn = " << _tn << std::endl;
+
+    assert(_child_list.size() > 0);
+
+    for (unsigned int i = 0; i < _child_list.size(); i++) {
+        Model* model = _child_list[i];
+
+        _event_table.init(model->i_message(_tn), model);
+    }
+    _tl = t;
+    _tn = _event_table.get_current_time();
+
+    std::cout << "[" << get_name() << "] at " << t << ": BEFORE - i_message => "
+              << "tl = " << _tl << " ; tn = " << _tn << std::endl;
+
+    return _tn;
+}
+
+Time Coordinator::s_message(Time t)
+{
+
+    std::cout << "[" << get_name() << "] at " << t << ": BEFORE - s_message => "
+              << "tl = " << _tl << " ; tn = " << _tn << std::endl;
+    std::cout << "[" << get_name() << "]: " << _event_table.to_string()
+              << std::endl;
+
+    assert(t == _tn);
+
+    Model* current = _event_table.get_current_model();
+    Time tn = current->s_message(_tn);
+
+    _event_table.put(tn, current);
+
+    _tl = t;
+    _tn = _event_table.get_current_time();
+
+    std::cout << "[" << get_name() << "] at " << t << ": AFTER - s_message => "
+              << "tl = " << _tl << " ; tn = " << _tn << std::endl;
+    std::cout << "[" << get_name() << "]: " << _event_table.to_string()
+              << std::endl;
+    std::cout << "**************" << std::endl;
+
+    return _tn;
+}
+
+Time Coordinator::x_message(const Message& xmsg, Time t)
+{
+
+    std::cout << "[" << get_name() << "] at " << t << ": BEFORE - x_message on "
+              << xmsg.get_port_name() << " => "
+              << "tl = " << _tl << " ; tn = " << _tn << std::endl;
+    std::cout << "[" << get_name() << "] " << _link_list.to_string()
+              << std::endl;
+
+    assert(tl <= t and t <= tn);
+
+    std::pair < Links::iterator, Links::iterator > result =
+        _link_list.equal_range(Node(xmsg.get_port_name(), this));
+
+    for (Links::iterator it_r = result.first; it_r != result.second; ++it_r) {
+
+        std::cout << "[" << get_name() << "] => "
+                  << it_r->second.get_port_name()
+                  << " / " << it_r->second.get_model()->get_name() << std::endl;
+
+        _tn = (*it_r).second.get_model()->x_message(
+            Message(it_r->second.get_port_name(), it_r->second.get_model(),
+                    xmsg.get_content()), t);
+        _event_table.put(_tn, it_r->second.get_model());
+    }
+
+    _tl = t;
+    _tn = _event_table.get_current_time();
+
+    std::cout << "[" << get_name() << "] at " << t << ": AFTER - x_message => "
+              << "tl = " << _tl << " ; tn = " << _tn << std::endl;
+
+    return _tn;
+}
+
+Time Coordinator::y_message(Messages messages, Time t)
+{
+
+    std::cout << "[" << get_name() << "] at " << t << ": BEFORE - y_message => "
+              << "tl = " << _tl << " ; tn = " << _tn << std::endl;
+    std::cout << "[" << get_name() << "] at " << t << ": "
+              << messages.to_string() << std::endl;
+
+    if (not messages.empty()) {
+        bool internal = false;
+
+        while (not messages.empty()) {
+            Message ymsg = messages.back();
+
+            messages.pop_back();
+
+            std::pair <Links::iterator , Links::iterator > result_model =
+                _link_list.equal_range(Node(ymsg.get_port_name(), ymsg.get_model()));
+
+            assert(result_model.first != result_model.second);
+
+            for (Links::iterator it = result_model.first;
+                 it != result_model.second; ++it) {
+                // event on output port of coupled model
+                if (it->second.get_model() == this) {
+                    Messages ymessages;
+
+                    ymessages.push_back(Message(it->second.get_port_name(),
+                                                it->second.get_model(),
+                                                ymsg.get_content()));
+                    dynamic_cast < Coordinator* >(get_parent())->y_message(ymessages,
+                                                                           t);
+                } else { // event on input port of internal model
+                    Message message(it->second.get_port_name(),
+                                    it->second.get_model(),
+                                    ymsg.get_content());
+                    Time tn = it->second.get_model()->x_message(message, t);
+
+                    _event_table.put(tn, it->second.get_model());
+                    internal = true;
+                }
+            }
+        }
+        if (internal) {
+            _tl = t;
+            _tn = _event_table.get_current_time();
+        }
+    }
+
+    std::cout << "[" << get_name() << "] at " << t << ": AFTER - y_message => "
+              << "tl = " << _tl << " ; tn = " << _tn << std::endl;
+
+    return _tn;
+}
+
+void Coordinator::observation(std::ostream& file) const
+{
+    for (unsigned i = 0; i < _child_list.size(); i++) {
+        _child_list[i]->observation(file);
+    }
+}
+
+void Coordinator::add_child(Model* child)
+{
+    _child_list.push_back(child);
+    child->set_parent(this);
+}
+
+void Coordinator::add_link(const Node& source, const Node& destination)
+{ _link_list.insert(std::pair < Node, Node >(source, destination)); }
+
+} // namespace paradevs

+ 67 - 0
src/devs/Coordinator.hpp

@@ -0,0 +1,67 @@
+/**
+ * @file Coordinator.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef DEVS_COORDINATOR
+#define DEVS_COORDINATOR 1
+
+#include <devs/Model.hpp>
+#include <devs/EventTable.hpp>
+#include <devs/Links.hpp>
+#include <devs/Message.hpp>
+#include <devs/Node.hpp>
+
+#include <iostream>
+#include <vector>
+#include <map>
+
+namespace paradevs {
+
+class Coordinator : public Model
+{
+public :
+    Coordinator(const std::string& name);
+    virtual ~Coordinator();
+
+// DEVS methods
+    virtual Time i_message(Time /* t */);
+    virtual Time s_message(Time /* t */);
+    virtual Time x_message(const Message& /* message */, Time /* t */);
+    virtual Time y_message(Messages /* messages */, Time /* t */);
+    virtual void observation(std::ostream& file) const;
+
+// graph methods
+    virtual void add_child(Model* child);
+    virtual void add_link(const Node& source, const Node& destination);
+
+private :
+    Links      _link_list;
+    Models     _child_list;
+    EventTable _event_table;
+};
+
+} // namespace paradevs
+
+#endif

+ 41 - 0
src/devs/Dynamics.cpp

@@ -0,0 +1,41 @@
+/**
+ * @file Dynamics.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <devs/Dynamics.hpp>
+
+namespace paradevs {
+
+Dynamics::Dynamics(const std::string& name) : _name(name)
+{ }
+
+Dynamics::~Dynamics()
+{ }
+
+Messages Dynamics::lambda() const
+{ return Messages(); }
+
+} // namespace paradevs
+

+ 69 - 0
src/devs/Dynamics.hpp

@@ -0,0 +1,69 @@
+/**
+ * @file Dynamics.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef DEVS_DYNAMICS
+#define DEVS_DYNAMICS 1
+
+#include <devs/Message.hpp>
+#include <devs/Time.hpp>
+
+#include <limits>
+#include <string>
+#include <vector>
+
+namespace paradevs {
+
+class Message;
+class Messages;
+
+class Dynamics
+{
+public:
+    Dynamics(const std::string& name);
+    virtual ~Dynamics();
+
+    virtual void dint(const Time& /* t */)
+    { }
+    virtual void dext(const Time& /* e */, const Message& /* msg */)
+    { }
+    virtual Time start()
+    { return std::numeric_limits < double >::max(); }
+    virtual Time ta() const
+    { return std::numeric_limits < double >::max(); }
+    virtual Messages lambda() const;
+    virtual void observation(std::ostream& /* file */) const
+    { }
+
+    const std::string& get_name() const
+    { return _name; }
+
+private:
+    std::string _name;
+};
+
+} // namespace paradevs
+
+#endif

+ 76 - 0
src/devs/EventTable.cpp

@@ -0,0 +1,76 @@
+/**
+ * @file EventTable.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <devs/EventTable.hpp>
+
+#include <algorithm>
+#include <sstream>
+
+namespace paradevs {
+
+Model* EventTable::get_current_model()
+{ return back().get_model(); }
+
+void EventTable::init(Time time, Model* model)
+{
+    push_back(InternalEvent(time, model));
+    std::sort(begin(), end());
+}
+
+void EventTable::put(Time time, Model* model)
+{
+    remove(model);
+    push_back(InternalEvent(time, model));
+    std::sort(begin(), end());
+}
+
+void EventTable::remove(Model* model)
+{
+    iterator jt = begin();
+
+    while (jt != end()) {
+        if (jt->get_model() == model) {
+            jt = erase(jt);
+        } else {
+            ++jt;
+        }
+    }
+}
+
+std::string EventTable::to_string() const
+{
+    std::stringstream ss;
+
+    ss << "EventTable = { ";
+    for (const_iterator it = begin(); it != end(); ++it) {
+        ss << "(" << it->get_time() << " -> " << it->get_model()->get_name()
+           << ") ";
+    }
+    ss << "}";
+    return ss.str();
+}
+
+} // namespace paradevs

+ 59 - 0
src/devs/EventTable.hpp

@@ -0,0 +1,59 @@
+/**
+ * @file EventTable.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef DEVS_EVENT_TABLE
+#define DEVS_EVENT_TABLE 1
+
+#include <devs/InternalEvent.hpp>
+
+namespace paradevs {
+
+class EventTable : protected std::vector < InternalEvent >
+{
+public:
+    EventTable()
+    { }
+    virtual ~EventTable()
+    { }
+
+    Model* get_current_model();
+
+    Time get_current_time() const
+    { return back().get_time(); }
+
+    void init(Time time, Model* model);
+    void put(Time time, Model* model);
+
+    std::string to_string() const;
+
+private:
+    void remove(Model* model);
+
+};
+
+} // namespace paradevs
+
+#endif

+ 43 - 0
src/devs/InternalEvent.cpp

@@ -0,0 +1,43 @@
+/**
+ * @file InternalEvent.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <devs/InternalEvent.hpp>
+
+namespace paradevs {
+
+InternalEvent::InternalEvent(const Time& time, Model* model)
+ : _time(time), _model(model)
+{ }
+
+InternalEvent::~InternalEvent()
+{ }
+
+bool InternalEvent::operator<(InternalEvent const &e) const
+{
+    return e._time < _time;
+}
+
+} // namespace paradevs

+ 57 - 0
src/devs/InternalEvent.hpp

@@ -0,0 +1,57 @@
+/**
+ * @file InternalEvent.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef DEVS_INTERNAL_EVENT
+#define DEVS_INTERNAL_EVENT 1
+
+#include <devs/Model.hpp>
+#include <devs/Time.hpp>
+
+namespace paradevs {
+
+class InternalEvent
+{
+public:
+
+    InternalEvent(const Time& time, Model* model);
+    virtual ~InternalEvent();
+
+    Model* get_model() const
+    { return _model; }
+
+    Time get_time() const
+    { return _time; }
+
+    bool operator<(InternalEvent const& e) const;
+
+private:
+    Time   _time;
+    Model* _model;
+};
+
+} // namespace paradevs
+
+#endif

+ 50 - 0
src/devs/Links.cpp

@@ -0,0 +1,50 @@
+/**
+ * @file Links.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <devs/Links.hpp>
+
+#include <sstream>
+
+namespace paradevs {
+
+std::string Links::to_string() const
+{
+    std::stringstream ss;
+
+    ss << "Graph = { ";
+    for (const_iterator it = begin(); it != end(); ++it) {
+        ss << "(" << it->first.get_model()->get_name() << ":"
+           << it->first.get_port_name()
+           << " -> "
+           << it->second.get_model()->get_name() << ":"
+           << it->second.get_port_name()
+           << ") ";
+    }
+    ss << "}";
+    return ss.str();
+}
+
+} // namespace paradevs

+ 51 - 0
src/devs/Links.hpp

@@ -0,0 +1,51 @@
+/**
+ * @file Links.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef DEVS_LINKS
+#define DEVS_LINKS 1
+
+#include <devs/Node.hpp>
+
+#include <map>
+
+namespace paradevs {
+
+class Node;
+
+class Links : public std::multimap < Node, Node >
+{
+public:
+    Links()
+    { }
+    virtual ~Links()
+    { }
+
+    std::string to_string() const;
+};
+
+} // namespace paradevs
+
+#endif

+ 84 - 0
src/devs/Message.cpp

@@ -0,0 +1,84 @@
+/**
+ * @file Message.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <devs/Message.hpp>
+#include <devs/Node.hpp>
+
+#include <cassert>
+#include <sstream>
+
+namespace paradevs {
+
+Message::Message(const std::string& port_name, double content) :
+    _port_name(port_name), _model(0), _content(content)
+{ }
+
+Message::Message(const std::string& port_name, Model* model, double content) :
+    _port_name(port_name), _model(model), _content(content)
+{ }
+
+Message::Message()
+{ }
+
+Message::~Message()
+{ }
+
+const std::string& Message::get_port_name() const
+{ return _port_name; }
+
+double Message::get_content() const
+{ return _content; }
+
+void Message::set_content(double content)
+{ _content = content; }
+
+Model* Message::get_model() const
+{ return _model; }
+
+void Message::set_model(Model* model)
+{ _model = model; }
+
+std::string Message::to_string() const
+{
+    std::ostringstream ss;
+
+    ss << "( " << _port_name << " , " << _model->get_name() << ")";
+    return ss.str();
+}
+
+std::string Messages::to_string() const
+{
+    std::ostringstream ss;
+
+    ss << "{ ";
+    for (const_iterator it = begin(); it != end(); ++it) {
+        ss << it->to_string() << " ";
+    }
+    ss << "}";
+    return ss.str();
+}
+
+} // namespace paradevs

+ 76 - 0
src/devs/Message.hpp

@@ -0,0 +1,76 @@
+/**
+ * @file Message.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef DEVS_MESSAGE
+#define DEVS_MESSAGE 1
+
+#include <devs/Model.hpp>
+
+#include <string>
+#include <vector>
+
+namespace paradevs {
+
+class Model;
+typedef std::vector < Model* > Models;
+
+class Message
+{
+public:
+    Message(const std::string& port_name, double content);
+    Message(const std::string& port_name, Model* model, double content);
+    Message();
+    virtual ~Message();
+
+    double get_content() const;
+    Model* get_model() const;
+    const std::string& get_port_name() const;
+
+    void set_content(double content);
+    void set_model(Model* model);
+
+    std::string to_string() const;
+
+private :
+    std::string _port_name;
+    Model*      _model;
+    double      _content;
+};
+
+class Messages : public std::vector < Message >
+{
+public:
+    Messages()
+    { }
+    virtual ~Messages()
+    { }
+
+    std::string to_string() const;
+};
+
+} // namespace paradevs
+
+#endif

+ 44 - 0
src/devs/Model.cpp

@@ -0,0 +1,44 @@
+/**
+ * @file Model.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <devs/Model.hpp>
+
+namespace paradevs {
+
+Model::Model(const std::string& name) :
+    _tl(0), _tn(0), _parent(0), _name(name)
+{ }
+
+Model::~Model()
+{ }
+
+Model* Model::get_parent() const
+{ return _parent; }
+
+void Model::set_parent(Model* parent)
+{ _parent = parent; }
+
+} // namespace paradevs

+ 80 - 0
src/devs/Model.hpp

@@ -0,0 +1,80 @@
+/**
+ * @file Model.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef DEVS_CHILD
+#define DEVS_CHILD 1
+
+#include <devs/Dynamics.hpp>
+#include <devs/Links.hpp>
+#include <devs/Message.hpp>
+#include <devs/Node.hpp>
+#include <devs/Time.hpp>
+
+#include <iostream>
+#include <limits>
+#include <vector>
+
+namespace paradevs {
+
+class Dynamics;
+class Links;
+class Message;
+class Messages;
+class Node;
+
+class Model;
+typedef std::vector < Model* > Models;
+
+class Model
+{
+public:
+    Model(const std::string& name);
+    virtual ~Model();
+
+    virtual Time i_message(Time /* t */) = 0;
+    virtual Time s_message(Time /* t */) =0;
+    virtual Time x_message(const Message& /* message */, Time /* t */) =0;
+    // virtual Time y_message(Messages /* messages */, Time /* t */) =0;
+    virtual void observation(std::ostream& file) const = 0;
+
+    virtual const std::string& get_name() const
+    { return _name; }
+
+    virtual Model* get_parent() const;
+    virtual void set_parent(Model* parent);
+
+protected:
+    Time        _tl;
+    Time        _tn;
+
+private :
+    Model*      _parent;
+    std::string _name;
+};
+
+} // namespace paradevs
+
+#endif

+ 62 - 0
src/devs/Node.cpp

@@ -0,0 +1,62 @@
+/**
+ * @file Node.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <devs/Node.hpp>
+
+namespace paradevs {
+
+Node::Node(const std::string& port_name, Model* model)
+    : _port_name(port_name), _model(model)
+{ }
+
+Node::Node(const Node& other)
+    : _port_name(other._port_name), _model(other._model)
+{ }
+
+Node::~Node()
+{ }
+
+bool Node::operator<(const Node& o) const
+{
+    if (o._model == _model) {
+        return o._port_name < _port_name;
+    } else {
+        return o._model < _model;
+    }
+}
+
+bool Node::operator==(const Node& o) const
+{
+    return (o._port_name == _port_name and o._model == _model);
+}
+
+const std::string& Node::get_port_name() const
+{ return _port_name; }
+
+Model* Node::get_model() const
+{ return _model; }
+
+} // namespace paradevs

+ 58 - 0
src/devs/Node.hpp

@@ -0,0 +1,58 @@
+/**
+ * @file Node.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef DEVS_NODE
+#define DEVS_NODE 1
+
+#include <devs/Model.hpp>
+
+#include <string>
+
+namespace paradevs {
+
+class Model;
+
+class Node
+{
+public :
+    Node(const std::string& port_name, Model* model);
+    Node(const Node & other);
+    virtual ~Node();
+
+    Model* get_model() const;
+    const std::string& get_port_name() const;
+
+    virtual bool operator<(const Node& e) const;
+    virtual bool operator==(const Node& other) const;
+
+private :
+    std::string _port_name;
+    Model*      _model;
+};
+
+} // namespace paradevs
+
+#endif

+ 47 - 0
src/devs/RootCoordinator.cpp

@@ -0,0 +1,47 @@
+/**
+ * @file RootCoordinator.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <devs/RootCoordinator.hpp>
+
+namespace paradevs {
+
+RootCoordinator::RootCoordinator(const Time& t_start, const Time& t_max,
+                                 const Builder& builder) :
+    _root(builder.build()), _t_max(t_max), _tn(t_start)
+{ }
+
+RootCoordinator::~RootCoordinator()
+{ delete _root; }
+
+void RootCoordinator::run()
+{
+    _tn = _root->i_message(_tn);
+    while (_tn <= _t_max) {
+        _tn = _root->s_message(_tn);
+    }
+}
+
+} // namespace paradevs

+ 53 - 0
src/devs/RootCoordinator.hpp

@@ -0,0 +1,53 @@
+/**
+ * @file RootCoordinator.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef DEVS_ROOT_COORDINATOR
+#define DEVS_ROOT_COORDINATOR 1
+
+#include <devs/Builder.hpp>
+#include <devs/Coordinator.hpp>
+
+namespace paradevs {
+
+class RootCoordinator
+{
+public :
+    RootCoordinator(const Time& t_start, const Time& t_max,
+                    const Builder& builder);
+    virtual ~RootCoordinator();
+
+    void run();
+
+private :
+    Coordinator* _root;
+    Time         _t_max;
+
+    Time _tn;
+};
+
+} // namespace paradevs
+
+#endif

+ 99 - 0
src/devs/Simulator.cpp

@@ -0,0 +1,99 @@
+/**
+ * @file Simulator.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <devs/Coordinator.hpp>
+#include <devs/Simulator.hpp>
+
+#include <cassert>
+#include <stdexcept>
+
+namespace paradevs {
+
+Simulator::Simulator(Dynamics* dynamics) :
+    Model(dynamics->get_name()), _dynamics(dynamics)
+{ }
+
+Simulator::~Simulator()
+{ delete _dynamics; }
+
+Time Simulator::i_message(Time t)
+{
+    _tl = t;
+    _tn = _tl + _dynamics->start();
+    return _tn;
+}
+
+Time Simulator::s_message(Time t)
+{
+
+    std::cout << "[" << get_name() << "] at " << t << ": BEFORE - s_message => "
+              << "tl = " << _tl << " ; tn = " << _tn << std::endl;
+
+    assert(t == _tn);
+
+    Messages msgs = _dynamics->lambda();
+
+    if (not msgs.empty()) {
+        for (Messages::iterator it = msgs.begin(); it != msgs.end(); ++it) {
+            it->set_model(this);
+        }
+        dynamic_cast < Coordinator* >(get_parent())->y_message(msgs, t);
+    }
+
+    _dynamics->dint(t);
+    _tl = t;
+    _tn = t + _dynamics->ta();
+
+    std::cout << "[" << get_name() << "] at " << t << ": AFTER - s_message => "
+              << "tl = " << _tl << " ; tn = " << _tn << std::endl;
+
+    return _tn;
+}
+
+Time Simulator::x_message(const Message& msg, Time t)
+{
+
+    std::cout << "[" << get_name() << "] at " << t << ": BEFORE - x_message => "
+              << "tl = " << _tl << " ; tn = " << _tn << std::endl;
+
+    assert(_tl <= t and t <= _tn);
+
+    Time e = t - _tl;
+
+    _dynamics->dext(e, msg);
+    _tl = t;
+    _tn = _tl + _dynamics->ta();
+
+    std::cout << "[" << get_name() << "] at " << t << ": AFTER - x_message => "
+              << "tl = " << _tl << " ; tn = " << _tn << std::endl;
+
+    return _tn;
+}
+
+void Simulator::observation(std::ostream &file) const
+{ _dynamics->observation(file); }
+
+} // namespace paradevs

+ 57 - 0
src/devs/Simulator.hpp

@@ -0,0 +1,57 @@
+/**
+ * @file Simulator.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef DEVS_SIMULATOR
+#define DEVS_SIMULATOR 1
+
+#include <devs/Model.hpp>
+#include <devs/Dynamics.hpp>
+#include <devs/Links.hpp>
+#include <devs/Node.hpp>
+
+namespace paradevs {
+
+class Simulator : public Model
+{
+public :
+    Simulator(Dynamics* dynamics);
+    virtual ~Simulator();
+
+    virtual Time i_message(Time /* t */);
+    virtual Time s_message(Time /* t */);
+    virtual Time x_message(const Message& /* message */, Time /* t */);
+    virtual void observation(std::ostream& file) const;
+
+    virtual Dynamics* get_dynamics() const
+    { return _dynamics; }
+
+private :
+    Dynamics* _dynamics;
+};
+
+} // namespace paradevs
+
+#endif

+ 36 - 0
src/devs/Time.hpp

@@ -0,0 +1,36 @@
+/**
+ * @file Time.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef DEVS_TIME
+#define DEVS_TIME 1
+
+namespace paradevs {
+
+typedef double Time;
+
+} // namespace paradevs
+
+#endif

+ 32 - 0
src/examples/CMakeLists.txt

@@ -0,0 +1,32 @@
+INCLUDE_DIRECTORIES(
+  ${PARADEVS_BINARY_DIR}/src
+  ${PARADEVS_SOURCE_DIR}/src
+  ${Boost_INCLUDE_DIRS}
+  ${GLIBMM_INCLUDE_DIRS}
+  ${LIBXML_INCLUDE_DIRS})
+
+LINK_DIRECTORIES(
+  ${GLIBMM_LIBRARY_DIRS}
+  ${LIBXML_LIBRARY_DIR})
+
+SET(EXAMPLES_CPP Examples.cpp)
+
+SET(EXAMPLES_HPP Examples.hpp)
+
+ADD_LIBRARY(examples SHARED ${EXAMPLES_CPP};${EXAMPLES_HPP})
+
+SET_TARGET_PROPERTIES(examples PROPERTIES ${PARADEVS_LIBRARY_PROPERTIES})
+SET_TARGET_PROPERTIES(examples PROPERTIES OUTPUT_NAME
+  "paradevs-examples${PARADEVS_VERSION_SHORT}")
+
+TARGET_LINK_LIBRARIES(examples
+  ${GLIBMM_LIBRARIES}
+  ${LIBXML_LIBRARIES}
+  ${GTHREAD_LIBRARIES})
+
+INSTALL(TARGETS examples
+  RUNTIME DESTINATION bin
+  LIBRARY DESTINATION lib
+  ARCHIVE DESTINATION lib)
+
+INSTALL(FILES ${EXAMPLES_HPP} DESTINATION ${PARADEVS_INCLUDE_DIRS}/examples)

+ 167 - 0
src/examples/Examples.cpp

@@ -0,0 +1,167 @@
+/**
+ * @file examples.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <examples/Examples.hpp>
+
+namespace paradevs {
+
+void A::dint(const Time& t)
+{
+
+    std::cout << "[ model " << get_name() << " ] dint at " << t << std::endl;
+
+    if (_phase == SEND) {
+        _phase = WAIT;
+    }
+}
+
+void A::dext(const Time& /* e */, const Message& msg)
+{
+
+    std::cout << "[ model " << get_name() << " ] dext: "
+              << msg.get_content()
+              << " on " << msg.get_port_name() << std::endl;
+
+    _phase = SEND;
+}
+
+Time A::start()
+{
+
+    std::cout << "[ model " << get_name() << " ] start" << std::endl;
+
+    _phase = WAIT;
+    return 0;
+}
+
+Time A::ta() const
+{
+    if (_phase == WAIT) {
+        return 1;
+    } else {
+        return 0;
+    }
+}
+
+Messages A::lambda() const
+{
+
+    std::cout << "[ model " << get_name() << " ] lambda" << std::endl;
+
+    Messages msgs;
+
+    msgs.push_back(Message("out", 0, true));
+    return msgs;
+}
+
+void A::observation(std::ostream& /* file */) const
+{ }
+
+void B::dint(const Time& t)
+{
+
+    std::cout << "[ model " << get_name() << " ] dint at " << t
+              << std::endl;
+
+    if (_phase == SEND) {
+        _phase = WAIT;
+    }
+}
+
+void B::dext(const Time& /* e */, const Message& msg)
+{
+
+    std::cout << "[ model " << get_name() << " ] dext: "
+              << msg.get_content()
+              << " on " << msg.get_port_name() << std::endl;
+
+    _phase = SEND;
+}
+
+Time B::start()
+{
+
+    std::cout << "[ model " << get_name() << " ] start" << std::endl;
+
+    _phase = WAIT;
+    return 0;
+}
+
+Time B::ta() const
+{
+    if (_phase == WAIT) {
+        return std::numeric_limits < double >::max();
+    } else {
+        return 0;
+    }
+}
+
+Messages B::lambda() const
+{
+
+    std::cout << "[ model " << get_name() << " ] lambda" << std::endl;
+
+    Messages msgs;
+
+    msgs.push_back(Message("out", 0, true));
+    return msgs;
+}
+
+void B::observation(std::ostream& /* file */) const
+{ }
+
+Coordinator* MyBuilder::build() const
+{
+    Coordinator* root = new Coordinator("root");
+
+    Coordinator* S1 = new Coordinator("S1");
+    {
+        Simulator* a = new Simulator(new A("a1"));
+        Simulator* b = new Simulator(new B("b1"));
+
+        S1->add_child(a);
+        S1->add_child(b);
+        S1->add_link(Node("out", a), Node("in", b));
+        S1->add_link(Node("out", b), Node("out", S1));
+    }
+
+    Coordinator* S2 = new Coordinator("S2");
+    {
+        Simulator* a = new Simulator(new A("a2"));
+        Simulator* b = new Simulator(new B("b2"));
+
+        S2->add_child(a);
+        S2->add_child(b);
+        S2->add_link(Node("out", a), Node("in", b));
+        S2->add_link(Node("in", S2), Node("in", a));
+    }
+    root->add_child(S1);
+    root->add_child(S2);
+    root->add_link(Node("out", S1), Node("in", S2));
+    return root;
+}
+
+} // namespace paradevs

+ 86 - 0
src/examples/Examples.hpp

@@ -0,0 +1,86 @@
+/**
+ * @file examples.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <devs/Builder.hpp>
+#include <devs/Dynamics.hpp>
+#include <devs/Simulator.hpp>
+
+namespace paradevs {
+
+class A : public Dynamics
+{
+public:
+    A(const std::string& name) : Dynamics(name)
+    { }
+    virtual ~A()
+    { }
+
+    virtual void dint(const Time& t);
+    virtual void dext(const Time& /* e */, const Message& msg);
+    virtual Time start();
+    virtual Time ta() const;
+    virtual Messages lambda() const;
+    virtual void observation(std::ostream& /* file */) const;
+
+private:
+    enum Phase { WAIT, SEND };
+
+    Phase _phase;
+};
+
+class B : public Dynamics
+{
+public:
+    B(const std::string& name) : Dynamics(name)
+    { }
+    virtual ~B()
+    { }
+
+    virtual void dint(const Time& t);
+    virtual void dext(const Time& /* e */, const Message& msg);
+    virtual Time start();
+    virtual Time ta() const;
+    virtual Messages lambda() const;
+    virtual void observation(std::ostream& /* file */) const;
+
+private:
+    enum Phase { WAIT, SEND };
+
+    Phase _phase;
+};
+
+class MyBuilder : public Builder
+{
+public:
+    MyBuilder()
+    { }
+    virtual ~MyBuilder()
+    { }
+
+    virtual Coordinator* build() const;
+};
+
+} // namespace paradevs

+ 12 - 0
src/paradevs.pc.in

@@ -0,0 +1,12 @@
+prefix=@PARADEVS_PKGCONFIG_PREFIXPATH@
+exec_prefix=${prefix}
+libdir=${exec_prefix}/@PARADEVS_PKGCONFIG_LIBDIR@
+includedir=${prefix}/include
+
+Name: vle
+Description: PARADEVS multimodelling and Simulation tools
+Requires: libxml-2.0 glibmm-2.4
+Version: @PARADEVS_VERSION@
+Libs:	-L${libdir} \
+    -lpdevs-@PARADEVS_VERSION_SHORT@
+Cflags: -I${includedir}/vle-@PARADEVS_VERSION_SHORT@ -I@PARADEVS_PKGCONFIG_BOOSTINCLUDE_DIRS@