Parcourir la source

Add new time representation: rational and integer

Eric Ramat il y a 4 ans
Parent
commit
237a72ba46

+ 4 - 7
CMakeLists.txt

@@ -84,10 +84,7 @@ ENDIF (WIN32)
 SET(Boost_DETAILED_FAILURE_MSG FALSE)
 SET(Boost_DEBUG FALSE)
 
-FIND_PACKAGE(Boost COMPONENTS graph mpi timer serialization system)
-IF (NOT Boost_GRAPH_FOUND)
-  MESSAGE(FATAL_ERROR "The boost graph library is required")
-ENDIF (NOT Boost_GRAPH_FOUND)
+FIND_PACKAGE(Boost COMPONENTS mpi timer serialization system)
 IF (Boost_MINOR_VERSION AND ${Boost_MINOR_VERSION} LESS "35")
   SET(Boost_SYSTEM_LIBRARY "")
 ENDIF (Boost_MINOR_VERSION AND ${Boost_MINOR_VERSION} LESS "35")
@@ -104,7 +101,7 @@ ENDIF (Boost_MINOR_VERSION AND ${Boost_MINOR_VERSION} LESS "41")
 CHECK_INCLUDE_FILE_CXX(cxxabi.h ARTIS_HAVE_GCC_ABI_DEMANGLE)
 CHECK_INCLUDE_FILE_CXX(execinfo.h ARTIS_HAVE_EXECINFO)
 CHECK_INCLUDE_FILE_CXX(signal.h ARTIS_HAVE_SIGNAL)
-INCLUDE_DIRECTORIES(${ARTIS_BINARY_DIR})
+INCLUDE_DIRECTORIES(${ARTIS_STAR_BINARY_DIR})
 
 #
  # Generate the vle.pc pkg-config file.
@@ -118,8 +115,8 @@ SET(ARTIS_PKGCONFIG_BOOSTINCLUDE_DIRS "${Boost_INCLUDE_DIRS}")
 SET(ARTIS_PKGCONFIG_LIBDIR "lib")
 
 CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/src/artis-star.pc.in
-  ${ARTIS_BINARY_DIR}/artis-star-${ARTIS_VERSION_SHORT}.pc @ONLY)
-INSTALL(FILES ${ARTIS_BINARY_DIR}/artis-star-${ARTIS_VERSION_SHORT}.pc
+  ${ARTIS_STAR_BINARY_DIR}/artis-star-${ARTIS_VERSION_SHORT}.pc @ONLY)
+INSTALL(FILES ${ARTIS_STAR_BINARY_DIR}/artis-star-${ARTIS_VERSION_SHORT}.pc
   DESTINATION lib/pkgconfig)
 
 #

+ 2 - 3
src/artis-star.pc.in

@@ -4,9 +4,8 @@ libdir=${exec_prefix}/@ARTIS_PKGCONFIG_LIBDIR@
 includedir=${prefix}/include
 
 Name: artis-star
-Description: ARTIS multimodeling and Simulation tools
+Description: ARTIS* Multimodeling and Simulation tools
 Requires:
 Version: @ARTIS_VERSION@
-Libs:	-L${libdir} \
-    -lpdevs-@ARTIS_VERSION_SHORT@
+Libs:	-L${libdir}
 Cflags: -I${includedir}/artis-star-@ARTIS_VERSION_SHORT@ -I@ARTIS_PKGCONFIG_BOOSTINCLUDE_DIRS@

+ 2 - 3
src/artis-star/common/time/CMakeLists.txt

