diff -Nru scram-0.16.1/.clang-tidy scram-0.16.2/.clang-tidy
--- scram-0.16.1/.clang-tidy 1970-01-01 00:00:00.000000000 +0000
+++ scram-0.16.2/.clang-tidy 2018-01-12 11:42:47.000000000 +0000
@@ -0,0 +1,27 @@
+Checks: 'google-*'
+WarningsAsErrors: ''
+HeaderFilterRegex: ''
+AnalyzeTemporaryDtors: false
+FormatStyle: none
+User: user
+CheckOptions:
+ - key: google-readability-braces-around-statements.ShortStatementLines
+ value: '2'
+ - key: google-readability-function-size.StatementThreshold
+ value: '800'
+ - key: google-readability-namespace-comments.ShortNamespaceLines
+ value: '10'
+ - key: google-readability-namespace-comments.SpacesBeforeComments
+ value: '2'
+ - key: modernize-loop-convert.MaxCopySize
+ value: '16'
+ - key: modernize-loop-convert.MinConfidence
+ value: reasonable
+ - key: modernize-loop-convert.NamingStyle
+ value: CamelCase
+ - key: modernize-pass-by-value.IncludeStyle
+ value: llvm
+ - key: modernize-replace-auto-ptr.IncludeStyle
+ value: llvm
+ - key: modernize-use-nullptr.NullMacros
+ value: 'NULL'
diff -Nru scram-0.16.1/CMakeLists.txt scram-0.16.2/CMakeLists.txt
--- scram-0.16.1/CMakeLists.txt 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/CMakeLists.txt 2018-01-12 11:42:47.000000000 +0000
@@ -1,10 +1,10 @@
-cmake_minimum_required(VERSION 3.5)
+cmake_minimum_required(VERSION 3.8)
# In-source build prevention.
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
-project(SCRAM VERSION 0.16.1 LANGUAGES CXX)
+project(SCRAM VERSION 0.16.2 LANGUAGES CXX)
####################### Begin Options ###################
@@ -27,8 +27,8 @@
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Needed for Clang Tooling.
-# Default to C++14.
-set(CMAKE_CXX_STANDARD 14)
+# Default to C++17.
+set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
@@ -40,32 +40,37 @@
add_definitions(-DPROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}") # Needed to print file paths.
-set(CMAKE_CXX_FLAGS_DEBUG
- "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -Werror -Wno-sign-compare -Wnon-virtual-dtor -Wno-missing-field-initializers -Wold-style-cast")
+# Strict debug flags for SCRAM targets (opt-in, must subscribe to quality checks explicitly).
+# NOTE: This is a list unlike CMAKE_CXX_FLAGS.
+set(SCRAM_CXX_FLAGS_DEBUG
+ -Wall -Wextra -Werror -Wno-sign-compare -Wnon-virtual-dtor
+ -Wno-missing-field-initializers -Wold-style-cast
+ )
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
- CHECK_COMPILER_VERSION("4.9") # TODO: Wpedantic with gcc 4.9 errors with default arg lambdas.
- set(CMAKE_CXX_FLAGS_DEBUG
- "${CMAKE_CXX_FLAGS_DEBUG} -Wredundant-decls -Wcast-align -Wlogical-op -Wvla -Wuseless-cast -Wunreachable-code")
-
- if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wshadow -Wpedantic -Wmissing-declarations")
- endif()
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-new-ttp-matching") # TODO: Boost ICL failure.
+ CHECK_COMPILER_VERSION("7.1")
+ list(APPEND SCRAM_CXX_FLAGS_DEBUG
+ -Wredundant-decls -Wcast-align -Wlogical-op -Wvla -Wuseless-cast -Wunreachable-code
+ -Wshadow -Wpedantic -Wmissing-declarations
+ -Wimplicit-fallthrough=0 # TODO: Consider explicit fallthrough.
+ )
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- CHECK_COMPILER_VERSION("3.6")
- set(CMAKE_CXX_FLAGS_DEBUG
- "${CMAKE_CXX_FLAGS_DEBUG} -Wno-missing-braces -Wshadow -Wunused-exception-parameter")
+ CHECK_COMPILER_VERSION("5.0")
+ list(APPEND SCRAM_CXX_FLAGS_DEBUG -Wno-missing-braces -Wshadow -Wunused-exception-parameter)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
- CHECK_COMPILER_VERSION("6.1")
+ CHECK_COMPILER_VERSION("9.0")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
- CHECK_COMPILER_VERSION("17.0.2")
- # TODO: CMAKE_CXX_STANDARD has no effect on icc.
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
+ CHECK_COMPILER_VERSION("18.0.1")
# TODO: Warning with overload of private override.
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -diag-disable=1125")
+ list(APPEND SCRAM_CXX_FLAGS_DEBUG -diag-disable=1125)
+endif()
+
+if(WIN32)
+ list(APPEND SCRAM_CXX_FLAGS_DEBUG -Wno-error)
endif()
if(WITH_COVERAGE)
@@ -76,20 +81,11 @@
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
endif()
-if(WIN32)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-error")
-endif()
-
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
message(STATUS "Using CCache for builds")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
-
- if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR
- "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
- add_definitions("-Qunused-arguments") # TODO: CCache bug with not splitting args.
- endif()
endif()
######################## End compiler configurations ####################
@@ -153,24 +149,21 @@
# Include the boost header files and the program_options library.
# Please be sure to use Boost rather than BOOST.
-if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
- set(BOOST_MIN_VERSION "1.58.0")
- list(APPEND LIBS ${CMAKE_DL_LIBS})
-else()
- set(BOOST_MIN_VERSION "1.61.0")
-endif()
+set(BOOST_MIN_VERSION "1.61.0")
if(NOT WIN32)
set(Boost_USE_MULTITHREADED OFF)
endif()
find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS
- program_options filesystem system date_time random
+ program_options filesystem system random
)
message(STATUS "Boost Include directory: ${Boost_INCLUDE_DIR}")
message(STATUS "Boost Library directories: ${Boost_LIBRARY_DIRS}")
list(APPEND LIBS ${Boost_LIBRARIES})
+list(APPEND LIBS ${CMAKE_DL_LIBS})
+
message(STATUS "Libraries: ${LIBS}")
########################## End of find libraries ########################
diff -Nru scram-0.16.1/debian/changelog scram-0.16.2/debian/changelog
--- scram-0.16.1/debian/changelog 2018-01-04 10:55:10.000000000 +0000
+++ scram-0.16.2/debian/changelog 2018-01-12 12:28:58.000000000 +0000
@@ -1,3 +1,17 @@
+scram (0.16.2-1) unstable; urgency=medium
+
+ * New upstream release
+ * Require g++ 7.1 or later (for C++17)
+ * Bump CMake required version to 3.8
+ * Bump Boost required version to 1.61
+ * Bump Qt required version to 5.9.1
+ * Update copyright years w/ 2018
+ * Update man pages
+ * Add copyright to boost.scope_guard source
+ * Update VCS control fields to point to Salsa
+
+ -- Olzhas Rakhimov
Fri, 12 Jan 2018 04:28:58 -0800
+
scram (0.16.1-1) unstable; urgency=medium
* New upstream release
diff -Nru scram-0.16.1/debian/control scram-0.16.2/debian/control
--- scram-0.16.1/debian/control 2018-01-04 10:55:10.000000000 +0000
+++ scram-0.16.2/debian/control 2018-01-12 12:28:58.000000000 +0000
@@ -4,19 +4,20 @@
Maintainer: Debian Science Maintainers
Uploaders: Olzhas Rakhimov
Build-Depends: debhelper (>= 10),
- cmake (>= 3.5),
+ g++ (>= 4:7.1),
+ cmake (>= 3.8),
libxml2-dev (>= 2.9.1),
- libboost-all-dev (>= 1.58.0),
+ libboost-all-dev (>= 1.61.0),
libgoogle-perftools-dev,
- qtbase5-dev (>= 5.2.1),
+ qtbase5-dev (>= 5.9.1),
qtbase5-dev-tools,
qttools5-dev,
qttools5-dev-tools,
libqt5svg5-dev,
libqt5opengl5-dev
Standards-Version: 4.1.3
-Vcs-Git: https://anonscm.debian.org/git/debian-science/packages/scram.git
-Vcs-Browser: https://anonscm.debian.org/git/debian-science/packages/scram.git
+Vcs-Git: https://salsa.debian.org/science-team/scram.git
+Vcs-Browser: https://salsa.debian.org/science-team/scram
Homepage: https://scram-pra.org
Package: scram
diff -Nru scram-0.16.1/debian/copyright scram-0.16.2/debian/copyright
--- scram-0.16.1/debian/copyright 2017-11-22 10:24:14.000000000 +0000
+++ scram-0.16.2/debian/copyright 2018-01-12 12:28:58.000000000 +0000
@@ -3,7 +3,7 @@
Source: https://github.com/rakhimov/scram
Files: *
-Copyright: Copyright © 2014-2017 Olzhas Rakhimov
+Copyright: Copyright © 2014-2018 Olzhas Rakhimov
License: GPL-3+
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,3 +20,33 @@
.
On Debian systems, the complete text of the GNU General
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
+
+Files: src/ext/scope_guard.h
+Copyright: Copyright © 2017-2018 Yuri Kilochek
+License: Boost
+ Boost Software License - Version 1.0
+ ------------------------------------
+ .
+ Boost Software License - Version 1.0 - August 17th, 2003
+ .
+ Permission is hereby granted, free of charge, to any person or organization
+ obtaining a copy of the software and accompanying documentation covered by
+ this license (the "Software") to use, reproduce, display, distribute,
+ execute, and transmit the Software, and to prepare derivative works of the
+ Software, and to permit third-parties to whom the Software is furnished to
+ do so, all subject to the following:
+ .
+ The copyright notices in the Software and this entire statement, including
+ the above license grant, this restriction and the following disclaimer,
+ must be included in all copies of the Software, in whole or in part, and
+ all derivative works of the Software, unless such copies or derivative
+ works are solely in the form of machine-executable object code generated by
+ a source language processor.
+ .
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+ SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+ FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
diff -Nru scram-0.16.1/debian/scram.1 scram-0.16.2/debian/scram.1
--- scram-0.16.1/debian/scram.1 2018-01-04 10:55:10.000000000 +0000
+++ scram-0.16.2/debian/scram.1 2018-01-12 12:28:58.000000000 +0000
@@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.3.
-.TH SCRAM "1" "January 2018" "SCRAM 0.16.1" "SCRAM Manual"
+.TH SCRAM "1" "January 2018" "SCRAM 0.16.2" "SCRAM Manual"
.SH NAME
SCRAM \- Command-line Risk Analysis Multi-tool
.SH SYNOPSIS
diff -Nru scram-0.16.1/debian/scram-gui.1 scram-0.16.2/debian/scram-gui.1
--- scram-0.16.1/debian/scram-gui.1 2018-01-04 10:55:10.000000000 +0000
+++ scram-0.16.2/debian/scram-gui.1 2018-01-12 12:28:58.000000000 +0000
@@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.3.
-.TH SCRAM\-GUI "1" "January 2018" "SCRAM\-GUI 0.16.1" "SCRAM GUI Manual"
+.TH SCRAM\-GUI "1" "January 2018" "SCRAM\-GUI 0.16.2" "SCRAM GUI Manual"
.SH NAME
SCRAM\-GUI \- The GUI front-end for SCRAM
.SH SYNOPSIS
diff -Nru scram-0.16.1/doc/coding_standards.rst scram-0.16.2/doc/coding_standards.rst
--- scram-0.16.1/doc/coding_standards.rst 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/doc/coding_standards.rst 2018-01-12 11:42:47.000000000 +0000
@@ -30,6 +30,7 @@
Deviations from the GCSG
------------------------
+- Use ``pragma once`` instead of header guards.
- Exceptions are allowed.
- Name mutator functions without ``set_`` prefix.
- Multiple *implementation* inheritance is allowed (mostly for mixins).
@@ -60,42 +61,17 @@
* Sections are grouped by a blank line.
* Within each section the includes are ordered alphabetically.
-- Class Format:
+- The GCSG-style `declaration order`_ in class definition.
- * Section order:
+- Use ``nullptr`` instead of literal ``0`` or ``NULL``.
- #. ``public:`` member functions
- #. ``signals:`` (public by default in Qt5)
- #. ``public slots:``
- #. ``protected:`` member functions
- #. ``protected slots:``
- #. ``private:`` member functions
- #. ``private slots:``
- #. ``private:`` all data members
-
- * No blank lines after access specifiers.
-
- * One blank line before access specifiers except for the first one.
-
- * Declaration order (the GCSG style):
-
- #. Using declarations, Typedefs, Structs/Classes, and Enums.
- #. Static const data members
- #. Constructors
- #. Destructors
- #. Methods
- #. Data members
-
-- Automatic connection of signals and slots is forbidden.
-
-- Using literal ``0`` for pointers is forbidden.
- Only ``nullptr`` is allowed for null pointers.
+.. _declaration order: https://google.github.io/styleguide/cppguide.html#Declaration_Order
Additional Coding Conventions
-----------------------------
-- Use *modern C++* (C++14).
+- Use *modern C++* (C++17).
Refer to `C++ Core Guidelines`_ for best practices.
- Do not use ``inline``
@@ -133,7 +109,7 @@
- Prefer implicit dereference in a function call through a pointer.
-.. _C++ Core Guidelines: https://github.com/isocpp/CppCoreGuidelines
+.. _C++ Core Guidelines: https://isocpp.github.io/CppCoreGuidelines
Core C++ Code
@@ -155,7 +131,7 @@
they are never null pointers
unless explicitly specified.
Null-based logic must be
- rare, localized, and explicit (consider using ``boost::optional`` instead).
+ rare, localized, and explicit (consider using ``std::optional`` instead).
- Consider supplying a typedef or alias declaration
for common smart pointers.
@@ -247,10 +223,6 @@
- Avoid default arguments in signals and slots.
-- Prefer Qt5 style connections without ``SIGNAL``/``SLOT`` macros.
-
-- Prefer normalized signatures in connect statements with ``SIGNAL``/``SLOT`` macros.
-
- Prefer Qt Designer UI forms over hand-coded GUI.
- Common Qt includes may be omitted,
@@ -262,6 +234,8 @@
- Avoid ``qobject_cast`` and its flavors.
Avoid the RTTI in general.
+- Automatic (implicit) connection of signals and slots is forbidden.
+
Monitoring Code Quality
=======================
@@ -337,9 +311,9 @@
through unit, integration, regression, and benchmarking tests.
The following tools are used for this purpose:
-- GoogleTest_
+- Catch2_
- `Qt Test`_
-- Nose_
+- Pytest_
These tests are automated,
and continuous integration is provided by `Travis CI`_ and AppVeyor_.
@@ -348,9 +322,9 @@
with auto-generated analysis input files
to discover bugs, bottlenecks, and assumption failures.
-.. _GoogleTest: https://github.com/google/googletest
+.. _Catch2: https://github.com/catchorg/Catch2
.. _Qt Test: http://doc.qt.io/qt-5/qtest-overview.html
-.. _Nose: httpss://nose.readthedocs.io/en/latest/
+.. _Pytest: https://pytest.org
.. _Travis CI: https://travis-ci.org/rakhimov/scram
.. _AppVeyor: https://ci.appveyor.com/project/rakhimov/scram
diff -Nru scram-0.16.1/doc/design_description.rst scram-0.16.2/doc/design_description.rst
--- scram-0.16.1/doc/design_description.rst 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/doc/design_description.rst 2018-01-12 11:42:47.000000000 +0000
@@ -95,6 +95,4 @@
cppdep Component Dependency Report
==================================
-.. image:: ../build/scram_core.svg
-
.. literalinclude:: ../build/dep_report.txt
diff -Nru scram-0.16.1/doc/release/v0.16.2.md scram-0.16.2/doc/release/v0.16.2.md
--- scram-0.16.1/doc/release/v0.16.2.md 1970-01-01 00:00:00.000000000 +0000
+++ scram-0.16.2/doc/release/v0.16.2.md 2018-01-12 11:42:47.000000000 +0000
@@ -0,0 +1,29 @@
+# Release Notes v0.16.2 : Transition to C++17
+
+With this release, the codebase transitions to C++17,
+requiring more modern compilers (gcc 7, clang 5) and dependencies.
+
+
+## Minor Changes
+
+- Transition to C++17 (#250)
+- Replace header guards w/ '#pragma once' (#253)
+- Replace Nose w/ Pytest (#252)
+- Replace GoogleTest w/ Catch2 (#251)
+
+
+## Removed Features
+
+- Non-MEF, API-only random deviates (use STL or Boost ``random`` directly).
+
+
+## Since v0.16.1
+
+80 commits resulted in 193 files changed, 3321 insertions(+), 4040 deletions(-)
+
+- Core: 96 files changed, 1061 insertions(+), 1613 deletions(-)
+- Scripts: 1 file changed, 111 insertions(+), 88 deletions(-)
+- GUI: 39 files changed, 240 insertions(+), 443 deletions(-)
+- Tests: 40 files changed, 1724 insertions(+), 1727 deletions(-)
+- Documentation: 4 files changed, 41 insertions(+), 61 deletions(-)
+- Schemas: No change
diff -Nru scram-0.16.1/doc/uncertainty_analysis.rst scram-0.16.2/doc/uncertainty_analysis.rst
--- scram-0.16.1/doc/uncertainty_analysis.rst 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/doc/uncertainty_analysis.rst 2018-01-12 11:42:47.000000000 +0000
@@ -27,6 +27,8 @@
but this parameter can be changed by a user,
for example, to test the analysis tool.
+Available statistical distributions are specified in Open-PSA [MEF]_.
+
.. _MT 19937: https://en.wikipedia.org/wiki/Mersenne_twister
@@ -45,26 +47,6 @@
mean, sigma, quantiles, probability density histogram.
-Statistical Distributions
--------------------------
-
-- Uniform
-- Triangular (only via API)
-- Piecewise Linear (only via API)
-- Histogram
-- Discrete (only via API)
-- Normal
-- Log-Normal
-- Poisson (only via API)
-- Binomial (only via API)
-- Beta
-- Gamma
-- Weibull
-- Exponential (only via API)
-- Log-Uniform (only via API)
-- Log-Triangular (only via API)
-
-
Adjustment of Invalid Samples
-----------------------------
diff -Nru scram-0.16.1/Dockerfile scram-0.16.2/Dockerfile
--- scram-0.16.1/Dockerfile 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/Dockerfile 2018-01-12 11:42:47.000000000 +0000
@@ -1,8 +1,19 @@
-FROM alpine:edge
-RUN apk add --update --no-cache g++ make cmake binutils boost-dev jemalloc-dev \
- libxml2-dev
+FROM ubuntu:17.10
+ENV BUILD_PACKAGES \
+ make cmake g++ libxml2-dev \
+ libgoogle-perftools-dev libboost-program-options-dev \
+ libboost-math-dev libboost-random-dev libboost-filesystem-dev \
+ libboost-date-time-dev
+ENV RUNTIME_PACKAGES \
+ libxml2 libboost-filesystem1.62.0 libboost-program-options1.62.0 \
+ libtcmalloc-minimal4
ADD . scram/
-RUN cd scram && mkdir -p build && cd build && \
- cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_GUI=OFF && make install
-RUN rm -rf scram /var/cache/*
+RUN apt-get update && \
+ apt-get install -y --no-install-recommends $BUILD_PACKAGES && \
+ cd scram && mkdir -p build && cd build && \
+ cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_GUI=OFF && make install && \
+ cd ../.. && rm -rf ./scram && \
+ apt-get remove --purge -y $BUILD_PACKAGES $(apt-mark showauto) && \
+ apt-get install -y --no-install-recommends $RUNTIME_PACKAGES && \
+ rm -rf /var/lib/apt/lists/*
ENTRYPOINT ["scram"]
diff -Nru scram-0.16.1/.gitignore scram-0.16.2/.gitignore
--- scram-0.16.1/.gitignore 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/.gitignore 2018-01-12 11:42:47.000000000 +0000
@@ -20,3 +20,6 @@
# Python compiled files
*.pyc
+
+# Pytest cache
+.cache
diff -Nru scram-0.16.1/.gitmodules scram-0.16.2/.gitmodules
--- scram-0.16.1/.gitmodules 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/.gitmodules 2018-01-12 11:42:47.000000000 +0000
@@ -1,9 +1,9 @@
-[submodule "tests/googletest"]
- path = tests/googletest
- url = https://github.com/rakhimov/googletest
[submodule "scripts/translators"]
path = scripts/translators
url = https://github.com/rakhimov/translators
[submodule "gui/qtango"]
path = gui/qtango
url = https://github.com/rakhimov/qtango
+[submodule "tests/catch2"]
+ path = tests/catch2
+ url = https://github.com/catchorg/Catch2
diff -Nru scram-0.16.1/gui/align.h scram-0.16.2/gui/align.h
--- scram-0.16.1/gui/align.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/align.h 2018-01-12 11:42:47.000000000 +0000
@@ -18,18 +18,13 @@
/// @file
/// Text alignment common conventions.
-#include
+#pragma once
-#ifndef ALIGN_H
-#define ALIGN_H
+#include
-namespace scram {
-namespace gui {
+namespace scram::gui {
/// Default alignment of numerical values in tables.
const int ALIGN_NUMBER_IN_TABLE = Qt::AlignRight | Qt::AlignVCenter;
-} // namespace gui
-} // namespace scram
-
-#endif // ALIGN_H
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/CMakeLists.txt scram-0.16.2/gui/CMakeLists.txt
--- scram-0.16.1/gui/CMakeLists.txt 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/CMakeLists.txt 2018-01-12 11:42:47.000000000 +0000
@@ -3,27 +3,12 @@
# Qt5 with Homebrew.
list(APPEND CMAKE_PREFIX_PATH /usr/local/opt/qt5)
endif()
-find_package(Qt5 "5.2.1" REQUIRED COMPONENTS
+find_package(Qt5 "5.9.1" REQUIRED COMPONENTS
Core Widgets Svg OpenGL PrintSupport Concurrent
)
message(STATUS "Found Qt5")
message(STATUS "Qt5 Version: ${Qt5_VERSION}")
-# Prevent implicit QString(const char*), string concat with "+", and other anti-patterns.
-set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_URL_CAST_FROM_STRING -DQT_USE_QSTRINGBUILDER")
-
-if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
- # TODO: MOC generated code has some useless casts.
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-useless-cast")
-elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
- # TODO: Qt moc offsetof applied to non-POD types is nonstandard.
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -diag-disable=1875")
-elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- if(Qt5Widgets_VERSION_STRING VERSION_LESS 5.4)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-inconsistent-missing-override")
- endif()
-endif()
-
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
@@ -70,6 +55,11 @@
target_link_libraries(scram-gui
${LIBS} scram
Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Svg Qt5::OpenGL Qt5::PrintSupport Qt5::Concurrent)
+target_compile_options(scram-gui PUBLIC $<$:${SCRAM_CXX_FLAGS_DEBUG} -Wno-useless-cast>) # TODO: MOC failure.
+# Prevent implicit QString(const char*), string concat with "+", and other anti-patterns.
+target_compile_definitions(scram-gui PRIVATE
+ $<$:QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_BYTEARRAY QT_NO_URL_CAST_FROM_STRING QT_USE_QSTRINGBUILDER>
+ )
add_executable(scram-gui-bin WIN32 main.cpp scram.rc ${SCRAM_GUI_RES})
set_target_properties(scram-gui-bin PROPERTIES OUTPUT_NAME scram-gui)
@@ -81,24 +71,26 @@
)
if(UNIX AND NOT APPLE)
- foreach (size IN ITEMS 32 128)
+ foreach(size IN ITEMS 32 128)
install(
FILES images/scram_solid${size}x${size}.png
DESTINATION share/icons/hicolor/${size}x${size}/apps
- COMPONENT gui
+ COMPONENT gui
RENAME scram.png)
- endforeach ()
+ endforeach()
+
install(
FILES images/scram_solid.svg
DESTINATION share/icons/hicolor/scalable/apps
- COMPONENT gui
+ COMPONENT gui
RENAME scram.svg)
# Install a desktop file
# so that SCRAM appears in the application start menu with an icon.
- install(FILES scram-gui.desktop
+ install(
+ FILES scram-gui.desktop
DESTINATION share/applications
- COMPONENT gui)
+ COMPONENT gui)
endif()
if(PACKAGE)
@@ -116,7 +108,8 @@
set(_qt_plugin_dir "plugins")
endif()
set(_qt_plugin_dest "${_qt_plugin_dir}/${_qt_plugin_type}")
- install(FILES "${_qt_plugin_path}"
+ install(
+ FILES "${_qt_plugin_path}"
DESTINATION "${_qt_plugin_dest}"
COMPONENT gui)
set(${_qt_plugins_var}
@@ -138,7 +131,8 @@
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
"[Paths]\nPlugins = ../${_qt_plugin_dir}\nTranslations = ../translations\n")
- install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
+ install(
+ FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
DESTINATION bin
COMPONENT gui)
endif()
diff -Nru scram-0.16.1/gui/command.h scram-0.16.2/gui/command.h
--- scram-0.16.1/gui/command.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/command.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -42,15 +42,13 @@
/// after its corresponding constructive/destructive commands are destroyed
/// (e.g., by being popped/removed from the undo stack).
-#ifndef COMMAND_H
-#define COMMAND_H
+#pragma once
#include
#include
-namespace scram {
-namespace gui {
+namespace scram::gui {
/// The function inverse is the function itself (i.e., f(f(x)) = id(x)).
/// In other words, undo and redo codes are exactly the same,
@@ -74,7 +72,7 @@
template
class Inverse : public T
{
- static_assert(std::is_base_of::value, "");
+ static_assert(std::is_base_of_v);
public:
/// Applies the command.
@@ -87,7 +85,4 @@
using T::T;
};
-} // namespace gui
-} // namespace scram
-
-#endif // COMMAND_H
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/diagram.cpp scram-0.16.2/gui/diagram.cpp
--- scram-0.16.1/gui/diagram.cpp 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/diagram.cpp 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2017 Olzhas Rakhimov
+ * Copyright (C) 2016-2018 Olzhas Rakhimov
*
* 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
@@ -42,9 +42,7 @@
#include "guiassert.h"
#include "overload.h"
-namespace scram {
-namespace gui {
-namespace diagram {
+namespace scram::gui::diagram {
const QSizeF Event::m_size = {16, 11};
const double Event::m_baseHeight = 6.5;
@@ -224,7 +222,7 @@
double linkY = (m_size.height() - 1) * units().height();
std::vector> children;
for (const mef::Formula::EventArg &eventArg : event->args()) {
- auto *child = boost::apply_visitor(formula_visitor, eventArg);
+ auto *child = std::visit(formula_visitor, eventArg);
auto *link = new QGraphicsLineItem(0, 0, 0, units().height(), this);
if (!children.empty())
m_width += m_space * units().height();
@@ -417,7 +415,7 @@
connect(gate, &model::Gate::formulaChanged, this, &DiagramScene::redraw,
Qt::UniqueConnection);
for (const mef::Formula::EventArg &arg : gate->args())
- boost::apply_visitor(visitor, arg);
+ std::visit(visitor, arg);
};
/// @todo Finer signal tracking.
@@ -426,6 +424,4 @@
link(m_model->gates().find(entry.first)->get());
}
-} // namespace diagram
-} // namespace gui
-} // namespace scram
+} // namespace scram::gui::diagram
diff -Nru scram-0.16.1/gui/diagram.h scram-0.16.2/gui/diagram.h
--- scram-0.16.1/gui/diagram.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/diagram.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2017 Olzhas Rakhimov
+ * Copyright (C) 2016-2018 Olzhas Rakhimov
*
* 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
@@ -18,8 +18,7 @@
/// @file
/// Graphics classes to draw diagrams.
-#ifndef DIAGRAM_H
-#define DIAGRAM_H
+#pragma once
#include
#include
@@ -32,9 +31,7 @@
#include "model.h"
-namespace scram {
-namespace gui {
-namespace diagram {
+namespace scram::gui::diagram {
/// The base class for probabilistic events in a fault tree.
///
@@ -207,8 +204,4 @@
model::Model *m_model; ///< The proxy model providing change signals.
};
-} // namespace diagram
-} // namespace gui
-} // namespace scram
-
-#endif // DIAGRAM_H
+} // namespace scram::gui::diagram
diff -Nru scram-0.16.1/gui/elementcontainermodel.cpp scram-0.16.2/gui/elementcontainermodel.cpp
--- scram-0.16.1/gui/elementcontainermodel.cpp 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/elementcontainermodel.cpp 2018-01-12 11:42:47.000000000 +0000
@@ -27,9 +27,7 @@
#include "guiassert.h"
#include "overload.h"
-namespace scram {
-namespace gui {
-namespace model {
+namespace scram::gui::model {
template
ElementContainerModel::ElementContainerModel(const T &container, Model *model,
@@ -404,6 +402,4 @@
return QSortFilterProxyModel::lessThan(lhs, rhs);
}
-} // namespace model
-} // namespace gui
-} // namespace scram
+} // namespace scram::gui::model
diff -Nru scram-0.16.1/gui/elementcontainermodel.h scram-0.16.2/gui/elementcontainermodel.h
--- scram-0.16.1/gui/elementcontainermodel.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/elementcontainermodel.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -18,8 +18,7 @@
/// @file
/// The table model for elements.
-#ifndef ELEMENTCONTAINERMODEL_H
-#define ELEMENTCONTAINERMODEL_H
+#pragma once
#include
@@ -34,9 +33,7 @@
#include "model.h"
-namespace scram {
-namespace gui {
-namespace model {
+namespace scram::gui::model {
/// The base class for models to list elements in a table.
///
@@ -216,8 +213,4 @@
/// @}
};
-} // namespace model
-} // namespace gui
-} // namespace scram
-
-#endif // ELEMENTCONTAINERMODEL_H
+} // namespace scram::gui::model
diff -Nru scram-0.16.1/gui/eventdialog.cpp scram-0.16.2/gui/eventdialog.cpp
--- scram-0.16.1/gui/eventdialog.cpp 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/eventdialog.cpp 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -39,8 +39,7 @@
#include "overload.h"
#include "validator.h"
-namespace scram {
-namespace gui {
+namespace scram::gui {
QString EventDialog::redBackground(QStringLiteral("background : red;"));
QString EventDialog::yellowBackground(QStringLiteral("background : yellow;"));
@@ -211,7 +210,7 @@
for (const mef::Formula::EventArg &arg : gate->formula().event_args()) {
if (ext::as(arg) == m_event)
return true;
- if (boost::apply_visitor(visitor, arg))
+ if (std::visit(visitor, arg))
return true;
}
return false;
@@ -273,7 +272,7 @@
{
setupData(element, element.data());
typeBox->setCurrentIndex(ext::one_bit_index(BasicEvent) + element.flavor());
- auto &basicEvent = static_cast(*element.data());
+ const mef::BasicEvent &basicEvent = *element.data();
if (basicEvent.HasExpression()) {
expressionBox->setChecked(true);
if (auto *constExpr = dynamic_cast(
@@ -508,5 +507,4 @@
addArgLine->setCompleter(completer);
}
-} // namespace gui
-} // namespace scram
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/eventdialog.h scram-0.16.2/gui/eventdialog.h
--- scram-0.16.1/gui/eventdialog.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/eventdialog.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -18,8 +18,7 @@
/// @file
/// Dialog to edit and validate events.
-#ifndef EVENTDIALOG_H
-#define EVENTDIALOG_H
+#pragma once
#include
#include
@@ -38,8 +37,7 @@
#include "model.h"
-namespace scram {
-namespace gui {
+namespace scram::gui {
/// The Dialog to create, present, and manipulate event data.
///
@@ -195,7 +193,4 @@
bool m_fixContainerName = false; ///< @todo Implement fault tree change.
};
-} // namespace gui
-} // namespace scram
-
-#endif // EVENTDIALOG_H
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/guiassert.h scram-0.16.2/gui/guiassert.h
--- scram-0.16.1/gui/guiassert.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/guiassert.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -18,8 +18,7 @@
/// @file
/// GUI assertions that should not crash the program by default.
-#ifndef GUIASSERT_H
-#define GUIASSERT_H
+#pragma once
#include
#include
@@ -45,5 +44,3 @@
QString::number(__LINE__))); \
return ret; \
} while (false)
-
-#endif // GUIASSERT_H
diff -Nru scram-0.16.1/gui/importancetablemodel.cpp scram-0.16.2/gui/importancetablemodel.cpp
--- scram-0.16.1/gui/importancetablemodel.cpp 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/importancetablemodel.cpp 2018-01-12 11:42:47.000000000 +0000
@@ -24,9 +24,7 @@
#include "align.h"
#include "guiassert.h"
-namespace scram {
-namespace gui {
-namespace model {
+namespace scram::gui::model {
ImportanceTableModel::ImportanceTableModel(
const std::vector *data, QObject *parent)
@@ -108,6 +106,4 @@
GUI_ASSERT(false && "unexpected column", {});
}
-} // namespace model
-} // namespace gui
-} // namespace scram
+} // namespace scram::gui::model
diff -Nru scram-0.16.1/gui/importancetablemodel.h scram-0.16.2/gui/importancetablemodel.h
--- scram-0.16.1/gui/importancetablemodel.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/importancetablemodel.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -18,8 +18,7 @@
/// @file
/// Table model for reporting importance factors.
-#ifndef IMPORTANCETABLEMODEL_H
-#define IMPORTANCETABLEMODEL_H
+#pragma once
#include
@@ -27,9 +26,7 @@
#include "src/importance_analysis.h"
-namespace scram {
-namespace gui {
-namespace model {
+namespace scram::gui::model {
/// Table model wrapping the importance analysis result data.
///
@@ -60,8 +57,4 @@
const std::vector &m_data; ///< The analysis result.
};
-} // namespace model
-} // namespace gui
-} // namespace scram
-
-#endif // IMPORTANCETABLEMODEL_H
+} // namespace scram::gui::model
diff -Nru scram-0.16.1/gui/language.cpp scram-0.16.2/gui/language.cpp
--- scram-0.16.1/gui/language.cpp 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/language.cpp 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -31,12 +31,11 @@
#include "guiassert.h"
-namespace scram {
-namespace gui {
+namespace scram::gui {
const std::string &translationsPath()
{
- static const std::string tsPath(scram::Env::install_dir()
+ static const std::string tsPath(scram::env::install_dir()
+ "/share/scram/translations");
return tsPath;
}
@@ -78,5 +77,4 @@
return language;
}
-} // namespace gui
-} // namespace scram
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/language.h scram-0.16.2/gui/language.h
--- scram-0.16.1/gui/language.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/language.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -18,16 +18,14 @@
/// @file
/// Localization and translation facilities.
-#ifndef LANGUAGE_H
-#define LANGUAGE_H
+#pragma once
#include
#include
#include
-namespace scram {
-namespace gui {
+namespace scram::gui {
/// @returns The path to SCRAM GUI translations directory.
const std::string &translationsPath();
@@ -45,7 +43,4 @@
/// @pre The locale language is a valid human language (not "C").
QString nativeLanguageName(const std::string &locale);
-} // namespace gui
-} // namespace scram
-
-#endif // LANGUAGE_H
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/main.cpp scram-0.16.2/gui/main.cpp
--- scram-0.16.1/gui/main.cpp 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/main.cpp 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2017 Olzhas Rakhimov
+ * Copyright (C) 2015-2018 Olzhas Rakhimov
*
* 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
@@ -18,8 +18,6 @@
/// @file
/// The main entrance to the SCRAM GUI.
-#include
-
#include
#include
#include
diff -Nru scram-0.16.1/gui/mainwindow.cpp scram-0.16.2/gui/mainwindow.cpp
--- scram-0.16.1/gui/mainwindow.cpp 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/mainwindow.cpp 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2017 Olzhas Rakhimov
+ * Copyright (C) 2015-2018 Olzhas Rakhimov
*
* 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
@@ -66,8 +66,7 @@
#include "settingsdialog.h"
#include "validator.h"
-namespace scram {
-namespace gui {
+namespace scram::gui {
/// The dialog to set the model name.
class NameDialog : public QDialog, public Ui::NameDialog
@@ -100,9 +99,8 @@
explicit WaitDialog(QWidget *parent) : QProgressDialog(parent)
{
setFixedSize(size());
- setWindowFlags(static_cast(
- windowFlags() | Qt::MSWindowsFixedSizeDialogHint
- | Qt::FramelessWindowHint));
+ setWindowFlags(windowFlags() | Qt::MSWindowsFixedSizeDialogHint
+ | Qt::FramelessWindowHint);
setCancelButton(nullptr);
setRange(0, 0);
setMinimumDuration(0);
@@ -288,7 +286,7 @@
bool MainWindow::addInputFiles(const std::vector &inputFiles)
{
- static xml::Validator validator(Env::install_dir()
+ static xml::Validator validator(env::install_dir()
+ "/share/scram/gui.rng");
if (inputFiles.empty())
@@ -583,7 +581,7 @@
{
auto *startPage = new StartPage(this);
QString examplesDir =
- QString::fromStdString(Env::install_dir() + "/share/scram/input");
+ QString::fromStdString(env::install_dir() + "/share/scram/input");
startPage->exampleModelsButton->setEnabled(QDir(examplesDir).exists());
connect(startPage->newModelButton, &QAbstractButton::clicked,
ui->actionNewModel, &QAction::trigger);
@@ -890,7 +888,7 @@
template
void MainWindow::setupPrintableView(T *view)
{
- static_assert(std::is_base_of::value, "Missing QObject");
+ static_assert(std::is_base_of_v, "Missing QObject");
struct PrintFilter : public QObject
{
PrintFilter(T *printable, MainWindow *window)
@@ -1656,5 +1654,4 @@
m_analysis = std::move(analysis);
}
-} // namespace gui
-} // namespace scram
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/mainwindow.h scram-0.16.2/gui/mainwindow.h
--- scram-0.16.1/gui/mainwindow.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/mainwindow.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2017 Olzhas Rakhimov
+ * Copyright (C) 2015-2018 Olzhas Rakhimov
*
* 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
@@ -18,8 +18,7 @@
/// @file
/// The main application window.
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
+#pragma once
#include
#include
@@ -49,8 +48,7 @@
class MainWindow;
}
-namespace scram {
-namespace gui {
+namespace scram::gui {
class EventDialog; ///< @todo Static build issues if the header is included.
@@ -306,7 +304,4 @@
std::unique_ptr m_analysis; ///< Report container.
};
-} // namespace gui
-} // namespace scram
-
-#endif // MAINWINDOW_H
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/model.cpp scram-0.16.2/gui/model.cpp
--- scram-0.16.1/gui/model.cpp 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/model.cpp 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -25,9 +25,7 @@
#include "guiassert.h"
-namespace scram {
-namespace gui {
-namespace model {
+namespace scram::gui::model {
Element::SetLabel::SetLabel(Element *element, QString label)
: Involution(QObject::tr("Set element '%1' label to '%2'")
@@ -224,6 +222,4 @@
{
}
-} // namespace model
-} // namespace gui
-} // namespace scram
+} // namespace scram::gui::model
diff -Nru scram-0.16.1/gui/model.h scram-0.16.2/gui/model.h
--- scram-0.16.1/gui/model.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/model.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -18,8 +18,7 @@
/// @file
/// Wrapper Model classes for the MEF data.
-#ifndef MODEL_H
-#define MODEL_H
+#pragma once
#include
#include
@@ -41,9 +40,7 @@
#include "command.h"
-namespace scram {
-namespace gui {
-namespace model {
+namespace scram::gui::model {
/// Fault tree container element management assuming normalized model.
/// @{
@@ -218,11 +215,16 @@
/// @returns The probability value of the event.
///
- /// @pre The basic event has expression.
+ /// @pre The basic event has expression or the type has null state.
template
T probability() const
{
- return data()->p();
+ if constexpr (std::is_same_v) {
+ return data()->HasExpression() ? QVariant(data()->p()) : QVariant();
+
+ } else {
+ return data()->p();
+ }
}
/// Sets the basic event expression.
@@ -272,11 +274,10 @@
Flavor m_flavor; ///< The current flavor of the basic event.
};
-/// @returns The optional probability value of the basic event.
-template <>
-inline QVariant BasicEvent::probability() const
+/// Converts Boolean value to a UI string.
+inline QString boolToString(bool value)
{
- return data()->HasExpression() ? QVariant(probability()) : QVariant();
+ return value ? QObject::tr("True") : QObject::tr("False");
}
/// The proxy to manage mef::HouseEvent.
@@ -292,7 +293,12 @@
template
T state() const
{
- return data()->state();
+ if constexpr (std::is_same_v) {
+ return boolToString(state());
+
+ } else {
+ return data()->state();
+ }
}
/// Flips the house event state.
@@ -314,19 +320,6 @@
void stateChanged(bool value);
};
-/// Converts Boolean value to a UI string.
-inline QString boolToString(bool value)
-{
- return value ? QObject::tr("True") : QObject::tr("False");
-}
-
-/// @returns The string representation of the house event state.
-template <>
-inline QString HouseEvent::state() const
-{
- return boolToString(state());
-}
-
/// The proxy to manage mef::Gate.
///
/// @pre The gate formula is flat.
@@ -342,7 +335,34 @@
template
T type() const
{
- return data()->formula().type();
+ if constexpr (std::is_same_v) {
+ switch (type()) {
+ case mef::kAnd:
+ return tr("and");
+ case mef::kOr:
+ return tr("or");
+ case mef::kVote:
+ //: Also named as 'vote', 'voting or', 'combination', 'combo'.
+ return tr("at-least %1").arg(voteNumber());
+ case mef::kXor:
+ return tr("xor");
+ case mef::kNot:
+ return tr("not");
+ case mef::kNull:
+ //: This is 'pass-through' or 'no-action' gate type.
+ return tr("null");
+ case mef::kNand:
+ //: not and.
+ return tr("nand");
+ case mef::kNor:
+ //: not or.
+ return tr("nor");
+ }
+ assert(false);
+
+ } else {
+ return data()->formula().type();
+ }
}
/// @returns The number of gate arguments.
@@ -380,35 +400,6 @@
void formulaChanged();
};
-/// @returns The UI string representation for gate connective types.
-template <>
-inline QString Gate::type() const
-{
- switch (type()) {
- case mef::kAnd:
- return tr("and");
- case mef::kOr:
- return tr("or");
- case mef::kVote:
- //: Also named as 'vote', 'voting or', 'combination', 'combo'.
- return tr("at-least %1").arg(voteNumber());
- case mef::kXor:
- return tr("xor");
- case mef::kNot:
- return tr("not");
- case mef::kNull:
- //: This is 'pass-through' or 'no-action' gate type.
- return tr("null");
- case mef::kNand:
- //: not and.
- return tr("nand");
- case mef::kNor:
- //: not or.
- return tr("nor");
- }
- assert(false);
-}
-
/// Table of proxy elements uniquely wrapping the core model element.
///
/// @tparam T The proxy type.
@@ -440,7 +431,19 @@
/// Generic access to event tables.
template
- ProxyTable &table();
+ ProxyTable &table()
+ {
+ if constexpr (std::is_same_v) {
+ return m_gates;
+
+ } else if constexpr (std::is_same_v) {
+ return m_basicEvents;
+
+ } else {
+ static_assert(std::is_same_v, "Unknown type.");
+ return m_houseEvents;
+ }
+ }
/// @param[in] event The event defined/registered in the model.
///
@@ -570,7 +573,7 @@
template
class RemoveEvent : public Inverse>
{
- static_assert(std::is_base_of::value, "");
+ static_assert(std::is_base_of_v);
public:
/// Stores model containers and the existing event for removal.
@@ -589,9 +592,9 @@
template
class ChangeEventType : public QUndoCommand
{
- static_assert(!std::is_same::value, "");
- static_assert(std::is_base_of::value, "");
- static_assert(std::is_base_of::value, "");
+ static_assert(!std::is_same_v);
+ static_assert(std::is_base_of_v);
+ static_assert(std::is_base_of_v);
public:
/// Assumes that events have the same ID.
@@ -701,27 +704,4 @@
/// @}
};
-/// Specializations for the typed access to the proxy model container.
-/// @{
-template <>
-inline ProxyTable &Model::table()
-{
- return m_gates;
-}
-template <>
-inline ProxyTable &Model::table()
-{
- return m_basicEvents;
-}
-template <>
-inline ProxyTable &Model::table()
-{
- return m_houseEvents;
-}
-/// @}
-
-} // namespace model
-} // namespace gui
-} // namespace scram
-
-#endif // MODEL_H
+} // namespace scram::gui::model
diff -Nru scram-0.16.1/gui/modeltree.cpp scram-0.16.2/gui/modeltree.cpp
--- scram-0.16.1/gui/modeltree.cpp 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/modeltree.cpp 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -22,8 +22,7 @@
#include "guiassert.h"
#include "overload.h"
-namespace scram {
-namespace gui {
+namespace scram::gui {
ModelTree::ModelTree(model::Model *model, QObject *parent)
: QAbstractItemModel(parent), m_model(model)
@@ -139,5 +138,4 @@
GUI_ASSERT(false, {});
}
-} // namespace gui
-} // namespace scram
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/modeltree.h scram-0.16.2/gui/modeltree.h
--- scram-0.16.1/gui/modeltree.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/modeltree.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -18,8 +18,7 @@
/// @file
/// The main tree representation of the Model.
-#ifndef MODELTREE_H
-#define MODELTREE_H
+#pragma once
#include
@@ -30,8 +29,7 @@
#include "model.h"
-namespace scram {
-namespace gui {
+namespace scram::gui {
/// The tree representation for the Model constructs.
class ModelTree : public QAbstractItemModel
@@ -89,7 +87,4 @@
boost::container::flat_set m_faultTrees;
};
-} // namespace gui
-} // namespace scram
-
-#endif // MODELTREE_H
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/preferencesdialog.cpp scram-0.16.2/gui/preferencesdialog.cpp
--- scram-0.16.1/gui/preferencesdialog.cpp 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/preferencesdialog.cpp 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -33,8 +33,7 @@
#include "language.h"
#include "overload.h"
-namespace scram {
-namespace gui {
+namespace scram::gui {
PreferencesDialog::PreferencesDialog(QSettings *preferences,
QUndoStack *undoStack,
@@ -137,5 +136,4 @@
});
}
-} // namespace gui
-} // namespace scram
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/preferencesdialog.h scram-0.16.2/gui/preferencesdialog.h
--- scram-0.16.1/gui/preferencesdialog.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/preferencesdialog.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -18,8 +18,7 @@
/// @file
/// Dialog to manage the application's persistent preferences.
-#ifndef PREFERENCESDIALOG_H
-#define PREFERENCESDIALOG_H
+#pragma once
#include
@@ -32,8 +31,7 @@
class PreferencesDialog;
}
-namespace scram {
-namespace gui {
+namespace scram::gui {
/// The dialog to present and manage GUI application preferences.
///
@@ -70,7 +68,4 @@
QSettings *m_preferences; ///< The persistent preferences to be saved.
};
-} // namespace gui
-} // namespace scram
-
-#endif // PREFERENCESDIALOG_H
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/printable.cpp scram-0.16.2/gui/printable.cpp
--- scram-0.16.1/gui/printable.cpp 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/printable.cpp 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -24,8 +24,7 @@
#include
#include
-namespace scram {
-namespace gui {
+namespace scram::gui {
void Printable::print()
{
@@ -44,5 +43,4 @@
preview.exec();
}
-} // namespace gui
-} // namespace scram
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/printable.h scram-0.16.2/gui/printable.h
--- scram-0.16.1/gui/printable.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/printable.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -18,13 +18,11 @@
/// @file
/// Interface for printable objects.
-#ifndef PRINTABLE_H
-#define PRINTABLE_H
+#pragma once
#include
-namespace scram {
-namespace gui {
+namespace scram::gui {
/// An abstract mixin class for printable objects.
class Printable
@@ -43,7 +41,4 @@
virtual void doPrint(QPrinter *printer) = 0;
};
-} // namespace gui
-} // namespace scram
-
-#endif // PRINTABLE_H
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/producttablemodel.cpp scram-0.16.2/gui/producttablemodel.cpp
--- scram-0.16.1/gui/producttablemodel.cpp 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/producttablemodel.cpp 2018-01-12 11:42:47.000000000 +0000
@@ -24,9 +24,7 @@
#include "align.h"
#include "guiassert.h"
-namespace scram {
-namespace gui {
-namespace model {
+namespace scram::gui::model {
ProductTableModel::ProductTableModel(const core::ProductContainer &products,
bool withProbability, QObject *parent)
@@ -112,6 +110,4 @@
GUI_ASSERT(false && "unexpected column", {});
}
-} // namespace model
-} // namespace gui
-} // namespace scram
+} // namespace scram::gui::model
diff -Nru scram-0.16.1/gui/producttablemodel.h scram-0.16.2/gui/producttablemodel.h
--- scram-0.16.1/gui/producttablemodel.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/producttablemodel.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -18,8 +18,7 @@
/// @file
/// Table model for reporting products.
-#ifndef PRODUCTTABLEMODEL_H
-#define PRODUCTTABLEMODEL_H
+#pragma once
#include
@@ -27,9 +26,7 @@
#include "src/fault_tree_analysis.h"
-namespace scram {
-namespace gui {
-namespace model {
+namespace scram::gui::model {
/// The table model for immutable analysis products.
class ProductTableModel : public QAbstractTableModel
@@ -71,8 +68,4 @@
bool m_withProbability; ///< The flag for probability data inclusion.
};
-} // namespace model
-} // namespace gui
-} // namespace scram
-
-#endif // PRODUCTTABLEMODEL_H
+} // namespace scram::gui::model
diff -Nru scram-0.16.1/gui/reporttree.cpp scram-0.16.2/gui/reporttree.cpp
--- scram-0.16.1/gui/reporttree.cpp 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/reporttree.cpp 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -23,8 +23,7 @@
#include "guiassert.h"
-namespace scram {
-namespace gui {
+namespace scram::gui {
ReportTree::ReportTree(const std::vector *results,
QObject *parent)
@@ -100,8 +99,7 @@
if (!index.parent().isValid()) {
GUI_ASSERT(index.row() < m_results.size(), {});
- return boost::apply_visitor(nameExtractor,
- m_results[index.row()].id.target);
+ return std::visit(nameExtractor, m_results[index.row()].id.target);
}
GUI_ASSERT(index.parent().row() < m_results.size(), {});
const core::RiskAnalysis::Result &result = m_results[index.parent().row()];
@@ -121,5 +119,4 @@
GUI_ASSERT(false && "Unexpected analysis report data", {});
}
-} // namespace gui
-} // namespace scram
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/reporttree.h scram-0.16.2/gui/reporttree.h
--- scram-0.16.1/gui/reporttree.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/reporttree.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -18,8 +18,7 @@
/// @file
/// Report tree model to represent the analysis results.
-#ifndef REPORTTREE_H
-#define REPORTTREE_H
+#pragma once
#include
@@ -27,8 +26,7 @@
#include "src/risk_analysis.h"
-namespace scram {
-namespace gui {
+namespace scram::gui {
/// The report is organized by its top items as analysis identifiers
/// and its descendant items as analysis result types.
@@ -67,7 +65,4 @@
const std::vector &m_results; ///< The data.
};
-} // namespace gui
-} // namespace scram
-
-#endif // REPORTTREE_H
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/settingsdialog.cpp scram-0.16.2/gui/settingsdialog.cpp
--- scram-0.16.1/gui/settingsdialog.cpp 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/settingsdialog.cpp 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -24,8 +24,7 @@
#include "guiassert.h"
-namespace scram {
-namespace gui {
+namespace scram::gui {
SettingsDialog::SettingsDialog(const core::Settings &initSettings,
QWidget *parent)
@@ -138,5 +137,4 @@
});
}
-} // namespace gui
-} // namespace scram
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/settingsdialog.h scram-0.16.2/gui/settingsdialog.h
--- scram-0.16.1/gui/settingsdialog.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/settingsdialog.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -18,8 +18,7 @@
/// @file
/// Dialog to manage analysis settings.
-#ifndef SETTINGSDIALOG_H
-#define SETTINGSDIALOG_H
+#pragma once
#include
@@ -31,8 +30,7 @@
class SettingsDialog;
}
-namespace scram {
-namespace gui {
+namespace scram::gui {
/// The dialog to present and set analysis settings.
class SettingsDialog : public QDialog
@@ -59,7 +57,4 @@
std::unique_ptr ui; ///< The dialog UI.
};
-} // namespace gui
-} // namespace scram
-
-#endif // SETTINGSDIALOG_H
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/tests/CMakeLists.txt scram-0.16.2/gui/tests/CMakeLists.txt
--- scram-0.16.1/gui/tests/CMakeLists.txt 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/tests/CMakeLists.txt 2018-01-12 11:42:47.000000000 +0000
@@ -1,8 +1,5 @@
find_package(Qt5Test REQUIRED)
-# There are no tr() strings in test, so no need to be strict with string construction.
-set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -UQT_NO_CAST_FROM_ASCII")
-
macro(TEST NAME FILE)
add_executable(scramgui_${NAME} ${FILE})
target_link_libraries(scramgui_${NAME} scram-gui Qt5::Test)
diff -Nru scram-0.16.1/gui/tests/data.h scram-0.16.2/gui/tests/data.h
--- scram-0.16.1/gui/tests/data.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/tests/data.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -15,27 +15,15 @@
* along with this program. If not, see .
*/
-#ifndef SCRAM_GUI_TEST_DATA_H
-#define SCRAM_GUI_TEST_DATA_H
+#pragma once
#include
+#include
#include
namespace detail {
-/// Tuple with implicit constructor for convenience sake.
-///
-/// @todo Not necessary in C++17.
-template
-struct tuple : public std::tuple
-{
- template
- constexpr tuple(Us &&... us) : std::tuple(std::forward(us)...)
- {
- }
-};
-
/// Initializes columns in the test data table.
///
/// @tparam Ts void terminated type list.
@@ -43,36 +31,24 @@
void initializeColumns(const char *const *it)
{
QTest::addColumn(*it);
- initializeColumns(++it);
-}
-/// Terminal case for test column initialization.
-template <>
-inline void initializeColumns(const char *const *)
-{
+ if constexpr (sizeof...(Ts))
+ initializeColumns(++it);
}
+/// Initializes rows in the test data table.
+///
/// @tparam N The number of columns to initialize in the row.
-template
-struct RowInitializer
+template
+void initializeRows(QTestData &data, const std::tuple &row)
{
- template
- void operator()(QTestData &data, const std::tuple &row)
- {
- RowInitializer{}(data, row);
- data << std::get(row);
- }
-};
+ static_assert(N >= 0);
-/// Terminal case for row initialization.
-template <>
-struct RowInitializer<0>
-{
- template
- void operator()(QTestData &, const std::tuple &)
- {
+ if constexpr (N != 0) {
+ initializeRows(data, row);
+ data << std::get(row);
}
-};
+}
} // namespace detail
@@ -83,15 +59,12 @@
/// @param[in] columns The column names.
/// @param[in] rows The row name and data.
template
-void populateData(
- const char *const (&columns)[sizeof...(Ts)],
- std::initializer_list> rows)
+void populateData(const char *const (&columns)[sizeof...(Ts)],
+ std::initializer_list> rows)
{
- detail::initializeColumns(columns);
+ detail::initializeColumns(columns);
for (const auto &row : rows)
- detail::RowInitializer{}(QTest::newRow(std::get<0>(row)),
- row);
+ detail::initializeRows(QTest::newRow(std::get<0>(row)),
+ row);
}
-
-#endif // SCRAM_GUI_TEST_DATA_H
diff -Nru scram-0.16.1/gui/tests/help.h scram-0.16.2/gui/tests/help.h
--- scram-0.16.1/gui/tests/help.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/tests/help.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -18,8 +18,7 @@
/// @file
/// Helper workarounds or additions to Qt Test.
-#ifndef SCRAM_GUI_TEST_HELP_H
-#define SCRAM_GUI_TEST_HELP_H
+#pragma once
#include
#include
@@ -87,20 +86,9 @@
connect(sender, sig, this, &SignalSpy::accept, Qt::DirectConnection);
}
- SignalSpy(SignalSpy &&); ///< Only to enable RVO. Undefined.
-
private:
/// Stores the signal arguments.
void accept(Ts... args) { this->emplace_back(args...); }
};
-/// Convenience function to construct a SignalSpy with deduced types.
-template
-auto make_spy(const T *sender, void (U::*sig)(Ts...))
-{
- return SignalSpy(sender, sig);
-}
-
} // namespace ext
-
-#endif // SCRAM_GUI_TEST_HELP_H
diff -Nru scram-0.16.1/gui/tests/testmodel.cpp scram-0.16.2/gui/tests/testmodel.cpp
--- scram-0.16.1/gui/tests/testmodel.cpp 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/tests/testmodel.cpp 2018-01-12 11:42:47.000000000 +0000
@@ -78,7 +78,7 @@
const char *name = "pump";
mef::BasicEvent event(name);
gui::model::BasicEvent proxy(&event);
- auto spy = ext::make_spy(&proxy, &gui::model::Element::labelChanged);
+ auto spy = ext::SignalSpy(&proxy, &gui::model::Element::labelChanged);
TEST_EQ(event.name(), name);
TEST_EQ(event.id(), name);
@@ -118,7 +118,7 @@
QVERIFY(!model.name().empty());
const char *name = "model";
- auto spy = ext::make_spy(&proxy, &gui::model::Model::modelNameChanged);
+ auto spy = ext::SignalSpy(&proxy, &gui::model::Model::modelNameChanged);
gui::model::Model::SetName setter(name, &proxy);
setter.redo();
@@ -151,9 +151,9 @@
QVERIFY(model.fault_trees().empty());
QVERIFY(proxyModel.faultTrees().empty());
- auto spyAdd = ext::make_spy(
+ auto spyAdd = ext::SignalSpy(
&proxyModel, OVERLOAD(gui::model::Model, added, mef::FaultTree *));
- auto spyRemove = ext::make_spy(
+ auto spyRemove = ext::SignalSpy(
&proxyModel, OVERLOAD(gui::model::Model, removed, mef::FaultTree *));
auto *address = faultTree.get();
@@ -188,9 +188,9 @@
gui::model::Model proxyModel(&model);
TEST_EQ(proxyModel.faultTrees().size(), 1);
- auto spyAdd = ext::make_spy(
+ auto spyAdd = ext::SignalSpy(
&proxyModel, OVERLOAD(gui::model::Model, added, mef::FaultTree *));
- auto spyRemove = ext::make_spy(
+ auto spyRemove = ext::SignalSpy(
&proxyModel, OVERLOAD(gui::model::Model, removed, mef::FaultTree *));
gui::model::Model::RemoveFaultTree remover(address, &proxyModel);
@@ -310,9 +310,9 @@
QVERIFY(proxyModel.table().empty());
auto spyAdd =
- ext::make_spy(&proxyModel, OVERLOAD(gui::model::Model, added, T *));
+ ext::SignalSpy(&proxyModel, OVERLOAD(gui::model::Model, added, T *));
auto spyRemove =
- ext::make_spy(&proxyModel, OVERLOAD(gui::model::Model, removed, T *));
+ ext::SignalSpy(&proxyModel, OVERLOAD(gui::model::Model, removed, T *));
auto event = std::make_unique("pump");
auto *address = event.get();
@@ -362,9 +362,9 @@
QCOMPARE(proxyEvent->data(), address);
auto spyAdd =
- ext::make_spy(&proxyModel, OVERLOAD(gui::model::Model, added, T *));
+ ext::SignalSpy(&proxyModel, OVERLOAD(gui::model::Model, added, T *));
auto spyRemove =
- ext::make_spy(&proxyModel, OVERLOAD(gui::model::Model, removed, T *));
+ ext::SignalSpy(&proxyModel, OVERLOAD(gui::model::Model, removed, T *));
gui::model::Model::RemoveEvent remover(proxyEvent, &proxyModel,
faultTree);
@@ -396,7 +396,7 @@
QCOMPARE(proxy.state(), false);
TEST_EQ(proxy.state(), "False");
- auto spy = ext::make_spy(&proxy, &gui::model::HouseEvent::stateChanged);
+ auto spy = ext::SignalSpy(&proxy, &gui::model::HouseEvent::stateChanged);
gui::model::HouseEvent::SetState setter(&proxy, true);
setter.redo();
TEST_EQ(spy.size(), 1);
@@ -429,7 +429,7 @@
QVERIFY(event.attributes().empty());
QCOMPARE(proxy.flavor(), gui::model::BasicEvent::Basic);
- auto spy = ext::make_spy(&proxy, &gui::model::BasicEvent::flavorChanged);
+ auto spy = ext::SignalSpy(&proxy, &gui::model::BasicEvent::flavorChanged);
auto value = gui::model::BasicEvent::Undeveloped;
gui::model::BasicEvent::SetFlavor setter(&proxy, value);
setter.redo();
@@ -477,7 +477,7 @@
double value = 0.1;
mef::ConstantExpression prob(value);
auto spy =
- ext::make_spy(&proxy, &gui::model::BasicEvent::expressionChanged);
+ ext::SignalSpy(&proxy, &gui::model::BasicEvent::expressionChanged);
gui::model::BasicEvent::SetExpression setter(&proxy, &prob);
setter.redo();
QCOMPARE(prob.value(), value);
@@ -535,7 +535,7 @@
auto formula = std::make_unique(mef::kNull);
auto *address = formula.get();
- auto spy = ext::make_spy(&proxy, &gui::model::Gate::formulaChanged);
+ auto spy = ext::SignalSpy(&proxy, &gui::model::Gate::formulaChanged);
gui::model::Gate::SetFormula setter(&proxy, std::move(formula));
setter.redo();
TEST_EQ(spy.size(), 1);
@@ -597,7 +597,7 @@
TEST_EQ(proxyEvent->id(), oldName);
const char newName[] = "valve";
- auto spy = ext::make_spy(proxyEvent, &gui::model::Element::idChanged);
+ auto spy = ext::SignalSpy(proxyEvent, &gui::model::Element::idChanged);
gui::model::Element::SetId setter(proxyEvent, newName, &model,
faultTree);
setter.redo();
diff -Nru scram-0.16.1/gui/validator.cpp scram-0.16.2/gui/validator.cpp
--- scram-0.16.1/gui/validator.cpp 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/validator.cpp 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -26,8 +26,7 @@
#include
#include
-namespace scram {
-namespace gui {
+namespace scram::gui {
const QValidator *Validator::name()
{
@@ -57,5 +56,4 @@
return &nonNegativeValidator;
}
-} // namespace gui
-} // namespace scram
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/validator.h scram-0.16.2/gui/validator.h
--- scram-0.16.1/gui/validator.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/validator.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -18,13 +18,11 @@
/// @file
/// Collection of validators.
-#ifndef VALIDATOR_H
-#define VALIDATOR_H
+#pragma once
#include
-namespace scram {
-namespace gui {
+namespace scram::gui {
/// Provider of common validators.
class Validator
@@ -43,7 +41,4 @@
static const QValidator *nonNegative();
};
-} // namespace gui
-} // namespace scram
-
-#endif // VALIDATOR_H
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/zoomableview.cpp scram-0.16.2/gui/zoomableview.cpp
--- scram-0.16.1/gui/zoomableview.cpp 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/zoomableview.cpp 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -21,8 +21,7 @@
#include
-namespace scram {
-namespace gui {
+namespace scram::gui {
void ZoomableView::setZoom(int level)
{
@@ -64,5 +63,4 @@
}
}
-} // namespace gui
-} // namespace scram
+} // namespace scram::gui
diff -Nru scram-0.16.1/gui/zoomableview.h scram-0.16.2/gui/zoomableview.h
--- scram-0.16.1/gui/zoomableview.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/gui/zoomableview.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -18,14 +18,12 @@
/// @file
/// Provides a GraphicsView with zoom in/out and other convenience features.
-#ifndef ZOOMABLEVIEW_H
-#define ZOOMABLEVIEW_H
+#pragma once
#include
#include
-namespace scram {
-namespace gui {
+namespace scram::gui {
/// The base class for graphics views with default zoom logic.
/// The zoom level is given as percents.
@@ -66,7 +64,4 @@
int m_zoom = 100; ///< The zoom level value in percents.
};
-} // namespace gui
-} // namespace scram
-
-#endif // ZOOMABLEVIEW_H
+} // namespace scram::gui
diff -Nru scram-0.16.1/README.rst scram-0.16.2/README.rst
--- scram-0.16.1/README.rst 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/README.rst 2018-01-12 11:42:47.000000000 +0000
@@ -60,7 +60,7 @@
Git Submodules
==============
-Some dependencies are provided with git submodules (e.g., Google Test).
+Some dependencies are provided with git submodules (e.g., Catch2).
In order to initialize all the submodules,
this repository must be cloned recursively with ``git clone --recursive``,
or the following commands must be executed after a normal clone.
@@ -73,38 +73,38 @@
Dependencies
============
-==================== ====================
+==================== ===============
Package Minimum Version
-==================== ====================
-CMake 3.5
-boost 1.61 (1.58 on Linux)
+==================== ===============
+CMake 3.8
+boost 1.61
libxml2 2.9.1
Python 2.7.3 or 3.3
-Qt 5.2.1
-==================== ====================
+Qt 5.9.1
+==================== ===============
Optional Dependencies
---------------------
-==================== ==================
+==================== ===============
Package Minimum Version
-==================== ==================
+==================== ===============
TCMalloc 1.7
JEMalloc 3.6
-==================== ==================
+==================== ===============
Compilers
---------
-==================== ==================
+==================== ===============
Package Minimum Version
-==================== ==================
-GCC/G++ 4.9
-Clang/LLVM 3.6
-Intel 17.0.2
-==================== ==================
+==================== ===============
+GCC/G++ 7.1
+Clang/LLVM 5.0
+Intel 18.0.1
+==================== ===============
Installing Dependencies
@@ -114,7 +114,7 @@
------
Python and GCC/G++ compiler are assumed to be available on the system.
-The process is tested on Ubuntu 16.04 LTS using ``apt-get`` as the package manager:
+The process is tested on Ubuntu 17.10 using ``apt-get`` as the package manager:
.. code-block:: bash
@@ -126,8 +126,7 @@
If on a Mac system, homebrew_ is a good package manager to use.
It is assumed that some dependencies are provided by Xcode (e.g., Python, llvm/clang, make).
-The following instructions are tested on OS X 10.9,
-but it should work for later versions as well:
+The following instructions are tested on OS X 10.12:
.. code-block:: bash
@@ -263,13 +262,13 @@
.. code-block:: bash
- nosetests -w scripts/ test/
+ .../scram/scripts$ pythom -m pytest test/
To test the command-line call of SCRAM:
.. code-block:: bash
- nosetests -w tests/
+ .../scram/tests$ python -m pytest test_scram_call.py
To run performance tests
@@ -284,7 +283,7 @@
.. code-block:: bash
- scram_tests --gtest_also_run_disabled_tests --gtest_filter=*Performance*
+ scram_tests [.perf]
To run GUI tests
diff -Nru scram-0.16.1/requirements-tests.txt scram-0.16.2/requirements-tests.txt
--- scram-0.16.1/requirements-tests.txt 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/requirements-tests.txt 2018-01-12 11:42:47.000000000 +0000
@@ -1,2 +1,4 @@
-nose
+coverage
+pytest
+pytest-cov
lxml
diff -Nru scram-0.16.1/scripts/test/test_fault_tree_generator.py scram-0.16.2/scripts/test/test_fault_tree_generator.py
--- scram-0.16.1/scripts/test/test_fault_tree_generator.py 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/scripts/test/test_fault_tree_generator.py 2018-01-12 11:42:47.000000000 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2017 Olzhas Rakhimov
+# Copyright (C) 2014-2018 Olzhas Rakhimov
#
# 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
@@ -22,97 +22,120 @@
from unittest import TestCase
from lxml import etree
-from nose.tools import assert_equal, assert_true, assert_is_not_none, \
- assert_less, assert_raises
+import pytest
from fault_tree_generator import FactorError, Factors, generate_fault_tree, \
write_info, write_summary, main
+# pylint: disable=redefined-outer-name
-class FactorsTestCase(TestCase):
- """Tests for correct setting and calculation of factors."""
- def setUp(self):
- """Creates partially constructed factors collection."""
- self.factors = Factors()
-
- def test_min_max_prob(self):
- """Tests setting of probability factors."""
- assert_raises(FactorError, self.factors.set_min_max_prob, -0.1, 0.5)
- assert_raises(FactorError, self.factors.set_min_max_prob, 1.1, 0.5)
- assert_raises(FactorError, self.factors.set_min_max_prob, 0.1, -0.5)
- assert_raises(FactorError, self.factors.set_min_max_prob, 0.1, 1.5)
- assert_raises(FactorError, self.factors.set_min_max_prob, 0.5, 0.1)
- self.factors.set_min_max_prob(0.1, 0.5)
- assert_equal(0.1, self.factors.min_prob)
- assert_equal(0.5, self.factors.max_prob)
-
- def test_set_common_event_factors(self):
- """Tests setting of probability factors."""
- self.factors.set_common_event_factors(0.1, 0.1, 2, 2) # no fail
- assert_raises(FactorError, self.factors.set_common_event_factors, -0.1,
- 0.5, 2, 2)
- assert_raises(FactorError, self.factors.set_common_event_factors, 1.0,
- 0.5, 2, 2)
- assert_raises(FactorError, self.factors.set_common_event_factors, 0.1,
- -0.5, 2, 2)
- assert_raises(FactorError, self.factors.set_common_event_factors, 0.1,
- 1.0, 2, 2)
- assert_raises(FactorError, self.factors.set_common_event_factors, 0, 0,
- 2, 2)
- assert_raises(FactorError, self.factors.set_common_event_factors, 0.1,
- 0.1, 1, 2)
- assert_raises(FactorError, self.factors.set_common_event_factors, 0.1,
- 0.1, 101, 2)
- assert_raises(FactorError, self.factors.set_common_event_factors, 0.1,
- 0.1, 2, 1)
- assert_raises(FactorError, self.factors.set_common_event_factors, 0.1,
- 0.1, 2, 101)
- self.factors.set_common_event_factors(0.4, 0.2, 3, 4)
- assert_equal(0.4, self.factors.common_b)
- assert_equal(0.2, self.factors.common_g)
- assert_equal(3, self.factors.parents_b)
- assert_equal(4, self.factors.parents_g)
-
- def test_set_num_factors(self):
- """Tests setting of size factors."""
- self.factors.set_num_factors(3, 100, 5, 4)
- assert_equal(3, self.factors.num_args)
- assert_equal(100, self.factors.num_basic)
- assert_equal(5, self.factors.num_house)
- assert_equal(4, self.factors.num_ccf)
- # Invalid values.
- assert_raises(FactorError, self.factors.set_num_factors, 1.5, 100)
- assert_raises(FactorError, self.factors.set_num_factors, 3, 0)
- assert_raises(FactorError, self.factors.set_num_factors, 3, 100, -5)
- assert_raises(FactorError, self.factors.set_num_factors, 3, 100, 0, -4)
+@pytest.fixture()
+def factors():
+ """Creates partially constructed factors collection."""
+ return Factors()
+
+
+def test_min_max_prob_valid(factors):
+ """Tests setting of valid probability min-max factors."""
+ factors.set_min_max_prob(0.1, 0.5)
+ assert factors.min_prob == 0.1
+ assert factors.max_prob == 0.5
+
+
+@pytest.mark.parametrize("min_value,max_value",
+ [(-0.1, 0.5), (1.1, 0.5), (0.1, -0.5), (0.1, 1.5),
+ (0.5, 0.1)])
+def test_min_max_prob_fail(factors, min_value, max_value):
+ """Tests setting of invalid probability min-max factors."""
+ with pytest.raises(FactorError):
+ factors.set_min_max_prob(min_value, max_value)
+
+
+def test_set_common_event_valid(factors):
+ """Tests valid common event factors."""
+ factors.set_common_event_factors(0.4, 0.2, 3, 4)
+ assert factors.common_b == 0.4
+ assert factors.common_g == 0.2
+ assert factors.parents_b == 3
+ assert factors.parents_g == 4
+
+
+@pytest.mark.parametrize(
+ "args", [(-0.1, 0.5, 2, 2), (1.0, 0.5, 2, 2), (0.1, -0.5, 2, 2),
+ (0.1, 1.0, 2, 2), (0, 0, 2, 2), (0.1, 0.1, 1, 2),
+ (0.1, 0.1, 101, 2), (0.1, 0.1, 2, 1), (0.1, 0.1, 2, 101)])
+def test_set_common_event_fail(factors, args):
+ """Tests setting of invalid common event factors."""
+ factors.set_common_event_factors(0.1, 0.1, 2, 2) # no fail
+ with pytest.raises(FactorError):
+ factors.set_common_event_factors(*args)
+
+
+def test_set_num_factors_valid(factors):
+ """Tests setting of valid size factors."""
+ factors.set_num_factors(3, 100, 5, 4)
+ assert factors.num_args == 3
+ assert factors.num_basic == 100
+ assert factors.num_house == 5
+ assert factors.num_ccf == 4
+
+
+@pytest.mark.parametrize(
+ "args",
+ [
+ (1.5, 100),
+ (3, 0),
+ (3, 100, -5),
+ (3, 100, 0, -4),
# Too many house events.
- assert_raises(FactorError, self.factors.set_num_factors, 3, 5, 5)
+ (3, 5, 5),
# Too many CCF groups.
- assert_raises(FactorError, self.factors.set_num_factors, 5, 50, 0, 11)
-
- def test_set_gate_weights(self):
- """Tests the setting of gate weights."""
- assert_raises(FactorError, self.factors.set_gate_weights, [])
- assert_raises(FactorError, self.factors.set_gate_weights, [-1, 2, 3])
- assert_raises(FactorError, self.factors.set_gate_weights, [0, 0, 0])
+ (5, 50, 0, 11)
+ ])
+def test_set_num_factors_fail(factors, args):
+ """Tests setting of invalid size factors."""
+ with pytest.raises(FactorError):
+ factors.set_num_factors(*args)
+
+
+@pytest.mark.parametrize(
+ "args,expected",
+ [
+ ([5, 8, 4, 2, 1], [5, 8, 4, 2, 1]),
+ ([5, 8, 4], [5, 8, 4, 0, 0]) # for padding with 0s
+ ])
+def test_set_gate_weights_valid(factors, args, expected):
+ """Tests the setting of valid gate weights."""
+ factors.set_gate_weights(args)
+ assert factors.get_gate_weights() == expected
+
+
+@pytest.mark.parametrize(
+ "args",
+ [
+ [],
+ [-1, 2, 3],
+ [0, 0, 0],
# Too many weights.
- assert_raises(FactorError, self.factors.set_gate_weights,
- [1, 2, 3, 4, 5, 6])
+ [1, 2, 3, 4, 5, 6],
# XOR or NOT only.
- assert_raises(FactorError, self.factors.set_gate_weights,
- [0, 0, 0, 1, 2])
- self.factors.set_gate_weights([5, 8, 4, 2, 1])
- assert_equal([5, 8, 4, 2, 1], self.factors.get_gate_weights())
- self.factors.set_gate_weights([5, 8, 4]) # for padding with 0s
- assert_equal([5, 8, 4, 0, 0], self.factors.get_gate_weights())
-
- def test_constrain_num_gates(self):
- """Checks invalid setup for constraining gate numbers."""
- assert_raises(FactorError, self.factors.constrain_num_gate, 0)
- self.factors.num_args = 4
- self.factors.num_basic = 400
- assert_raises(FactorError, self.factors.constrain_num_gate, 50)
+ [0, 0, 0, 1, 2],
+ ])
+def test_set_gate_weights_fail(factors, args):
+ """Tests the setting of invalid gate weights."""
+ with pytest.raises(FactorError):
+ factors.set_gate_weights(args)
+
+
+def test_constrain_num_gates(factors):
+ """Checks invalid setup for constraining gate numbers."""
+ with pytest.raises(FactorError):
+ factors.constrain_num_gate(0)
+ factors.num_args = 4
+ factors.num_basic = 400
+ with pytest.raises(FactorError):
+ factors.constrain_num_gate(50) # unsatisfiable
class FaultTreeGeneratorTestCase(TestCase):
@@ -136,7 +159,7 @@
self.factors.num_ccf = 10
self.factors.calculate()
fault_tree = generate_fault_tree("TestingTree", "root", self.factors)
- assert_is_not_none(fault_tree)
+ assert fault_tree is not None
write_info(fault_tree, self.output, 123)
write_summary(fault_tree, self.output)
self.output.write(fault_tree.to_xml(1))
@@ -145,7 +168,7 @@
relaxng = etree.RelaxNG(relaxng_doc)
with open(self.output.name, "r") as test_file:
doc = etree.parse(test_file)
- assert_true(relaxng.validate(doc))
+ assert relaxng.validate(doc)
def test_aralia_output(self):
"""Checks if the Aralia format output passes validation."""
@@ -154,12 +177,12 @@
self.factors.num_ccf = 10
self.factors.calculate()
fault_tree = generate_fault_tree("TestingTree", "root", self.factors)
- assert_is_not_none(fault_tree)
+ assert fault_tree is not None
self.output.write(fault_tree.to_aralia())
self.output.file.flush()
tmp = NamedTemporaryFile(mode="w+")
cmd = ["./translators/aralia.py", self.output.name, "-o", tmp.name]
- assert_equal(0, call(cmd))
+ assert call(cmd) == 0
def test_constrain_num_gates(self):
"""Checks the case of the constrained number of gates."""
@@ -168,8 +191,8 @@
self.factors.constrain_num_gate(200)
self.factors.calculate()
fault_tree = generate_fault_tree("TestingTree", "root", self.factors)
- assert_is_not_none(fault_tree)
- assert_less(abs(1 - len(fault_tree.gates) / 200), 0.1)
+ assert fault_tree is not None
+ assert abs(1 - len(fault_tree.gates) / 200) < 0.1
def test_main():
@@ -180,11 +203,11 @@
relaxng = etree.RelaxNG(relaxng_doc)
with open(tmp.name, "r") as test_file:
doc = etree.parse(test_file)
- assert_true(relaxng.validate(doc))
+ assert relaxng.validate(doc)
main(["-b", "200", "-g", "200", "-o", tmp.name, "--aralia"])
cmd = [
"./translators/aralia.py", tmp.name, "-o",
NamedTemporaryFile(mode="w+").name
]
- assert_equal(0, call(cmd))
+ assert call(cmd) == 0
diff -Nru scram-0.16.1/src/alignment.cc scram-0.16.2/src/alignment.cc
--- scram-0.16.1/src/alignment.cc 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/alignment.cc 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -23,8 +23,7 @@
#include "error.h"
#include "ext/float_compare.h"
-namespace scram {
-namespace mef {
+namespace scram::mef {
Phase::Phase(std::string name, double time_fraction)
: Element(std::move(name)), time_fraction_(time_fraction) {
@@ -46,5 +45,4 @@
"' do not sum to 1."));
}
-} // namespace mef
-} // namespace scram
+} // namespace scram::mef
diff -Nru scram-0.16.1/src/alignment.h scram-0.16.2/src/alignment.h
--- scram-0.16.1/src/alignment.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/alignment.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -18,23 +18,19 @@
/// @file
/// Mission and phase constructs.
-#ifndef SCRAM_SRC_ALIGNMENT_H_
-#define SCRAM_SRC_ALIGNMENT_H_
+#pragma once
#include
#include
#include
-#include
-
#include "element.h"
#include "instruction.h"
-namespace scram {
-namespace mef {
+namespace scram::mef {
/// Phases of alignments the models spends its time fraction.
-class Phase : public Element, private boost::noncopyable {
+class Phase : public Element {
public:
/// @copydoc Element::Element
///
@@ -64,7 +60,7 @@
using PhasePtr = std::unique_ptr; ///< Phases are unique to alignments.
/// Alignment configuration for the whole model per analysis.
-class Alignment : public Element, private boost::noncopyable {
+class Alignment : public Element {
public:
using Element::Element;
@@ -89,7 +85,4 @@
using AlignmentPtr = std::unique_ptr; ///< Unique model alignments.
-} // namespace mef
-} // namespace scram
-
-#endif // SCRAM_SRC_ALIGNMENT_H_
+} // namespace scram::mef
diff -Nru scram-0.16.1/src/analysis.cc scram-0.16.2/src/analysis.cc
--- scram-0.16.1/src/analysis.cc 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/analysis.cc 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2017 Olzhas Rakhimov
+ * Copyright (C) 2015-2018 Olzhas Rakhimov
*
* 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
@@ -20,13 +20,11 @@
#include "analysis.h"
-namespace scram {
-namespace core {
+namespace scram::core {
Analysis::Analysis(Settings settings)
: settings_(std::move(settings)), analysis_time_(0) {}
Analysis::~Analysis() = default; ///< Pure virtual destructor.
-} // namespace core
-} // namespace scram
+} // namespace scram::core
diff -Nru scram-0.16.1/src/analysis.h scram-0.16.2/src/analysis.h
--- scram-0.16.1/src/analysis.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/analysis.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2017 Olzhas Rakhimov
+ * Copyright (C) 2015-2018 Olzhas Rakhimov
*
* 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
@@ -18,8 +18,7 @@
/// @file
/// Common facilities for all analysis classes.
-#ifndef SCRAM_SRC_ANALYSIS_H_
-#define SCRAM_SRC_ANALYSIS_H_
+#pragma once
#include
@@ -29,8 +28,7 @@
#include "settings.h"
-namespace scram {
-namespace core {
+namespace scram::core {
/// Base abstract class for all analysis with settings.
class Analysis : private boost::noncopyable {
@@ -76,7 +74,4 @@
std::string warnings_; ///< Generated warnings in analysis.
};
-} // namespace core
-} // namespace scram
-
-#endif // SCRAM_SRC_ANALYSIS_H_
+} // namespace scram::core
diff -Nru scram-0.16.1/src/bdd.cc scram-0.16.2/src/bdd.cc
--- scram-0.16.1/src/bdd.cc 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/bdd.cc 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2017 Olzhas Rakhimov
+ * Copyright (C) 2015-2018 Olzhas Rakhimov
*
* 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
@@ -27,8 +27,7 @@
#include "logger.h"
#include "zbdd.h"
-namespace scram {
-namespace core {
+namespace scram::core {
int GetPrimeNumber(int n) {
assert(n > 0 && "Only natural numbers.");
@@ -371,5 +370,4 @@
TestStructure(ite.low());
}
-} // namespace core
-} // namespace scram
+} // namespace scram::core
diff -Nru scram-0.16.1/src/bdd.h scram-0.16.2/src/bdd.h
--- scram-0.16.1/src/bdd.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/bdd.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2017 Olzhas Rakhimov
+ * Copyright (C) 2015-2018 Olzhas Rakhimov
*
* 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
@@ -18,8 +18,7 @@
/// @file
/// Fault tree analysis with the Binary Decision Diagram algorithms.
-#ifndef SCRAM_SRC_BDD_H_
-#define SCRAM_SRC_BDD_H_
+#pragma once
#include
@@ -37,8 +36,7 @@
#include "pdag.h"
#include "settings.h"
-namespace scram {
-namespace core {
+namespace scram::core {
/// The default management of BDD vertices.
///
@@ -989,7 +987,4 @@
std::unique_ptr zbdd_; ///< ZBDD as a result of analysis.
};
-} // namespace core
-} // namespace scram
-
-#endif // SCRAM_SRC_BDD_H_
+} // namespace scram::core
diff -Nru scram-0.16.1/src/ccf_group.cc scram-0.16.2/src/ccf_group.cc
--- scram-0.16.1/src/ccf_group.cc 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/ccf_group.cc 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2017 Olzhas Rakhimov
+ * Copyright (C) 2014-2018 Olzhas Rakhimov
*
* 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
@@ -29,8 +29,7 @@
#include "ext/combination_iterator.h"
#include "ext/float_compare.h"
-namespace scram {
-namespace mef {
+namespace scram::mef {
CcfEvent::CcfEvent(std::string name, const CcfGroup* ccf_group)
: BasicEvent(std::move(name), ccf_group->base_path(), ccf_group->role()),
@@ -65,7 +64,7 @@
member->expression(distribution_);
}
-void CcfGroup::AddFactor(Expression* factor, boost::optional level) {
+void CcfGroup::AddFactor(Expression* factor, std::optional level) {
int min_level = this->min_level();
if (!level)
level = prev_level_ ? (prev_level_ + 1) : min_level;
@@ -290,5 +289,4 @@
return probabilities;
}
-} // namespace mef
-} // namespace scram
+} // namespace scram::mef
diff -Nru scram-0.16.1/src/ccf_group.h scram-0.16.2/src/ccf_group.h
--- scram-0.16.1/src/ccf_group.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/ccf_group.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2017 Olzhas Rakhimov
+ * Copyright (C) 2014-2018 Olzhas Rakhimov
*
* 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
@@ -22,24 +22,20 @@
/// with alpha, beta, MGL,
/// or direct parameter assignment in phi model.
-#ifndef SCRAM_SRC_CCF_GROUP_H_
-#define SCRAM_SRC_CCF_GROUP_H_
+#pragma once
#include
+#include
#include
#include
#include
#include
-#include
-#include
-
#include "element.h"
#include "event.h"
#include "expression.h"
-namespace scram {
-namespace mef {
+namespace scram::mef {
class CcfGroup; // CCF Events know their own groups.
@@ -87,7 +83,7 @@
};
/// Abstract base class for all common cause failure models.
-class CcfGroup : public Id, private boost::noncopyable {
+class CcfGroup : public Id {
public:
using Id::Id;
@@ -131,7 +127,7 @@
/// @throws RedefinitionError The factor for the level already exists.
/// @throws LogicError The level is not positive,
/// or the CCF group members are undefined.
- void AddFactor(Expression* factor, boost::optional level = {});
+ void AddFactor(Expression* factor, std::optional level = {});
/// Validates the setup for the CCF model and group.
/// Checks if the provided distribution is between 0 and 1.
@@ -266,7 +262,4 @@
ExpressionMap CalculateProbabilities() override;
};
-} // namespace mef
-} // namespace scram
-
-#endif // SCRAM_SRC_CCF_GROUP_H_
+} // namespace scram::mef
diff -Nru scram-0.16.1/src/CMakeLists.txt scram-0.16.2/src/CMakeLists.txt
--- scram-0.16.1/src/CMakeLists.txt 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/CMakeLists.txt 2018-01-12 11:42:47.000000000 +0000
@@ -2,16 +2,14 @@
execute_process(COMMAND git describe --tags OUTPUT_VARIABLE core_version
OUTPUT_STRIP_TRAILING_WHITESPACE)
configure_file(version.cc.in version.cc @ONLY)
-configure_file(env.cc.in env.cc @ONLY)
################### End File Configurations ####################
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SCRAM_CORE_SRC
- ${CMAKE_CURRENT_BINARY_DIR}/env.cc
+ env.cc
${CMAKE_CURRENT_BINARY_DIR}/version.cc
logger.cc
- random.cc
settings.cc
xml.cc
config.cc
@@ -50,6 +48,7 @@
)
add_library(scram SHARED ${SCRAM_CORE_SRC})
target_link_libraries(scram ${LIBS})
+target_compile_options(scram PRIVATE $<$:${SCRAM_CXX_FLAGS_DEBUG}>)
install(
TARGETS scram
@@ -62,6 +61,7 @@
add_executable(scram-cli scram.cc)
set_target_properties(scram-cli PROPERTIES OUTPUT_NAME scram)
target_link_libraries(scram-cli scram ${Boost_LIBRARIES})
+target_compile_options(scram-cli PRIVATE $<$:${SCRAM_CXX_FLAGS_DEBUG}>)
install(
TARGETS scram-cli
diff -Nru scram-0.16.1/src/config.cc scram-0.16.2/src/config.cc
--- scram-0.16.1/src/config.cc 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/config.cc 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2017 Olzhas Rakhimov
+ * Copyright (C) 2014-2018 Olzhas Rakhimov
*
* 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
@@ -23,6 +23,7 @@
#include
#include
+#include
#include
@@ -54,7 +55,7 @@
} // namespace
Config::Config(const std::string& config_file) {
- static xml::Validator validator(Env::config_schema());
+ static xml::Validator validator(env::config_schema());
if (fs::exists(config_file) == false) {
SCRAM_THROW(IOError("The configuration file does not exist."))
@@ -67,8 +68,8 @@
fs::path base_path = fs::path(config_file).parent_path();
GatherInputFiles(root, base_path);
- if (boost::optional out = root.child("output-path")) {
- output_path_ = normalize(out->text().to_string(), base_path);
+ if (std::optional out = root.child("output-path")) {
+ output_path_ = normalize(std::string(out->text()), base_path);
}
try {
@@ -81,17 +82,18 @@
void Config::GatherInputFiles(const xml::Element& root,
const fs::path& base_path) {
- boost::optional input_files = root.child("input-files");
+ std::optional input_files = root.child("input-files");
if (!input_files)
return;
for (xml::Element input_file : input_files->children()) {
assert(input_file.name() == "file");
- input_files_.push_back(normalize(input_file.text().to_string(), base_path));
+ input_files_.push_back(
+ normalize(std::string(input_file.text()), base_path));
}
}
void Config::GatherOptions(const xml::Element& root) {
- boost::optional options_element = root.child("options");
+ std::optional options_element = root.child("options");
if (!options_element)
return;
// The loop is used instead of query
@@ -99,7 +101,7 @@
// yet this function should not know what the order is.
for (xml::Element option_group : options_element->children()) {
try {
- xml::string_view name = option_group.name();
+ std::string_view name = option_group.name();
if (name == "algorithm") {
settings_.algorithm(option_group.attribute("name"));
@@ -117,7 +119,7 @@
throw;
}
}
- if (boost::optional analysis_group =
+ if (std::optional analysis_group =
options_element->child("analysis")) {
try {
SetAnalysis(*analysis_group);
@@ -130,7 +132,7 @@
void Config::SetAnalysis(const xml::Element& analysis) {
auto set_flag = [&analysis](const char* tag, auto setter) {
- if (boost::optional flag = analysis.attribute(tag))
+ if (std::optional flag = analysis.attribute(tag))
setter(*flag);
};
set_flag("probability",
@@ -146,7 +148,7 @@
void Config::SetLimits(const xml::Element& limits) {
for (xml::Element limit : limits.children()) {
- xml::string_view name = limit.name();
+ std::string_view name = limit.name();
if (name == "product-order") {
settings_.limit_order(limit.text());
diff -Nru scram-0.16.1/src/config.h scram-0.16.2/src/config.h
--- scram-0.16.1/src/config.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/config.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2017 Olzhas Rakhimov
+ * Copyright (C) 2014-2018 Olzhas Rakhimov
*
* 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
@@ -19,8 +19,7 @@
/// Configuration management facilities
/// to make various setups for analysis possible.
-#ifndef SCRAM_SRC_CONFIG_H_
-#define SCRAM_SRC_CONFIG_H_
+#pragma once
#include
#include
@@ -91,5 +90,3 @@
};
} // namespace scram
-
-#endif // SCRAM_SRC_CONFIG_H_
diff -Nru scram-0.16.1/src/cycle.h scram-0.16.2/src/cycle.h
--- scram-0.16.1/src/cycle.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/cycle.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2017 Olzhas Rakhimov
+ * Copyright (C) 2014-2018 Olzhas Rakhimov
*
* 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
@@ -18,8 +18,7 @@
/// @file
/// Validation facilities to detect and print cycles in graphs.
-#ifndef SCRAM_SRC_CYCLE_H_
-#define SCRAM_SRC_CYCLE_H_
+#pragma once
#include
#include
@@ -36,9 +35,7 @@
#include "instruction.h"
#include "parameter.h"
-namespace scram {
-namespace mef {
-namespace cycle {
+namespace scram::mef::cycle {
/// Determines the connectors between nodes.
///
@@ -65,7 +62,7 @@
return connector->event_args() |
boost::adaptors::transformed(
[](const Formula::EventArg& event_args) -> Gate* {
- if (auto* arg = boost::get(&event_args))
+ if (auto* arg = std::get_if(&event_args))
return *arg;
return nullptr;
}) |
@@ -183,7 +180,7 @@
decltype(cycle) cycle_;
} continue_connector{cycle};
- return boost::apply_visitor(continue_connector, connector->target());
+ return std::visit(continue_connector, connector->target());
}
/// Cycle detection specialization for visitor-based traversal of instructions.
@@ -248,7 +245,7 @@
std::vector* cycle) {
struct {
void operator()(const Branch* branch) {
- boost::apply_visitor(*this, branch->target());
+ std::visit(*this, branch->target());
}
void operator()(Fork* fork) {
for (Branch& branch : fork->paths())
@@ -334,8 +331,4 @@
}
}
-} // namespace cycle
-} // namespace mef
-} // namespace scram
-
-#endif // SCRAM_SRC_CYCLE_H_
+} // namespace scram::mef::cycle
diff -Nru scram-0.16.1/src/element.cc scram-0.16.2/src/element.cc
--- scram-0.16.1/src/element.cc 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/element.cc 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2017 Olzhas Rakhimov
+ * Copyright (C) 2014-2018 Olzhas Rakhimov
*
* 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
@@ -25,8 +25,7 @@
#include "error.h"
#include "ext/algorithm.h"
-namespace scram {
-namespace mef {
+namespace scram::mef {
Element::Element(std::string name) { Element::name(std::move(name)); }
@@ -105,5 +104,4 @@
id_ = MakeId(*this);
}
-} // namespace mef
-} // namespace scram
+} // namespace scram::mef
diff -Nru scram-0.16.1/src/element.h scram-0.16.2/src/element.h
--- scram-0.16.1/src/element.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/element.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2017 Olzhas Rakhimov
+ * Copyright (C) 2014-2018 Olzhas Rakhimov
*
* 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
@@ -19,8 +19,7 @@
/// Helper classes, structs, and properties
/// common to all other classes.
-#ifndef SCRAM_SRC_ELEMENT_H_
-#define SCRAM_SRC_ELEMENT_H_
+#pragma once
#include
@@ -30,9 +29,9 @@
#include
#include
#include
+#include
-namespace scram {
-namespace mef {
+namespace scram::mef {
/// This struct allows any attribute.
struct Attribute {
@@ -45,7 +44,7 @@
/// any element of analysis
/// that can have extra descriptions,
/// such as attributes and a label.
-class Element {
+class Element : private boost::noncopyable {
public:
/// Constructs an element with an original name.
/// The name is expected to conform to identifier requirements
@@ -318,7 +317,4 @@
bool usage_ = false; ///< Elements are assumed to be unused at construction.
};
-} // namespace mef
-} // namespace scram
-
-#endif // SCRAM_SRC_ELEMENT_H_
+} // namespace scram::mef
diff -Nru scram-0.16.1/src/env.cc scram-0.16.2/src/env.cc
--- scram-0.16.1/src/env.cc 1970-01-01 00:00:00.000000000 +0000
+++ scram-0.16.2/src/env.cc 2018-01-12 11:42:47.000000000 +0000
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2014-2018 Olzhas Rakhimov
+ *
+ * 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 .
+ */
+
+/// @file
+/// The environment variables discovered at run-time.
+
+#include "env.h"
+
+#include
+
+namespace scram::env {
+
+const std::string& config_schema() {
+ static const std::string schema_path =
+ install_dir() + "/share/scram/config.rng";
+ return schema_path;
+}
+
+const std::string& input_schema() {
+ static const std::string schema_path =
+ install_dir() + "/share/scram/input.rng";
+ return schema_path;
+}
+
+const std::string& report_schema() {
+ static const std::string schema_path =
+ install_dir() + "/share/scram/report.rng";
+ return schema_path;
+}
+
+const std::string& install_dir() {
+ static const std::string install_path =
+ boost::dll::program_location() // executable
+ .parent_path() // bin
+ .parent_path() // install
+ .generic_string(); // POSIX format.
+ return install_path;
+}
+
+} // namespace scram::env
diff -Nru scram-0.16.1/src/env.cc.in scram-0.16.2/src/env.cc.in
--- scram-0.16.1/src/env.cc.in 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/env.cc.in 1970-01-01 00:00:00.000000000 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2014-2017 Olzhas Rakhimov
- *
- * 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 .
- */
-
-/// @file
-/// Implementation of Env class.
-/// The variables are filled by CMake or discovered at run-time.
-
-#include "env.h"
-
-#include
-
-#if BOOST_OS_WINDOWS
-
-#include
-
-/// Finds the installation directory on Windows.
-///
-/// @returns POSIX path to the installation directory.
-///
-/// @pre The main executable is located at "install_dir/bin/prog.exe".
-///
-/// @note This function will terminate the program if any system calls fail.
-static std::string GetInstallPath() noexcept {
- return boost::dll::program_location() // executable
- .parent_path() // bin
- .parent_path() // install
- .generic_string(); // POSIX format.
-}
-#else
-// clang-format off
-/// @returns Path to the installation directory known at compile-time.
-static std::string GetInstallPath() { return "@CMAKE_INSTALL_PREFIX@"; } // NOLINT
-// clang-format on
-#endif
-
-namespace scram {
-
-const std::string Env::kInstallDir_ = GetInstallPath(); // NOLINT
-
-std::string Env::config_schema() {
- return kInstallDir_ + "/share/scram/config.rng";
-}
-
-std::string Env::input_schema() {
- return kInstallDir_ + "/share/scram/input.rng";
-}
-
-std::string Env::report_schema() {
- return kInstallDir_ + "/share/scram/report.rng";
-}
-
-} // namespace scram
diff -Nru scram-0.16.1/src/env.h scram-0.16.2/src/env.h
--- scram-0.16.1/src/env.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/env.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2017 Olzhas Rakhimov
+ * Copyright (C) 2014-2018 Olzhas Rakhimov
*
* 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
@@ -16,34 +16,28 @@
*/
/// @file
-/// Environmental Variables
+/// SCRAM-specific environment variables.
+///
+/// All paths are absolute, canonical, and POSIX (with '/' separator).
+///
+/// @pre The system follows the Filesystem Hierarchy Standard.
-#ifndef SCRAM_SRC_ENV_H_
-#define SCRAM_SRC_ENV_H_
+#pragma once
#include
-namespace scram {
+namespace scram::env {
-/// Provides environmental variables.
-class Env {
- public:
- /// @returns The location of the RELAX NG schema for configuration files.
- static std::string config_schema();
+/// @returns The location of the RELAX NG schema for configuration files.
+const std::string& config_schema();
- /// @returns The location of the RELAX NG schema for input files.
- static std::string input_schema();
+/// @returns The location of the RELAX NG schema for input files.
+const std::string& input_schema();
- /// @returns The location of the RELAX NG schema for output report files.
- static std::string report_schema();
+/// @returns The location of the RELAX NG schema for output report files.
+const std::string& report_schema();
- /// @returns The path to the installation directory.
- static const std::string& install_dir() { return kInstallDir_; }
+/// @returns The path to the installation directory.
+const std::string& install_dir();
- private:
- static const std::string kInstallDir_; ///< Installation directory.
-};
-
-} // namespace scram
-
-#endif // SCRAM_SRC_ENV_H_
+} // namespace scram::env
diff -Nru scram-0.16.1/src/error.h scram-0.16.2/src/error.h
--- scram-0.16.1/src/error.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/error.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2017 Olzhas Rakhimov
+ * Copyright (C) 2014-2018 Olzhas Rakhimov
*
* 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
@@ -18,8 +18,7 @@
/// @file
/// Exceptions for SCRAM.
-#ifndef SCRAM_SRC_ERROR_H_
-#define SCRAM_SRC_ERROR_H_
+#pragma once
#include
#include
@@ -160,5 +159,3 @@
} // namespace xml
} // namespace scram
-
-#endif // SCRAM_SRC_ERROR_H_
diff -Nru scram-0.16.1/src/event.cc scram-0.16.2/src/event.cc
--- scram-0.16.1/src/event.cc 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/event.cc 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2017 Olzhas Rakhimov
+ * Copyright (C) 2014-2018 Olzhas Rakhimov
*
* 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
@@ -26,8 +26,7 @@
#include "ext/algorithm.h"
#include "ext/variant.h"
-namespace scram {
-namespace mef {
+namespace scram::mef {
Event::~Event() = default;
@@ -56,11 +55,12 @@
}
int num_conditional = boost::count_if(
formula_->event_args(), [](const Formula::EventArg& event) {
- if (!boost::get(&event))
- return false;
- auto& basic_event = boost::get(event);
- return basic_event->HasAttribute("flavor") &&
- basic_event->GetAttribute("flavor").value == "conditional";
+ if (BasicEvent* const* basic_event = std::get_if(&event)) {
+ return (*basic_event)->HasAttribute("flavor") &&
+ (*basic_event)->GetAttribute("flavor").value == "conditional";
+ }
+
+ return false;
});
if (num_conditional != 1)
SCRAM_THROW(ValidityError(Element::name() + " : INHIBIT gate must have" +
@@ -139,5 +139,4 @@
}
}
-} // namespace mef
-} // namespace scram
+} // namespace scram::mef
diff -Nru scram-0.16.1/src/event.h scram-0.16.2/src/event.h
--- scram-0.16.1/src/event.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/event.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2017 Olzhas Rakhimov
+ * Copyright (C) 2014-2018 Olzhas Rakhimov
*
* 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
@@ -18,26 +18,25 @@
/// @file
/// Contains event classes for fault trees.
-#ifndef SCRAM_SRC_EVENT_H_
-#define SCRAM_SRC_EVENT_H_
+#pragma once
#include
#include
#include
+#include
+#include
#include
#include
-#include
#include "element.h"
#include "expression.h"
-namespace scram {
-namespace mef {
+namespace scram::mef {
/// Abstract base class for general fault tree events.
-class Event : public Id, public Usage, private boost::noncopyable {
+class Event : public Id, public Usage {
public:
using Id::Id;
@@ -176,7 +175,7 @@
return *formula_;
}
Formula& formula() {
- return const_cast(static_cast(this)->formula());
+ return const_cast(std::as_const(*this).formula());
}
/// @}
@@ -228,7 +227,7 @@
class Formula : private boost::noncopyable {
public:
/// Event arguments of a formula.
- using EventArg = boost::variant;
+ using EventArg = std::variant;
/// Constructs a formula.
///
@@ -297,7 +296,4 @@
std::vector formula_args_; ///< Nested formula arguments.
};
-} // namespace mef
-} // namespace scram
-
-#endif // SCRAM_SRC_EVENT_H_
+} // namespace scram::mef
diff -Nru scram-0.16.1/src/event_tree_analysis.cc scram-0.16.2/src/event_tree_analysis.cc
--- scram-0.16.1/src/event_tree_analysis.cc 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/event_tree_analysis.cc 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -23,8 +23,7 @@
#include "ext/find_iterator.h"
#include "instruction.h"
-namespace scram {
-namespace core {
+namespace scram::core {
EventTreeAnalysis::EventTreeAnalysis(
const mef::InitiatingEvent& initiating_event, const Settings& settings,
@@ -89,7 +88,7 @@
} cloner{set_instructions, clones};
for (const mef::Formula::EventArg& arg : formula.event_args())
- new_formula->AddArgument(boost::apply_visitor(cloner, arg));
+ new_formula->AddArgument(std::visit(cloner, arg));
for (const mef::FormulaPtr& arg : formula.formula_args())
new_formula->AddArgument(Clone(*arg, set_instructions, clones));
return new_formula;
@@ -227,7 +226,7 @@
for (const mef::Instruction* instruction : branch->instructions())
instruction->Accept(&visitor);
- boost::apply_visitor(*this, branch->target());
+ std::visit(*this, branch->target());
}
SequenceCollector* result_;
@@ -239,5 +238,4 @@
Collector{result, &events_}(&initial_state); // NOLINT(whitespace/braces)
}
-} // namespace core
-} // namespace scram
+} // namespace scram::core
diff -Nru scram-0.16.1/src/event_tree_analysis.h scram-0.16.2/src/event_tree_analysis.h
--- scram-0.16.1/src/event_tree_analysis.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/event_tree_analysis.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -17,8 +17,7 @@
/// @file
/// Event tree analysis facilities.
-#ifndef SCRAM_SRC_EVENT_TREE_ANALYSIS_H_
-#define SCRAM_SRC_EVENT_TREE_ANALYSIS_H_
+#pragma once
#include
#include
@@ -32,8 +31,7 @@
#include "expression/test_event.h"
#include "settings.h"
-namespace scram {
-namespace core {
+namespace scram::core {
/// Event tree analysis functionality.
class EventTreeAnalysis : public Analysis {
@@ -104,7 +102,4 @@
mef::Context* context_; ///< The communication channel with test-events.
};
-} // namespace core
-} // namespace scram
-
-#endif // SCRAM_SRC_EVENT_TREE_ANALYSIS_H_
+} // namespace scram::core
diff -Nru scram-0.16.1/src/event_tree.cc scram-0.16.2/src/event_tree.cc
--- scram-0.16.1/src/event_tree.cc 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/event_tree.cc 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -24,8 +24,7 @@
#include "error.h"
-namespace scram {
-namespace mef {
+namespace scram::mef {
Path::Path(std::string state) : state_(std::move(state)) {
if (state_.empty())
@@ -66,5 +65,4 @@
"Duplicate named branch: ");
}
-} // namespace mef
-} // namespace scram
+} // namespace scram::mef
diff -Nru scram-0.16.1/src/event_tree.h scram-0.16.2/src/event_tree.h
--- scram-0.16.1/src/event_tree.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/event_tree.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -18,22 +18,18 @@
/// @file
/// Event Tree facilities.
-#ifndef SCRAM_SRC_EVENT_TREE_H_
-#define SCRAM_SRC_EVENT_TREE_H_
+#pragma once
#include
#include
+#include
#include
-#include
-#include
-
#include "element.h"
#include "ext/variant.h"
#include "instruction.h"
-namespace scram {
-namespace mef {
+namespace scram::mef {
/// Representation of sequences in event trees.
class Sequence : public Element, public Usage {
@@ -88,7 +84,7 @@
class Branch {
public:
/// The types of possible branch end-points.
- using Target = boost::variant;
+ using Target = std::variant;
/// Sets the instructions to execute at the branch.
void instructions(std::vector instructions) {
@@ -166,7 +162,7 @@
};
/// Event Tree representation with MEF constructs.
-class EventTree : public Element, public Usage, private boost::noncopyable {
+class EventTree : public Element, public Usage {
public:
using Element::Element;
@@ -241,7 +237,4 @@
/// Unique initiating events in a model.
using InitiatingEventPtr = std::unique_ptr;
-} // namespace mef
-} // namespace scram
-
-#endif // SCRAM_SRC_EVENT_TREE_H_
+} // namespace scram::mef
diff -Nru scram-0.16.1/src/expression/boolean.h scram-0.16.2/src/expression/boolean.h
--- scram-0.16.1/src/expression/boolean.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/expression/boolean.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -18,15 +18,13 @@
/// @file
/// Boolean expressions.
-#ifndef SCRAM_SRC_EXPRESSION_BOOLEAN_H_
-#define SCRAM_SRC_EXPRESSION_BOOLEAN_H_
+#pragma once
#include
#include "src/expression.h"
-namespace scram {
-namespace mef {
+namespace scram::mef {
using Not = NaryExpression, 1>; ///< Logical negation.
using And = NaryExpression, -1>; ///< Logical conjunction.
@@ -38,7 +36,4 @@
using Leq = NaryExpression, 2>; ///< (<=) test.
using Geq = NaryExpression, 2>; ///< (>=) test.
-} // namespace mef
-} // namespace scram
-
-#endif // SCRAM_SRC_EXPRESSION_BOOLEAN_H_
+} // namespace scram::mef
diff -Nru scram-0.16.1/src/expression/conditional.cc scram-0.16.2/src/expression/conditional.cc
--- scram-0.16.1/src/expression/conditional.cc 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/expression/conditional.cc 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -22,8 +22,7 @@
#include
-namespace scram {
-namespace mef {
+namespace scram::mef {
Interval Ite::interval() noexcept {
assert(args().size() == 3);
@@ -56,5 +55,4 @@
return Interval::closed(min_value, max_value);
}
-} // namespace mef
-} // namespace scram
+} // namespace scram::mef
diff -Nru scram-0.16.1/src/expression/conditional.h scram-0.16.2/src/expression/conditional.h
--- scram-0.16.1/src/expression/conditional.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/expression/conditional.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -18,15 +18,13 @@
/// @file
/// Conditional (if-then-else, switch-case) expressions.
-#ifndef SCRAM_SRC_EXPRESSION_CONDITIONAL_H_
-#define SCRAM_SRC_EXPRESSION_CONDITIONAL_H_
+#pragma once
#include
#include "src/expression.h"
-namespace scram {
-namespace mef {
+namespace scram::mef {
/// If-Then-Else ternary expression.
class Ite : public ExpressionFormula {
@@ -77,7 +75,4 @@
Expression& default_value_; ///< The default case value.
};
-} // namespace mef
-} // namespace scram
-
-#endif // SCRAM_SRC_EXPRESSION_CONDITIONAL_H_
+} // namespace scram::mef
diff -Nru scram-0.16.1/src/expression/constant.cc scram-0.16.2/src/expression/constant.cc
--- scram-0.16.1/src/expression/constant.cc 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/expression/constant.cc 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2017 Olzhas Rakhimov
+ * Copyright (C) 2014-2018 Olzhas Rakhimov
*
* 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
@@ -22,13 +22,11 @@
#include
-namespace scram {
-namespace mef {
+namespace scram::mef {
ConstantExpression ConstantExpression::kOne(1);
ConstantExpression ConstantExpression::kZero(0);
ConstantExpression ConstantExpression::kPi( // This line confuses some linters!
boost::math::constants::pi());
-} // namespace mef
-} // namespace scram
+} // namespace scram::mef
diff -Nru scram-0.16.1/src/expression/constant.h scram-0.16.2/src/expression/constant.h
--- scram-0.16.1/src/expression/constant.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/expression/constant.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2017 Olzhas Rakhimov
+ * Copyright (C) 2014-2018 Olzhas Rakhimov
*
* 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
@@ -18,13 +18,11 @@
/// @file
/// Constant expressions that cannot have uncertainties.
-#ifndef SCRAM_SRC_EXPRESSION_CONSTANT_H_
-#define SCRAM_SRC_EXPRESSION_CONSTANT_H_
+#pragma once
#include "src/expression.h"
-namespace scram {
-namespace mef {
+namespace scram::mef {
/// Indicates a constant value.
class ConstantExpression : public Expression {
@@ -48,7 +46,4 @@
const double value_; ///< The universal value to represent int, bool, double.
};
-} // namespace mef
-} // namespace scram
-
-#endif // SCRAM_SRC_EXPRESSION_CONSTANT_H_
+} // namespace scram::mef
diff -Nru scram-0.16.1/src/expression/exponential.cc scram-0.16.2/src/expression/exponential.cc
--- scram-0.16.1/src/expression/exponential.cc 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/expression/exponential.cc 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2017 Olzhas Rakhimov
+ * Copyright (C) 2014-2018 Olzhas Rakhimov
*
* 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
@@ -24,8 +24,7 @@
#include "src/error.h"
-namespace scram {
-namespace mef {
+namespace scram::mef {
namespace { // Poisson process probability evaluators.
@@ -304,5 +303,4 @@
sigma_.Sample(), omega_.Sample(), time_.Sample());
}
-} // namespace mef
-} // namespace scram
+} // namespace scram::mef
diff -Nru scram-0.16.1/src/expression/exponential.h scram-0.16.2/src/expression/exponential.h
--- scram-0.16.1/src/expression/exponential.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/expression/exponential.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2017 Olzhas Rakhimov
+ * Copyright (C) 2014-2018 Olzhas Rakhimov
*
* 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
@@ -19,15 +19,13 @@
/// Expressions and distributions
/// that are described with exponential formulas.
-#ifndef SCRAM_SRC_EXPRESSION_EXPONENTIAL_H_
-#define SCRAM_SRC_EXPRESSION_EXPONENTIAL_H_
+#pragma once
#include
#include "src/expression.h"
-namespace scram {
-namespace mef {
+namespace scram::mef {
/// Negative exponential distribution
/// with hourly failure rate and time.
@@ -256,7 +254,4 @@
std::unique_ptr flavor_; ///< Specialized flavor of calculations.
};
-} // namespace mef
-} // namespace scram
-
-#endif // SCRAM_SRC_EXPRESSION_EXPONENTIAL_H_
+} // namespace scram::mef
diff -Nru scram-0.16.1/src/expression/extern.cc scram-0.16.2/src/expression/extern.cc
--- scram-0.16.1/src/expression/extern.cc 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/expression/extern.cc 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -20,121 +20,11 @@
#include "extern.h"
-#include
-
#include
-#include
-
-#if BOOST_VERSION < 106100
-
-#if !BOOST_OS_LINUX
-#error "Dynamic library loading w/o Boost 1.61 is supported only on Linux."
-#endif
-
-#include
-
-/// Use POSIX directly on Linux only.
-#define DSO_LINUX 1
-
-#else
-
-#include
-#include
-#include
-#include
-
-#endif
-
-#include "src/error.h"
namespace fs = boost::filesystem;
-namespace scram {
-namespace mef {
-
-#if DSO_LINUX
-/// Implementation of external library load facilities.
-class ExternLibrary::Pimpl {
- public:
- /// Loads the library for ExternLibrary.
- Pimpl(std::string lib_path, const fs::path& reference_dir, bool system,
- bool decorate)
- : lib_handle_(nullptr) {
- if (decorate) {
- lib_path += ".so";
- auto pos = lib_path.rfind('/');
- lib_path.insert(pos == std::string::npos ? 0 : (pos + 1), "lib");
- }
- if (!system || lib_path.find('/') != std::string::npos) {
- fs::path abs_path = fs::absolute(lib_path, reference_dir);
- lib_handle_ = dlopen(abs_path.c_str(), RTLD_LAZY);
- } else {
- lib_handle_ = dlopen(lib_path.c_str(), RTLD_LAZY);
- }
-
- if (!lib_handle_)
- SCRAM_THROW(DLError(dlerror()));
- }
-
- /// @copydoc ExternLibrary::~ExternLibrary
- ~Pimpl() {
- int err = dlclose(lib_handle_);
- assert(!err && "Failed to close dynamic library.");
- }
-
- /// Retrieves the symbol from the loaded library.
- void* get(const char* symbol) const {
- dlerror(); // Clear the error message.
- void* fptr = dlsym(lib_handle_, symbol);
- const char* err = dlerror();
- if (!fptr && err)
- SCRAM_THROW(UndefinedElement(err));
-
- return fptr;
- }
-
- private:
- void* lib_handle_; ///< Handle to the library for reference.
-};
-#else
-/// Implementation of external library load facilities.
-class ExternLibrary::Pimpl {
- public:
- /// Loads the library for ExternLibrary.
- Pimpl(std::string lib_path, const fs::path& reference_dir, bool system,
- bool decorate) {
- boost::dll::load_mode::type load_type = boost::dll::load_mode::default_mode;
- if (decorate)
- load_type |= boost::dll::load_mode::append_decorations;
- if (system)
- load_type |= boost::dll::load_mode::search_system_folders;
-
- fs::path ref_path = lib_path;
- if (!system || ref_path.has_parent_path())
- ref_path = fs::absolute(ref_path, reference_dir);
-
- try {
- lib_handle_.load(ref_path, load_type);
- } catch (const boost::system::system_error& err) {
- SCRAM_THROW(DLError(err.what()))
- << boost::errinfo_nested_exception(boost::current_exception());
- }
- }
-
- /// Retrieves the symbol from the loaded library.
- void* get(const char* symbol) const {
- try {
- return reinterpret_cast(lib_handle_.get(symbol));
- } catch (const boost::system::system_error& err) {
- SCRAM_THROW(UndefinedElement(err.what()))
- << boost::errinfo_nested_exception(boost::current_exception());
- }
- }
-
- private:
- boost::dll::shared_library lib_handle_; ///< Shared Library abstraction.
-};
-#endif
+namespace scram::mef {
ExternLibrary::ExternLibrary(std::string name, std::string lib_path,
const fs::path& reference_dir, bool system,
@@ -153,14 +43,22 @@
}
// clang-format on
- pimpl_ = new Pimpl(std::move(lib_path), reference_dir, system, decorate);
-}
-
-ExternLibrary::~ExternLibrary() { delete pimpl_; }
-
-void* ExternLibrary::get(const char* symbol) const {
- return pimpl_->get(symbol);
+ boost::dll::load_mode::type load_type = boost::dll::load_mode::default_mode;
+ if (decorate)
+ load_type |= boost::dll::load_mode::append_decorations;
+ if (system)
+ load_type |= boost::dll::load_mode::search_system_folders;
+
+ fs::path ref_path = lib_path;
+ if (!system || ref_path.has_parent_path())
+ ref_path = fs::absolute(ref_path, reference_dir);
+
+ try {
+ lib_handle_.load(ref_path, load_type);
+ } catch (const boost::system::system_error& err) {
+ SCRAM_THROW(DLError(err.what()))
+ << boost::errinfo_nested_exception(boost::current_exception());
+ }
}
-} // namespace mef
-} // namespace scram
+} // namespace scram::mef
diff -Nru scram-0.16.1/src/expression/extern.h scram-0.16.2/src/expression/extern.h
--- scram-0.16.1/src/expression/extern.h 2018-01-04 10:06:34.000000000 +0000
+++ scram-0.16.2/src/expression/extern.h 2018-01-12 11:42:47.000000000 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Olzhas Rakhimov
+ * Copyright (C) 2017-2018 Olzhas Rakhimov
*
* 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
@@ -18,28 +18,29 @@
/// @file
/// The MEF facilities to call external functions in expressions.
-#ifndef SCRAM_SRC_EXPRESSION_EXTERN_H_
-#define SCRAM_SRC_EXPRESSION_EXTERN_H_
+#pragma once
#include
#include
#include
#include
+#include
+#include
+#include
#include
-#include
+#include