Skip to content

Commit

Permalink
C++17: Replace auxiliary::Option with std::optional
Browse files Browse the repository at this point in the history
* Replace auxiliary::Option with std::optional
  • Loading branch information
franzpoeschel authored and ax3l committed Jan 24, 2022
1 parent 43da126 commit d487461
Show file tree
Hide file tree
Showing 20 changed files with 118 additions and 340 deletions.
14 changes: 7 additions & 7 deletions include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "openPMD/IO/IOTask.hpp"
#include "openPMD/IO/InvalidatableFile.hpp"
#include "openPMD/auxiliary/JSON_internal.hpp"
#include "openPMD/auxiliary/Option.hpp"
#include "openPMD/backend/Writable.hpp"
#include "openPMD/config.hpp"
#include "openPMD/IterationEncoding.hpp"
Expand All @@ -47,6 +46,7 @@
#include <future>
#include <iostream>
#include <memory> // shared_ptr
#include <optional>
#include <set>
#include <string>
#include <unordered_map>
Expand Down Expand Up @@ -320,11 +320,11 @@ class ADIOS2IOHandlerImpl
* @return first parameter: the operators, second parameters: whether
* operators have been configured
*/
auxiliary::Option< std::vector< ParameterizedOperator > >
std::optional< std::vector< ParameterizedOperator > >
getOperators( json::TracingJSON config );

// use m_config
auxiliary::Option< std::vector< ParameterizedOperator > >
std::optional< std::vector< ParameterizedOperator > >
getOperators();

std::string
Expand Down Expand Up @@ -367,7 +367,7 @@ class ADIOS2IOHandlerImpl

// Helper methods.

auxiliary::Option< adios2::Operator >
std::optional< adios2::Operator >
getCompressionOperator( std::string const & compression );

/*
Expand Down Expand Up @@ -1227,7 +1227,7 @@ namespace detail

private:
ADIOS2IOHandlerImpl * m_impl;
auxiliary::Option< adios2::Engine > m_engine; //! ADIOS engine
std::optional< adios2::Engine > m_engine; //! ADIOS engine
/**
* The ADIOS2 engine type, to be passed to adios2::IO::SetEngine
*/
Expand Down Expand Up @@ -1343,8 +1343,8 @@ namespace detail
* the map that would be returned by a call to
* IO::Available(Attributes|Variables).
*/
auxiliary::Option< AttributeMap_t > m_availableAttributes;
auxiliary::Option< AttributeMap_t > m_availableVariables;
std::optional< AttributeMap_t > m_availableAttributes;
std::optional< AttributeMap_t > m_availableVariables;

/*
* finalize() will set this true to avoid running twice.
Expand Down
4 changes: 2 additions & 2 deletions include/openPMD/IO/HDF5/HDF5IOHandlerImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
# include "openPMD/IO/AbstractIOHandlerImpl.hpp"

# include "openPMD/auxiliary/JSON_internal.hpp"
# include "openPMD/auxiliary/Option.hpp"

# include <hdf5.h>
# include <optional>
# include <unordered_map>
# include <unordered_set>
#endif
Expand Down Expand Up @@ -88,7 +88,7 @@ namespace openPMD
std::string name;
hid_t id;
};
auxiliary::Option< File > getFile( Writable * );
std::optional< File > getFile( Writable * );
}; // HDF5IOHandlerImpl
#else
class HDF5IOHandlerImpl
Expand Down
5 changes: 3 additions & 2 deletions include/openPMD/Iteration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*/
#pragma once

#include "openPMD/auxiliary/Option.hpp"
#include "openPMD/auxiliary/Variant.hpp"
#include "openPMD/backend/Attributable.hpp"
#include "openPMD/backend/Container.hpp"
Expand All @@ -29,6 +28,8 @@
#include "openPMD/ParticleSpecies.hpp"
#include "openPMD/Streaming.hpp"

#include <optional>