@@ -6,7 +6,6 @@ INCLUDE_DIRECTORIES(
 LINK_DIRECTORIES(
         ${Boost_LIBRARY_DIRS})
 
-SET(COMMON_TIME_HPP DoubleTime.hpp Time.hpp)
+SET(COMMON_TIME_HPP DoubleTime.hpp IntegerTime.hpp Limits.hpp RationalTime.hpp Time.hpp)
 
-INSTALL(FILES ${COMMON_TIME_HPP} DESTINATION
-        ${ARTIS_INCLUDE_DIRS}/common/time)
+INSTALL(FILES ${COMMON_TIME_HPP} DESTINATION ${ARTIS_INCLUDE_DIRS}/common/time)

+ 1 - 11
src/artis-star/common/time/DoubleTime.hpp

@@ -27,22 +27,12 @@
 #ifndef COMMON_TIME_DOUBLE_TIME
 #define COMMON_TIME_DOUBLE_TIME 1
 
+#include <artis-star/common/time/Limits.hpp>
 #include <artis-star/common/time/Time.hpp>
 
-#include <limits>
-
 namespace artis {
     namespace common {
 
-        template<typename T>
-        struct Limits {
-            static constexpr T negative_infinity =
-                    -std::numeric_limits<T>::infinity();
-            static constexpr T positive_infinity =
-                    std::numeric_limits<T>::infinity();
-            static constexpr T null = 0;
-        };
-
         typedef Time<double, Limits<double> > DoubleTime;
 
     }

+ 43 - 0
src/artis-star/common/time/IntegerTime.hpp

@@ -0,0 +1,43 @@
+/**
+ * @file common/time/DoubleTime.hpp
+ * @author The ARTIS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * ARTIS - the multimodeling and simulation environment
+ * This file is a part of the ARTIS environment
+ *
+ * Copyright (C) 2013-2019 ULCO http://www.univ-littoral.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 COMMON_TIME_INTEGER_TIME
+#define COMMON_TIME_INTEGER_TIME 1
+
+#include <artis-star/common/time/Limits.hpp>
+#include <artis-star/common/time/Time.hpp>
+
+#include <limits>
+
+namespace artis {
+    namespace common {
+
+        typedef Time<int, Limits<int> > IntegerTime;
+
+    }
+} // namespace artis common
+
+#endif

+ 45 - 0
src/artis-star/common/time/Limits.hpp

@@ -0,0 +1,45 @@
+/**
+ * @file common/time/DoubleTime.hpp
+ * @author The ARTIS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * ARTIS - the multimodeling and simulation environment
+ * This file is a part of the ARTIS environment
+ *
+ * Copyright (C) 2013-2019 ULCO http://www.univ-littoral.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 COMMON_TIME_LIMITS
+#define COMMON_TIME_LIMITS 1
+
+#include <limits>
+
+namespace artis {
+    namespace common {
+
+        template<typename T>
+        struct Limits {
+            static constexpr T negative_infinity = std::numeric_limits<T>::lowest();
+            static constexpr T positive_infinity = std::numeric_limits<T>::max();
+            static constexpr T null = 0;
+        };
+
+    }
+} // namespace artis common
+
+#endif

+ 48 - 0
src/artis-star/common/time/RationalTime.hpp

@@ -0,0 +1,48 @@
+/**
+ * @file common/time/RationalTime.hpp
+ * @author The ARTIS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * ARTIS - the multimodeling and simulation environment
+ * This file is a part of the ARTIS environment
+ *
+ * Copyright (C) 2013-2019 ULCO http://www.univ-littoral.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 COMMON_TIME_RATIONAL_TIME
+#define COMMON_TIME_RATIONAL_TIME 1
+
+#include <artis-star/common/time/Time.hpp>
+
+#include <boost/rational.hpp>
+
+namespace artis {
+    namespace common {
+
+        struct RationalLimits {
+            static constexpr boost::rational<int> negative_infinity = boost::rational<int>(std::numeric_limits<int>::lowest());
+            static constexpr boost::rational<int> positive_infinity = boost::rational<int>(std::numeric_limits<int>::max());
+            static constexpr boost::rational<int> null = boost::rational<int>();
+        };
+
+        typedef Time<boost::rational<int>, RationalLimits> RationalTime;
+
+    }
+} // namespace artis common
+
+#endif

+ 12 - 3
src/artis-star/common/time/Time.hpp

@@ -32,12 +32,21 @@ namespace artis {
 
         template<typename Type, typename Limits>
         struct Time {
-            static constexpr Type negative_infinity = Limits::negative_infinity;
-            static constexpr Type infinity = Limits::positive_infinity;
-            static constexpr Type null = Limits::null;
+            static Type negative_infinity;
+            static Type infinity;
+            static Type null;
             typedef Type type;
         };
 
+        template<typename Type, typename Limits>
+        Type Time<Type, Limits>::negative_infinity = Limits::negative_infinity;
+
+        template<typename Type, typename Limits>
+        Type Time<Type, Limits>::infinity = Limits::positive_infinity;
+
+        template<typename Type, typename Limits>
+        Type Time<Type, Limits>::null = Limits::null;
+
     }
 } // namespace artis common