namespace openPMD
{
Expand Down Expand Up @@ -100,7 +101,7 @@ namespace internal
* Information on a parsing request that has not yet been executed.
* Otherwise empty.
*/
auxiliary::Option< DeferredParseAccess > m_deferredParseAccess{};
std::optional< DeferredParseAccess > m_deferredParseAccess{};
};
}
/** @brief Logical compilation of data from one snapshot (e.g. a single simulation cycle).
Expand Down
4 changes: 3 additions & 1 deletion include/openPMD/ReadIterations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "openPMD/Iteration.hpp"
#include "openPMD/Series.hpp"

#include <optional>

namespace openPMD
{
/**
Expand Down Expand Up @@ -51,7 +53,7 @@ class SeriesIterator
{
using iteration_index_t = IndexedIteration::index_t;

using maybe_series_t = auxiliary::Option< Series >;
using maybe_series_t = std::optional< Series >;

maybe_series_t m_series;
iteration_index_t m_currentIteration = 0;
Expand Down
6 changes: 3 additions & 3 deletions include/openPMD/Series.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "openPMD/IterationEncoding.hpp"
#include "openPMD/Streaming.hpp"
#include "openPMD/WriteIterations.hpp"
#include "openPMD/auxiliary/Option.hpp"
#include "openPMD/auxiliary/Variant.hpp"
#include "openPMD/backend/Attributable.hpp"
#include "openPMD/backend/Container.hpp"
Expand All @@ -42,6 +41,7 @@
#endif

#include <map>
#include <optional>
#include <string>

// expose private and protected members for invasive testing
Expand Down Expand Up @@ -85,7 +85,7 @@ class SeriesData : public AttributableData
* This ensures that Series::writeIteration() always returns
* the same instance.
*/
auxiliary::Option< WriteIterations > m_writeIterations;
std::optional< WriteIterations > m_writeIterations;
/**
* Needed if reading a single iteration of a file-based series.
* Users may specify the concrete filename of one iteration instead of the
Expand All @@ -95,7 +95,7 @@ class SeriesData : public AttributableData
* Instead, the user-specified filename should be used directly.
* Store that filename in the following Option to indicate this situation.
*/
auxiliary::Option< std::string > m_overrideFilebasedFilename;
std::optional< std::string > m_overrideFilebasedFilename;
/**
* Name of the iteration without filename suffix.
* In case of file-based iteration encoding, with expansion pattern.
Expand Down
5 changes: 3 additions & 2 deletions include/openPMD/WriteIterations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
#pragma once

#include "openPMD/Iteration.hpp"
#include "openPMD/auxiliary/Option.hpp"
#include "openPMD/backend/Container.hpp"

#include <optional>


namespace openPMD
{
Expand Down Expand Up @@ -61,7 +62,7 @@ class WriteIterations
struct SharedResources
{
iterations_t iterations;
auxiliary::Option< uint64_t > currentlyOpen;
std::optional< uint64_t > currentlyOpen;

SharedResources( iterations_t );
~SharedResources();
Expand Down
7 changes: 4 additions & 3 deletions include/openPMD/auxiliary/JSON_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
#include "openPMD/config.hpp"

#include "openPMD/Error.hpp"
#include "openPMD/auxiliary/Option.hpp"

#include <nlohmann/json.hpp>
#include <toml.hpp>

#include <optional>

#if openPMD_HAVE_MPI
# include <mpi.h>
#endif
Expand Down Expand Up @@ -223,12 +224,12 @@ namespace json
* If it is a bool, convert it to either "0" or "1".
* If it is not a literal, return an empty option.
*/
auxiliary::Option< std::string > asStringDynamic( nlohmann::json const & );
std::optional< std::string > asStringDynamic( nlohmann::json const & );

/**
* Like asStringDynamic(), but convert the string to lowercase afterwards.
*/
auxiliary::Option< std::string >
std::optional< std::string >
asLowerCaseStringDynamic( nlohmann::json const & );

/**
Expand Down
172 changes: 0 additions & 172 deletions include/openPMD/auxiliary/Option.hpp

This file was deleted.

1 change: 0 additions & 1 deletion include/openPMD/openPMD.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ namespace openPMD {}
#include "openPMD/auxiliary/Date.hpp"
#include "openPMD/auxiliary/DerefDynamicCast.hpp"
#include "openPMD/auxiliary/JSON.hpp"
#include "openPMD/auxiliary/Option.hpp"
#include "openPMD/auxiliary/OutOfRangeMsg.hpp"
#include "openPMD/auxiliary/ShareRaw.hpp"
#include "openPMD/auxiliary/StringManip.hpp"
Expand Down
Loading

0 comments on commit d487461

Please sign in to comment.