diff --git a/.github/workflows/ContinuousIntegration.yml b/.github/workflows/ContinuousIntegration.yml index 6f987cf69..f57079935 100644 --- a/.github/workflows/ContinuousIntegration.yml +++ b/.github/workflows/ContinuousIntegration.yml @@ -2,7 +2,10 @@ name: Continuous Integration # This workflow is triggered on pushes and pull requests to the repository. +# This workflow will also run each Monday on the default branch (i.e. master) on: + schedule: + - cron: '0 0 * * 1' push: branches: '**' pull_request: @@ -14,10 +17,16 @@ jobs: strategy: matrix: os: [ ubuntu-18.04, macos-10.15 ] - cxx: [ g++-9, clang++ ] + cxx: [ clang++, g++-9 ] build_type: [ Debug, Release ] steps: + - name: Install hdf5 libraries for Linux + if: matrix.os == 'ubuntu-18.04' + run: sudo apt-get install libhdf5-dev + - name: Install hdf5 libraries for MacOS + if: matrix.os == 'macos-10.15' + run: brew install hdf5 - name: which CXX run: | which ${{matrix.cxx}} diff --git a/CMakeLists.txt b/CMakeLists.txt index a33c52da1..50ba390f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ target_link_libraries( GNDStk INTERFACE catch-adapter INTERFACE pugixml-adapter INTERFACE nlohmann_json::nlohmann_json + INTERFACE HighFive ) add_executable( json2class.exe @@ -57,28 +58,162 @@ target_link_libraries( json2class.exe # GNDStk : python bindings # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -include_directories( python/src/ ) +include_directories( python/src/ autogen/prototype/proto/src/ ) pybind11_add_module( GNDStk.python EXCLUDE_FROM_ALL python/src/GNDStk.python.cpp python/src/core/Node.python.cpp - python/src/Interpolation.python.cpp + python/src/BoundaryCondition.python.cpp + python/src/ContributorType.python.cpp + python/src/DateType.python.cpp + python/src/DecayType.python.cpp + python/src/Frame.python.cpp python/src/GridStyle.python.cpp - python/src/v1.9/containers.python.cpp - python/src/v1.9/containers/Axis.python.cpp - python/src/v1.9/containers/Values.python.cpp - python/src/v1.9/containers/Link.python.cpp - python/src/v1.9/containers/Grid.python.cpp - python/src/v1.9/containers/Axes.python.cpp - python/src/v1.9/containers/XYs1d.python.cpp - python/src/v1.9/containers/Regions1d.python.cpp - python/src/v1.9/transport/CrossSection.python.cpp - python/src/v1.9/transport/Reaction.python.cpp - python/src/v1.9/transport/Reactions.python.cpp - python/src/v1.9/transport/ReactionSuite.python.cpp - python/src/v1.9/transport.python.cpp - python/src/v1.9/GNDS.python.cpp + python/src/HashAlgorithm.python.cpp + python/src/Interaction.python.cpp + python/src/Interpolation.python.cpp + python/src/InterpolationQualifier.python.cpp + python/src/Parity.python.cpp + python/src/RelationType.python.cpp + autogen/prototype/proto/python/src/v1.9/containers.python.cpp + autogen/prototype/proto/python/src/v1.9/containers/Axis.python.cpp + autogen/prototype/proto/python/src/v1.9/containers/Values.python.cpp + autogen/prototype/proto/python/src/v1.9/containers/Link.python.cpp + autogen/prototype/proto/python/src/v1.9/containers/Grid.python.cpp + autogen/prototype/proto/python/src/v1.9/containers/Axes.python.cpp + autogen/prototype/proto/python/src/v1.9/containers/XYs1d.python.cpp + autogen/prototype/proto/python/src/v1.9/containers/Regions1d.python.cpp + autogen/prototype/proto/python/src/v1.9/transport/CrossSection.python.cpp + autogen/prototype/proto/python/src/v1.9/transport/Reaction.python.cpp + autogen/prototype/proto/python/src/v1.9/transport/Reactions.python.cpp + autogen/prototype/proto/python/src/v1.9/transport/ReactionSuite.python.cpp + autogen/prototype/proto/python/src/v1.9/transport.python.cpp + autogen/prototype/proto/python/src/v1.9/proto.python.cpp + python/src/v2.0/GNDS.python.cpp + python/src/v2.0/containers.python.cpp + python/src/v2.0/containers/Array.python.cpp + python/src/v2.0/containers/Axes.python.cpp + python/src/v2.0/containers/Axis.python.cpp + python/src/v2.0/containers/Column.python.cpp + python/src/v2.0/containers/ColumnHeaders.python.cpp + python/src/v2.0/containers/Constant1d.python.cpp + python/src/v2.0/containers/Data.python.cpp + python/src/v2.0/containers/Double.python.cpp + python/src/v2.0/containers/Fraction.python.cpp + python/src/v2.0/containers/Function1ds.python.cpp + python/src/v2.0/containers/Function2ds.python.cpp + python/src/v2.0/containers/Function3ds.python.cpp + python/src/v2.0/containers/Grid.python.cpp + python/src/v2.0/containers/Gridded1d.python.cpp + python/src/v2.0/containers/Gridded2d.python.cpp + python/src/v2.0/containers/Gridded3d.python.cpp + python/src/v2.0/containers/Integer.python.cpp + python/src/v2.0/containers/Legendre.python.cpp + python/src/v2.0/containers/Link.python.cpp + python/src/v2.0/containers/Polynomial1d.python.cpp + python/src/v2.0/containers/Regions1d.python.cpp + python/src/v2.0/containers/Regions2d.python.cpp + python/src/v2.0/containers/Regions3d.python.cpp + python/src/v2.0/containers/String.python.cpp + python/src/v2.0/containers/Table.python.cpp + python/src/v2.0/containers/Values.python.cpp + python/src/v2.0/containers/XYs1d.python.cpp + python/src/v2.0/containers/XYs2d.python.cpp + python/src/v2.0/containers/XYs3d.python.cpp + python/src/v2.0/containers/Ys1d.python.cpp + python/src/v2.0/fissionFragmentData.python.cpp + python/src/v2.0/fissionFragmentData/DelayedNeutron.python.cpp + python/src/v2.0/fissionFragmentData/DelayedNeutrons.python.cpp + python/src/v2.0/fissionFragmentData/FissionFragmentData.python.cpp + python/src/v2.0/fpy.python.cpp + python/src/v2.0/fpy/ElapsedTime.python.cpp + python/src/v2.0/fpy/ElapsedTimes.python.cpp + python/src/v2.0/fpy/Energy.python.cpp + python/src/v2.0/fpy/IncidentEnergies.python.cpp + python/src/v2.0/fpy/IncidentEnergy.python.cpp + python/src/v2.0/fpy/Nuclides.python.cpp + python/src/v2.0/fpy/ProductYield.python.cpp + python/src/v2.0/fpy/ProductYields.python.cpp + python/src/v2.0/fpy/Time.python.cpp + python/src/v2.0/fpy/Yields.python.cpp + python/src/v2.0/fissionFragmentData/Rate.python.cpp + python/src/v2.0/pops.python.cpp + python/src/v2.0/pops/Alias.python.cpp + python/src/v2.0/pops/Aliases.python.cpp + python/src/v2.0/pops/Atomic.python.cpp + python/src/v2.0/pops/AverageEnergies.python.cpp + python/src/v2.0/pops/AverageEnergy.python.cpp + python/src/v2.0/pops/Baryon.python.cpp + python/src/v2.0/pops/Baryons.python.cpp + python/src/v2.0/pops/BindingEnergy.python.cpp + python/src/v2.0/pops/Charge.python.cpp + python/src/v2.0/pops/ChemicalElement.python.cpp + python/src/v2.0/pops/ChemicalElements.python.cpp + python/src/v2.0/pops/Configuration.python.cpp + python/src/v2.0/pops/Configurations.python.cpp + python/src/v2.0/pops/Continuum.python.cpp + python/src/v2.0/pops/Decay.python.cpp + python/src/v2.0/pops/DecayData.python.cpp + python/src/v2.0/pops/DecayMode.python.cpp + python/src/v2.0/pops/DecayModes.python.cpp + python/src/v2.0/pops/DecayPath.python.cpp + python/src/v2.0/pops/Discrete.python.cpp + python/src/v2.0/pops/Energy.python.cpp + python/src/v2.0/pops/GaugeBoson.python.cpp + python/src/v2.0/pops/GaugeBosons.python.cpp + python/src/v2.0/pops/Halflife.python.cpp + python/src/v2.0/pops/Intensity.python.cpp + python/src/v2.0/pops/InternalConversionCoefficients.python.cpp + python/src/v2.0/pops/InternalPairFormationCoefficient.python.cpp + python/src/v2.0/pops/Isotope.python.cpp + python/src/v2.0/pops/Isotopes.python.cpp + python/src/v2.0/pops/Lepton.python.cpp + python/src/v2.0/pops/Leptons.python.cpp + python/src/v2.0/pops/Mass.python.cpp + python/src/v2.0/pops/MetaStable.python.cpp + python/src/v2.0/pops/Nucleus.python.cpp + python/src/v2.0/pops/Nuclide.python.cpp + python/src/v2.0/pops/Nuclides.python.cpp + python/src/v2.0/pops/Parity.python.cpp + python/src/v2.0/pops/PhotonEmissionProbabilities.python.cpp + python/src/v2.0/pops/PoPs.python.cpp + python/src/v2.0/pops/Probability.python.cpp + python/src/v2.0/pops/Product.python.cpp + python/src/v2.0/pops/Products.python.cpp + python/src/v2.0/pops/Q.python.cpp + python/src/v2.0/pops/Shell.python.cpp + python/src/v2.0/pops/Spectra.python.cpp + python/src/v2.0/pops/Spectrum.python.cpp + python/src/v2.0/pops/Spin.python.cpp + python/src/v2.0/pops/Unorthodox.python.cpp + python/src/v2.0/pops/Unorthodoxes.python.cpp + python/src/v2.0/resonances.python.cpp + python/src/v2.0/resonances/BreitWigner.python.cpp + python/src/v2.0/resonances/Channel.python.cpp + python/src/v2.0/resonances/Channels.python.cpp + python/src/v2.0/resonances/EnergyInterval.python.cpp + python/src/v2.0/resonances/EnergyIntervals.python.cpp + python/src/v2.0/resonances/ExternalRMatrix.python.cpp + python/src/v2.0/resonances/HardSphereRadius.python.cpp + python/src/v2.0/resonances/J.python.cpp + python/src/v2.0/resonances/Js.python.cpp + python/src/v2.0/resonances/L.python.cpp + python/src/v2.0/resonances/LevelSpacing.python.cpp + python/src/v2.0/resonances/Ls.python.cpp + python/src/v2.0/resonances/RMatrix.python.cpp + python/src/v2.0/resonances/Resolved.python.cpp + python/src/v2.0/resonances/ResonanceParameters.python.cpp + python/src/v2.0/resonances/ResonanceReaction.python.cpp + python/src/v2.0/resonances/ResonanceReactions.python.cpp + python/src/v2.0/resonances/Resonances.python.cpp + python/src/v2.0/resonances/ScatteringRadius.python.cpp + python/src/v2.0/resonances/SpinGroup.python.cpp + python/src/v2.0/resonances/SpinGroups.python.cpp + python/src/v2.0/resonances/TabulatedWidths.python.cpp + python/src/v2.0/resonances/Unresolved.python.cpp + python/src/v2.0/resonances/Width.python.cpp + python/src/v2.0/resonances/Widths.python.cpp ) target_link_libraries( GNDStk.python PRIVATE GNDStk ) target_compile_options( GNDStk.python PRIVATE "-fvisibility=hidden" ) diff --git a/README.md b/README.md index a8734aac2..0d05e30ed 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ +![Continuous Integration](https://github.com/njoy/GNDStk/workflows/Continuous%20Integration/badge.svg) + # GNDStk -Generalized Nuclear Database Structure toolkit +Toolkit for reading and interacting with GNDS formatted files. This toolkit provides a full C++ library along with python bindings. ## LICENSE This software is copyrighted by Los Alamos National Laboratory and distributed according to the conditions in the accompanying [LICENSE](LICENSE) file. diff --git a/autogen/.gitignore b/autogen/.gitignore deleted file mode 100644 index 321656c44..000000000 --- a/autogen/.gitignore +++ /dev/null @@ -1 +0,0 @@ -json2class.exe diff --git a/autogen/changes.json b/autogen/changes.json index 87832d157..a895b0e3a 100644 --- a/autogen/changes.json +++ b/autogen/changes.json @@ -11,7 +11,6 @@ "metadata": { "type": { "Boolean": "bool", - "string": "std::string", "encoding": "enums::Encoding", "frame": "enums::Frame", "interaction": "enums::Interaction", @@ -40,7 +39,7 @@ "nuclear": "enums::Interaction::nuclear", "atomic": "enums::Interaction::atomic", "thermalNeutronScatteringLaw": - "enums::Interaction::thermalNeutronScatteringLaw", + "enums::Interaction::thermalNeutronScatteringLaw", "// INTERPOLATION": {}, "flat": "enums::Interpolation::flat", diff --git a/autogen/json2class.cpp b/autogen/json2class.cpp index ff4a91686..29f1391e6 100644 --- a/autogen/json2class.cpp +++ b/autogen/json2class.cpp @@ -4,13 +4,18 @@ // ----------------------------------------------------------------------------- #include "GNDStk.hpp" -#include "cstring" -using namespace njoy::GNDStk::core; +#include +using namespace njoy::GNDStk; // Report cases of nodes that have no metadata, and zero or one child node(s). // Where these exist, a simplification of the spec may be worth considering. const bool singletons = true; +// Extra debug/informational printing? +const bool debugging = false; + +// Put print statements in constructor and assignment calls. For debugging. +const bool printCtorCalls = false; // ----------------------------------------------------------------------------- @@ -18,11 +23,9 @@ const bool singletons = true; // ----------------------------------------------------------------------------- // KeyValue -// Too bad the JSON library doesn't provide this more straightforwardly +// Too bad the JSON library doesn't provide this directly using KeyValue = nlohmann::detail::iteration_proxy_value< - nlohmann::detail::iter_impl< - const nlohmann::basic_json<> - > + nlohmann::detail::iter_impl >; // NamespaceAndClass @@ -57,14 +60,15 @@ struct Class2Dependencies { // InfoMetadata struct InfoMetadata { - // A .json spec can make a metadatum be: + // A JSON spec can make a metadatum be: // - a std::optional, or // - a GNDStk::defaulted // but (in contrast with child nodes) can't make it be a vector of metadata. // An individual metadatum may be a vector in its own right, as in an XML - // construct such as (so that meta is a vector of + // construct such as (so that meta is a vector of // integers). We mean here that there isn't a vector of such [meta] entries, - // and shouldn't be (XML wouldn't allow it). + // and there shouldn't be (XML wouldn't allow it). + std::string original; // without e.g. the "double" to "Double" change std::string name; std::string type; // underlying type std::string typeFull; // WITH any optional<> or defaulted<> @@ -75,13 +79,16 @@ struct InfoMetadata { // InfoChildren struct InfoChildren { - // A .json spec can make a child node be: + // A JSON spec can make a child node be: // - a std::optional, and/or // - a std::vector // but can't make it be a GNDStk::defaulted. (The use of a default value for // child nodes just doesn't exist in the GNDS specifications, even though the // concept would seem to make sense.) + std::string original; // without e.g. the "double" to "Double" change std::string name; + std::string ns; // enclosing namespace + std::string plain; // underlying type, excluding namespace std::string type; // underlying type std::string typeFull; // WITH any optional<> or vector<> std::string typeHalf; // withOUT any vector<> @@ -92,7 +99,9 @@ struct InfoChildren { // InfoVariantsChildren struct InfoVariantsChildren { std::string name; - std::string type; + std::string ns; // enclosing namespace + std::string plain; // underlying type, excluding namespace + std::string type; // underlying type bool isVector; }; @@ -116,6 +125,8 @@ struct PerNamespace { struct PerClass { std::string cppPython; // cpp file for this class' Python interface std::string hppGNDStk; // hpp file for this class in GNDStk + std::string headerC; // header that works with both C and C++ + std::string sourceC; // C++ backend source for the C interface std::string nsname; // name of this class' namespace std::string clname; // name of this class @@ -148,7 +159,6 @@ struct PerClass { }; - // ----------------------------------------------------------------------------- // InfoSpecs // ----------------------------------------------------------------------------- @@ -156,26 +166,32 @@ struct PerClass { // Overarching data structure reflecting all of the autogenerator's input // as well as various processed information struct InfoSpecs { - // From the .json file on the command line + // From the JSON file on the command line + std::string Path; + std::string Project; + std::string Version; std::string JSONDir; std::vector JSONFiles; - std::string GNDSDir; - std::string Version; // Version, but with '_' in place of '.' std::string VersionUnderscore; // Directory-prefixed names std::string hppVersion; // hpp file for this version - std::string hppKey; // hpp file for this version's Meta<>/Child<> keys + std::string hppKey; // hpp file for this version's Meta and Child keys + std::string hVersion; // header file for both C and C++ + std::string cVersion; // C++ backend source for the C interface - // Changes to apply to a metadatum's or child node's name. - // Example: "double" (GNDS v1.9 does have this) to "Double" for C++. + // Changes to apply to a metadatum's name or a child node's name. + // Example: "double" (GNDS v1.9 actually has "double") to "Double" for C++. std::map mapName; - // Changes to apply to metadata/attribute type and default. + // Changes to apply to metadata/attribute type. // Examples: "Boolean" to "bool", "interpolation" to "enums::Interpolation". - std::map mapMetaType; + // We'll give a string ==> std::string type change as a freebie. :-) + std::map mapMetaType = {{"string","std::string"}}; + + // Changes to apply to metadata/attribute default. std::map mapMetaDefault; // For each class in the input JSON specifications, the namespace(s) @@ -194,9 +210,8 @@ struct InfoSpecs { std::map namespace2data; // Map from namespace::class to information about the class - std::map class2data; -}; - + nlohmann::ordered_map class2data; +}; // InfoSpecs // ----------------------------------------------------------------------------- @@ -206,9 +221,15 @@ struct InfoSpecs { // Print text describing an action the code is about to take void action(const std::string &str) { + static const std::string inverse = "\033[7m"; + static const std::string background(80,' '); std::cout - << "\n" - << colors::plain::blue << str << "..." << colors::reset << std::endl; + << inverse << colors::plain::blue << '\n' + << background << '\n' + << std::setw(80) << std::left << str << '\n' + << background << '\n' + << colors::reset + << std::endl; } // Is the string all whitespace? @@ -274,6 +295,19 @@ std::string allcaps(const std::string &str) return ret; } +// UpperCamel +std::string UpperCamel(const std::string &str) +{ + std::string ret; + for (size_t i = 0; i < str.size(); ++i) + if (str[i] != '_') + ret += i ? str[i] : toupper(str[i]); + else if (++i < str.size()) + ret += toupper(str[i]); + return ret; +} + + // Replace character std::string replace(const std::string &str, const char from, const char to) { @@ -286,10 +320,10 @@ std::string replace(const std::string &str, const char from, const char to) // Stringify JSON // See: https://github.com/nlohmann/json/issues/642 -std::string stringify(const nlohmann::json &j) +std::string stringify(const orderedJSON &j) { const auto tmp = j.dump(); - return j.type() == nlohmann::json::value_t::string + return j.type() == orderedJSON::value_t::string ? tmp.substr(1, tmp.size()-2) : tmp; } @@ -322,6 +356,31 @@ bool isClass(const KeyValue &keyval) return true; } +std::string getTimes( + const PerClass &per, const std::string &key, const orderedJSON &value +) { + const std::string times = "times"; // shorter, less easily misspelled + const std::string occurrence = "occurrence"; // accept; used in GNDS specs + + // need exactly one - not neither, not both + if (value.contains(times) == value.contains(occurrence)) { + log::error( + "In namespace \"{}\", class \"{}\":\n" + "Child node \"{}\" needs exactly one of \"times\" or \"occurrence\".\n" + "Or, did you possibly intend \"{}\" to be an attribute/metadatum?", + per.nsname, per.clname, key, key); + throw std::exception{}; + } + + return value.contains(times) + ? value[times] + : value[occurrence]; +} + +std::string sep(int &count, const int total) +{ + return ++count < total ? "," : ""; +} // ----------------------------------------------------------------------------- @@ -329,11 +388,28 @@ bool isClass(const KeyValue &keyval) // ----------------------------------------------------------------------------- // nameGNDS -// Name in GNDS (e.g., name of an XML element) -std::string nameGNDS(const KeyValue &keyval) -{ - // As-is, directly as stipulated in a key in the JSON spec, except - // that we allow a "name" entry to override the key. +// Name in a GNDS file (e.g., name of an XML element) +std::string nameGNDS( + const KeyValue &keyval, + const std::string &nsname = "", + const bool print = false +) { + // For debugging + if (debugging && print) { + const std::string key = keyval.key(); + const std::string name = keyval.value().contains("name") + ? std::string(keyval.value()["name"]) + : key; + std::cout + << "class: " + << std::setw(20) << std::left << nsname << " " + << std::setw(48) << std::left << key << " " + << (key == name ? " " : "*") << " " + << std::left << name << std::endl; + } + + // As-is, directly as stipulated in the key in the JSON spec, except + // that we allow a "name" entry in the key's value to override the key. return keyval.value().contains("name") ? std::string(keyval.value()["name"]) : keyval.key(); @@ -343,9 +419,10 @@ std::string nameGNDS(const KeyValue &keyval) // Name of a field (metadatum or child node) in an autogenerated class std::string nameField(const KeyValue &keyval, const InfoSpecs &specs) { - // Like nameGNDS, except that we apply any name-modification map that - // may have been provided. That can fix, for example, the name "double", - // which appears in GNDS v1.9 but is unsuitable for a name in C++. + // Like nameGNDS above, except that we apply any name-modification + // map that may have been provided in a "changes" file. Such changes + // can fix, for example, the name "double" that appears in some GNDS + // specs as a JSON key, because "double" is unsuitable for use in C++. const std::string name = nameGNDS(keyval); const auto it = specs.mapName.find(name); return it == specs.mapName.end() ? name : it->second; @@ -355,8 +432,11 @@ std::string nameField(const KeyValue &keyval, const InfoSpecs &specs) // Name of an autogenerated class std::string nameClass(const KeyValue &keyval, const InfoSpecs &specs) { - // Like nameField, but capitalized (per our class naming convention). - return capital(nameField(keyval,specs)); + // Capitalized version of either the JSON key, or, if applicable, + // its change under the name-modification map in a "changes" file. + const std::string name = keyval.key(); + const auto it = specs.mapName.find(name); + return capital(it == specs.mapName.end() ? name : it->second); } // namePython @@ -376,13 +456,12 @@ std::string namePython(const std::string &name) } - // ----------------------------------------------------------------------------- // Functions for getting certain information from JSON input // ----------------------------------------------------------------------------- // Get the JSON's "namespace" -std::string getFileNamespace(const nlohmann::json &j) +std::string getFileNamespace(const orderedJSON &j) { return j.contains("__namespace__") ? j["__namespace__"] @@ -390,7 +469,7 @@ std::string getFileNamespace(const nlohmann::json &j) } // Get the JSON's "type", with any relevant specs.mapMetaType entry applied -std::string getMetadatumType(const nlohmann::json &j, const InfoSpecs &specs) +std::string getMetadatumType(const orderedJSON &j, const InfoSpecs &specs) { const std::string type = j["type"]; const auto it = specs.mapMetaType.find(type); @@ -400,9 +479,9 @@ std::string getMetadatumType(const nlohmann::json &j, const InfoSpecs &specs) // Determine to what namespace childClass belongs. Context: we're (1) in a JSON // spec with namespace parent.nsname, (2) in a parent node named parent.clname, // and (3) wish to determine the proper namespace for the parent's child node -// named "child". Parameter j is the JSON value ({...}) for this child node. +// named childClass. Parameter j is the JSON value ({...}) for this child node. std::string getChildNamespace( - const nlohmann::json &j, const InfoSpecs &specs, + const orderedJSON &j, const InfoSpecs &specs, const PerClass &per, const std::string &childClass ) { // childClass' namespace... @@ -414,7 +493,7 @@ std::string getChildNamespace( // ...isn't given, and this child isn't in any of the JSONs :-( if (specs.class2nspace.count(childClass) == 0) { log::warning( - "{}::{} has child of unknown class {}", + "{}::{} has a child of unknown class {}", per.nsname, per.clname, childClass ); return "unknownNamespace"; @@ -429,7 +508,13 @@ std::string getChildNamespace( const auto range = specs.class2nspace.equal_range(childClass); for (auto it = range.first; it != range.second; ++it) if (it->second == per.nsname) { - // fixme: a *warning* might be in order, re: our assumption + log::warning( + "{}::{} has a child {} that appears in the present\n" + "namespace but also in one or more other namespaces. We'll\n" + "assume that the one in the present namespace is intended.\n" + "If this is wrong, please provide a \"namespace\" entry.", + per.nsname, per.clname, childClass + ); return per.nsname; } @@ -440,7 +525,7 @@ std::string getChildNamespace( for (auto it = range.first; it != range.second; ++it) warn << (count++ == 0 ? "" : ", ") << it->second; log::warning( - "{}::{} has child of ambiguous class {}.\n" + "{}::{} has a child of ambiguous class {}.\n" "Child class {} appears in all of the following namespaces:\n{}", per.nsname, per.clname, childClass, childClass, warn.str() ); @@ -449,20 +534,20 @@ std::string getChildNamespace( } - // ----------------------------------------------------------------------------- // getClass* functions re: metadata, children, variant children // ----------------------------------------------------------------------------- // getClassMetadata void getClassMetadata( - const nlohmann::json &j, const InfoSpecs &specs, PerClass &per + const orderedJSON &j, const InfoSpecs &specs, PerClass &per ) { for (const auto &field : j.items()) { const auto &metaRHS = field.value(); // Name InfoMetadata m; + m.original = nameGNDS(field); m.name = nameField(field,specs); // Type @@ -472,13 +557,22 @@ void getClassMetadata( m.defaultValue = ""; if (metaRHS.contains("default") && !metaRHS["default"].is_null()) { m.defaultValue = stringify(metaRHS["default"]); + // Apply the "changes.json" change, if any, to the given value const auto it = specs.mapMetaDefault.find(m.defaultValue); if (it != specs.mapMetaDefault.end()) m.defaultValue = it->second; }; if (m.defaultValue != "") { // If it has a default, then presumably it isn't required... - assert(!metaRHS["required"]); + if (metaRHS["required"]) { + log::error( + "In namespace \"{}\", class \"{}\",\n" + "metadatum \"{}\" has a default ({}), but is required.\n" + "If it really is required, then it shouldn't have a default.\n" + "If it really has a default, then presumably it isn't required.", + per.nsname, per.clname, m.name, m.defaultValue); + throw std::exception{}; + } } // Optional? (not required, and has no default) @@ -505,25 +599,30 @@ void getClassMetadata( // getClassChildren void getClassChildren( - const nlohmann::json &j, const InfoSpecs &specs, + const orderedJSON &j, const InfoSpecs &specs, PerClass &per, Class2Dependencies &dep ) { for (const auto &field : j.items()) { + if (beginsin(field.key(), "//")) + continue; const auto &elemRHS = field.value(); // Choice children are handled elsewhere - const std::string occ = elemRHS["occurrence"]; - if (occ == "choice" || occ == "choice+" || occ == "choice2+") + const std::string times = getTimes(per, field.key(), elemRHS); + if (times == "choice" || times == "choice+" || times == "choice2+") continue; // Name InfoChildren c; + c.original = nameGNDS(field); c.name = nameField(field,specs); + // Type, excluding namespace + c.plain = nameClass(field,specs); + // Type, including namespace - c.type = nameClass(field,specs); - const std::string ns = getChildNamespace(elemRHS, specs, per, c.type); - c.type = ns + "::" + c.type; + c.ns = getChildNamespace(elemRHS, specs, per, c.plain); + c.type = c.ns + "::" + c.plain; // Optional? c.isOptional = !elemRHS["required"]; @@ -531,7 +630,7 @@ void getClassChildren( const std::string optSuffix = c.isOptional ? ">" : ""; // Vector? - c.isVector = occ == "0+" || occ == "1+" || occ == "2+"; + c.isVector = times == "0+" || times == "1+" || times == "2+"; const std::string vecPrefix = c.isVector ? "std::vector<" : ""; const std::string vecSuffix = c.isVector ? ">" : ""; @@ -553,7 +652,7 @@ void getClassChildren( // Save as a dependency (if it's not its own dependency) if (c.type != per.name()) dep.dependencies.push_back( - NamespaceAndClass(ns,nameClass(field,specs))); + NamespaceAndClass(c.ns,nameClass(field,specs))); // Add to per.children per.children.push_back(c); @@ -563,7 +662,7 @@ void getClassChildren( // getClassVariants void getClassVariants( - const nlohmann::json &j, const InfoSpecs &specs, + const orderedJSON &j, const InfoSpecs &specs, PerClass &per, Class2Dependencies &dep ) { // Initialize per.variants, a vector that has the "choice" @@ -585,10 +684,13 @@ void getClassVariants( // Collect "variant" names, and if ever it's absent, a to-be-determined // name for all choice children for which it's absent for (const auto &field : j.items()) { + if (beginsin(field.key(), "//")) + continue; + // Is it a choice child? const auto &elemRHS = field.value(); - const std::string occ = elemRHS["occurrence"]; - if (occ != "choice" && occ != "choice+" && occ != "choice2+") + const std::string times = getTimes(per,field.key(),elemRHS); + if (times != "choice" && times != "choice+" && times != "choice2+") continue; // Variant name @@ -600,29 +702,33 @@ void getClassVariants( // Pass 2 for (const auto &field : j.items()) { + if (beginsin(field.key(), "//")) + continue; + // Is it a choice child? const auto &elemRHS = field.value(); - const std::string occ = elemRHS["occurrence"]; - if (occ != "choice" && occ != "choice+" && occ != "choice2+") + const std::string times = getTimes(per,field.key(),elemRHS); + if (times != "choice" && times != "choice+" && times != "choice2+") continue; // Variant name - const std::string variant = elemRHS.contains("variant") + const std::string variantName = elemRHS.contains("variant") ? elemRHS["variant"] : ""; - auto it = map.find(variant); + auto it = map.find(variantName); assert(it != map.end()); // should be there from the earlier loop // For the individual child that's part of a choice... InfoVariantsChildren c; // ...its name c.name = nameField(field,specs); + // ...its type, excluding namespace + c.plain = nameClass(field,specs); // ...its type, including namespace - c.type = nameClass(field,specs); - const std::string ns = getChildNamespace(elemRHS, specs, per, c.type); - c.type = ns + "::" + c.type; + c.ns = getChildNamespace(elemRHS, specs, per, c.plain); + c.type = c.ns + "::" + c.plain; // ...its vector-ness - c.isVector = occ == "choice+" || occ == "choice2+"; + c.isVector = times == "choice+" || times == "choice2+"; // The GNDS JSON specifications all have "required":false for individual // choices in a set of choices; the concept of "the entire choice can be @@ -637,7 +743,7 @@ void getClassVariants( // Save as a dependency (if it's not its own dependency) if (c.type != per.name()) dep.dependencies.push_back( - NamespaceAndClass(ns,nameClass(field,specs))); + NamespaceAndClass(c.ns,nameClass(field,specs))); } // Pass 3 @@ -664,7 +770,6 @@ void getClassVariants( } // getClassVariants - // ----------------------------------------------------------------------------- // writer // ----------------------------------------------------------------------------- @@ -695,9 +800,9 @@ class writer { if (recurse == 0) { using last = decltype( std::get(std::make_tuple(value,args...))); - const size_t nsub = std::count(str.begin(), str.end(), substitute); + const std::size_t nsub = std::count(str.begin(),str.end(),substitute); // a bool last argument is not interpreted as an argument to print... - const size_t narg = + const std::size_t narg = 1 + sizeof...(args) - std::is_same_v,bool>; if (narg != nsub) { log::error( @@ -817,7 +922,16 @@ class writer { int writer::recurse = 0; - +// helper +template +void section(writer &out, const std::string &str, Ts &&...args) +{ + out(); + out(); + out(largeComment); + out(str, std::forward(args)...); + out(largeComment); +} // ----------------------------------------------------------------------------- // write* @@ -827,25 +941,31 @@ int writer::recurse = 0; // Class prefix void writeClassPrefix(writer &out, const PerClass &per) { + // namespace + out("namespace @ {", per.nsname); + // comment introducing class out(); - out(); - out(); out(largeComment); out("// @::", per.nsname); out("// class @", per.clname); out(largeComment); - // namespace+class begin - out(); - out("namespace @ {", per.nsname); + // class begin out(); - out("class @ : public Component<@@> {", - per.clname, per.clname, + out("class @ : public Component<@::@@> {", + // A namespace prefix in Component<> prevents possible ambiguities with + // the Child<> object for the class that was brought in through key.hpp. + // Normally the class name is capitalized while the Child<> object isn't, + // but if the node name was already capitalized in the specs (an example + // we encountered was "XYs1d"), then the Child<> key would reflect that. + // Then, without the nsname:: here, we'd have an ambiguity. + per.clname, per.nsname, per.clname, per.isData ? (",true" + (per.dataType == "" ? "" : "," + per.dataType)) : "" ); + out(1,"friend class Component;"); } // writeClassPrefix @@ -853,12 +973,14 @@ void writeClassPrefix(writer &out, const PerClass &per) void writeClassForComponent(writer &out, const PerClass &per) { // using [name for variant] = ... - out(); + if (per.variants.size()) + out(); for (const auto &v : per.variants) { out(1,"using @ = std::variant<", v.type); - int count = 0, total = v.children.size(); + int count = 0; + const int total = v.children.size(); for (const auto &c : v.children) - out(2,"@@", c.type, ++count == total ? "" : ","); + out(2,"@@", c.type, sep(count,total)); out(1,">;"); } @@ -867,21 +989,20 @@ void writeClassForComponent(writer &out, const PerClass &per) out(1,"// For Component"); out(1,smallComment); out(); - out(1,"friend class Component;"); - out(); - out(1,"// Current namespace, current class, and GNDS node name"); - out(1,"static auto namespaceName() { return \"@\"; }", per.nsname); - out(1,"static auto className() { return \"@\"; }", per.clname); - out(1,"static auto GNDSName() { return \"@\"; }", per.nameGNDS); + out(1,"// Names: this namespace, this class, a field/node of this type"); + out(1,"static auto NAMESPACE() { return \"@\"; }", per.nsname); + out(1,"static auto CLASS() { return \"@\"; }", per.clname); + out(1,"static auto FIELD() { return \"@\"; }", per.nameGNDS); - // keys() begin + // KEYS() begin out(); out(1,"// Core Interface multi-query to extract metadata and child nodes"); - out(1,"static auto keys()"); + out(1,"static auto KEYS()"); out(1,"{"); - // keys() contents - int count = 0, total = per.nfields(); + // KEYS() contents + int count = 0; + const int total = per.nfields(); if (total == 0) out(2,"return std::tuple<>{};"); else { @@ -892,21 +1013,24 @@ void writeClassForComponent(writer &out, const PerClass &per) out(3,"// metadata"); for (const auto &m : per.metadata) { out(3,"@{@}", m.typeFull, initializer(m)); - out(4,"/ Meta<>(\"@\")@", m.name, ++count < total ? " |" : ""); + out(4,"/ Meta<>(\"@\")@", m.original, ++count < total ? " |" : ""); } // children if (per.children.size() || per.variants.size()) out(3,"// children"); for (const auto &c : per.children) { - out(3,"@{}", c.typeHalf); // w/o any std::vector - out(4,"/ @Child<>(\"@\")@", - c.isVector ? "++" : "--", c.name, ++count < total ? " |" : ""); + out(3,"@Child<@>(\"@\")@", + c.isVector ? "++" : "--", + c.typeHalf, // without any std::vector + c.original, + ++count < total ? " |" : "" + ); } // variants for (const auto &v : per.variants) { - out(3,"@{}", v.typeHalf); // w/o any std::vector + out(3,"@{}", v.typeHalf); // without any std::vector out(4,"/ @(", v.isVector ? "++" : "--", false); int n = 0; // for alternatives; not to be confused w/count for (const auto &c : v.children) @@ -917,7 +1041,7 @@ void writeClassForComponent(writer &out, const PerClass &per) out(2,";"); } - // keys() end + // KEYS() end out(1,"}"); out(); out("public:"); @@ -926,39 +1050,90 @@ void writeClassForComponent(writer &out, const PerClass &per) // Class suffix void writeClassSuffix( - writer &out, const PerClass &per, const std::string &version + writer &out, const PerClass &per, const InfoSpecs &specs ) { + // ------------------------ // assignment + // ------------------------ + out(); out(1,smallComment); - out(1,"// Assignment"); + out(1,"// Assignment operators"); out(1,smallComment); out(); - out(1,"// copy"); - out(1,"@ &operator=(const @ &) = default;", per.clname, per.clname); - out(); - out(1,"// move"); - out(1,"@ &operator=(@ &&) = default;", per.clname, per.clname); + if (printCtorCalls) { + // copy + out(1,"// copy"); + out(1,"@ &operator=(const @ &other)", per.clname, per.clname); + out(1,"{"); + out(2,"if (this != &other) {"); + out(3,"std::cout << \"assign: @: copy\" << std::endl;", per.clname); + out(3,"Component::operator=(other);"); + if (per.nfields() > 0) { + for (const auto &m : per.metadata) + out(3,"@ = other.@;", m.name, m.name); + for (const auto &c : per.children) + out(3,"@ = other.@;", c.name, c.name); + for (const auto &v : per.variants) + out(3,"@ = other.@;", v.name, v.name); + } + out(2,"}"); + out(2,"return *this;"); + out(1,"}"); + out(); + + // move + out(1,"// move"); + out(1,"@ &operator=(@ &&other)", per.clname, per.clname); + out(1,"{"); + out(2,"if (this != &other) {"); + out(3,"std::cout << \"assign: @: move\" << std::endl;", per.clname); + out(3,"Component::operator=(std::move(other));"); + if (per.nfields() > 0) { + for (const auto &m : per.metadata) + out(3,"@ = std::move(other.@);", m.name, m.name); + for (const auto &c : per.children) + out(3,"@ = std::move(other.@);", c.name, c.name); + for (const auto &v : per.variants) + out(3,"@ = std::move(other.@);", v.name, v.name); + } + out(2,"}"); + out(2,"return *this;"); + out(1,"}"); + + } else { + // copy + out(1,"@ &operator=(const @ &) = default;", per.clname, per.clname); + // move + out(1,"@ &operator=(@ &&) = default;", per.clname, per.clname); + } + + // ------------------------ // customization #include + // ------------------------ + out(); out(1,smallComment); out(1,"// Custom functionality"); out(1,smallComment); out(); - out(1,"#include \"GNDStk/@/@/@/src/custom.hpp\"", - version, per.nsname, per.clname); + out(1,"#include \"@/@/@/@/src/custom.hpp\"", + specs.Project, specs.Version, per.nsname, per.clname); + // this *follows* the customization #include (because it might be used there) + out(1,"#undef GNDSTK_COMPONENT"); + + // ------------------------ // class+namespace end - out(); + // ------------------------ + out("}; // class @", per.clname); out(); out("} // namespace @", per.nsname); } // writeClassSuffix - - // ----------------------------------------------------------------------------- // writeClass* // For metadata, children, and variant children @@ -967,251 +1142,71 @@ void writeClassSuffix( // writeClassContentMetadata void writeClassContentMetadata(writer &out, const PerClass &per) { - if (per.metadata.size()) - out(2,"// metadata"); + if (per.metadata.size()) { + out(); + out(1,"// metadata"); + } + for (const auto &m : per.metadata) { per.isData && ( m.name == "length" || m.name == "start" || m.name == "valueType") - ? out(2,"mutable @ @", m.typeFull, m.name, false) - : out(2, "@ @", m.typeFull, m.name, false); + ? out(1,"mutable Field<@> @{this", m.typeFull, m.name, false) + : out(1, "Field<@> @{this", m.typeFull, m.name, false); if (m.defaultValue != "") - out("{@}", initializer(m), false); - out(";"); + out(",defaults.@", m.name, false); + out("};"); } } // writeClassContentChildren void writeClassContentChildren(writer &out, const PerClass &per) { - if (per.children.size()) - out(2,"// children"); - for (const auto &c : per.children) - out(2,"@ @;", c.typeFull, c.name); + if (per.children.size()) { + out(); + out(1,"// children"); + } + for (const auto &c : per.children) { + out(1,"Field<@> @{this};", c.typeFull, c.name); + + if (debugging && c.name == "xs") { + // todo + // Consider some terminology changes... + // ns ==> nsname + // plain ==> key (as in, the JSON key) + // typeFull ==> ? + // typeHalf ==> ? + // Also ordering: + // nsname + // key + // name + // type + // typeFull + // typeHalf + std::cout << "name == " << c.name << std::endl; + std::cout << "ns == " << c.ns << std::endl; + std::cout << "plain == " << c.plain << std::endl; + std::cout << "type == " << c.type << std::endl; + std::cout << "typeFull == " << c.typeFull << std::endl; + std::cout << "typeHalf == " << c.typeHalf << std::endl; + } + } } // writeClassContentVariants void writeClassContentVariants(writer &out, const PerClass &per) { - if (per.variants.size()) - out(2,"// children - variant"); - for (const auto &v : per.variants) - out(2,"@ @;", v.typeFull, v.name); -} - - - -// ----------------------------------------------------------------------------- -// writeClassGetters -// ----------------------------------------------------------------------------- - -void writeClassGetters(writer &out, const PerClass &per) -{ - out(); - out(1,smallComment); - out(1,"// Getters"); - out(1,"// const and non-const"); - out(1,smallComment); - - const auto write = - [&out](auto &&i, const bool isVector) - { - // i: info for metadatum, child, or variant - out(); - out(1,"// @", i.name); - out(1,"const @ &@() const", i.typeFull, i.name); - out(2,"{ return content.@; }", i.name); - out(1, "@ &@()", i.typeFull, i.name); - out(2,"{ return content.@; }", i.name); - - const auto indlab = - [&out,&i](const auto &T, const auto &par) - { - // T par: index or label parameter - out(); - out(1,"// @(@)", i.name, par); - out(1,"const @ &@(const @@) const", i.type, i.name, T, par); - out(2,"{ return getter(@(), @, \"@\"); }", i.name, par, i.name); - out(1, "@ &@(const @@)", i.type, i.name, T, par); - out(2,"{ return getter(@(), @, \"@\"); }", i.name, par, i.name); - }; - - if (isVector) { - // with index or label - indlab("std::size_t ", "index"); - indlab("std::string &", "label"); - } - }; - - // metadata, children, variants - for (const auto &m : per.metadata) write(m, false); - for (const auto &c : per.children) write(c, c.isVector); - for (const auto &v : per.variants) write(v, v.isVector); - - // variant alternatives - for (const auto &v : per.variants) { - for (const auto &c : v.children) { - const auto indlab = - [&out,&v,&c](const auto &T, const auto &par) - { - // T par: index or label parameter - out(); - out(1,"// @(@)", c.name, par); - out(1,"const @ *@(const @@) const", c.type, c.name, T, par); - out(2,"{ return getter<@>(@(), @, \"@\"); }", - c.type, v.name, par, c.name); - out(1, "@ *@(const @@)", c.type, c.name, T, par); - out(2,"{ return getter<@>(@(), @, \"@\"); }", - c.type, v.name, par, c.name); - }; - - if (v.isVector) { - // with index or label - indlab("std::size_t ", "index"); - indlab("std::string &", "label"); - } else { - out(); - out(1,"// @", c.name); - out(1,"const @ *@() const", c.type, c.name); - out(2,"{ return getter<@>(@(), \"@\"); }", c.type, v.name, c.name); - out(1, "@ *@()", c.type, c.name); - out(2,"{ return getter<@>(@(), \"@\"); }", c.type, v.name, c.name); - } - } - } -} // writeClassGetters - - - -// ----------------------------------------------------------------------------- -// writeClassSetter* -// ----------------------------------------------------------------------------- - -// writeClassSetterChild -template // InfoChildren or InfoVariants -void writeClassSetterChild( - writer &out, const PerClass &parent, const INFO &child -) { - // setter - // note that if type is optional, a T can still be sent - out(); - out(1,"// @(value)", child.name); - out(1,"@ &@(const @ &obj)", parent.clname, child.name, child.typeFull); - out(2,"{ @() = obj; return *this; }", child.name); - - const auto indlab = - [&out,&parent,&child](const auto &T, const auto &par) - { - // T par: index or label parameter - out(); - out(1,"// @(@,value)", child.name, par); - out(1,"@ &@(", parent.clname, child.name); - out(2,"const @@,", T, par); - out(2,"const @ &obj", child.type); - out(1,") {"); - out(2,"@(@) = obj; return *this;", child.name, par); - out(1,"}"); - }; - - // with index or label - if (child.isVector) { - indlab("std::size_t ", "index"); - indlab("std::string &", "label"); - } -} // writeClassSetterChild - - -// writeClassSetters -void writeClassSetters(writer &out, const PerClass &per) -{ - out(); - out(1,smallComment); - out(1,"// Setters"); - out(1,"// non-const"); - out(1,"// All return *this"); - out(1,smallComment); - - // Reminder: - // metadata can have: optional, defaulted (but not vector) - // children can have: optional, vector (but not defaulted) - - // metadata - for (const auto &m : per.metadata) { + if (per.variants.size()) { out(); - out(1,"// @(value)", m.name); - - // special cases: we want to send length, start, and valueType - // to the BodyText base as well - const bool special = - per.isData && - (m.name == "length" || m.name == "start" || m.name == "valueType"); - - // setter - // note that if type is optional, a T can still be sent - out(1,"@ &@(const @ &obj)", per.clname, m.name, m.typeFull); - if (special && m.isDefaulted) - out(2,"{ BodyText::@(content.@ = obj); return *this; }", - m.name, m.name); - if (special && !m.isDefaulted) - out(2,"{ BodyText::@(@() = obj); return *this; }", - m.name, m.name); - if (!special && m.isDefaulted) - out(2,"{ content.@ = obj; return *this; }", - m.name); - if (!special && !m.isDefaulted) - out(2,"{ @() = obj; return *this; }", - m.name); - - // setter, if type is Defaulted - if (m.isDefaulted) { - out(1,"@ &@(const std::optional<@> &obj)", per.clname, m.name, m.type); - special - ? out(2,"{ BodyText::@(content.@ = obj); return *this; }", - m.name, m.name) - : out(2,"{ content.@ = obj; return *this; }", m.name); - } + out(1,"// children - variant"); } - - // children, variants - for (const auto &c : per.children) writeClassSetterChild(out, per, c); - for (const auto &v : per.variants) writeClassSetterChild(out, per, v); - - // variant alternatives for (const auto &v : per.variants) { - if (v.isVector) { - // choice is a vector - for (const auto &c : v.children) { - const auto indlab = - [&out,&per,&v,&c](const auto &T, const auto &par) - { - // T par: index or label parameter - out(); - out(1,"// @(@,value)", c.name, par); - out(1,"@ &@(", per.clname, c.name); - out(2,"const @@,", T, par); - out(2,"const std::optional<@> &obj", c.type); - out(1,") {"); - out(2,"if (obj) @(@,obj.value());", v.name, par); - out(2,"return *this;"); - out(1,"}"); - }; - - // with index or label - indlab("std::size_t ", "index"); - indlab("std::string &", "label"); - } - } else { - // choice is a variant - for (const auto &c : v.children) { - out(); - out(1,"// @(value)", c.name); - out(1,"@ &@(const std::optional<@> &obj)", - per.clname, c.name, c.type); - out(2,"{ if (obj) @(obj.value()); return *this; }", v.name); - } + out(1,"Field<@> @{this};", v.typeFull, v.name); + for (const auto &c : v.children) { + out(1,"FieldPart @{@};", + v.name, c.type, c.name, v.name); } } -} // writeClassSetters - +} // ----------------------------------------------------------------------------- @@ -1220,83 +1215,74 @@ void writeClassSetters(writer &out, const PerClass &per) // writeClassCtorComponent void writeClassCtorComponent( - writer &out, const PerClass &per, const bool hasOther + writer &out, const PerClass &per, const bool copyOrMove, + const bool newline = true ) { - out(2,"Component{"); - out(3, hasOther ? "other" : "BodyText{}", false); - - for (const auto &m : per.metadata) { // metadata - out(","); - out(3,"content.@", m.name, false); - } - for (const auto &c : per.children) { // children - out(","); - out(3,"content.@", c.name, false); - } - for (const auto &v : per.variants) { // variants - out(","); - out(3,"content.@", v.name, false); - } - - out(); - out(2,"}",false); -} // writeClassCtorComponent + out(2,"GNDSTK_COMPONENT(@)", + std::string(copyOrMove ? "other.baseBlockData()" : "BlockData{}"), + newline); +} // writeClassCtorBody -void writeClassCtorBody(writer &out, const std::string &argName) -{ +void writeClassCtorBody( + writer &out, + const std::string &kind, + const std::string &clname, + const std::string &argName +) { out(1,"{"); + if (printCtorCalls) + out(2,"std::cout << \"ctor: @: @\" << std::endl;", clname, kind); out(2,"Component::finish(@);", argName); out(1,"}"); -} // writeClassCtorBody +} // writeClassCtors void writeClassCtors(writer &out, const PerClass &per) { - // ctor: default - out(); - out(1,"// default"); - out(1,"@() :", per.clname); - writeClassCtorComponent(out, per, false); - out(); - writeClassCtorBody(out, ""); + // ------------------------ + // macro + // ------------------------ - // ctor: copy + int count; const int total = per.nfields(); out(); - out(1,"// copy"); - out(1,"@(const @ &other) :", per.clname, per.clname); - writeClassCtorComponent(out, per, true); - out(","); - out(2,"content{other.content}"); - writeClassCtorBody(out, "other"); - // ctor: move - out(); - out(1,"// move"); - out(1,"@(@ &&other) :", per.clname, per.clname); - writeClassCtorComponent(out, per, true); - out(","); - out(2,"content{std::move(other.content)}"); - writeClassCtorBody(out, "other"); + if (total == 0) + out(1,"#define GNDSTK_COMPONENT(blockdata) Component(blockdata)"); + else { + out(1,"#define GNDSTK_COMPONENT(blockdata) Component(blockdata, \\"); + count = 0; + for (const auto &m : per.metadata) + out(2,"this->@@", m.name, ++count < total ? ", \\" : ")"); + for (const auto &c : per.children) + out(2,"this->@@", c.name, ++count < total ? ", \\" : ")"); + for (const auto &v : per.variants) + out(2,"this->@@", v.name, ++count < total ? ", \\" : ")"); + } + + // ------------------------ + // ctor: default + // ------------------------ - // ctor: node out(); - out(1,"// from node"); - out(1,"@(const Node &node) :", per.clname); + out(1,"// default"); + out(1,"@() :", per.clname); writeClassCtorComponent(out, per, false); - out(); - writeClassCtorBody(out, "node"); + writeClassCtorBody(out, "default", per.clname, ""); // ------------------------ - // ctor: fields + // ctor: from fields // ------------------------ - const auto total = per.nfields(); - if (total != 0) { + if (total > 0) { out(); + + // comment for this constructor out(1,"// from fields"); + + // informational message, if applicable for (const auto &m : per.metadata) if (m.isDefaulted) { out(1,"// std::optional replaces Defaulted; " @@ -1305,45 +1291,71 @@ void writeClassCtors(writer &out, const PerClass &per) } // signature, and base constructor call - // Note: we don't need "explicit" unless this constructor can be called - // with one argument. We'll always write it, however, in case someone - // modifies the auto-generated constructor (say, giving its arguments - // defaults) in such a way that is *can* be called with one argument. - // But we'd rather nobody modify the auto-generated classes. - int count = 0; + count = 0; out(1,"explicit @(", per.clname); - for (const auto &m : per.metadata) - out(2,"const @ &@@", - m.isDefaulted ? "std::optional<" + m.type + ">" : m.typeFull, - m.name, ++count < total ? "," : ""); - for (const auto &c : per.children) - out(2,"const @ &@@", c.typeFull, c.name, ++count < total ? "," : ""); - for (const auto &v : per.variants) - out(2,"const @ &@@", v.typeFull, v.name, ++count < total ? "," : ""); + + for (const auto &m : per.metadata) { + out( + 2,"const wrapper<@> &@@@", + m.isDefaulted ? "std::optional<" + m.type + ">" : m.typeFull, + m.name, + count ? " = {}" : "", + count+1 < total ? "," : "" + ); + count++; + } + for (const auto &c : per.children) { + out( + 2,"const wrapper<@> &@@@", + c.typeFull, + c.name, + count ? " = {}" : "", + count+1 < total ? "," : "" + ); + count++; + } + for (const auto &v : per.variants) { + out( + 2,"const wrapper<@> &@@@", + v.typeFull, + v.name, + count ? " = {}" : "", + count+1 < total ? "," : "" + ); + count++; + } out(1,") :"); - writeClassCtorComponent(out, per, false); + writeClassCtorComponent(out, per, false, false); // initialize fields out(","); - out(2,"content{"); count = 0; for (const auto &m : per.metadata) - out(3,"@@", - m.isDefaulted - ? "Defaulted<"+m.type+">(defaults."+m.name+","+m.name+")" - : m.name, - ++count < total ? "," : ""); + if (m.isDefaulted) + out(2,"@(this,defaults.@,@)@", + m.name, m.name, m.name, sep(count,total)); + else + out(2,"@(this,@)@", m.name, m.name, sep(count,total)); for (const auto &c : per.children) - out(3,"@@", c.name, ++count < total ? "," : ""); + out(2,"@(this,@)@", c.name, c.name, sep(count,total)); for (const auto &v : per.variants) - out(3,"@@", v.name, ++count < total ? "," : ""); - out(2,"}"); + out(2,"@(this,@)@", v.name, v.name, sep(count,total)); // body - writeClassCtorBody(out, ""); + writeClassCtorBody(out, "fields", per.clname, ""); } + // ------------------------ + // ctor: node + // ------------------------ + + out(); + out(1,"// from node"); + out(1,"explicit @(const Node &node) :", per.clname); + writeClassCtorComponent(out, per, false); + writeClassCtorBody(out, "node", per.clname, "node"); + // ------------------------ // ctor: vector // ------------------------ @@ -1352,14 +1364,52 @@ void writeClassCtors(writer &out, const PerClass &per) out(); out(1,"// from vector"); out(1,"template>>"); + "std::enable_if_t>>"); out(1,"@(const std::vector &vector) :", per.clname); writeClassCtorComponent(out, per, false); - out(); - writeClassCtorBody(out, "vector"); + writeClassCtorBody(out, "vector", per.clname, "vector"); } -} // writeClassCtors + // ------------------------ + // ctor: copy + // ------------------------ + + out(); + out(1,"// copy"); + out(1,"@(const @ &other) :", per.clname, per.clname); + writeClassCtorComponent(out, per, true, total == 0); + if (total > 0) { + out(","); + count = 0; + for (const auto &m : per.metadata) + out(2,"@(this,other.@)@", m.name, m.name, sep(count,total)); + for (const auto &c : per.children) + out(2,"@(this,other.@)@", c.name, c.name, sep(count,total)); + for (const auto &v : per.variants) + out(2,"@(this,other.@)@", v.name, v.name, sep(count,total)); + } + writeClassCtorBody(out, "copy", per.clname, "other"); + + // ------------------------ + // ctor: move + // ------------------------ + + out(); + out(1,"// move"); + out(1,"@(@ &&other) :", per.clname, per.clname); + writeClassCtorComponent(out, per, true, total == 0); + if (total > 0) { + out(","); + count = 0; + for (const auto &m : per.metadata) + out(2,"@(this,std::move(other.@))@", m.name, m.name, sep(count,total)); + for (const auto &c : per.children) + out(2,"@(this,std::move(other.@))@", c.name, c.name, sep(count,total)); + for (const auto &v : per.variants) + out(2,"@(this,std::move(other.@))@", v.name, v.name, sep(count,total)); + } + writeClassCtorBody(out, "move", per.clname, "other"); +} // writeClassCtors // ----------------------------------------------------------------------------- @@ -1373,79 +1423,67 @@ void writeClass(PerClass &per, const InfoSpecs &specs) writer out(false); // output: class begin - writeClassPrefix(out,per); + writeClassPrefix(out, per); // output: for the Component base - writeClassForComponent(out,per); + writeClassForComponent(out, per); // output: using directives - out(); out(1,"using Component::construct;"); if (per.isData) - out(1,"using BodyText::operator=;"); + out(1,"using BlockData::operator=;"); // output: defaults (applicable only to metadata) - out(); - out(1,smallComment); - out(1,"// Relevant defaults"); - out(1,"// FYI for users"); - out(1,smallComment); - out(); - out(1,"static inline const struct Defaults {"); + std::size_t ndefaults = 0; for (auto &m : per.metadata) if (m.isDefaulted) - out(2,"static inline const @ @ = @;", m.type, m.name, initializer(m)); - out(1,"} defaults;"); + ++ndefaults; + if (ndefaults > 0) { + out(); + out(1,"// defaults"); + out(1,"static inline const struct Defaults {"); + for (auto &m : per.metadata) + if (m.isDefaulted) + out(2, "static inline const @ @ = @;", + m.type, m.name, initializer(m)); + out(1,"} defaults;"); + } - // output: content (the metadata/children computed earlier) - out(); - out(1,smallComment); - out(1,"// Raw GNDS content"); - out(1,smallComment); - out(); - out(1,"struct {"); + // output: fields writeClassContentMetadata(out, per); writeClassContentChildren(out, per); writeClassContentVariants(out, per); - out(1,"} content;"); - - // output: getters, setters - if (per.metadata.size() || per.children.size() || per.variants.size()) { - writeClassGetters(out, per); - writeClassSetters(out, per); - } // output: constructors out(); out(1,smallComment); - out(1,"// Construction"); + out(1,"// Constructors"); out(1,smallComment); writeClassCtors(out, per); // output: class end - writeClassSuffix(out, per, specs.Version); + writeClassSuffix(out, per, specs); // done per.code = out.str(); } // writeClass - // ----------------------------------------------------------------------------- // Miscellaneous functions for getting JSON content // ----------------------------------------------------------------------------- // readJSONFile -nlohmann::json readJSONFile(const std::string &file, const bool print = false) +orderedJSON readJSONFile(const std::string &file, const bool print = false) { static const std::string underlineON = "\033[4m"; static const std::string underlineOFF = "\033[24m"; - // Depending on call context, we might want to print the file name + // Depending on the call context, we might or might not print the file name if (print) { - std::cout << " "; - std::cout << underlineON << "File:" << underlineOFF << " "; - std::cout << '"' << colors::vivid::green << file << colors::reset << '"'; + const std::string f = beginsin(file,"./") ? std::string(&file[2]) : file; + std::cout << "File: "; + std::cout << '"' << colors::plain::purple << f << colors::reset << '"'; std::cout << std::endl; } @@ -1455,7 +1493,7 @@ nlohmann::json readJSONFile(const std::string &file, const bool print = false) throw std::exception{}; } - nlohmann::json j; + orderedJSON j; ifs >> j; return j; } // readJSONFile @@ -1463,7 +1501,7 @@ nlohmann::json readJSONFile(const std::string &file, const bool print = false) // getMetadataJSON template -auto getMetadataJSON(const nlohmann::json &j) +auto getMetadataJSON(const orderedJSON &j) { static const std::string metastr = "metadata"; static const std::string attrstr = "attributes"; @@ -1476,15 +1514,15 @@ auto getMetadataJSON(const nlohmann::json &j) return meta ? j[metastr] : j[attrstr]; } else { assert(!(meta && attr)); // not both - return std::optional( - meta ? j[metastr] : attr ? j[attrstr] : nlohmann::json{}); + return std::optional( + meta ? j[metastr] : attr ? j[attrstr] : orderedJSON{}); } } // getMetadataJSON // getChildrenJSON template -auto getChildrenJSON(const nlohmann::json &j) +auto getChildrenJSON(const orderedJSON &j) { static const std::string chldstr = "children"; static const std::string nodestr = "childNodes"; @@ -1497,13 +1535,12 @@ auto getChildrenJSON(const nlohmann::json &j) return chld ? j[chldstr] : j[nodestr]; } else { assert(!(chld && node)); // not both - return std::optional( - chld ? j[chldstr] : node ? j[nodestr] : nlohmann::json{}); + return std::optional( + chld ? j[chldstr] : node ? j[nodestr] : orderedJSON{}); } } // getChildrenJSON - // ----------------------------------------------------------------------------- // commandLine and its helper functions // ----------------------------------------------------------------------------- @@ -1511,7 +1548,7 @@ auto getChildrenJSON(const nlohmann::json &j) // readChangesFile void readChangesFile(const std::string &file, InfoSpecs &specs) { - const nlohmann::json jchanges = readJSONFile(file); + const orderedJSON jchanges = readJSONFile(file); using pair = std::pair; // Changes to name? @@ -1540,36 +1577,41 @@ void readChangesFile(const std::string &file, InfoSpecs &specs) // printSingletons void printSingletons(const std::string &file) { - const nlohmann::json &jfile = readJSONFile(file,true); + const orderedJSON &jfile = readJSONFile(file,true); for (const auto &item : jfile.items()) { const std::string parent = item.key(); - const nlohmann::json rhs = item.value(); + const orderedJSON rhs = item.value(); if (!isClass(item)) continue; const auto metadata = getMetadataJSON(rhs); const auto children = getChildrenJSON(rhs); - - if (metadata.size() == 0 && children.size() == 0) - log::info("Class \"{}\" has no metadata and no children", parent); - if (metadata.size() == 0 && children.size() == 1) - log::info("Class \"{}\" has no metadata and just one child", parent); + const bool data = rhs.contains("data") && !rhs["data"].is_null(); + const bool body = rhs.contains("bodyText") && !rhs["bodyText"].is_null(); + + if (metadata.size() == 0 && children.size() == 0 && !data && !body) + log::info("This class has no metadata, data, or children: " + "\"{}\"", parent); + if (metadata.size() == 0 && children.size() == 1 && !data && !body) + log::info("This class has no metadata or data, and just one child: " + "\"{}\"", parent); } } // printSingletons // commandLine -// Gather information from the .json file given on the command line +// Gather information from the JSON file given on the command line void commandLine( const int argc, const char *const *const argv, InfoSpecs &specs ) { - // Keys we'll look for + // JSON keys we'll look for + static const std::string path = "Path"; + static const std::string project = "Project"; + static const std::string version = "Version"; static const std::string input = "JSONDir"; static const std::string files = "JSONFiles"; - static const std::string output = "GNDSDir"; - static const std::string version = "Version"; static const std::string changes = "Changes"; // Usage @@ -1579,21 +1621,31 @@ void commandLine( } // Input file - const nlohmann::json jmain = readJSONFile(argv[1]); + const orderedJSON jmain = readJSONFile(argv[1]); - // Validate content - if (!(jmain.contains(input) && jmain.contains(output) && - jmain.contains(files) && jmain.contains(version))) { - log::error("The input json file needs {}, {}, {}, and {}", - input, files, output, version); + // Need "Version" + if (!jmain.contains(version)) { + log::error("The input JSON file needs {}", version); throw std::exception{}; } - // Extract information from the command line .json - specs.JSONDir = jmain[input]; - specs.JSONFiles = std::vector(jmain[files]); - specs.GNDSDir = jmain[output]; - specs.Version = jmain[version]; + // Need "JSONFiles" + if (!jmain.contains(files)) { + log::error("The input JSON file needs {}", files); + throw std::exception{}; + } + + // Extract information from the command line JSON file... + // ...these are optional: + specs.Path = jmain.contains(path ) ? jmain[path ] : "."; + specs.Project = jmain.contains(project) ? jmain[project] : "GNDStk"; + specs.JSONDir = jmain.contains(input ) ? jmain[input ] : "."; + // ...these are required: + specs.Version = jmain[version]; + for (const auto &str : jmain[files]) + specs.JSONFiles.push_back(str); + + // Version, with underscores in place of periods specs.VersionUnderscore = replace(specs.Version, '.', '_'); // Prepend the JSON file names with their directory @@ -1601,12 +1653,26 @@ void commandLine( file = specs.JSONDir + '/' + file; // File names - specs.hppVersion = specs.GNDSDir + "/src/GNDStk/" + specs.Version + ".hpp"; - specs.hppKey = specs.GNDSDir + "/src/GNDStk/" + specs.Version + "/key.hpp"; + { + // For C++ + const std::string base = + specs.Path + "/" + specs.Project + "/src/" + specs.Project + "/"; + specs.hppVersion = base + specs.Version + ".hpp"; + specs.hppKey = base + specs.Version + "/key.hpp"; + } + { + // For the C interface + const std::string base = + specs.Path + "/" + specs.Project + "/c/src/"; + specs.hVersion = base + specs.Version + ".h"; + // We don't currently know of anything that we'd have in the following + // file, so we won't create it. But I'll leave this in as a placeholder. + specs.cVersion = base + specs.Version + ".cpp"; + } // Report on "singletons" if (singletons) { - action("Finding possible simplifications"); + action("Finding Possible Simplifications"); for (const std::string &file : specs.JSONFiles) printSingletons(file); } @@ -1617,7 +1683,6 @@ void commandLine( } // commandLine - // ----------------------------------------------------------------------------- // preprocess* functions // ----------------------------------------------------------------------------- @@ -1641,21 +1706,24 @@ void preprocessClass( // custom files as needed // ------------------------ - // Given the base GNDS directory and the GNDS version, as obtained earlier - // from the JSON input file to this tool, compute relevant directory names. - const std::string - // For the present namespace: C++ and Python directories. The present - // namespace probably contains multiple classes, so its directories - // may have been created already, but that's fine. - nsdir = specs.GNDSDir + "/src/GNDStk/" + specs.Version + "/" + nsname, - nsdirpy = specs.GNDSDir + "/python/src/" + specs.Version + "/" + nsname, - // For the present class: C++ source and test directories. - clsrc = nsdir + "/" + clname + "/src", - cltest = nsdir + "/" + clname + "/test"; + // For the present namespace: C++, Python, and C directories. The present + // namespace probably contains multiple classes, so these directories may + // have been created already, but that's fine. + const std::string nsdir = specs.Path + "/" + specs.Project + + "/src/" + specs.Project + "/" + specs.Version + "/" + nsname; + const std::string nsdirpy = specs.Path + "/" + specs.Project + + "/python/src/" + specs.Version + "/" + nsname; + const std::string nsdirc = specs.Path + "/" + specs.Project + + "/c/src/" + specs.Version + "/" + nsname; + + // For the present class: C++ source and test directories. + const std::string clsrc = nsdir + "/" + clname + "/src"; + const std::string cltest = nsdir + "/" + clname + "/test"; // Create the above directories, if (and only if) they don't already exist. system(("mkdir -p " + nsdir ).data()); system(("mkdir -p " + nsdirpy).data()); + system(("mkdir -p " + nsdirc ).data()); system(("mkdir -p " + clsrc ).data()); system(("mkdir -p " + cltest ).data()); @@ -1688,11 +1756,14 @@ void preprocessClass( // For this namespace::class: // The cpp file for Python // The hpp file for GNDStk + // The C/C++ header, and the C++ backend for the C interface auto cl = specs.class2data.insert( std::make_pair(NamespaceAndClass{nsname,clname}, PerClass{})); assert(cl.second); // should have been inserted - not there already cl.first->second.cppPython = nsdirpy + "/" + clname + ".python.cpp"; cl.first->second.hppGNDStk = nsdir + "/" + clname + ".hpp"; + cl.first->second.headerC = nsdirc + "/" + clname + ".h"; + cl.first->second.sourceC = nsdirc + "/" + clname + ".cpp"; } // preprocessClass @@ -1708,10 +1779,10 @@ void preprocessClass( // names are computed as part of the "information" for the maps just mentioned. void preprocessFiles(InfoSpecs &specs) { - action("Preprocessing input files"); + action("Preprocessing"); // files for (const std::string &file : specs.JSONFiles) { - const nlohmann::json jmain = readJSONFile(file,true); + const orderedJSON jmain = readJSONFile(file,true); const std::string nsname = getFileNamespace(jmain); // classes in the file for (const auto &cl : jmain.items()) @@ -1720,7 +1791,6 @@ void preprocessFiles(InfoSpecs &specs) } // preprocessFiles - // ----------------------------------------------------------------------------- // validate* // getClass @@ -1728,7 +1798,7 @@ void preprocessFiles(InfoSpecs &specs) // ----------------------------------------------------------------------------- // Helper: validateMetadata -void validateMetadata(const nlohmann::json &metadata) +void validateMetadata(const orderedJSON &metadata) { for (const auto &field : metadata.items()) { assert(field.value().contains("type")); @@ -1738,19 +1808,32 @@ void validateMetadata(const nlohmann::json &metadata) // Helper: validateChildren -void validateChildren(const nlohmann::json &children) +void validateChildren(const orderedJSON &children, const PerClass &per) { for (const auto &field : children.items()) { - assert(field.value().contains("occurrence")); assert(field.value().contains("required")); - // Consistency check: certain "occurrence" values imply *not* required. + // Consistency check: certain occurrence values imply *not* required. // Remark: the GNDS manual speaks of "choice2" and "choice2+" options // for occurrence. We're not sure if those will remain in future GNDS // specifications, so we won't worry now about how they might fit in. - const std::string occ = field.value()["occurrence"]; - if (occ == "0+" || occ == "choice" || occ == "choice+") + const std::string times = getTimes(per,field.key(),field.value()); + if (times == "0+" || times == "choice" || times == "choice+") assert(!field.value()["required"]); // not required + + if (debugging) { + const std::string key = field.key(); + const std::string name = field.value().contains("name") + ? std::string(field.value()["name"]) + : key; + std::cout + << "child: " + << std::setw(20) << std::left << per.nsname << " " + << std::setw(48) << std::left << per.clname << " " + << std::setw(48) << std::left << key << " " + << (key == name ? " " : "*") << " " + << std::left << name << std::endl; + } } } @@ -1776,13 +1859,13 @@ void getClass( // names per.nsname = nsname; per.clname = clname; - per.nameGNDS = nameGNDS(keyval); + per.nameGNDS = nameGNDS(keyval,nsname,true); // metadata/children information - const nlohmann::json attrs = getMetadataJSON(classRHS); - const nlohmann::json elems = getChildrenJSON(classRHS); + const orderedJSON attrs = getMetadataJSON(classRHS); + const orderedJSON elems = getChildrenJSON(classRHS); validateMetadata(attrs); - validateChildren(elems); + validateChildren(elems, per); getClassMetadata(attrs, specs, per); getClassChildren(elems, specs, per, dep); getClassVariants(elems, specs, per, dep); @@ -1794,7 +1877,13 @@ void getClass( const bool body = classRHS.contains(bodystr) && !classRHS[bodystr].is_null(); assert(!(data && body)); // not both per.isData = data || body; - per.dataType = data ? classRHS[datastr] : ""; + if (data) { + // A type change, as with metadata, may be warranted here as well + const std::string type = classRHS[datastr]; + const auto it = specs.mapMetaType.find(type); + per.dataType = it == specs.mapMetaType.end() ? type : it->second; + } else + per.dataType = ""; // per.code will contain printed C++ code for the class itself writeClass(per,specs); @@ -1807,10 +1896,10 @@ void getClass( // getFiles void getFiles(InfoSpecs &specs) { - action("Creating classes"); + action("Generating Code"); // files for (const std::string &file : specs.JSONFiles) { - const nlohmann::json jmain = readJSONFile(file,true); + const orderedJSON jmain = readJSONFile(file,true); const std::string nsname = getFileNamespace(jmain); // classes in the file for (const auto &cl : jmain.items()) @@ -1819,7 +1908,6 @@ void getFiles(InfoSpecs &specs) } // getFiles - // ----------------------------------------------------------------------------- // Functions relating to our topological sort // Adapted from: http://coliru.stacked-crooked.com/a/7c0bf8d3443b804d @@ -1856,61 +1944,91 @@ void sortDependencies(InfoSpecs &specs) } - // ----------------------------------------------------------------------------- -// Functions for creating output files +// For the C++ header files +// fileGNDStkVersion +// fileGNDStkKey +// fileGNDStkClass // ----------------------------------------------------------------------------- +// ------------------------ // fileGNDStkVersion +// ------------------------ + void fileGNDStkVersion(const InfoSpecs &specs) { - // Create an overarching file for this version - writer out(specs.hppVersion); - out(); - out("#ifndef NJOY_GNDSTK_@", allcaps(specs.VersionUnderscore)); - out("#define NJOY_GNDSTK_@", allcaps(specs.VersionUnderscore)); - - std::string nsname_last = ""; - for (auto &c : specs.class2data) { - const std::string nsname = c.first.nsname; - const std::string clname = c.first.clname; - if (nsname != nsname_last) - out(); - nsname_last = nsname; - out("#include \"GNDStk/@/@/@.hpp\"", specs.Version, nsname, clname); + // ------------------------ + // Create a C++ header + // for this version + // ------------------------ + + { + writer out(specs.hppVersion); + out(); + out("#ifndef @_@", + allcaps(specs.Project), allcaps(specs.VersionUnderscore)); + out("#define @_@", + allcaps(specs.Project), allcaps(specs.VersionUnderscore)); + + std::string nsname_last = ""; + for (auto &c : specs.class2data) { + const std::string nsname = c.first.nsname; + const std::string clname = c.first.clname; + if (nsname != nsname_last) + out(); + nsname_last = nsname; + out("#include \"@/@/@/@.hpp\"", + specs.Project, specs.Version, nsname, clname); + } + + out(); + out("#endif"); } - out(); - out("#include \"GNDStk/@/key.hpp\"", specs.Version); - out(); - out("#endif"); + // ------------------------ + // Create a C/C++ header + // for the C interface + // ------------------------ + + { + writer out(specs.hVersion); + out(); + out(largeComment); + out("// This header file is designed to work with both C and C++"); + out(largeComment); + out(); + out("#ifndef C_INTERFACE_@_@", + allcaps(specs.Project), allcaps(specs.VersionUnderscore)); + out("#define C_INTERFACE_@_@", + allcaps(specs.Project), allcaps(specs.VersionUnderscore)); + + out(); + out("#include \"GNDStk.h\""); + out(); + out("#ifdef __cplusplus"); + out(1,"// For C++"); + out(1,"#include \"@/@.hpp\"", specs.Project, specs.VersionUnderscore); + out("#endif"); + + std::string nsname_last = ""; + for (auto &c : specs.class2data) { + const std::string nsname = c.first.nsname; + const std::string clname = c.first.clname; + if (nsname != nsname_last) + out(); + nsname_last = nsname; + out("#include \"@/@/@.h\"", specs.Version, nsname, clname); + } + + out(); + out("#endif"); + } } // fileGNDStkVersion -// fixme Reconsider the arrangement described here... +// ------------------------ // fileGNDStkKey -const std::string file_key_comment = -R"***( -This file contains Meta and Child objects for metadata and child nodes in the -current GNDS version. These may prove to be useful if you wish to use the Core -Interface in conjunction with the autogenerated classes for this GNDS version. - -Within the outer njoy::GNDStk::version namespace below, the remaining namespace -arrangement was chosen to make the use of these objects smooth and logical. - -Meta and Child objects are collectively called "keys." Meta keys are placed -into key::meta. Child keys correspond to autogenerated classes, each of which -is already in some namespace; we thus use theNamespace::key::child::. That way, -an autogenerated class [ns::Foo] has [ns::key::foo] as its Child object, and -a "using namespace ns" allows the class and the Child object to be [Foo] and -[key::foo], respectively. (If we reordered ns:: and key::, that wouldn't work.) - -Within key::, we use meta:: and child:: around Meta and Child objects, just in -case there exist any identical GNDS metadata names and child-node names. (That -can, in fact, happen). The "using namespace meta" and "using namespace child" -directives then make the Meta<> and Child<> objects appear directly in key::, -so that "meta::" and "child::" are needed only to disambiguate identical names. -)***"; +// ------------------------ void fileGNDStkKey(const InfoSpecs &specs) { @@ -1930,7 +2048,7 @@ void fileGNDStkKey(const InfoSpecs &specs) std::multimap> namespace2children; for (const auto &file : specs.JSONFiles) { - const nlohmann::json jmain = readJSONFile(file); + const orderedJSON jmain = readJSONFile(file); auto it = namespace2children.insert( std::make_pair(getFileNamespace(jmain),std::set{})); @@ -1939,14 +2057,14 @@ void fileGNDStkKey(const InfoSpecs &specs) // nodes ==> children it->second.insert(std::make_pair( nameField(node,specs), - nameGNDS (node))); + nameGNDS(node))); // attributes ==> metadata const auto attrs = getMetadataJSON(node.value()); for (const auto &attr : attrs.items()) metadata.insert(std::make_pair( nameField(attr,specs), - nameGNDS (attr))); + nameGNDS(attr))); } } } @@ -1958,54 +2076,56 @@ void fileGNDStkKey(const InfoSpecs &specs) writer out(specs.hppKey); out(); - out("/*",false); - out(file_key_comment,false); - out("*/"); + out("#ifndef @_@_KEY", + allcaps(specs.Project), allcaps(specs.VersionUnderscore)); + out("#define @_@_KEY", + allcaps(specs.Project), allcaps(specs.VersionUnderscore)); out(); - out("#ifndef NJOY_GNDSTK_@_KEY", allcaps(specs.VersionUnderscore)); - out("#define NJOY_GNDSTK_@_KEY", allcaps(specs.VersionUnderscore)); + out("// GNDStk Core Interface"); + out("#include \"GNDStk.hpp\""); out(); - out("namespace njoy {"); - out("namespace GNDStk {"); + if (specs.Project == "GNDStk") // <== use namespace njoy only for this + out("namespace njoy {"); + out("namespace @ {", specs.Project); out("namespace @ {", specs.VersionUnderscore); + out(); + out("using namespace njoy::GNDStk;"); // ------------------------ // Meta<> objects // ------------------------ + section(out,"// meta::"); out(); - out(); - out(largeComment); - out("// key::meta::"); - out(largeComment); - out(); - out("namespace key {"); out("namespace meta {"); if (metadata.size() > 0) { + out(); + out(0,"#define GNDSTK_MAKE_LOOKUP(nameField,nameGNDS) \\"); + out(1, "inline const auto nameField = makeLookup( \\"); + out(2, "[](const auto &obj) -> decltype(obj.nameField()) \\"); + out(2, "{ return obj.nameField(); }, \\"); + out(2, "#nameGNDS \\"); + out(1, ")"); + out(0, "// nameField vs. nameGNDS: for, e.g., Double vs. double in GNDS"); out(); for (const auto &meta : metadata) - out("inline const Meta<> @(\"@\");", meta.first, meta.second); + out("GNDSTK_MAKE_LOOKUP(@,@);", meta.first, meta.second); + out(); + out(0,"#undef GNDSTK_MAKE_LOOKUP"); out(); } out("} // namespace meta"); - out("using namespace meta;"); - out("} // namespace key"); // ------------------------ // Child<> objects // ------------------------ for (const auto &nspace : namespace2children) { - out(); - out(); - out(largeComment); - out("// @::key::child::", nspace.first); - out(largeComment); + section(out, "// @::child::", nspace.first); out(); out("namespace @ {", nspace.first); - out("namespace key {"); out("namespace child {"); const auto &children = nspace.second; @@ -2018,10 +2138,25 @@ void fileGNDStkKey(const InfoSpecs &specs) out("} // namespace child"); out("using namespace child;"); - out("} // namespace key"); out("} // namespace @", nspace.first); } + // ------------------------ + // Using directives + // ------------------------ + + section(out, "// For convenience: using directives"); + out(); + out("namespace key {"); + out(1,"using namespace meta;"); + for (const auto &nspace : namespace2children) + out(1,"using namespace @::child;", nspace.first); + out("} // namespace key"); + out(); + out("using namespace key;"); + for (const auto &nspace : namespace2children) + out("using namespace @;", nspace.first); + // ------------------------ // finish // ------------------------ @@ -2032,54 +2167,992 @@ void fileGNDStkKey(const InfoSpecs &specs) out(largeComment); out(); out("} // namespace @", specs.VersionUnderscore); - out("} // namespace GNDStk"); - out("} // namespace njoy"); + out("} // namespace @", specs.Project); + if (specs.Project == "GNDStk") // <== end namespace njoy only for this + out("} // namespace njoy"); out(); out("#endif"); } // fileGNDStkKey +// ------------------------ // fileGNDStkClass +// ------------------------ + void fileGNDStkClass( const InfoSpecs &specs, const PerClass &per, const Class2Dependencies &c2d ) { // class-specific hpp file writer out(per.hppGNDStk); const std::string guard = - "NJOY_GNDSTK_" + allcaps(specs.VersionUnderscore) + "_" + - allcaps(per.nsname) + "_" + allcaps(per.clname); + allcaps(specs.Project) + "_" + + allcaps(specs.VersionUnderscore) + "_" + + allcaps(per.nsname) + "_" + + allcaps(per.clname); out(); out("#ifndef @", guard); out("#define @", guard); - out(); - out("// core interface"); - out("#include \"GNDStk.hpp\""); - if (c2d.dependencies.size() > 0) { - out(); - out("// @ dependencies", specs.Version); - for (const auto &dep : c2d.dependencies) - out("#include \"GNDStk/@/@/@.hpp\"", - specs.Version, dep.nsname, dep.clname); - } + out(); + if (c2d.dependencies.size() == 0) // <== otherwise, comes in through deps + out("#include \"@/@/key.hpp\"", specs.Project, specs.Version); + for (const auto &dep : c2d.dependencies) + out("#include \"@/@/@/@.hpp\"", + specs.Project, specs.Version, dep.nsname, dep.clname); out(); - out("namespace njoy {"); - out("namespace GNDStk {"); + if (specs.Project == "GNDStk") + out("namespace njoy {"); + out("namespace @ {", specs.Project); out("namespace @ {", specs.VersionUnderscore); - out(); - out("using namespace njoy::GNDStk::core;"); out(per.code,false); out("} // namespace @", specs.VersionUnderscore); - out("} // namespace GNDStk"); - out("} // namespace njoy"); + out("} // namespace @", specs.Project); + if (specs.Project == "GNDStk") + out("} // namespace njoy"); out(); out("#endif"); } // fileGNDStkClass +// ----------------------------------------------------------------------------- +// C interface: +// Helpers +// ----------------------------------------------------------------------------- + +// two +// Forward args to two places: header and source +template +void two(writer &hdr, writer &src, Ts &&...args) +{ + hdr(std::forward(args)...); + src(std::forward(args)...); +} + +// ext +// For writing (or not writing) 'extern "C"' +template +void ext(writer &hdr, writer &src, const std::string &str, Ts &&...args) +{ + hdr("extern_c "+str, std::forward(args)...); + src( str, std::forward(args)...); +} + +// ppp +// Comment, prefixed in header file with "+++" +template +void ppp(writer &hdr, writer &src, const std::string &str, Ts &&...args) +{ + hdr("// +++ "+str, std::forward(args)...); + src("// " +str, std::forward(args)...); +} +template +void PPP(writer &hdr, writer &src, Ts &&...args) +{ + two(hdr,src); + ppp(hdr,src,std::forward(args)...); +} + +// mmm +// Comment, prefixed in header file with "---" +template +void mmm(writer &hdr, writer &src, const std::string &str, Ts &&...args) +{ + hdr("// --- "+str, std::forward(args)...); + src("// " +str, std::forward(args)...); +} +template +void MMM(writer &hdr, writer &src, Ts &&...args) +{ + two(hdr,src); + mmm(hdr,src,std::forward(args)...); +} + +// sig +// End C interface function signature; style dependent on hadFields bool +void sig(writer &hdr, writer &src, const bool hadFields = false) +{ + // header: end of parameters, semicolon for declaration + hdr(");"); + // source: end of parameters, left brace for definition + src(hadFields ? ") {" : ")\n{"); +} + +// mtype_param +// Get metadata type, for C interface +std::string mtype_param(const InfoMetadata &m) +{ + return m.type == "std::string" + ? "char *const" + : m.type; +} + +// mtype_return +// Get metadata type, for C interface +std::string mtype_return(const InfoMetadata &m) +{ + return m.type == "std::string" + ? "const char *" + : m.type; +} + +// ctype +// Get child-node type, for C interface +std::string ctype(const InfoChildren &c) +{ + // Why not ...2Const... in the first case? See: + // https://stackoverflow.com/questions/5055655 + // and: + // https://c-faq.com/ansi/constmismatch.html + // Remember that we're making C code here, not C++. + return c.isVector + ? "ConstHandle2" + c.plain + " *const" + : "ConstHandle2Const" + c.plain; +} + +// section +template +void section(writer &hdr, writer &src, const std::string &str, Ts &&...args) +{ + two(hdr,src); + two(hdr,src); + two(hdr,src,largeComment); + two(hdr,src,str, std::forward(args)...); + two(hdr,src,largeComment); +} + + +// ----------------------------------------------------------------------------- +// C interface: +// fileCInterfaceCreate* +// ----------------------------------------------------------------------------- + +// fileCInterfaceCreateParams +void fileCInterfaceCreateParams(writer &hdr, writer &src, const PerClass &per) +{ + int count = 0; + const int total = per.nfields(); + + // metadata + for (const auto &m : per.metadata) { + two(hdr,src); + two(hdr,src,1,"const @ @@", + mtype_param(m), + m.name, + ++count < total ? "," : "", + false); + } + + // children + for (const auto &c : per.children) { + two(hdr,src); + two(hdr,src,1,"@ @@@", + ctype(c), + c.name, + c.isVector ? ", const size_t "+c.name+"Size" : "", + ++count < total ? "," : "", + false + ); + } + + // variants + // todo + + if (total) + two(hdr,src); +} + +// fileCInterfaceCreateCall +void fileCInterfaceCreateCall(writer &hdr, writer &src, const PerClass &per) +{ + // metadata + for (const auto &m : per.metadata) { + src(","); + src(2,"@", m.name, false); + } + + // children + for (const auto &c : per.children) { + src(","); + const std::string Child = c.plain; + const std::string child = c.name; + c.isVector + ? src(2,"std::vector{}", Child, false) + : src(2,"detail::tocpp(@)", Child, child, false); + } + + // variants + // todo + + src(); + src(1,");"); + for (const auto &c : per.children) { + if (!c.isVector) + continue; + const std::string Child = c.plain; + const std::string child = c.name; + src(1,"for (size_t @N = 0; @N < @Size; ++@N)", + Child, Child, child, Child); + src(2,"@@Add(handle, @[@N]);", + per.clname, Child, child, Child); + } + src(1,"return handle;"); + src("}"); +} + + +// ----------------------------------------------------------------------------- +// C interface: +// fileCInterfaceBasics +// ----------------------------------------------------------------------------- + +void fileCInterfaceBasics(writer &hdr, writer &src, const PerClass &per) +{ + // section comment + section(hdr,src, + "// Basics\n" + "// Create, Assign, Delete"); + + // create: default, const + MMM(hdr,src,"Create, default, const"); + ext(hdr,src,"Handle2Const@", per.clname); + two(hdr,src,"@DefaultConst(", per.clname, false); + sig(hdr,src); + src(1,"return detail::createHandle"); + src(2,"(CLASSNAME, CLASSNAME+\"DefaultConst\");"); + src("}"); + + // create: default, non-const + PPP(hdr,src,"Create, default"); + ext(hdr,src,"Handle2@", per.clname); + two(hdr,src,"@Default(", per.clname, false); + sig(hdr,src); + src(1,"return detail::createHandle"); + src(2,"(CLASSNAME, CLASSNAME+\"Default\");"); + src("}"); + + // create: general, const + MMM(hdr,src,"Create, general, const"); + ext(hdr,src,"Handle2Const@", per.clname); + two(hdr,src,"@CreateConst(", per.clname, false); + fileCInterfaceCreateParams(hdr,src,per); + sig(hdr,src, per.nfields() != 0); + src(1,"ConstHandle2@ handle = detail::createHandle(", per.clname); + src(2,"CLASSNAME, CLASSNAME+\"CreateConst\"", false); + fileCInterfaceCreateCall(hdr,src,per); + + // create: general, non-const + PPP(hdr,src,"Create, general"); + ext(hdr,src,"Handle2@", per.clname); + two(hdr,src,"@Create(", per.clname, false); + fileCInterfaceCreateParams(hdr,src,per); + sig(hdr,src, per.nfields() != 0); + src(1,"ConstHandle2@ handle = detail::createHandle(", per.clname); + src(2,"CLASSNAME, CLASSNAME+\"Create\"", false); + fileCInterfaceCreateCall(hdr,src,per); + + // assign + PPP(hdr,src,"Assign"); + ppp(hdr,src,"Use this to assign one handled object to another. " + "Don't assign handles,"); + ppp(hdr,src,"as with to = from. That has a meaning that you probably " + "don't intend."); + ext(hdr,src,"void"); + two(hdr,src,"@Assign(", per.clname, false); + two(hdr,src,"ConstHandle2@ This, ConstHandle2Const@ from", + per.clname, per.clname, false); + sig(hdr,src); + src(1,"detail::assignHandle"); + src(2,"(CLASSNAME, CLASSNAME+\"Assign\", This, from);"); + src("}"); + + // delete + PPP(hdr,src,"Delete"); + ppp(hdr,src,"We'll attempt to remove no-longer-used objects " + "automatically, but you"); + ppp(hdr,src,"may improve performance if you delete them when " + "you're done with them."); + ext(hdr,src,"void"); + two(hdr,src,"@Delete(", per.clname, false); + two(hdr,src,"ConstHandle2Const@ This", per.clname, false); + sig(hdr,src); + src(1,"detail::deleteHandle"); + src(2,"(CLASSNAME, CLASSNAME+\"Delete\", This);"); + src("}"); +} // fileCInterfaceBasics + + +// ----------------------------------------------------------------------------- +// C interface: +// fileCInterfaceIO +// ----------------------------------------------------------------------------- + +void fileCInterfaceIO(writer &hdr, writer &src, const PerClass &per) +{ + // section comment + section(hdr,src, + "// I/O\n" + "// Read, Write, Print\n" + "// Each returns 0 if failure, 1 if success."); + + // read from file + PPP(hdr,src,"Read from file"); + ppp(hdr,src,"File can be XML, JSON, or HDF5."); + ppp(hdr,src,"We'll examine the file's contents to determine " + "its type automatically."); + ext(hdr,src,"int"); + two(hdr,src,"@Read(", per.clname, false); + two(hdr,src,"ConstHandle2@ This, const char *const filename", + per.clname, false); + sig(hdr,src); + src(1,"return detail::readHandle"); + src(2,"(CLASSNAME, CLASSNAME+\"Read\", This, filename);"); + src("}"); + + // write to file + PPP(hdr,src,"Write to file"); + ppp(hdr,src,"File can be XML, JSON, or HDF5."); + ppp(hdr,src,"We'll use filename's extension to determine " + "the type you want written."); + ext(hdr,src,"int"); + two(hdr,src,"@Write(", per.clname, false); + two(hdr,src,"ConstHandle2Const@ This, const char *const filename", + per.clname, false); + sig(hdr,src); + src(1,"return detail::writeHandle"); + src(2,"(CLASSNAME, CLASSNAME+\"Write\", This, filename);"); + src("}"); + + // print + PPP(hdr,src,"Print to standard output, in our prettyprinting format"); + ext(hdr,src,"int"); + two(hdr,src,"@Print(", per.clname, false); + two(hdr,src,"ConstHandle2Const@ This", per.clname, false); + sig(hdr,src); + src(1,"return detail::printHandle"); + src(2,"(CLASSNAME, CLASSNAME+\"Print\", This);"); + src("}"); + + // print, XML + PPP(hdr,src,"Print to standard output, as XML"); + ext(hdr,src,"int"); + two(hdr,src,"@PrintXML(", per.clname, false); + two(hdr,src,"ConstHandle2Const@ This", per.clname, false); + sig(hdr,src); + src(1,"return detail::printHandle"); + src(2,"(CLASSNAME, CLASSNAME+\"PrintXML\", This, \"XML\");"); + src("}"); + + // print, JSON + PPP(hdr,src,"Print to standard output, as JSON"); + ext(hdr,src,"int"); + two(hdr,src,"@PrintJSON(", per.clname, false); + two(hdr,src,"ConstHandle2Const@ This", per.clname, false); + sig(hdr,src); + src(1,"return detail::printHandle"); + src(2,"(CLASSNAME, CLASSNAME+\"PrintJSON\", This, \"JSON\");"); + src("}"); +} // fileCInterfaceIO + + +// ----------------------------------------------------------------------------- +// C interface: +// fileCInterfaceVector +// ----------------------------------------------------------------------------- + +void fileCInterfaceVector( + writer &hdr, writer &src, + const PerClass &per, const std::string &type, + const bool isSection = true +) { + // section comment + if (isSection) + section(hdr,src,"// Data vector"); + else { + assert(type != ""); + two(hdr,src); + two(hdr,src,smallComment); + two(hdr,src,"// @", type); + two(hdr,src,smallComment); + } + + // dynamic type? + if (type == "") { + // for a C interface, these are probably sufficient + fileCInterfaceVector(hdr,src,per,"int", false); + fileCInterfaceVector(hdr,src,per,"unsigned",false); + fileCInterfaceVector(hdr,src,per,"float", false); + fileCInterfaceVector(hdr,src,per,"double", false); + return; + } + + // Example: + // type: "double" (parameter to the present function) + // Class: "Foobar" (class type; for brevity) + // types: "doubles" + // Types: "Doubles" + const std::string Class = per.clname; + const std::string types = type + 's'; + const std::string Types = capital(type) + 's'; + + PPP(hdr,src,"Clear"); + ext(hdr,src,"void"); + two(hdr,src,"@@Clear(", Class, Types, false); + two(hdr,src,"ConstHandle2@ This", Class, false); + sig(hdr,src); + src(1,"detail::vectorClear"); + src(2,"(CLASSNAME, CLASSNAME+\"@Clear\", This);", Types); + src("}"); + + PPP(hdr,src,"Get size"); + ext(hdr,src,"size_t"); + two(hdr,src,"@@Size(", Class, Types, false); + two(hdr,src,"ConstHandle2Const@ This", Class, false); + sig(hdr,src); + src(1,"return detail::vectorSize"); + src(2,"(CLASSNAME, CLASSNAME+\"@Size\", This);", Types); + src("}"); + + PPP(hdr,src,"Get value"); + ppp(hdr,src,"By index \\in [0,size)"); + ext(hdr,src,"@", type); + two(hdr,src,"@@Get(", Class, Types, false); + two(hdr,src,"ConstHandle2Const@ This, const size_t index", Class, false); + sig(hdr,src); + src(1,"return detail::vectorGet", type); + src(2,"(CLASSNAME, CLASSNAME+\"@Get\", This, index);", Types); + src("}"); + + PPP(hdr,src,"Set value"); + ppp(hdr,src,"By index \\in [0,size)"); + ext(hdr,src,"void"); + two(hdr,src,"@@Set(", Class, Types, false); + two(hdr,src,"ConstHandle2@ This, const size_t index, const @ value", + Class, type, false); + sig(hdr,src); + src(1,"detail::vectorSet", type); + src(2,"(CLASSNAME, CLASSNAME+\"@Set\", This, index, value);", Types); + src("}"); + + MMM(hdr,src,"Get pointer to existing values, const"); + ext(hdr,src,"const @ *", type); + two(hdr,src,"@@GetArrayConst(", Class, Types, false); + two(hdr,src,"ConstHandle2Const@ This", Class, false); + sig(hdr,src); + src(1,"return detail::vectorGet", type); + src(2,"(CLASSNAME, CLASSNAME+\"@GetArrayConst\", This);", Types); + src("}"); + + PPP(hdr,src,"Get pointer to existing values, non-const"); + ext(hdr,src,"@ *", type); + two(hdr,src,"@@GetArray(", Class, Types, false); + two(hdr,src,"ConstHandle2@ This", Class, false); + sig(hdr,src); + src(1,"return detail::vectorGet", type); + src(2,"(CLASSNAME, CLASSNAME+\"@GetArray\", This);", Types); + src("}"); + + PPP(hdr,src,"Set completely new values and size"); + ext(hdr,src,"void"); + two(hdr,src,"@@SetArray(", Class, Types, false); + two(hdr,src,"ConstHandle2@ This, const @ *const values, const size_t size", + Class, type, false); + sig(hdr,src); + src(1,"return detail::vectorSet", type); + src(2,"(CLASSNAME, CLASSNAME+\"@SetArray\", This, size, values);", Types); + src("}"); +} // fileCInterfaceVector + + +// ----------------------------------------------------------------------------- +// C interface: +// fileCInterfaceMeta +// ----------------------------------------------------------------------------- + +void fileCInterfaceMeta( + writer &hdr, writer &src, + const PerClass &per, const InfoMetadata &m +) { + const std::string Class = per.clname; + const std::string Meta = UpperCamel(m.name); + const std::string meta = m.name; + + // section comment + section(hdr,src,"// Metadatum: @", meta); + + // has + // if (m.isOptional) // <== may or may not want this + { + PPP(hdr,src,"Has"); + ext(hdr,src,"int"); + two(hdr,src,"@@Has(", Class, Meta, false); + two(hdr,src,"ConstHandle2Const@ This", Class, false); + sig(hdr,src); + src(1,"return detail::hasField"); + src(2,"(CLASSNAME, CLASSNAME+\"@Has\", This, extract::@);", Meta, meta); + src("}"); + } + + // get + PPP(hdr,src,"Get"); + ppp(hdr,src,"Returns by value"); + ext(hdr,src,"@", mtype_return(m)); + two(hdr,src,"@@Get(", Class, Meta, false); + two(hdr,src,"ConstHandle2Const@ This", Class, false); + sig(hdr,src); + src(1,"return detail::getField"); + src(2,"(CLASSNAME, CLASSNAME+\"@Get\", This, extract::@);", Meta, meta); + src("}"); + + // set + PPP(hdr,src,"Set"); + ext(hdr,src,"void"); + two(hdr,src,"@@Set(", Class, Meta, false); + two(hdr,src,"ConstHandle2@ This, const @ @", + Class, mtype_param(m), meta, false); + sig(hdr,src); + src(1,"detail::setField"); + src(2,"(CLASSNAME, CLASSNAME+\"@Set\", This, extract::@, @);", + Meta, meta, meta); + src("}"); +} + + +// ----------------------------------------------------------------------------- +// C interface: +// fileCInterfaceChild +// ----------------------------------------------------------------------------- + +void fileCInterfaceChild( + writer &hdr, writer &src, + const InfoSpecs &specs, + const PerClass &per, const InfoChildren &c +) { + const std::string Class = per.clname; + const std::string Child = c.plain; + const std::string child = c.name; + + // section comment + section(hdr,src,"// Child: @", child); + + // has + // if (c.isOptional) // <== may or may not want this + { + PPP(hdr,src,"Has"); + ext(hdr,src,"int"); + two(hdr,src,"@@Has(", Class, Child, false); + two(hdr,src,"ConstHandle2Const@ This", Class, false); + sig(hdr,src); + src(1,"return detail::hasField"); + src(2,"(CLASSNAME, CLASSNAME+\"@Has\", This, extract::@);", Child, child); + src("}"); + } + + // ------------------------ + // scalar case + // ------------------------ + + if (!c.isVector) { + // get, const + MMM(hdr,src,"Get, const"); + ext(hdr,src,"Handle2Const@", Child); + two(hdr,src,"@@GetConst(", Class, Child, false); + two(hdr,src,"ConstHandle2Const@ This", Class, false); + sig(hdr,src); + src(1,"return detail::getField", Child); + src(2,"(CLASSNAME, CLASSNAME+\"@GetConst\", This, extract::@);", + Child, child); + src("}"); + + // get, non-const + PPP(hdr,src,"Get, non-const"); + ext(hdr,src,"Handle2@", Child); + two(hdr,src,"@@Get(", Class, Child, false); + two(hdr,src,"ConstHandle2@ This", Class, false); + sig(hdr,src); + src(1,"return detail::getField", Child); + src(2,"(CLASSNAME, CLASSNAME+\"@Get\", This, extract::@);", Child, child); + src("}"); + + // set + PPP(hdr,src,"Set"); + ext(hdr,src,"void"); + two(hdr,src,"@@Set(", Class, Child, false); + two(hdr,src,"ConstHandle2@ This, ConstHandle2Const@ @", + Class, Child, child, false); + sig(hdr,src); + src(1,"detail::setField", Child); + src(2,"(CLASSNAME, CLASSNAME+\"@Set\", This, extract::@, @);", + Child, child, child); + src("}"); + + return; + } + + // ------------------------ + // vector case + // ------------------------ + + // clear + PPP(hdr,src,"Clear"); + ext(hdr,src,"void"); + two(hdr,src,"@@Clear(", Class, Child, false); + two(hdr,src,"ConstHandle2@ This", Class, false); + sig(hdr,src); + src(1,"detail::clearContainer"); + src(2,"(CLASSNAME, CLASSNAME+\"@Clear\", This, extract::@);", Child, child); + src("}"); + + // size + PPP(hdr,src,"Size"); + ext(hdr,src,"size_t"); + two(hdr,src,"@@Size(", Class, Child, false); + two(hdr,src,"ConstHandle2Const@ This", Class, false); + sig(hdr,src); + src(1,"return detail::sizeOfContainer"); + src(2,"(CLASSNAME, CLASSNAME+\"@Size\", This, extract::@);", Child, child); + src("}"); + + // add + PPP(hdr,src,"Add"); + ext(hdr,src,"void"); + two(hdr,src,"@@Add(", Class, Child, false); + two(hdr,src,"ConstHandle2@ This, ", Class, false); + two(hdr,src,"ConstHandle2Const@ @", Child, child, false); + sig(hdr,src); + src(1,"detail::addToContainer", Child); + src(2,"(CLASSNAME, CLASSNAME+\"@Add\", This, extract::@, @);", + Child, child, child); + src("}"); + + // get, by index, const + MMM(hdr,src,"Get, by index \\in [0,size), const"); + ext(hdr,src,"Handle2Const@", Child); + two(hdr,src,"@@GetConst(", Class, Child, false); + two(hdr,src,"ConstHandle2Const@ This, ", Class, false); + two(hdr,src,"const size_t index_", false); + sig(hdr,src); + src(1,"return detail::getByIndex", Child); + src(2,"(CLASSNAME, CLASSNAME+\"@GetConst\", This, extract::@, index_);", + Child, child); + src("}"); + + // get, by index, non-const + PPP(hdr,src,"Get, by index \\in [0,size), non-const"); + ext(hdr,src,"Handle2@", Child); + two(hdr,src,"@@Get(", Class, Child, false); + two(hdr,src,"ConstHandle2@ This, ", Class, false); + two(hdr,src,"const size_t index_", false); + sig(hdr,src); + src(1,"return detail::getByIndex", Child); + src(2,"(CLASSNAME, CLASSNAME+\"@Get\", This, extract::@, index_);", + Child, child); + src("}"); + + // set, by index + PPP(hdr,src,"Set, by index \\in [0,size)"); + ext(hdr,src,"void"); + two(hdr,src,"@@Set(", Class, Child, false); + two(hdr,src); + two(hdr,src,1,"ConstHandle2@ This,", Class); + two(hdr,src,1,"const size_t index_,"); + two(hdr,src,1,"ConstHandle2Const@ @", Child, child); + sig(hdr,src,true); + src(1,"detail::setByIndex", Child); + src(2,"(CLASSNAME, CLASSNAME+\"@Set\", This, extract::@, index_, @);", + Child, child, child); + src("}"); + + // for this child's metadata: has, get, set + const auto it = specs.class2data.find(NamespaceAndClass(c.ns,c.plain)); + if (it == specs.class2data.end()) { + log::warning( + "Unable to generate C interface has/get/set functions for:\n" + " class: {}::{}\n" + " child: {}::{}\n" + "Child class is unknown, so its metadata for has/get/set are unknown.", + per.nsname, Class, + c.ns, Child + ); + return; + } + + for (const auto &m : it->second.metadata) { + const std::string Meta = UpperCamel(m.name); + const std::string meta = m.name; + + // has, by metadatum + PPP(hdr,src,"Has, by @", meta); + ext(hdr,src,"int"); + two(hdr,src,"@@HasBy@(", Class, Child, Meta, false); + two(hdr,src); + two(hdr,src,1,"ConstHandle2Const@ This,", Class); + two(hdr,src,1,"const @ @", mtype_param(m), meta); + sig(hdr,src,true); + src(1,"return detail::hasByMetadatum"); + src(2,"(CLASSNAME, CLASSNAME+\"@HasBy@\",", Child, Meta); + src(2," This, extract::@, meta::@, @);", child, meta, meta); + src("}"); + + // get, by metadatum, const + MMM(hdr,src,"Get, by @, const", meta); + ext(hdr,src,"Handle2Const@", Child); + two(hdr,src,"@@GetBy@Const(", Class, Child, Meta, false); + two(hdr,src); + two(hdr,src,1,"ConstHandle2Const@ This,", Class); + two(hdr,src,1,"const @ @", mtype_param(m), meta); + sig(hdr,src,true); + src(1,"return detail::getByMetadatum", Child); + src(2,"(CLASSNAME, CLASSNAME+\"@GetBy@Const\",", Child, Meta); + src(2," This, extract::@, meta::@, @);", child, meta, meta); + src("}"); + + // get, by metadatum, non-const + PPP(hdr,src,"Get, by @, non-const", meta); + ext(hdr,src,"Handle2@", Child); + two(hdr,src,"@@GetBy@(", Class, Child, Meta, false); + two(hdr,src); + two(hdr,src,1,"ConstHandle2@ This,", Class); + two(hdr,src,1,"const @ @", mtype_param(m), meta); + sig(hdr,src,true); + src(1,"return detail::getByMetadatum", Child); + src(2,"(CLASSNAME, CLASSNAME+\"@GetBy@\",", Child, Meta); + src(2," This, extract::@, meta::@, @);", child, meta, meta); + src("}"); + + // set, by metadatum + PPP(hdr,src,"Set, by @", meta); + ext(hdr,src,"void"); + two(hdr,src,"@@SetBy@(", Class, Child, Meta, false); + two(hdr,src); + two(hdr,src,1,"ConstHandle2@ This,", Class); + two(hdr,src,1,"const @ @,", mtype_param(m), meta); + two(hdr,src,1,"ConstHandle2Const@ @", Child, child); + sig(hdr,src,true); + src(1,"detail::setByMetadatum", Child); + src(2,"(CLASSNAME, CLASSNAME+\"@SetBy@\",", Child, Meta); + src(2," This, extract::@, meta::@, @, @);", child, meta, meta, child); + src("}"); + } // metadata +} // fileCInterfaceChild + + +// ----------------------------------------------------------------------------- +// For the C interface +// fileCInterfaceHeader +// fileCInterfaceSource +// fileCInterfaceCommon +// fileCInterface +// ----------------------------------------------------------------------------- + +// ------------------------ +// fileCInterfaceHeader +// ------------------------ + +void fileCInterfaceHeader( + writer &hdr, const InfoSpecs &specs, + const PerClass &per, const Class2Dependencies &c2d +) { + // Initial remarks + hdr(); + hdr("// Interface for C"); + hdr("// This header file is designed to work with both C and C++"); + hdr("// Function definitions are in this file's .cpp source"); + hdr(); + + // Instructions + hdr(largeComment); + hdr(largeComment); + hdr("// Instructions for Users"); + hdr("//"); + hdr("// Constructs you're MORE likely to care about are preceded with:"); + hdr("// // +++ comment"); + hdr("// Constructs you're LESS likely to care about are preceded with:"); + hdr("// // --- comment"); + hdr("// Anything not marked as above can be ignored by most users."); + hdr("//"); + hdr("// @ is the basic handle type in this file. Example:", per.clname); + hdr("// // Create a default @ object:", per.clname); + hdr("// @ handle = @Default();", per.clname, per.clname); + hdr("// Functions involving @ are declared throughout this file.", + per.clname); + hdr(largeComment); + hdr(largeComment); + + // Preliminaries + section(hdr, "// Preliminaries"); + const std::string guard = + allcaps(specs.Project) + "_" + + allcaps(specs.VersionUnderscore) + "_" + + allcaps(per.nsname) + "_" + + allcaps(per.clname); + + hdr(); + hdr("#ifndef C_INTERFACE_@", guard); + hdr("#define C_INTERFACE_@", guard); + hdr(); + hdr("#include \"GNDStk.h\""); + for (const auto &dep : c2d.dependencies) + hdr("#include \"@/@/@.h\"", specs.Version, dep.nsname, dep.clname); + hdr(); + hdr("#ifdef __cplusplus"); + hdr(1,"#define extern_c extern \"C\""); + hdr("#else"); + hdr(1,"#define extern_c"); + hdr("#endif"); + hdr(); + hdr("// Proxy C struct for the handled C++ class"); + hdr("struct @Class { };", per.clname); + + // Handle types + section(hdr, "// Handle types"); + hdr(); + hdr("// +++ @", per.clname); + hdr("// +++ General handle, suitable for most users. " + "If you're not concerned about"); + hdr("// +++ strict \"const correctness\" in your C code, " + "you can probably use this in"); + hdr("// +++ place of any function parameter of a const-aware handle type."); + hdr("typedef struct @Class *@;", per.clname, per.clname); + hdr(); + hdr("// --- Const-aware handles."); + hdr("typedef const struct @Class *const ConstHandle2Const@;", + per.clname, per.clname); + hdr("typedef struct @Class *const ConstHandle2@;", + per.clname, per.clname); + hdr("typedef const struct @Class * Handle2Const@;", + per.clname, per.clname); + hdr("typedef struct @Class * Handle2@;", + per.clname, per.clname); +} // fileCInterfaceHeader + + +// ------------------------ +// fileCInterfaceSource +// ------------------------ + +void fileCInterfaceSource( + writer &src, const InfoSpecs &specs, + const PerClass &per, const Class2Dependencies &c2d +) { + // includes + src(); + src("#include \"@/@/@/@.hpp\"", + specs.Project, specs.VersionUnderscore, per.nsname, per.clname); + src("#include \"@.h\"", per.clname); + src(); + + // using namespace + src("using namespace njoy::GNDStk;"); + src("using namespace @::@;", specs.Project, specs.VersionUnderscore); + src(); + + // using + src("using C = @Class;", per.clname); + src("using CPP = multigroup::@;", per.clname); + src(); + + // class name + src("static const std::string CLASSNAME = \"@\";", per.clname); + + // extract: namespace begin + if (per.nfields()) { + src(); + src("namespace extract {"); + } + + // extract: metadata + for (const auto &m : per.metadata) + src(1,"static auto @ = [](auto &obj) { return &obj.@; };", + m.name, m.name); + + // extract: children + for (const auto &c : per.children) + src(1,"static auto @ = [](auto &obj) { return &obj.@; };", + c.name, c.name); + + // extract: variants + // todo Determine how the C interface should deal with C++ variants + + // extract: namespace end + if (per.nfields()) src("}"); + + if (c2d.dependencies.size()) + src(); + for (const auto &dep : c2d.dependencies) + src("using CPP@ = @::@;", dep.clname, dep.nsname, dep.clname); +} // fileCInterfaceSource + + +// ------------------------ +// fileCInterfaceCommon +// ------------------------ + +void fileCInterfaceCommon( + writer &hdr, writer &src, + const InfoSpecs &specs, + const PerClass &per, const Class2Dependencies &c2d +) { + // Basics: create, assign, delete + fileCInterfaceBasics(hdr,src, per); + + // IO: read, write, print + fileCInterfaceIO(hdr,src, per); + + // Array support, if BlockData + if (per.isData) + fileCInterfaceVector(hdr,src, per, per.dataType); + + // Functions regarding metadata + for (const auto &m : per.metadata) + fileCInterfaceMeta(hdr,src, per, m); + + // Functions regarding children + for (const auto &c : per.children) + fileCInterfaceChild(hdr,src, specs, per, c); + + // variants + // todo +} // fileCInterfaceCommon + + +// ------------------------ +// fileCInterface +// ------------------------ + +void fileCInterface( + const InfoSpecs &specs, const PerClass &per, const Class2Dependencies &c2d +) { + // header beginning + writer hdr(per.headerC); + fileCInterfaceHeader(hdr, specs, per, c2d); + + // source beginning + writer src(per.sourceC); + fileCInterfaceSource(src, specs, per, c2d); + + // common or partially common to both header and source + fileCInterfaceCommon(hdr,src, specs, per, c2d); + + // header: ending + section(hdr, "// Done"); + hdr(); + hdr("#undef extern_c"); + hdr("#endif"); +} // fileCInterface + + +// ----------------------------------------------------------------------------- +// Python: +// filePythonNamespace +// filePythonClass +// ----------------------------------------------------------------------------- + +// ------------------------ // filePythonNamespace +// ------------------------ + void filePythonNamespace(const InfoSpecs &specs, const PerNamespace &per) { writer out(per.cppPython); @@ -2107,7 +3180,10 @@ void filePythonNamespace(const InfoSpecs &specs, const PerNamespace &per) out(1,"// create the @ submodule", per.nsname); out(1,"python::module submodule = module.def_submodule("); out(2,"\"@\",", per.nsname); - out(2,"\"GNDS @ @\"", specs.Version, per.nsname); + if (specs.Project == "GNDStk") + out(2,"\"GNDS @ @\"", specs.Version, per.nsname); // "GNDS", not "GNDStk" + else + out(2,"\"@ @ @\"", specs.Project, specs.Version, per.nsname); out(1,");"); out(); @@ -2121,7 +3197,10 @@ void filePythonNamespace(const InfoSpecs &specs, const PerNamespace &per) } // filePythonNamespace +// ------------------------ // filePythonClass +// ------------------------ + void filePythonClass(const InfoSpecs &specs, const PerClass &per) { const std::string &nsname = per.nsname; @@ -2196,7 +3275,8 @@ void filePythonClass(const InfoSpecs &specs, const PerClass &per) out(); out("// local includes"); - out("#include \"GNDStk/@/@/@.hpp\"", specs.Version, nsname, clname); + out("#include \"@/@/@/@.hpp\"", + specs.Project, specs.Version, nsname, clname); out("#include \"definitions.hpp\""); out(); @@ -2211,8 +3291,10 @@ void filePythonClass(const InfoSpecs &specs, const PerClass &per) out("// @ wrapper", clname); out("void wrap@(python::module &module)", clname); out("{"); - out(1,"using namespace njoy::GNDStk;"); - out(1,"using namespace njoy::GNDStk::@;", specs.VersionUnderscore); + const std::string prefix = specs.Project == "GNDStk" ? "njoy::" : ""; + out(1,"using namespace @@;", prefix, specs.Project); + out(1,"using namespace @@::@;", + prefix, specs.Project, specs.VersionUnderscore); out(); out(1,"// type aliases"); out(1,"using Component = @::@;", nsname, clname); @@ -2220,9 +3302,10 @@ void filePythonClass(const InfoSpecs &specs, const PerClass &per) // using [variant name] = std::variant..., if necessary for (const auto &v : per.variants) { out(1,"using @ = std::variant<", v.type); - int count = 0, total = v.children.size(); + int count = 0; + const int total = v.children.size(); for (const auto &c : v.children) - out(2, "@@", c.type, ++count == total ? "" : ","); + out(2, "@@", c.type, sep(count,total)); out(1,">;"); } @@ -2240,15 +3323,16 @@ void filePythonClass(const InfoSpecs &specs, const PerClass &per) // python::init<...> for attributes and children out(2,".def("); out(3,"python::init<"); - int count = 0, total = per.nfields(); + int count = 0; + const int total = per.nfields(); for (auto &m : per.metadata) out(4,"const @ &@", m.isDefaulted ? "std::optional<" + m.type + ">" : m.typeFull, - ++count < total ? "," : ""); + sep(count,total)); for (auto &c : per.children) - out(4,"const @ &@", c.typeFull, ++count < total ? "," : ""); + out(4,"const @ &@", c.typeFull, sep(count,total)); for (auto &v : per.variants) - out(4,"const @ &@", v.typeFull, ++count < total ? "," : ""); + out(4,"const @ &@", v.typeFull, sep(count,total)); out(3,">(),"); for (auto &m : per.metadata) out(3,"python::arg(\"@\")@,", @@ -2281,7 +3365,7 @@ void filePythonClass(const InfoSpecs &specs, const PerClass &per) m.isDefaulted ? out(3,"[](const Component &self) { return self.@().value(); },", m.name) - : out(3,"&Component::@,", + : out(3,"[](const Component &self) { return self.@(); },", m.name); out(3,"Component::documentation(\"@\").data()", pyname); out(2,")"); @@ -2291,7 +3375,7 @@ void filePythonClass(const InfoSpecs &specs, const PerClass &per) const auto pyname = namePython(c.name); out(2,".def_property_readonly("); out(3,"\"@\",", pyname); - out(3,"python::overload_cast<>(&Component::@),", c.name); + out(3,"[](const Component &self) { return self.@(); },", c.name); out(3,"Component::documentation(\"@\").data()", pyname); out(2,")"); } @@ -2302,14 +3386,14 @@ void filePythonClass(const InfoSpecs &specs, const PerClass &per) const auto pyname = namePython(c.name); out(2,".def_property_readonly("); out(3,"\"@\",", pyname); - out(3,"python::overload_cast<>(&Component::@),", c.name); + out(3,"[](const Component &self) { return self.@(); },", c.name); out(3,"Component::documentation(\"@\").data()", pyname); out(2,")"); } const auto pyname = namePython(v.name); out(2,".def_property_readonly("); out(3,"\"@\",", pyname); - out(3,"python::overload_cast<>(&Component::@),", v.name); + out(3,"[](const Component &self) { return self.@(); },", v.name); out(3,"Component::documentation(\"@\").data()", pyname); out(2,")"); } @@ -2317,7 +3401,8 @@ void filePythonClass(const InfoSpecs &specs, const PerClass &per) for ( const auto& dataTypeName : dataTypesNames ) { out(2,".def_property_readonly("); out(3,"\"@\",", dataTypeName.second); - out(3,"[] (const Component &self) { return self.@(); },", dataTypeName.second); + out(3,"[] (const Component &self) { return self.@(); },", + dataTypeName.second); out(3,"Component::documentation(\"@\").data()", dataTypeName.second); out(2,")"); } @@ -2334,7 +3419,6 @@ void filePythonClass(const InfoSpecs &specs, const PerClass &per) } // filePythonClass - // ----------------------------------------------------------------------------- // main // ----------------------------------------------------------------------------- @@ -2364,11 +3448,15 @@ int main(const int argc, const char *const *const argv) // GNDStk hpp file for Meta and Child keys fileGNDStkKey(specs); - // GNDStk hpp file for each namespace::class + // GNDStk hpp file, as well as header and source files for the C interface, + // for each namespace::class for (const auto &obj : specs.ClassDependenciesSorted) { auto find = specs.class2data.find(obj.theClass); assert(find != specs.class2data.end()); + // C++ header fileGNDStkClass(specs, find->second, obj); + // C interface: header and source + fileCInterface(specs, find->second, obj); } // Python cpp file for each namespace diff --git a/autogen/prototype.json b/autogen/prototype.json deleted file mode 100644 index 856a88ec1..000000000 --- a/autogen/prototype.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "comment" : [ - "GNDSDir", - " Base GNDStk directory into which the autogenerator tool", - " should place src/GNDStk/version.hpp and src/GNDStk/version/*", - "", - "JSONDir", - " Directory where the listed .json input files are located", - "", - "TO AUTOGENERATE THE PROTOTYPE IN THE REAL GNDStk HIERARCHY", - " Set GNDSDir to .. if you run json2class.exe from within", - " GNDStk/autogen/, where GNDStk/ is the cloned repository", - "", - "Do NOT end the directories (JSONDir and GNDSDir) with a /" - ], - - "GNDSDir": "..", - "Version": "v1.9", - - "JSONDir": "prototype", - "JSONFiles": [ - "generalPurpose.json", - "reactionSuite.json" - ], - "Changes": "changes.json" -} diff --git a/autogen/prototype/.gitignore b/autogen/prototype/.gitignore deleted file mode 100644 index bd541c7e2..000000000 --- a/autogen/prototype/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -python -src diff --git a/autogen/prototype/generalPurpose.json b/autogen/prototype/generalPurpose.json index 0f0456417..a0f41ebc2 100644 --- a/autogen/prototype/generalPurpose.json +++ b/autogen/prototype/generalPurpose.json @@ -33,11 +33,11 @@ }, "children": { "axes": { - "occurrence": "1", + "times": "1", "required": false }, "values": { - "occurrence": "1", + "times": "1", "required": true } } @@ -52,12 +52,12 @@ }, "children": { "axis": { - "occurrence": "choice+", + "times": "choice+", "variant": "axis_grid", "required": false }, "grid": { - "occurrence": "choice+", + "times": "choice+", "variant": "axis_grid", "required": false } @@ -108,12 +108,12 @@ }, "children": { "values": { - "occurrence": "choice", + "times": "choice", "variant": "link_values", "required": false }, "link": { - "occurrence": "choice", + "times": "choice", "variant": "link_values", "required": false } @@ -154,11 +154,11 @@ }, "children": { "axes": { - "occurrence": "1", + "times": "1", "required": false }, "XYs1d": { - "occurrence": "1+", + "times": "1+", "required": true } }, diff --git a/autogen/prototype/proto/c/src/v1.9.h b/autogen/prototype/proto/c/src/v1.9.h new file mode 100644 index 000000000..12c4c688d --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9.h @@ -0,0 +1,32 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// ----------------------------------------------------------------------------- +// This header file is designed to work with both C and C++ +// ----------------------------------------------------------------------------- + +#ifndef C_INTERFACE_PROTO_V1_9 +#define C_INTERFACE_PROTO_V1_9 + +#include "GNDStk.h" + +#ifdef __cplusplus + // For C++ + #include "proto/v1_9.hpp" +#endif + +#include "v1.9/containers/Link.h" +#include "v1.9/containers/XYs1d.h" +#include "v1.9/containers/Axes.h" +#include "v1.9/containers/Axis.h" +#include "v1.9/containers/Grid.h" +#include "v1.9/containers/Values.h" +#include "v1.9/containers/Regions1d.h" + +#include "v1.9/transport/ReactionSuite.h" +#include "v1.9/transport/Reactions.h" +#include "v1.9/transport/Reaction.h" +#include "v1.9/transport/CrossSection.h" + +#endif diff --git a/autogen/prototype/proto/c/src/v1.9/containers/Axes.cpp b/autogen/prototype/proto/c/src/v1.9/containers/Axes.cpp new file mode 100644 index 000000000..9f0ce785a --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/containers/Axes.cpp @@ -0,0 +1,168 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include "proto/v1_9/containers/Axes.hpp" +#include "Axes.h" + +using namespace njoy::GNDStk; +using namespace proto::v1_9; + +using C = AxesClass; +using CPP = multigroup::Axes; + +static const std::string CLASSNAME = "Axes"; + +namespace extract { + static auto href = [](auto &obj) { return &obj.href; }; +} + +using CPPAxis = containers::Axis; +using CPPGrid = containers::Grid; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// Create, default, const +Handle2ConstAxes +AxesDefaultConst() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"DefaultConst"); +} + +// Create, default +Handle2Axes +AxesDefault() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"Default"); +} + +// Create, general, const +Handle2ConstAxes +AxesCreateConst( + const char *const href, +) { + ConstHandle2Axes handle = detail::createHandle( + CLASSNAME, CLASSNAME+"CreateConst", + href + ); + return handle; +} + +// Create, general +Handle2Axes +AxesCreate( + const char *const href, +) { + ConstHandle2Axes handle = detail::createHandle( + CLASSNAME, CLASSNAME+"Create", + href + ); + return handle; +} + +// Assign +// Use this to assign one handled object to another. Don't assign handles, +// as with to = from. That has a meaning that you probably don't intend. +void +AxesAssign(ConstHandle2Axes This, ConstHandle2ConstAxes from) +{ + detail::assignHandle + (CLASSNAME, CLASSNAME+"Assign", This, from); +} + +// Delete +// We'll attempt to remove no-longer-used objects automatically, but you +// may improve performance if you delete them when you're done with them. +void +AxesDelete(ConstHandle2ConstAxes This) +{ + detail::deleteHandle + (CLASSNAME, CLASSNAME+"Delete", This); +} + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// Read from file +// File can be XML, JSON, or HDF5. +// We'll examine the file's contents to determine its type automatically. +int +AxesRead(ConstHandle2Axes This, const char *const filename) +{ + return detail::readHandle + (CLASSNAME, CLASSNAME+"Read", This, filename); +} + +// Write to file +// File can be XML, JSON, or HDF5. +// We'll use filename's extension to determine the type you want written. +int +AxesWrite(ConstHandle2ConstAxes This, const char *const filename) +{ + return detail::writeHandle + (CLASSNAME, CLASSNAME+"Write", This, filename); +} + +// Print to standard output, in our prettyprinting format +int +AxesPrint(ConstHandle2ConstAxes This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"Print", This); +} + +// Print to standard output, as XML +int +AxesPrintXML(ConstHandle2ConstAxes This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintXML", This, "XML"); +} + +// Print to standard output, as JSON +int +AxesPrintJSON(ConstHandle2ConstAxes This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintJSON", This, "JSON"); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: href +// ----------------------------------------------------------------------------- + +// Has +int +AxesHrefHas(ConstHandle2ConstAxes This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"HrefHas", This, extract::href); +} + +// Get +// Returns by value +const char * +AxesHrefGet(ConstHandle2ConstAxes This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"HrefGet", This, extract::href); +} + +// Set +void +AxesHrefSet(ConstHandle2Axes This, const char *const href) +{ + detail::setField + (CLASSNAME, CLASSNAME+"HrefSet", This, extract::href, href); +} diff --git a/autogen/prototype/proto/c/src/v1.9/containers/Axes.h b/autogen/prototype/proto/c/src/v1.9/containers/Axes.h new file mode 100644 index 000000000..6f59d7f13 --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/containers/Axes.h @@ -0,0 +1,157 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// Interface for C +// This header file is designed to work with both C and C++ +// Function definitions are in this file's .cpp source + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// Instructions for Users +// +// Constructs you're MORE likely to care about are preceded with: +// // +++ comment +// Constructs you're LESS likely to care about are preceded with: +// // --- comment +// Anything not marked as above can be ignored by most users. +// +// Axes is the basic handle type in this file. Example: +// // Create a default Axes object: +// Axes handle = AxesDefault(); +// Functions involving Axes are declared throughout this file. +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// Preliminaries +// ----------------------------------------------------------------------------- + +#ifndef C_INTERFACE_PROTO_V1_9_CONTAINERS_AXES +#define C_INTERFACE_PROTO_V1_9_CONTAINERS_AXES + +#include "GNDStk.h" +#include "v1.9/containers/Axis.h" +#include "v1.9/containers/Grid.h" + +#ifdef __cplusplus + #define extern_c extern "C" +#else + #define extern_c +#endif + +// Proxy C struct for the handled C++ class +struct AxesClass { }; + + +// ----------------------------------------------------------------------------- +// Handle types +// ----------------------------------------------------------------------------- + +// +++ Axes +// +++ General handle, suitable for most users. If you're not concerned about +// +++ strict "const correctness" in your C code, you can probably use this in +// +++ place of any function parameter of a const-aware handle type. +typedef struct AxesClass *Axes; + +// --- Const-aware handles. +typedef const struct AxesClass *const ConstHandle2ConstAxes; +typedef struct AxesClass *const ConstHandle2Axes; +typedef const struct AxesClass * Handle2ConstAxes; +typedef struct AxesClass * Handle2Axes; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// --- Create, default, const +extern_c Handle2ConstAxes +AxesDefaultConst(); + +// +++ Create, default +extern_c Handle2Axes +AxesDefault(); + +// --- Create, general, const +extern_c Handle2ConstAxes +AxesCreateConst( + const char *const href, +); + +// +++ Create, general +extern_c Handle2Axes +AxesCreate( + const char *const href, +); + +// +++ Assign +// +++ Use this to assign one handled object to another. Don't assign handles, +// +++ as with to = from. That has a meaning that you probably don't intend. +extern_c void +AxesAssign(ConstHandle2Axes This, ConstHandle2ConstAxes from); + +// +++ Delete +// +++ We'll attempt to remove no-longer-used objects automatically, but you +// +++ may improve performance if you delete them when you're done with them. +extern_c void +AxesDelete(ConstHandle2ConstAxes This); + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// +++ Read from file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll examine the file's contents to determine its type automatically. +extern_c int +AxesRead(ConstHandle2Axes This, const char *const filename); + +// +++ Write to file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll use filename's extension to determine the type you want written. +extern_c int +AxesWrite(ConstHandle2ConstAxes This, const char *const filename); + +// +++ Print to standard output, in our prettyprinting format +extern_c int +AxesPrint(ConstHandle2ConstAxes This); + +// +++ Print to standard output, as XML +extern_c int +AxesPrintXML(ConstHandle2ConstAxes This); + +// +++ Print to standard output, as JSON +extern_c int +AxesPrintJSON(ConstHandle2ConstAxes This); + + +// ----------------------------------------------------------------------------- +// Metadatum: href +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +AxesHrefHas(ConstHandle2ConstAxes This); + +// +++ Get +// +++ Returns by value +extern_c const char * +AxesHrefGet(ConstHandle2ConstAxes This); + +// +++ Set +extern_c void +AxesHrefSet(ConstHandle2Axes This, const char *const href); + + +// ----------------------------------------------------------------------------- +// Done +// ----------------------------------------------------------------------------- + +#undef extern_c +#endif diff --git a/autogen/prototype/proto/c/src/v1.9/containers/Axis.cpp b/autogen/prototype/proto/c/src/v1.9/containers/Axis.cpp new file mode 100644 index 000000000..2be4366da --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/containers/Axis.cpp @@ -0,0 +1,235 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include "proto/v1_9/containers/Axis.hpp" +#include "Axis.h" + +using namespace njoy::GNDStk; +using namespace proto::v1_9; + +using C = AxisClass; +using CPP = multigroup::Axis; + +static const std::string CLASSNAME = "Axis"; + +namespace extract { + static auto index = [](auto &obj) { return &obj.index; }; + static auto label = [](auto &obj) { return &obj.label; }; + static auto unit = [](auto &obj) { return &obj.unit; }; +} + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// Create, default, const +Handle2ConstAxis +AxisDefaultConst() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"DefaultConst"); +} + +// Create, default +Handle2Axis +AxisDefault() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"Default"); +} + +// Create, general, const +Handle2ConstAxis +AxisCreateConst( + const int index, + const char *const label, + const char *const unit +) { + ConstHandle2Axis handle = detail::createHandle( + CLASSNAME, CLASSNAME+"CreateConst", + index, + label, + unit + ); + return handle; +} + +// Create, general +Handle2Axis +AxisCreate( + const int index, + const char *const label, + const char *const unit +) { + ConstHandle2Axis handle = detail::createHandle( + CLASSNAME, CLASSNAME+"Create", + index, + label, + unit + ); + return handle; +} + +// Assign +// Use this to assign one handled object to another. Don't assign handles, +// as with to = from. That has a meaning that you probably don't intend. +void +AxisAssign(ConstHandle2Axis This, ConstHandle2ConstAxis from) +{ + detail::assignHandle + (CLASSNAME, CLASSNAME+"Assign", This, from); +} + +// Delete +// We'll attempt to remove no-longer-used objects automatically, but you +// may improve performance if you delete them when you're done with them. +void +AxisDelete(ConstHandle2ConstAxis This) +{ + detail::deleteHandle + (CLASSNAME, CLASSNAME+"Delete", This); +} + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// Read from file +// File can be XML, JSON, or HDF5. +// We'll examine the file's contents to determine its type automatically. +int +AxisRead(ConstHandle2Axis This, const char *const filename) +{ + return detail::readHandle + (CLASSNAME, CLASSNAME+"Read", This, filename); +} + +// Write to file +// File can be XML, JSON, or HDF5. +// We'll use filename's extension to determine the type you want written. +int +AxisWrite(ConstHandle2ConstAxis This, const char *const filename) +{ + return detail::writeHandle + (CLASSNAME, CLASSNAME+"Write", This, filename); +} + +// Print to standard output, in our prettyprinting format +int +AxisPrint(ConstHandle2ConstAxis This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"Print", This); +} + +// Print to standard output, as XML +int +AxisPrintXML(ConstHandle2ConstAxis This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintXML", This, "XML"); +} + +// Print to standard output, as JSON +int +AxisPrintJSON(ConstHandle2ConstAxis This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintJSON", This, "JSON"); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: index +// ----------------------------------------------------------------------------- + +// Has +int +AxisIndexHas(ConstHandle2ConstAxis This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"IndexHas", This, extract::index); +} + +// Get +// Returns by value +int +AxisIndexGet(ConstHandle2ConstAxis This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"IndexGet", This, extract::index); +} + +// Set +void +AxisIndexSet(ConstHandle2Axis This, const int index) +{ + detail::setField + (CLASSNAME, CLASSNAME+"IndexSet", This, extract::index, index); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: label +// ----------------------------------------------------------------------------- + +// Has +int +AxisLabelHas(ConstHandle2ConstAxis This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"LabelHas", This, extract::label); +} + +// Get +// Returns by value +const char * +AxisLabelGet(ConstHandle2ConstAxis This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"LabelGet", This, extract::label); +} + +// Set +void +AxisLabelSet(ConstHandle2Axis This, const char *const label) +{ + detail::setField + (CLASSNAME, CLASSNAME+"LabelSet", This, extract::label, label); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: unit +// ----------------------------------------------------------------------------- + +// Has +int +AxisUnitHas(ConstHandle2ConstAxis This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"UnitHas", This, extract::unit); +} + +// Get +// Returns by value +const char * +AxisUnitGet(ConstHandle2ConstAxis This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"UnitGet", This, extract::unit); +} + +// Set +void +AxisUnitSet(ConstHandle2Axis This, const char *const unit) +{ + detail::setField + (CLASSNAME, CLASSNAME+"UnitSet", This, extract::unit, unit); +} diff --git a/autogen/prototype/proto/c/src/v1.9/containers/Axis.h b/autogen/prototype/proto/c/src/v1.9/containers/Axis.h new file mode 100644 index 000000000..6e0dcc16c --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/containers/Axis.h @@ -0,0 +1,195 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// Interface for C +// This header file is designed to work with both C and C++ +// Function definitions are in this file's .cpp source + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// Instructions for Users +// +// Constructs you're MORE likely to care about are preceded with: +// // +++ comment +// Constructs you're LESS likely to care about are preceded with: +// // --- comment +// Anything not marked as above can be ignored by most users. +// +// Axis is the basic handle type in this file. Example: +// // Create a default Axis object: +// Axis handle = AxisDefault(); +// Functions involving Axis are declared throughout this file. +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// Preliminaries +// ----------------------------------------------------------------------------- + +#ifndef C_INTERFACE_PROTO_V1_9_CONTAINERS_AXIS +#define C_INTERFACE_PROTO_V1_9_CONTAINERS_AXIS + +#include "GNDStk.h" + +#ifdef __cplusplus + #define extern_c extern "C" +#else + #define extern_c +#endif + +// Proxy C struct for the handled C++ class +struct AxisClass { }; + + +// ----------------------------------------------------------------------------- +// Handle types +// ----------------------------------------------------------------------------- + +// +++ Axis +// +++ General handle, suitable for most users. If you're not concerned about +// +++ strict "const correctness" in your C code, you can probably use this in +// +++ place of any function parameter of a const-aware handle type. +typedef struct AxisClass *Axis; + +// --- Const-aware handles. +typedef const struct AxisClass *const ConstHandle2ConstAxis; +typedef struct AxisClass *const ConstHandle2Axis; +typedef const struct AxisClass * Handle2ConstAxis; +typedef struct AxisClass * Handle2Axis; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// --- Create, default, const +extern_c Handle2ConstAxis +AxisDefaultConst(); + +// +++ Create, default +extern_c Handle2Axis +AxisDefault(); + +// --- Create, general, const +extern_c Handle2ConstAxis +AxisCreateConst( + const int index, + const char *const label, + const char *const unit +); + +// +++ Create, general +extern_c Handle2Axis +AxisCreate( + const int index, + const char *const label, + const char *const unit +); + +// +++ Assign +// +++ Use this to assign one handled object to another. Don't assign handles, +// +++ as with to = from. That has a meaning that you probably don't intend. +extern_c void +AxisAssign(ConstHandle2Axis This, ConstHandle2ConstAxis from); + +// +++ Delete +// +++ We'll attempt to remove no-longer-used objects automatically, but you +// +++ may improve performance if you delete them when you're done with them. +extern_c void +AxisDelete(ConstHandle2ConstAxis This); + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// +++ Read from file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll examine the file's contents to determine its type automatically. +extern_c int +AxisRead(ConstHandle2Axis This, const char *const filename); + +// +++ Write to file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll use filename's extension to determine the type you want written. +extern_c int +AxisWrite(ConstHandle2ConstAxis This, const char *const filename); + +// +++ Print to standard output, in our prettyprinting format +extern_c int +AxisPrint(ConstHandle2ConstAxis This); + +// +++ Print to standard output, as XML +extern_c int +AxisPrintXML(ConstHandle2ConstAxis This); + +// +++ Print to standard output, as JSON +extern_c int +AxisPrintJSON(ConstHandle2ConstAxis This); + + +// ----------------------------------------------------------------------------- +// Metadatum: index +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +AxisIndexHas(ConstHandle2ConstAxis This); + +// +++ Get +// +++ Returns by value +extern_c int +AxisIndexGet(ConstHandle2ConstAxis This); + +// +++ Set +extern_c void +AxisIndexSet(ConstHandle2Axis This, const int index); + + +// ----------------------------------------------------------------------------- +// Metadatum: label +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +AxisLabelHas(ConstHandle2ConstAxis This); + +// +++ Get +// +++ Returns by value +extern_c const char * +AxisLabelGet(ConstHandle2ConstAxis This); + +// +++ Set +extern_c void +AxisLabelSet(ConstHandle2Axis This, const char *const label); + + +// ----------------------------------------------------------------------------- +// Metadatum: unit +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +AxisUnitHas(ConstHandle2ConstAxis This); + +// +++ Get +// +++ Returns by value +extern_c const char * +AxisUnitGet(ConstHandle2ConstAxis This); + +// +++ Set +extern_c void +AxisUnitSet(ConstHandle2Axis This, const char *const unit); + + +// ----------------------------------------------------------------------------- +// Done +// ----------------------------------------------------------------------------- + +#undef extern_c +#endif diff --git a/autogen/prototype/proto/c/src/v1.9/containers/Grid.cpp b/autogen/prototype/proto/c/src/v1.9/containers/Grid.cpp new file mode 100644 index 000000000..31bda1f40 --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/containers/Grid.cpp @@ -0,0 +1,308 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include "proto/v1_9/containers/Grid.hpp" +#include "Grid.h" + +using namespace njoy::GNDStk; +using namespace proto::v1_9; + +using C = GridClass; +using CPP = multigroup::Grid; + +static const std::string CLASSNAME = "Grid"; + +namespace extract { + static auto index = [](auto &obj) { return &obj.index; }; + static auto interpolation = [](auto &obj) { return &obj.interpolation; }; + static auto label = [](auto &obj) { return &obj.label; }; + static auto style = [](auto &obj) { return &obj.style; }; + static auto unit = [](auto &obj) { return &obj.unit; }; +} + +using CPPValues = containers::Values; +using CPPLink = containers::Link; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// Create, default, const +Handle2ConstGrid +GridDefaultConst() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"DefaultConst"); +} + +// Create, default +Handle2Grid +GridDefault() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"Default"); +} + +// Create, general, const +Handle2ConstGrid +GridCreateConst( + const int index, + const enums::Interpolation interpolation, + const char *const label, + const enums::GridStyle style, + const char *const unit, +) { + ConstHandle2Grid handle = detail::createHandle( + CLASSNAME, CLASSNAME+"CreateConst", + index, + interpolation, + label, + style, + unit + ); + return handle; +} + +// Create, general +Handle2Grid +GridCreate( + const int index, + const enums::Interpolation interpolation, + const char *const label, + const enums::GridStyle style, + const char *const unit, +) { + ConstHandle2Grid handle = detail::createHandle( + CLASSNAME, CLASSNAME+"Create", + index, + interpolation, + label, + style, + unit + ); + return handle; +} + +// Assign +// Use this to assign one handled object to another. Don't assign handles, +// as with to = from. That has a meaning that you probably don't intend. +void +GridAssign(ConstHandle2Grid This, ConstHandle2ConstGrid from) +{ + detail::assignHandle + (CLASSNAME, CLASSNAME+"Assign", This, from); +} + +// Delete +// We'll attempt to remove no-longer-used objects automatically, but you +// may improve performance if you delete them when you're done with them. +void +GridDelete(ConstHandle2ConstGrid This) +{ + detail::deleteHandle + (CLASSNAME, CLASSNAME+"Delete", This); +} + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// Read from file +// File can be XML, JSON, or HDF5. +// We'll examine the file's contents to determine its type automatically. +int +GridRead(ConstHandle2Grid This, const char *const filename) +{ + return detail::readHandle + (CLASSNAME, CLASSNAME+"Read", This, filename); +} + +// Write to file +// File can be XML, JSON, or HDF5. +// We'll use filename's extension to determine the type you want written. +int +GridWrite(ConstHandle2ConstGrid This, const char *const filename) +{ + return detail::writeHandle + (CLASSNAME, CLASSNAME+"Write", This, filename); +} + +// Print to standard output, in our prettyprinting format +int +GridPrint(ConstHandle2ConstGrid This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"Print", This); +} + +// Print to standard output, as XML +int +GridPrintXML(ConstHandle2ConstGrid This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintXML", This, "XML"); +} + +// Print to standard output, as JSON +int +GridPrintJSON(ConstHandle2ConstGrid This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintJSON", This, "JSON"); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: index +// ----------------------------------------------------------------------------- + +// Has +int +GridIndexHas(ConstHandle2ConstGrid This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"IndexHas", This, extract::index); +} + +// Get +// Returns by value +int +GridIndexGet(ConstHandle2ConstGrid This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"IndexGet", This, extract::index); +} + +// Set +void +GridIndexSet(ConstHandle2Grid This, const int index) +{ + detail::setField + (CLASSNAME, CLASSNAME+"IndexSet", This, extract::index, index); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: interpolation +// ----------------------------------------------------------------------------- + +// Has +int +GridInterpolationHas(ConstHandle2ConstGrid This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"InterpolationHas", This, extract::interpolation); +} + +// Get +// Returns by value +enums::Interpolation +GridInterpolationGet(ConstHandle2ConstGrid This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"InterpolationGet", This, extract::interpolation); +} + +// Set +void +GridInterpolationSet(ConstHandle2Grid This, const enums::Interpolation interpolation) +{ + detail::setField + (CLASSNAME, CLASSNAME+"InterpolationSet", This, extract::interpolation, interpolation); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: label +// ----------------------------------------------------------------------------- + +// Has +int +GridLabelHas(ConstHandle2ConstGrid This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"LabelHas", This, extract::label); +} + +// Get +// Returns by value +const char * +GridLabelGet(ConstHandle2ConstGrid This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"LabelGet", This, extract::label); +} + +// Set +void +GridLabelSet(ConstHandle2Grid This, const char *const label) +{ + detail::setField + (CLASSNAME, CLASSNAME+"LabelSet", This, extract::label, label); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: style +// ----------------------------------------------------------------------------- + +// Has +int +GridStyleHas(ConstHandle2ConstGrid This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"StyleHas", This, extract::style); +} + +// Get +// Returns by value +enums::GridStyle +GridStyleGet(ConstHandle2ConstGrid This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"StyleGet", This, extract::style); +} + +// Set +void +GridStyleSet(ConstHandle2Grid This, const enums::GridStyle style) +{ + detail::setField + (CLASSNAME, CLASSNAME+"StyleSet", This, extract::style, style); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: unit +// ----------------------------------------------------------------------------- + +// Has +int +GridUnitHas(ConstHandle2ConstGrid This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"UnitHas", This, extract::unit); +} + +// Get +// Returns by value +const char * +GridUnitGet(ConstHandle2ConstGrid This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"UnitGet", This, extract::unit); +} + +// Set +void +GridUnitSet(ConstHandle2Grid This, const char *const unit) +{ + detail::setField + (CLASSNAME, CLASSNAME+"UnitSet", This, extract::unit, unit); +} diff --git a/autogen/prototype/proto/c/src/v1.9/containers/Grid.h b/autogen/prototype/proto/c/src/v1.9/containers/Grid.h new file mode 100644 index 000000000..250f1f752 --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/containers/Grid.h @@ -0,0 +1,237 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// Interface for C +// This header file is designed to work with both C and C++ +// Function definitions are in this file's .cpp source + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// Instructions for Users +// +// Constructs you're MORE likely to care about are preceded with: +// // +++ comment +// Constructs you're LESS likely to care about are preceded with: +// // --- comment +// Anything not marked as above can be ignored by most users. +// +// Grid is the basic handle type in this file. Example: +// // Create a default Grid object: +// Grid handle = GridDefault(); +// Functions involving Grid are declared throughout this file. +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// Preliminaries +// ----------------------------------------------------------------------------- + +#ifndef C_INTERFACE_PROTO_V1_9_CONTAINERS_GRID +#define C_INTERFACE_PROTO_V1_9_CONTAINERS_GRID + +#include "GNDStk.h" +#include "v1.9/containers/Values.h" +#include "v1.9/containers/Link.h" + +#ifdef __cplusplus + #define extern_c extern "C" +#else + #define extern_c +#endif + +// Proxy C struct for the handled C++ class +struct GridClass { }; + + +// ----------------------------------------------------------------------------- +// Handle types +// ----------------------------------------------------------------------------- + +// +++ Grid +// +++ General handle, suitable for most users. If you're not concerned about +// +++ strict "const correctness" in your C code, you can probably use this in +// +++ place of any function parameter of a const-aware handle type. +typedef struct GridClass *Grid; + +// --- Const-aware handles. +typedef const struct GridClass *const ConstHandle2ConstGrid; +typedef struct GridClass *const ConstHandle2Grid; +typedef const struct GridClass * Handle2ConstGrid; +typedef struct GridClass * Handle2Grid; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// --- Create, default, const +extern_c Handle2ConstGrid +GridDefaultConst(); + +// +++ Create, default +extern_c Handle2Grid +GridDefault(); + +// --- Create, general, const +extern_c Handle2ConstGrid +GridCreateConst( + const int index, + const enums::Interpolation interpolation, + const char *const label, + const enums::GridStyle style, + const char *const unit, +); + +// +++ Create, general +extern_c Handle2Grid +GridCreate( + const int index, + const enums::Interpolation interpolation, + const char *const label, + const enums::GridStyle style, + const char *const unit, +); + +// +++ Assign +// +++ Use this to assign one handled object to another. Don't assign handles, +// +++ as with to = from. That has a meaning that you probably don't intend. +extern_c void +GridAssign(ConstHandle2Grid This, ConstHandle2ConstGrid from); + +// +++ Delete +// +++ We'll attempt to remove no-longer-used objects automatically, but you +// +++ may improve performance if you delete them when you're done with them. +extern_c void +GridDelete(ConstHandle2ConstGrid This); + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// +++ Read from file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll examine the file's contents to determine its type automatically. +extern_c int +GridRead(ConstHandle2Grid This, const char *const filename); + +// +++ Write to file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll use filename's extension to determine the type you want written. +extern_c int +GridWrite(ConstHandle2ConstGrid This, const char *const filename); + +// +++ Print to standard output, in our prettyprinting format +extern_c int +GridPrint(ConstHandle2ConstGrid This); + +// +++ Print to standard output, as XML +extern_c int +GridPrintXML(ConstHandle2ConstGrid This); + +// +++ Print to standard output, as JSON +extern_c int +GridPrintJSON(ConstHandle2ConstGrid This); + + +// ----------------------------------------------------------------------------- +// Metadatum: index +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +GridIndexHas(ConstHandle2ConstGrid This); + +// +++ Get +// +++ Returns by value +extern_c int +GridIndexGet(ConstHandle2ConstGrid This); + +// +++ Set +extern_c void +GridIndexSet(ConstHandle2Grid This, const int index); + + +// ----------------------------------------------------------------------------- +// Metadatum: interpolation +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +GridInterpolationHas(ConstHandle2ConstGrid This); + +// +++ Get +// +++ Returns by value +extern_c enums::Interpolation +GridInterpolationGet(ConstHandle2ConstGrid This); + +// +++ Set +extern_c void +GridInterpolationSet(ConstHandle2Grid This, const enums::Interpolation interpolation); + + +// ----------------------------------------------------------------------------- +// Metadatum: label +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +GridLabelHas(ConstHandle2ConstGrid This); + +// +++ Get +// +++ Returns by value +extern_c const char * +GridLabelGet(ConstHandle2ConstGrid This); + +// +++ Set +extern_c void +GridLabelSet(ConstHandle2Grid This, const char *const label); + + +// ----------------------------------------------------------------------------- +// Metadatum: style +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +GridStyleHas(ConstHandle2ConstGrid This); + +// +++ Get +// +++ Returns by value +extern_c enums::GridStyle +GridStyleGet(ConstHandle2ConstGrid This); + +// +++ Set +extern_c void +GridStyleSet(ConstHandle2Grid This, const enums::GridStyle style); + + +// ----------------------------------------------------------------------------- +// Metadatum: unit +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +GridUnitHas(ConstHandle2ConstGrid This); + +// +++ Get +// +++ Returns by value +extern_c const char * +GridUnitGet(ConstHandle2ConstGrid This); + +// +++ Set +extern_c void +GridUnitSet(ConstHandle2Grid This, const char *const unit); + + +// ----------------------------------------------------------------------------- +// Done +// ----------------------------------------------------------------------------- + +#undef extern_c +#endif diff --git a/autogen/prototype/proto/c/src/v1.9/containers/Link.cpp b/autogen/prototype/proto/c/src/v1.9/containers/Link.cpp new file mode 100644 index 000000000..f8701d0bf --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/containers/Link.cpp @@ -0,0 +1,165 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include "proto/v1_9/containers/Link.hpp" +#include "Link.h" + +using namespace njoy::GNDStk; +using namespace proto::v1_9; + +using C = LinkClass; +using CPP = multigroup::Link; + +static const std::string CLASSNAME = "Link"; + +namespace extract { + static auto href = [](auto &obj) { return &obj.href; }; +} + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// Create, default, const +Handle2ConstLink +LinkDefaultConst() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"DefaultConst"); +} + +// Create, default +Handle2Link +LinkDefault() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"Default"); +} + +// Create, general, const +Handle2ConstLink +LinkCreateConst( + const char *const href +) { + ConstHandle2Link handle = detail::createHandle( + CLASSNAME, CLASSNAME+"CreateConst", + href + ); + return handle; +} + +// Create, general +Handle2Link +LinkCreate( + const char *const href +) { + ConstHandle2Link handle = detail::createHandle( + CLASSNAME, CLASSNAME+"Create", + href + ); + return handle; +} + +// Assign +// Use this to assign one handled object to another. Don't assign handles, +// as with to = from. That has a meaning that you probably don't intend. +void +LinkAssign(ConstHandle2Link This, ConstHandle2ConstLink from) +{ + detail::assignHandle + (CLASSNAME, CLASSNAME+"Assign", This, from); +} + +// Delete +// We'll attempt to remove no-longer-used objects automatically, but you +// may improve performance if you delete them when you're done with them. +void +LinkDelete(ConstHandle2ConstLink This) +{ + detail::deleteHandle + (CLASSNAME, CLASSNAME+"Delete", This); +} + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// Read from file +// File can be XML, JSON, or HDF5. +// We'll examine the file's contents to determine its type automatically. +int +LinkRead(ConstHandle2Link This, const char *const filename) +{ + return detail::readHandle + (CLASSNAME, CLASSNAME+"Read", This, filename); +} + +// Write to file +// File can be XML, JSON, or HDF5. +// We'll use filename's extension to determine the type you want written. +int +LinkWrite(ConstHandle2ConstLink This, const char *const filename) +{ + return detail::writeHandle + (CLASSNAME, CLASSNAME+"Write", This, filename); +} + +// Print to standard output, in our prettyprinting format +int +LinkPrint(ConstHandle2ConstLink This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"Print", This); +} + +// Print to standard output, as XML +int +LinkPrintXML(ConstHandle2ConstLink This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintXML", This, "XML"); +} + +// Print to standard output, as JSON +int +LinkPrintJSON(ConstHandle2ConstLink This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintJSON", This, "JSON"); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: href +// ----------------------------------------------------------------------------- + +// Has +int +LinkHrefHas(ConstHandle2ConstLink This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"HrefHas", This, extract::href); +} + +// Get +// Returns by value +const char * +LinkHrefGet(ConstHandle2ConstLink This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"HrefGet", This, extract::href); +} + +// Set +void +LinkHrefSet(ConstHandle2Link This, const char *const href) +{ + detail::setField + (CLASSNAME, CLASSNAME+"HrefSet", This, extract::href, href); +} diff --git a/autogen/prototype/proto/c/src/v1.9/containers/Link.h b/autogen/prototype/proto/c/src/v1.9/containers/Link.h new file mode 100644 index 000000000..c73319795 --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/containers/Link.h @@ -0,0 +1,155 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// Interface for C +// This header file is designed to work with both C and C++ +// Function definitions are in this file's .cpp source + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// Instructions for Users +// +// Constructs you're MORE likely to care about are preceded with: +// // +++ comment +// Constructs you're LESS likely to care about are preceded with: +// // --- comment +// Anything not marked as above can be ignored by most users. +// +// Link is the basic handle type in this file. Example: +// // Create a default Link object: +// Link handle = LinkDefault(); +// Functions involving Link are declared throughout this file. +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// Preliminaries +// ----------------------------------------------------------------------------- + +#ifndef C_INTERFACE_PROTO_V1_9_CONTAINERS_LINK +#define C_INTERFACE_PROTO_V1_9_CONTAINERS_LINK + +#include "GNDStk.h" + +#ifdef __cplusplus + #define extern_c extern "C" +#else + #define extern_c +#endif + +// Proxy C struct for the handled C++ class +struct LinkClass { }; + + +// ----------------------------------------------------------------------------- +// Handle types +// ----------------------------------------------------------------------------- + +// +++ Link +// +++ General handle, suitable for most users. If you're not concerned about +// +++ strict "const correctness" in your C code, you can probably use this in +// +++ place of any function parameter of a const-aware handle type. +typedef struct LinkClass *Link; + +// --- Const-aware handles. +typedef const struct LinkClass *const ConstHandle2ConstLink; +typedef struct LinkClass *const ConstHandle2Link; +typedef const struct LinkClass * Handle2ConstLink; +typedef struct LinkClass * Handle2Link; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// --- Create, default, const +extern_c Handle2ConstLink +LinkDefaultConst(); + +// +++ Create, default +extern_c Handle2Link +LinkDefault(); + +// --- Create, general, const +extern_c Handle2ConstLink +LinkCreateConst( + const char *const href +); + +// +++ Create, general +extern_c Handle2Link +LinkCreate( + const char *const href +); + +// +++ Assign +// +++ Use this to assign one handled object to another. Don't assign handles, +// +++ as with to = from. That has a meaning that you probably don't intend. +extern_c void +LinkAssign(ConstHandle2Link This, ConstHandle2ConstLink from); + +// +++ Delete +// +++ We'll attempt to remove no-longer-used objects automatically, but you +// +++ may improve performance if you delete them when you're done with them. +extern_c void +LinkDelete(ConstHandle2ConstLink This); + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// +++ Read from file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll examine the file's contents to determine its type automatically. +extern_c int +LinkRead(ConstHandle2Link This, const char *const filename); + +// +++ Write to file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll use filename's extension to determine the type you want written. +extern_c int +LinkWrite(ConstHandle2ConstLink This, const char *const filename); + +// +++ Print to standard output, in our prettyprinting format +extern_c int +LinkPrint(ConstHandle2ConstLink This); + +// +++ Print to standard output, as XML +extern_c int +LinkPrintXML(ConstHandle2ConstLink This); + +// +++ Print to standard output, as JSON +extern_c int +LinkPrintJSON(ConstHandle2ConstLink This); + + +// ----------------------------------------------------------------------------- +// Metadatum: href +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +LinkHrefHas(ConstHandle2ConstLink This); + +// +++ Get +// +++ Returns by value +extern_c const char * +LinkHrefGet(ConstHandle2ConstLink This); + +// +++ Set +extern_c void +LinkHrefSet(ConstHandle2Link This, const char *const href); + + +// ----------------------------------------------------------------------------- +// Done +// ----------------------------------------------------------------------------- + +#undef extern_c +#endif diff --git a/autogen/prototype/proto/c/src/v1.9/containers/Regions1d.cpp b/autogen/prototype/proto/c/src/v1.9/containers/Regions1d.cpp new file mode 100644 index 000000000..3746e216f --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/containers/Regions1d.cpp @@ -0,0 +1,498 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include "proto/v1_9/containers/Regions1d.hpp" +#include "Regions1d.h" + +using namespace njoy::GNDStk; +using namespace proto::v1_9; + +using C = Regions1dClass; +using CPP = multigroup::Regions1d; + +static const std::string CLASSNAME = "Regions1d"; + +namespace extract { + static auto label = [](auto &obj) { return &obj.label; }; + static auto outerDomainValue = [](auto &obj) { return &obj.outerDomainValue; }; + static auto axes = [](auto &obj) { return &obj.axes; }; + static auto XYs1d = [](auto &obj) { return &obj.XYs1d; }; +} + +using CPPAxes = containers::Axes; +using CPPXYs1d = containers::XYs1d; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// Create, default, const +Handle2ConstRegions1d +Regions1dDefaultConst() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"DefaultConst"); +} + +// Create, default +Handle2Regions1d +Regions1dDefault() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"Default"); +} + +// Create, general, const +Handle2ConstRegions1d +Regions1dCreateConst( + const char *const label, + const double outerDomainValue, + ConstHandle2ConstAxes axes, + ConstHandle2XYs1d *const XYs1d, const size_t XYs1dSize +) { + ConstHandle2Regions1d handle = detail::createHandle( + CLASSNAME, CLASSNAME+"CreateConst", + label, + outerDomainValue, + detail::tocpp(axes), + std::vector{} + ); + for (size_t XYs1dN = 0; XYs1dN < XYs1dSize; ++XYs1dN) + Regions1dXYs1dAdd(handle, XYs1d[XYs1dN]); + return handle; +} + +// Create, general +Handle2Regions1d +Regions1dCreate( + const char *const label, + const double outerDomainValue, + ConstHandle2ConstAxes axes, + ConstHandle2XYs1d *const XYs1d, const size_t XYs1dSize +) { + ConstHandle2Regions1d handle = detail::createHandle( + CLASSNAME, CLASSNAME+"Create", + label, + outerDomainValue, + detail::tocpp(axes), + std::vector{} + ); + for (size_t XYs1dN = 0; XYs1dN < XYs1dSize; ++XYs1dN) + Regions1dXYs1dAdd(handle, XYs1d[XYs1dN]); + return handle; +} + +// Assign +// Use this to assign one handled object to another. Don't assign handles, +// as with to = from. That has a meaning that you probably don't intend. +void +Regions1dAssign(ConstHandle2Regions1d This, ConstHandle2ConstRegions1d from) +{ + detail::assignHandle + (CLASSNAME, CLASSNAME+"Assign", This, from); +} + +// Delete +// We'll attempt to remove no-longer-used objects automatically, but you +// may improve performance if you delete them when you're done with them. +void +Regions1dDelete(ConstHandle2ConstRegions1d This) +{ + detail::deleteHandle + (CLASSNAME, CLASSNAME+"Delete", This); +} + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// Read from file +// File can be XML, JSON, or HDF5. +// We'll examine the file's contents to determine its type automatically. +int +Regions1dRead(ConstHandle2Regions1d This, const char *const filename) +{ + return detail::readHandle + (CLASSNAME, CLASSNAME+"Read", This, filename); +} + +// Write to file +// File can be XML, JSON, or HDF5. +// We'll use filename's extension to determine the type you want written. +int +Regions1dWrite(ConstHandle2ConstRegions1d This, const char *const filename) +{ + return detail::writeHandle + (CLASSNAME, CLASSNAME+"Write", This, filename); +} + +// Print to standard output, in our prettyprinting format +int +Regions1dPrint(ConstHandle2ConstRegions1d This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"Print", This); +} + +// Print to standard output, as XML +int +Regions1dPrintXML(ConstHandle2ConstRegions1d This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintXML", This, "XML"); +} + +// Print to standard output, as JSON +int +Regions1dPrintJSON(ConstHandle2ConstRegions1d This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintJSON", This, "JSON"); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: label +// ----------------------------------------------------------------------------- + +// Has +int +Regions1dLabelHas(ConstHandle2ConstRegions1d This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"LabelHas", This, extract::label); +} + +// Get +// Returns by value +const char * +Regions1dLabelGet(ConstHandle2ConstRegions1d This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"LabelGet", This, extract::label); +} + +// Set +void +Regions1dLabelSet(ConstHandle2Regions1d This, const char *const label) +{ + detail::setField + (CLASSNAME, CLASSNAME+"LabelSet", This, extract::label, label); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: outerDomainValue +// ----------------------------------------------------------------------------- + +// Has +int +Regions1dOuterDomainValueHas(ConstHandle2ConstRegions1d This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"OuterDomainValueHas", This, extract::outerDomainValue); +} + +// Get +// Returns by value +double +Regions1dOuterDomainValueGet(ConstHandle2ConstRegions1d This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"OuterDomainValueGet", This, extract::outerDomainValue); +} + +// Set +void +Regions1dOuterDomainValueSet(ConstHandle2Regions1d This, const double outerDomainValue) +{ + detail::setField + (CLASSNAME, CLASSNAME+"OuterDomainValueSet", This, extract::outerDomainValue, outerDomainValue); +} + + +// ----------------------------------------------------------------------------- +// Child: axes +// ----------------------------------------------------------------------------- + +// Has +int +Regions1dAxesHas(ConstHandle2ConstRegions1d This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"AxesHas", This, extract::axes); +} + +// Get, const +Handle2ConstAxes +Regions1dAxesGetConst(ConstHandle2ConstRegions1d This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"AxesGetConst", This, extract::axes); +} + +// Get, non-const +Handle2Axes +Regions1dAxesGet(ConstHandle2Regions1d This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"AxesGet", This, extract::axes); +} + +// Set +void +Regions1dAxesSet(ConstHandle2Regions1d This, ConstHandle2ConstAxes axes) +{ + detail::setField + (CLASSNAME, CLASSNAME+"AxesSet", This, extract::axes, axes); +} + + +// ----------------------------------------------------------------------------- +// Child: XYs1d +// ----------------------------------------------------------------------------- + +// Has +int +Regions1dXYs1dHas(ConstHandle2ConstRegions1d This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"XYs1dHas", This, extract::XYs1d); +} + +// Clear +void +Regions1dXYs1dClear(ConstHandle2Regions1d This) +{ + detail::clearContainer + (CLASSNAME, CLASSNAME+"XYs1dClear", This, extract::XYs1d); +} + +// Size +size_t +Regions1dXYs1dSize(ConstHandle2ConstRegions1d This) +{ + return detail::sizeOfContainer + (CLASSNAME, CLASSNAME+"XYs1dSize", This, extract::XYs1d); +} + +// Add +void +Regions1dXYs1dAdd(ConstHandle2Regions1d This, ConstHandle2ConstXYs1d XYs1d) +{ + detail::addToContainer + (CLASSNAME, CLASSNAME+"XYs1dAdd", This, extract::XYs1d, XYs1d); +} + +// Get, by index \in [0,size), const +Handle2ConstXYs1d +Regions1dXYs1dGetConst(ConstHandle2ConstRegions1d This, const size_t index_) +{ + return detail::getByIndex + (CLASSNAME, CLASSNAME+"XYs1dGetConst", This, extract::XYs1d, index_); +} + +// Get, by index \in [0,size), non-const +Handle2XYs1d +Regions1dXYs1dGet(ConstHandle2Regions1d This, const size_t index_) +{ + return detail::getByIndex + (CLASSNAME, CLASSNAME+"XYs1dGet", This, extract::XYs1d, index_); +} + +// Set, by index \in [0,size) +void +Regions1dXYs1dSet( + ConstHandle2Regions1d This, + const size_t index_, + ConstHandle2ConstXYs1d XYs1d +) { + detail::setByIndex + (CLASSNAME, CLASSNAME+"XYs1dSet", This, extract::XYs1d, index_, XYs1d); +} + +// Has, by index +int +Regions1dXYs1dHasByIndex( + ConstHandle2ConstRegions1d This, + const int index +) { + return detail::hasByMetadatum + (CLASSNAME, CLASSNAME+"XYs1dHasByIndex", + This, extract::XYs1d, meta::index, index); +} + +// Get, by index, const +Handle2ConstXYs1d +Regions1dXYs1dGetByIndexConst( + ConstHandle2ConstRegions1d This, + const int index +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"XYs1dGetByIndexConst", + This, extract::XYs1d, meta::index, index); +} + +// Get, by index, non-const +Handle2XYs1d +Regions1dXYs1dGetByIndex( + ConstHandle2Regions1d This, + const int index +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"XYs1dGetByIndex", + This, extract::XYs1d, meta::index, index); +} + +// Set, by index +void +Regions1dXYs1dSetByIndex( + ConstHandle2Regions1d This, + const int index, + ConstHandle2ConstXYs1d XYs1d +) { + detail::setByMetadatum + (CLASSNAME, CLASSNAME+"XYs1dSetByIndex", + This, extract::XYs1d, meta::index, index, XYs1d); +} + +// Has, by interpolation +int +Regions1dXYs1dHasByInterpolation( + ConstHandle2ConstRegions1d This, + const enums::Interpolation interpolation +) { + return detail::hasByMetadatum + (CLASSNAME, CLASSNAME+"XYs1dHasByInterpolation", + This, extract::XYs1d, meta::interpolation, interpolation); +} + +// Get, by interpolation, const +Handle2ConstXYs1d +Regions1dXYs1dGetByInterpolationConst( + ConstHandle2ConstRegions1d This, + const enums::Interpolation interpolation +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"XYs1dGetByInterpolationConst", + This, extract::XYs1d, meta::interpolation, interpolation); +} + +// Get, by interpolation, non-const +Handle2XYs1d +Regions1dXYs1dGetByInterpolation( + ConstHandle2Regions1d This, + const enums::Interpolation interpolation +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"XYs1dGetByInterpolation", + This, extract::XYs1d, meta::interpolation, interpolation); +} + +// Set, by interpolation +void +Regions1dXYs1dSetByInterpolation( + ConstHandle2Regions1d This, + const enums::Interpolation interpolation, + ConstHandle2ConstXYs1d XYs1d +) { + detail::setByMetadatum + (CLASSNAME, CLASSNAME+"XYs1dSetByInterpolation", + This, extract::XYs1d, meta::interpolation, interpolation, XYs1d); +} + +// Has, by label +int +Regions1dXYs1dHasByLabel( + ConstHandle2ConstRegions1d This, + const char *const label +) { + return detail::hasByMetadatum + (CLASSNAME, CLASSNAME+"XYs1dHasByLabel", + This, extract::XYs1d, meta::label, label); +} + +// Get, by label, const +Handle2ConstXYs1d +Regions1dXYs1dGetByLabelConst( + ConstHandle2ConstRegions1d This, + const char *const label +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"XYs1dGetByLabelConst", + This, extract::XYs1d, meta::label, label); +} + +// Get, by label, non-const +Handle2XYs1d +Regions1dXYs1dGetByLabel( + ConstHandle2Regions1d This, + const char *const label +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"XYs1dGetByLabel", + This, extract::XYs1d, meta::label, label); +} + +// Set, by label +void +Regions1dXYs1dSetByLabel( + ConstHandle2Regions1d This, + const char *const label, + ConstHandle2ConstXYs1d XYs1d +) { + detail::setByMetadatum + (CLASSNAME, CLASSNAME+"XYs1dSetByLabel", + This, extract::XYs1d, meta::label, label, XYs1d); +} + +// Has, by outerDomainValue +int +Regions1dXYs1dHasByOuterDomainValue( + ConstHandle2ConstRegions1d This, + const double outerDomainValue +) { + return detail::hasByMetadatum + (CLASSNAME, CLASSNAME+"XYs1dHasByOuterDomainValue", + This, extract::XYs1d, meta::outerDomainValue, outerDomainValue); +} + +// Get, by outerDomainValue, const +Handle2ConstXYs1d +Regions1dXYs1dGetByOuterDomainValueConst( + ConstHandle2ConstRegions1d This, + const double outerDomainValue +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"XYs1dGetByOuterDomainValueConst", + This, extract::XYs1d, meta::outerDomainValue, outerDomainValue); +} + +// Get, by outerDomainValue, non-const +Handle2XYs1d +Regions1dXYs1dGetByOuterDomainValue( + ConstHandle2Regions1d This, + const double outerDomainValue +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"XYs1dGetByOuterDomainValue", + This, extract::XYs1d, meta::outerDomainValue, outerDomainValue); +} + +// Set, by outerDomainValue +void +Regions1dXYs1dSetByOuterDomainValue( + ConstHandle2Regions1d This, + const double outerDomainValue, + ConstHandle2ConstXYs1d XYs1d +) { + detail::setByMetadatum + (CLASSNAME, CLASSNAME+"XYs1dSetByOuterDomainValue", + This, extract::XYs1d, meta::outerDomainValue, outerDomainValue, XYs1d); +} diff --git a/autogen/prototype/proto/c/src/v1.9/containers/Regions1d.h b/autogen/prototype/proto/c/src/v1.9/containers/Regions1d.h new file mode 100644 index 000000000..d09b37aaa --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/containers/Regions1d.h @@ -0,0 +1,355 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// Interface for C +// This header file is designed to work with both C and C++ +// Function definitions are in this file's .cpp source + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// Instructions for Users +// +// Constructs you're MORE likely to care about are preceded with: +// // +++ comment +// Constructs you're LESS likely to care about are preceded with: +// // --- comment +// Anything not marked as above can be ignored by most users. +// +// Regions1d is the basic handle type in this file. Example: +// // Create a default Regions1d object: +// Regions1d handle = Regions1dDefault(); +// Functions involving Regions1d are declared throughout this file. +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// Preliminaries +// ----------------------------------------------------------------------------- + +#ifndef C_INTERFACE_PROTO_V1_9_CONTAINERS_REGIONS1D +#define C_INTERFACE_PROTO_V1_9_CONTAINERS_REGIONS1D + +#include "GNDStk.h" +#include "v1.9/containers/Axes.h" +#include "v1.9/containers/XYs1d.h" + +#ifdef __cplusplus + #define extern_c extern "C" +#else + #define extern_c +#endif + +// Proxy C struct for the handled C++ class +struct Regions1dClass { }; + + +// ----------------------------------------------------------------------------- +// Handle types +// ----------------------------------------------------------------------------- + +// +++ Regions1d +// +++ General handle, suitable for most users. If you're not concerned about +// +++ strict "const correctness" in your C code, you can probably use this in +// +++ place of any function parameter of a const-aware handle type. +typedef struct Regions1dClass *Regions1d; + +// --- Const-aware handles. +typedef const struct Regions1dClass *const ConstHandle2ConstRegions1d; +typedef struct Regions1dClass *const ConstHandle2Regions1d; +typedef const struct Regions1dClass * Handle2ConstRegions1d; +typedef struct Regions1dClass * Handle2Regions1d; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// --- Create, default, const +extern_c Handle2ConstRegions1d +Regions1dDefaultConst(); + +// +++ Create, default +extern_c Handle2Regions1d +Regions1dDefault(); + +// --- Create, general, const +extern_c Handle2ConstRegions1d +Regions1dCreateConst( + const char *const label, + const double outerDomainValue, + ConstHandle2ConstAxes axes, + ConstHandle2XYs1d *const XYs1d, const size_t XYs1dSize +); + +// +++ Create, general +extern_c Handle2Regions1d +Regions1dCreate( + const char *const label, + const double outerDomainValue, + ConstHandle2ConstAxes axes, + ConstHandle2XYs1d *const XYs1d, const size_t XYs1dSize +); + +// +++ Assign +// +++ Use this to assign one handled object to another. Don't assign handles, +// +++ as with to = from. That has a meaning that you probably don't intend. +extern_c void +Regions1dAssign(ConstHandle2Regions1d This, ConstHandle2ConstRegions1d from); + +// +++ Delete +// +++ We'll attempt to remove no-longer-used objects automatically, but you +// +++ may improve performance if you delete them when you're done with them. +extern_c void +Regions1dDelete(ConstHandle2ConstRegions1d This); + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// +++ Read from file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll examine the file's contents to determine its type automatically. +extern_c int +Regions1dRead(ConstHandle2Regions1d This, const char *const filename); + +// +++ Write to file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll use filename's extension to determine the type you want written. +extern_c int +Regions1dWrite(ConstHandle2ConstRegions1d This, const char *const filename); + +// +++ Print to standard output, in our prettyprinting format +extern_c int +Regions1dPrint(ConstHandle2ConstRegions1d This); + +// +++ Print to standard output, as XML +extern_c int +Regions1dPrintXML(ConstHandle2ConstRegions1d This); + +// +++ Print to standard output, as JSON +extern_c int +Regions1dPrintJSON(ConstHandle2ConstRegions1d This); + + +// ----------------------------------------------------------------------------- +// Metadatum: label +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +Regions1dLabelHas(ConstHandle2ConstRegions1d This); + +// +++ Get +// +++ Returns by value +extern_c const char * +Regions1dLabelGet(ConstHandle2ConstRegions1d This); + +// +++ Set +extern_c void +Regions1dLabelSet(ConstHandle2Regions1d This, const char *const label); + + +// ----------------------------------------------------------------------------- +// Metadatum: outerDomainValue +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +Regions1dOuterDomainValueHas(ConstHandle2ConstRegions1d This); + +// +++ Get +// +++ Returns by value +extern_c double +Regions1dOuterDomainValueGet(ConstHandle2ConstRegions1d This); + +// +++ Set +extern_c void +Regions1dOuterDomainValueSet(ConstHandle2Regions1d This, const double outerDomainValue); + + +// ----------------------------------------------------------------------------- +// Child: axes +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +Regions1dAxesHas(ConstHandle2ConstRegions1d This); + +// --- Get, const +extern_c Handle2ConstAxes +Regions1dAxesGetConst(ConstHandle2ConstRegions1d This); + +// +++ Get, non-const +extern_c Handle2Axes +Regions1dAxesGet(ConstHandle2Regions1d This); + +// +++ Set +extern_c void +Regions1dAxesSet(ConstHandle2Regions1d This, ConstHandle2ConstAxes axes); + + +// ----------------------------------------------------------------------------- +// Child: XYs1d +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +Regions1dXYs1dHas(ConstHandle2ConstRegions1d This); + +// +++ Clear +extern_c void +Regions1dXYs1dClear(ConstHandle2Regions1d This); + +// +++ Size +extern_c size_t +Regions1dXYs1dSize(ConstHandle2ConstRegions1d This); + +// +++ Add +extern_c void +Regions1dXYs1dAdd(ConstHandle2Regions1d This, ConstHandle2ConstXYs1d XYs1d); + +// --- Get, by index \in [0,size), const +extern_c Handle2ConstXYs1d +Regions1dXYs1dGetConst(ConstHandle2ConstRegions1d This, const size_t index_); + +// +++ Get, by index \in [0,size), non-const +extern_c Handle2XYs1d +Regions1dXYs1dGet(ConstHandle2Regions1d This, const size_t index_); + +// +++ Set, by index \in [0,size) +extern_c void +Regions1dXYs1dSet( + ConstHandle2Regions1d This, + const size_t index_, + ConstHandle2ConstXYs1d XYs1d +); + +// +++ Has, by index +extern_c int +Regions1dXYs1dHasByIndex( + ConstHandle2ConstRegions1d This, + const int index +); + +// --- Get, by index, const +extern_c Handle2ConstXYs1d +Regions1dXYs1dGetByIndexConst( + ConstHandle2ConstRegions1d This, + const int index +); + +// +++ Get, by index, non-const +extern_c Handle2XYs1d +Regions1dXYs1dGetByIndex( + ConstHandle2Regions1d This, + const int index +); + +// +++ Set, by index +extern_c void +Regions1dXYs1dSetByIndex( + ConstHandle2Regions1d This, + const int index, + ConstHandle2ConstXYs1d XYs1d +); + +// +++ Has, by interpolation +extern_c int +Regions1dXYs1dHasByInterpolation( + ConstHandle2ConstRegions1d This, + const enums::Interpolation interpolation +); + +// --- Get, by interpolation, const +extern_c Handle2ConstXYs1d +Regions1dXYs1dGetByInterpolationConst( + ConstHandle2ConstRegions1d This, + const enums::Interpolation interpolation +); + +// +++ Get, by interpolation, non-const +extern_c Handle2XYs1d +Regions1dXYs1dGetByInterpolation( + ConstHandle2Regions1d This, + const enums::Interpolation interpolation +); + +// +++ Set, by interpolation +extern_c void +Regions1dXYs1dSetByInterpolation( + ConstHandle2Regions1d This, + const enums::Interpolation interpolation, + ConstHandle2ConstXYs1d XYs1d +); + +// +++ Has, by label +extern_c int +Regions1dXYs1dHasByLabel( + ConstHandle2ConstRegions1d This, + const char *const label +); + +// --- Get, by label, const +extern_c Handle2ConstXYs1d +Regions1dXYs1dGetByLabelConst( + ConstHandle2ConstRegions1d This, + const char *const label +); + +// +++ Get, by label, non-const +extern_c Handle2XYs1d +Regions1dXYs1dGetByLabel( + ConstHandle2Regions1d This, + const char *const label +); + +// +++ Set, by label +extern_c void +Regions1dXYs1dSetByLabel( + ConstHandle2Regions1d This, + const char *const label, + ConstHandle2ConstXYs1d XYs1d +); + +// +++ Has, by outerDomainValue +extern_c int +Regions1dXYs1dHasByOuterDomainValue( + ConstHandle2ConstRegions1d This, + const double outerDomainValue +); + +// --- Get, by outerDomainValue, const +extern_c Handle2ConstXYs1d +Regions1dXYs1dGetByOuterDomainValueConst( + ConstHandle2ConstRegions1d This, + const double outerDomainValue +); + +// +++ Get, by outerDomainValue, non-const +extern_c Handle2XYs1d +Regions1dXYs1dGetByOuterDomainValue( + ConstHandle2Regions1d This, + const double outerDomainValue +); + +// +++ Set, by outerDomainValue +extern_c void +Regions1dXYs1dSetByOuterDomainValue( + ConstHandle2Regions1d This, + const double outerDomainValue, + ConstHandle2ConstXYs1d XYs1d +); + + +// ----------------------------------------------------------------------------- +// Done +// ----------------------------------------------------------------------------- + +#undef extern_c +#endif diff --git a/autogen/prototype/proto/c/src/v1.9/containers/Values.cpp b/autogen/prototype/proto/c/src/v1.9/containers/Values.cpp new file mode 100644 index 000000000..59c60461f --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/containers/Values.cpp @@ -0,0 +1,488 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include "proto/v1_9/containers/Values.hpp" +#include "Values.h" + +using namespace njoy::GNDStk; +using namespace proto::v1_9; + +using C = ValuesClass; +using CPP = multigroup::Values; + +static const std::string CLASSNAME = "Values"; + +namespace extract { + static auto valueType = [](auto &obj) { return &obj.valueType; }; + static auto start = [](auto &obj) { return &obj.start; }; + static auto length = [](auto &obj) { return &obj.length; }; +} + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// Create, default, const +Handle2ConstValues +ValuesDefaultConst() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"DefaultConst"); +} + +// Create, default +Handle2Values +ValuesDefault() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"Default"); +} + +// Create, general, const +Handle2ConstValues +ValuesCreateConst( + const char *const valueType, + const int start, + const int length +) { + ConstHandle2Values handle = detail::createHandle( + CLASSNAME, CLASSNAME+"CreateConst", + valueType, + start, + length + ); + return handle; +} + +// Create, general +Handle2Values +ValuesCreate( + const char *const valueType, + const int start, + const int length +) { + ConstHandle2Values handle = detail::createHandle( + CLASSNAME, CLASSNAME+"Create", + valueType, + start, + length + ); + return handle; +} + +// Assign +// Use this to assign one handled object to another. Don't assign handles, +// as with to = from. That has a meaning that you probably don't intend. +void +ValuesAssign(ConstHandle2Values This, ConstHandle2ConstValues from) +{ + detail::assignHandle + (CLASSNAME, CLASSNAME+"Assign", This, from); +} + +// Delete +// We'll attempt to remove no-longer-used objects automatically, but you +// may improve performance if you delete them when you're done with them. +void +ValuesDelete(ConstHandle2ConstValues This) +{ + detail::deleteHandle + (CLASSNAME, CLASSNAME+"Delete", This); +} + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// Read from file +// File can be XML, JSON, or HDF5. +// We'll examine the file's contents to determine its type automatically. +int +ValuesRead(ConstHandle2Values This, const char *const filename) +{ + return detail::readHandle + (CLASSNAME, CLASSNAME+"Read", This, filename); +} + +// Write to file +// File can be XML, JSON, or HDF5. +// We'll use filename's extension to determine the type you want written. +int +ValuesWrite(ConstHandle2ConstValues This, const char *const filename) +{ + return detail::writeHandle + (CLASSNAME, CLASSNAME+"Write", This, filename); +} + +// Print to standard output, in our prettyprinting format +int +ValuesPrint(ConstHandle2ConstValues This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"Print", This); +} + +// Print to standard output, as XML +int +ValuesPrintXML(ConstHandle2ConstValues This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintXML", This, "XML"); +} + +// Print to standard output, as JSON +int +ValuesPrintJSON(ConstHandle2ConstValues This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintJSON", This, "JSON"); +} + + +// ----------------------------------------------------------------------------- +// Data vector +// ----------------------------------------------------------------------------- + +// ------------------------ +// int +// ------------------------ + +// Clear +void +ValuesIntsClear(ConstHandle2Values This) +{ + detail::vectorClear + (CLASSNAME, CLASSNAME+"IntsClear", This); +} + +// Get size +size_t +ValuesIntsSize(ConstHandle2ConstValues This) +{ + return detail::vectorSize + (CLASSNAME, CLASSNAME+"IntsSize", This); +} + +// Get value +// By index \in [0,size) +int +ValuesIntsGet(ConstHandle2ConstValues This, const size_t index) +{ + return detail::vectorGet + (CLASSNAME, CLASSNAME+"IntsGet", This, index); +} + +// Set value +// By index \in [0,size) +void +ValuesIntsSet(ConstHandle2Values This, const size_t index, const int value) +{ + detail::vectorSet + (CLASSNAME, CLASSNAME+"IntsSet", This, index, value); +} + +// Get pointer to existing values, const +const int * +ValuesIntsGetArrayConst(ConstHandle2ConstValues This) +{ + return detail::vectorGet + (CLASSNAME, CLASSNAME+"IntsGetArrayConst", This); +} + +// Get pointer to existing values, non-const +int * +ValuesIntsGetArray(ConstHandle2Values This) +{ + return detail::vectorGet + (CLASSNAME, CLASSNAME+"IntsGetArray", This); +} + +// Set completely new values and size +void +ValuesIntsSetArray(ConstHandle2Values This, const int *const values, const size_t size) +{ + return detail::vectorSet + (CLASSNAME, CLASSNAME+"IntsSetArray", This, size, values); +} + +// ------------------------ +// unsigned +// ------------------------ + +// Clear +void +ValuesUnsignedsClear(ConstHandle2Values This) +{ + detail::vectorClear + (CLASSNAME, CLASSNAME+"UnsignedsClear", This); +} + +// Get size +size_t +ValuesUnsignedsSize(ConstHandle2ConstValues This) +{ + return detail::vectorSize + (CLASSNAME, CLASSNAME+"UnsignedsSize", This); +} + +// Get value +// By index \in [0,size) +unsigned +ValuesUnsignedsGet(ConstHandle2ConstValues This, const size_t index) +{ + return detail::vectorGet + (CLASSNAME, CLASSNAME+"UnsignedsGet", This, index); +} + +// Set value +// By index \in [0,size) +void +ValuesUnsignedsSet(ConstHandle2Values This, const size_t index, const unsigned value) +{ + detail::vectorSet + (CLASSNAME, CLASSNAME+"UnsignedsSet", This, index, value); +} + +// Get pointer to existing values, const +const unsigned * +ValuesUnsignedsGetArrayConst(ConstHandle2ConstValues This) +{ + return detail::vectorGet + (CLASSNAME, CLASSNAME+"UnsignedsGetArrayConst", This); +} + +// Get pointer to existing values, non-const +unsigned * +ValuesUnsignedsGetArray(ConstHandle2Values This) +{ + return detail::vectorGet + (CLASSNAME, CLASSNAME+"UnsignedsGetArray", This); +} + +// Set completely new values and size +void +ValuesUnsignedsSetArray(ConstHandle2Values This, const unsigned *const values, const size_t size) +{ + return detail::vectorSet + (CLASSNAME, CLASSNAME+"UnsignedsSetArray", This, size, values); +} + +// ------------------------ +// float +// ------------------------ + +// Clear +void +ValuesFloatsClear(ConstHandle2Values This) +{ + detail::vectorClear + (CLASSNAME, CLASSNAME+"FloatsClear", This); +} + +// Get size +size_t +ValuesFloatsSize(ConstHandle2ConstValues This) +{ + return detail::vectorSize + (CLASSNAME, CLASSNAME+"FloatsSize", This); +} + +// Get value +// By index \in [0,size) +float +ValuesFloatsGet(ConstHandle2ConstValues This, const size_t index) +{ + return detail::vectorGet + (CLASSNAME, CLASSNAME+"FloatsGet", This, index); +} + +// Set value +// By index \in [0,size) +void +ValuesFloatsSet(ConstHandle2Values This, const size_t index, const float value) +{ + detail::vectorSet + (CLASSNAME, CLASSNAME+"FloatsSet", This, index, value); +} + +// Get pointer to existing values, const +const float * +ValuesFloatsGetArrayConst(ConstHandle2ConstValues This) +{ + return detail::vectorGet + (CLASSNAME, CLASSNAME+"FloatsGetArrayConst", This); +} + +// Get pointer to existing values, non-const +float * +ValuesFloatsGetArray(ConstHandle2Values This) +{ + return detail::vectorGet + (CLASSNAME, CLASSNAME+"FloatsGetArray", This); +} + +// Set completely new values and size +void +ValuesFloatsSetArray(ConstHandle2Values This, const float *const values, const size_t size) +{ + return detail::vectorSet + (CLASSNAME, CLASSNAME+"FloatsSetArray", This, size, values); +} + +// ------------------------ +// double +// ------------------------ + +// Clear +void +ValuesDoublesClear(ConstHandle2Values This) +{ + detail::vectorClear + (CLASSNAME, CLASSNAME+"DoublesClear", This); +} + +// Get size +size_t +ValuesDoublesSize(ConstHandle2ConstValues This) +{ + return detail::vectorSize + (CLASSNAME, CLASSNAME+"DoublesSize", This); +} + +// Get value +// By index \in [0,size) +double +ValuesDoublesGet(ConstHandle2ConstValues This, const size_t index) +{ + return detail::vectorGet + (CLASSNAME, CLASSNAME+"DoublesGet", This, index); +} + +// Set value +// By index \in [0,size) +void +ValuesDoublesSet(ConstHandle2Values This, const size_t index, const double value) +{ + detail::vectorSet + (CLASSNAME, CLASSNAME+"DoublesSet", This, index, value); +} + +// Get pointer to existing values, const +const double * +ValuesDoublesGetArrayConst(ConstHandle2ConstValues This) +{ + return detail::vectorGet + (CLASSNAME, CLASSNAME+"DoublesGetArrayConst", This); +} + +// Get pointer to existing values, non-const +double * +ValuesDoublesGetArray(ConstHandle2Values This) +{ + return detail::vectorGet + (CLASSNAME, CLASSNAME+"DoublesGetArray", This); +} + +// Set completely new values and size +void +ValuesDoublesSetArray(ConstHandle2Values This, const double *const values, const size_t size) +{ + return detail::vectorSet + (CLASSNAME, CLASSNAME+"DoublesSetArray", This, size, values); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: valueType +// ----------------------------------------------------------------------------- + +// Has +int +ValuesValueTypeHas(ConstHandle2ConstValues This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"ValueTypeHas", This, extract::valueType); +} + +// Get +// Returns by value +const char * +ValuesValueTypeGet(ConstHandle2ConstValues This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"ValueTypeGet", This, extract::valueType); +} + +// Set +void +ValuesValueTypeSet(ConstHandle2Values This, const char *const valueType) +{ + detail::setField + (CLASSNAME, CLASSNAME+"ValueTypeSet", This, extract::valueType, valueType); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: start +// ----------------------------------------------------------------------------- + +// Has +int +ValuesStartHas(ConstHandle2ConstValues This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"StartHas", This, extract::start); +} + +// Get +// Returns by value +int +ValuesStartGet(ConstHandle2ConstValues This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"StartGet", This, extract::start); +} + +// Set +void +ValuesStartSet(ConstHandle2Values This, const int start) +{ + detail::setField + (CLASSNAME, CLASSNAME+"StartSet", This, extract::start, start); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: length +// ----------------------------------------------------------------------------- + +// Has +int +ValuesLengthHas(ConstHandle2ConstValues This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"LengthHas", This, extract::length); +} + +// Get +// Returns by value +int +ValuesLengthGet(ConstHandle2ConstValues This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"LengthGet", This, extract::length); +} + +// Set +void +ValuesLengthSet(ConstHandle2Values This, const int length) +{ + detail::setField + (CLASSNAME, CLASSNAME+"LengthSet", This, extract::length, length); +} diff --git a/autogen/prototype/proto/c/src/v1.9/containers/Values.h b/autogen/prototype/proto/c/src/v1.9/containers/Values.h new file mode 100644 index 000000000..c1dcee295 --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/containers/Values.h @@ -0,0 +1,336 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// Interface for C +// This header file is designed to work with both C and C++ +// Function definitions are in this file's .cpp source + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// Instructions for Users +// +// Constructs you're MORE likely to care about are preceded with: +// // +++ comment +// Constructs you're LESS likely to care about are preceded with: +// // --- comment +// Anything not marked as above can be ignored by most users. +// +// Values is the basic handle type in this file. Example: +// // Create a default Values object: +// Values handle = ValuesDefault(); +// Functions involving Values are declared throughout this file. +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// Preliminaries +// ----------------------------------------------------------------------------- + +#ifndef C_INTERFACE_PROTO_V1_9_CONTAINERS_VALUES +#define C_INTERFACE_PROTO_V1_9_CONTAINERS_VALUES + +#include "GNDStk.h" + +#ifdef __cplusplus + #define extern_c extern "C" +#else + #define extern_c +#endif + +// Proxy C struct for the handled C++ class +struct ValuesClass { }; + + +// ----------------------------------------------------------------------------- +// Handle types +// ----------------------------------------------------------------------------- + +// +++ Values +// +++ General handle, suitable for most users. If you're not concerned about +// +++ strict "const correctness" in your C code, you can probably use this in +// +++ place of any function parameter of a const-aware handle type. +typedef struct ValuesClass *Values; + +// --- Const-aware handles. +typedef const struct ValuesClass *const ConstHandle2ConstValues; +typedef struct ValuesClass *const ConstHandle2Values; +typedef const struct ValuesClass * Handle2ConstValues; +typedef struct ValuesClass * Handle2Values; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// --- Create, default, const +extern_c Handle2ConstValues +ValuesDefaultConst(); + +// +++ Create, default +extern_c Handle2Values +ValuesDefault(); + +// --- Create, general, const +extern_c Handle2ConstValues +ValuesCreateConst( + const char *const valueType, + const int start, + const int length +); + +// +++ Create, general +extern_c Handle2Values +ValuesCreate( + const char *const valueType, + const int start, + const int length +); + +// +++ Assign +// +++ Use this to assign one handled object to another. Don't assign handles, +// +++ as with to = from. That has a meaning that you probably don't intend. +extern_c void +ValuesAssign(ConstHandle2Values This, ConstHandle2ConstValues from); + +// +++ Delete +// +++ We'll attempt to remove no-longer-used objects automatically, but you +// +++ may improve performance if you delete them when you're done with them. +extern_c void +ValuesDelete(ConstHandle2ConstValues This); + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// +++ Read from file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll examine the file's contents to determine its type automatically. +extern_c int +ValuesRead(ConstHandle2Values This, const char *const filename); + +// +++ Write to file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll use filename's extension to determine the type you want written. +extern_c int +ValuesWrite(ConstHandle2ConstValues This, const char *const filename); + +// +++ Print to standard output, in our prettyprinting format +extern_c int +ValuesPrint(ConstHandle2ConstValues This); + +// +++ Print to standard output, as XML +extern_c int +ValuesPrintXML(ConstHandle2ConstValues This); + +// +++ Print to standard output, as JSON +extern_c int +ValuesPrintJSON(ConstHandle2ConstValues This); + + +// ----------------------------------------------------------------------------- +// Data vector +// ----------------------------------------------------------------------------- + +// ------------------------ +// int +// ------------------------ + +// +++ Clear +extern_c void +ValuesIntsClear(ConstHandle2Values This); + +// +++ Get size +extern_c size_t +ValuesIntsSize(ConstHandle2ConstValues This); + +// +++ Get value +// +++ By index \in [0,size) +extern_c int +ValuesIntsGet(ConstHandle2ConstValues This, const size_t index); + +// +++ Set value +// +++ By index \in [0,size) +extern_c void +ValuesIntsSet(ConstHandle2Values This, const size_t index, const int value); + +// --- Get pointer to existing values, const +extern_c const int * +ValuesIntsGetArrayConst(ConstHandle2ConstValues This); + +// +++ Get pointer to existing values, non-const +extern_c int * +ValuesIntsGetArray(ConstHandle2Values This); + +// +++ Set completely new values and size +extern_c void +ValuesIntsSetArray(ConstHandle2Values This, const int *const values, const size_t size); + +// ------------------------ +// unsigned +// ------------------------ + +// +++ Clear +extern_c void +ValuesUnsignedsClear(ConstHandle2Values This); + +// +++ Get size +extern_c size_t +ValuesUnsignedsSize(ConstHandle2ConstValues This); + +// +++ Get value +// +++ By index \in [0,size) +extern_c unsigned +ValuesUnsignedsGet(ConstHandle2ConstValues This, const size_t index); + +// +++ Set value +// +++ By index \in [0,size) +extern_c void +ValuesUnsignedsSet(ConstHandle2Values This, const size_t index, const unsigned value); + +// --- Get pointer to existing values, const +extern_c const unsigned * +ValuesUnsignedsGetArrayConst(ConstHandle2ConstValues This); + +// +++ Get pointer to existing values, non-const +extern_c unsigned * +ValuesUnsignedsGetArray(ConstHandle2Values This); + +// +++ Set completely new values and size +extern_c void +ValuesUnsignedsSetArray(ConstHandle2Values This, const unsigned *const values, const size_t size); + +// ------------------------ +// float +// ------------------------ + +// +++ Clear +extern_c void +ValuesFloatsClear(ConstHandle2Values This); + +// +++ Get size +extern_c size_t +ValuesFloatsSize(ConstHandle2ConstValues This); + +// +++ Get value +// +++ By index \in [0,size) +extern_c float +ValuesFloatsGet(ConstHandle2ConstValues This, const size_t index); + +// +++ Set value +// +++ By index \in [0,size) +extern_c void +ValuesFloatsSet(ConstHandle2Values This, const size_t index, const float value); + +// --- Get pointer to existing values, const +extern_c const float * +ValuesFloatsGetArrayConst(ConstHandle2ConstValues This); + +// +++ Get pointer to existing values, non-const +extern_c float * +ValuesFloatsGetArray(ConstHandle2Values This); + +// +++ Set completely new values and size +extern_c void +ValuesFloatsSetArray(ConstHandle2Values This, const float *const values, const size_t size); + +// ------------------------ +// double +// ------------------------ + +// +++ Clear +extern_c void +ValuesDoublesClear(ConstHandle2Values This); + +// +++ Get size +extern_c size_t +ValuesDoublesSize(ConstHandle2ConstValues This); + +// +++ Get value +// +++ By index \in [0,size) +extern_c double +ValuesDoublesGet(ConstHandle2ConstValues This, const size_t index); + +// +++ Set value +// +++ By index \in [0,size) +extern_c void +ValuesDoublesSet(ConstHandle2Values This, const size_t index, const double value); + +// --- Get pointer to existing values, const +extern_c const double * +ValuesDoublesGetArrayConst(ConstHandle2ConstValues This); + +// +++ Get pointer to existing values, non-const +extern_c double * +ValuesDoublesGetArray(ConstHandle2Values This); + +// +++ Set completely new values and size +extern_c void +ValuesDoublesSetArray(ConstHandle2Values This, const double *const values, const size_t size); + + +// ----------------------------------------------------------------------------- +// Metadatum: valueType +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +ValuesValueTypeHas(ConstHandle2ConstValues This); + +// +++ Get +// +++ Returns by value +extern_c const char * +ValuesValueTypeGet(ConstHandle2ConstValues This); + +// +++ Set +extern_c void +ValuesValueTypeSet(ConstHandle2Values This, const char *const valueType); + + +// ----------------------------------------------------------------------------- +// Metadatum: start +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +ValuesStartHas(ConstHandle2ConstValues This); + +// +++ Get +// +++ Returns by value +extern_c int +ValuesStartGet(ConstHandle2ConstValues This); + +// +++ Set +extern_c void +ValuesStartSet(ConstHandle2Values This, const int start); + + +// ----------------------------------------------------------------------------- +// Metadatum: length +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +ValuesLengthHas(ConstHandle2ConstValues This); + +// +++ Get +// +++ Returns by value +extern_c int +ValuesLengthGet(ConstHandle2ConstValues This); + +// +++ Set +extern_c void +ValuesLengthSet(ConstHandle2Values This, const int length); + + +// ----------------------------------------------------------------------------- +// Done +// ----------------------------------------------------------------------------- + +#undef extern_c +#endif diff --git a/autogen/prototype/proto/c/src/v1.9/containers/XYs1d.cpp b/autogen/prototype/proto/c/src/v1.9/containers/XYs1d.cpp new file mode 100644 index 000000000..b2f00f53e --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/containers/XYs1d.cpp @@ -0,0 +1,357 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include "proto/v1_9/containers/XYs1d.hpp" +#include "XYs1d.h" + +using namespace njoy::GNDStk; +using namespace proto::v1_9; + +using C = XYs1dClass; +using CPP = multigroup::XYs1d; + +static const std::string CLASSNAME = "XYs1d"; + +namespace extract { + static auto index = [](auto &obj) { return &obj.index; }; + static auto interpolation = [](auto &obj) { return &obj.interpolation; }; + static auto label = [](auto &obj) { return &obj.label; }; + static auto outerDomainValue = [](auto &obj) { return &obj.outerDomainValue; }; + static auto axes = [](auto &obj) { return &obj.axes; }; + static auto values = [](auto &obj) { return &obj.values; }; +} + +using CPPAxes = containers::Axes; +using CPPValues = containers::Values; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// Create, default, const +Handle2ConstXYs1d +XYs1dDefaultConst() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"DefaultConst"); +} + +// Create, default +Handle2XYs1d +XYs1dDefault() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"Default"); +} + +// Create, general, const +Handle2ConstXYs1d +XYs1dCreateConst( + const int index, + const enums::Interpolation interpolation, + const char *const label, + const double outerDomainValue, + ConstHandle2ConstAxes axes, + ConstHandle2ConstValues values +) { + ConstHandle2XYs1d handle = detail::createHandle( + CLASSNAME, CLASSNAME+"CreateConst", + index, + interpolation, + label, + outerDomainValue, + detail::tocpp(axes), + detail::tocpp(values) + ); + return handle; +} + +// Create, general +Handle2XYs1d +XYs1dCreate( + const int index, + const enums::Interpolation interpolation, + const char *const label, + const double outerDomainValue, + ConstHandle2ConstAxes axes, + ConstHandle2ConstValues values +) { + ConstHandle2XYs1d handle = detail::createHandle( + CLASSNAME, CLASSNAME+"Create", + index, + interpolation, + label, + outerDomainValue, + detail::tocpp(axes), + detail::tocpp(values) + ); + return handle; +} + +// Assign +// Use this to assign one handled object to another. Don't assign handles, +// as with to = from. That has a meaning that you probably don't intend. +void +XYs1dAssign(ConstHandle2XYs1d This, ConstHandle2ConstXYs1d from) +{ + detail::assignHandle + (CLASSNAME, CLASSNAME+"Assign", This, from); +} + +// Delete +// We'll attempt to remove no-longer-used objects automatically, but you +// may improve performance if you delete them when you're done with them. +void +XYs1dDelete(ConstHandle2ConstXYs1d This) +{ + detail::deleteHandle + (CLASSNAME, CLASSNAME+"Delete", This); +} + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// Read from file +// File can be XML, JSON, or HDF5. +// We'll examine the file's contents to determine its type automatically. +int +XYs1dRead(ConstHandle2XYs1d This, const char *const filename) +{ + return detail::readHandle + (CLASSNAME, CLASSNAME+"Read", This, filename); +} + +// Write to file +// File can be XML, JSON, or HDF5. +// We'll use filename's extension to determine the type you want written. +int +XYs1dWrite(ConstHandle2ConstXYs1d This, const char *const filename) +{ + return detail::writeHandle + (CLASSNAME, CLASSNAME+"Write", This, filename); +} + +// Print to standard output, in our prettyprinting format +int +XYs1dPrint(ConstHandle2ConstXYs1d This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"Print", This); +} + +// Print to standard output, as XML +int +XYs1dPrintXML(ConstHandle2ConstXYs1d This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintXML", This, "XML"); +} + +// Print to standard output, as JSON +int +XYs1dPrintJSON(ConstHandle2ConstXYs1d This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintJSON", This, "JSON"); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: index +// ----------------------------------------------------------------------------- + +// Has +int +XYs1dIndexHas(ConstHandle2ConstXYs1d This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"IndexHas", This, extract::index); +} + +// Get +// Returns by value +int +XYs1dIndexGet(ConstHandle2ConstXYs1d This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"IndexGet", This, extract::index); +} + +// Set +void +XYs1dIndexSet(ConstHandle2XYs1d This, const int index) +{ + detail::setField + (CLASSNAME, CLASSNAME+"IndexSet", This, extract::index, index); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: interpolation +// ----------------------------------------------------------------------------- + +// Has +int +XYs1dInterpolationHas(ConstHandle2ConstXYs1d This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"InterpolationHas", This, extract::interpolation); +} + +// Get +// Returns by value +enums::Interpolation +XYs1dInterpolationGet(ConstHandle2ConstXYs1d This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"InterpolationGet", This, extract::interpolation); +} + +// Set +void +XYs1dInterpolationSet(ConstHandle2XYs1d This, const enums::Interpolation interpolation) +{ + detail::setField + (CLASSNAME, CLASSNAME+"InterpolationSet", This, extract::interpolation, interpolation); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: label +// ----------------------------------------------------------------------------- + +// Has +int +XYs1dLabelHas(ConstHandle2ConstXYs1d This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"LabelHas", This, extract::label); +} + +// Get +// Returns by value +const char * +XYs1dLabelGet(ConstHandle2ConstXYs1d This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"LabelGet", This, extract::label); +} + +// Set +void +XYs1dLabelSet(ConstHandle2XYs1d This, const char *const label) +{ + detail::setField + (CLASSNAME, CLASSNAME+"LabelSet", This, extract::label, label); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: outerDomainValue +// ----------------------------------------------------------------------------- + +// Has +int +XYs1dOuterDomainValueHas(ConstHandle2ConstXYs1d This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"OuterDomainValueHas", This, extract::outerDomainValue); +} + +// Get +// Returns by value +double +XYs1dOuterDomainValueGet(ConstHandle2ConstXYs1d This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"OuterDomainValueGet", This, extract::outerDomainValue); +} + +// Set +void +XYs1dOuterDomainValueSet(ConstHandle2XYs1d This, const double outerDomainValue) +{ + detail::setField + (CLASSNAME, CLASSNAME+"OuterDomainValueSet", This, extract::outerDomainValue, outerDomainValue); +} + + +// ----------------------------------------------------------------------------- +// Child: axes +// ----------------------------------------------------------------------------- + +// Has +int +XYs1dAxesHas(ConstHandle2ConstXYs1d This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"AxesHas", This, extract::axes); +} + +// Get, const +Handle2ConstAxes +XYs1dAxesGetConst(ConstHandle2ConstXYs1d This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"AxesGetConst", This, extract::axes); +} + +// Get, non-const +Handle2Axes +XYs1dAxesGet(ConstHandle2XYs1d This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"AxesGet", This, extract::axes); +} + +// Set +void +XYs1dAxesSet(ConstHandle2XYs1d This, ConstHandle2ConstAxes axes) +{ + detail::setField + (CLASSNAME, CLASSNAME+"AxesSet", This, extract::axes, axes); +} + + +// ----------------------------------------------------------------------------- +// Child: values +// ----------------------------------------------------------------------------- + +// Has +int +XYs1dValuesHas(ConstHandle2ConstXYs1d This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"ValuesHas", This, extract::values); +} + +// Get, const +Handle2ConstValues +XYs1dValuesGetConst(ConstHandle2ConstXYs1d This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"ValuesGetConst", This, extract::values); +} + +// Get, non-const +Handle2Values +XYs1dValuesGet(ConstHandle2XYs1d This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"ValuesGet", This, extract::values); +} + +// Set +void +XYs1dValuesSet(ConstHandle2XYs1d This, ConstHandle2ConstValues values) +{ + detail::setField + (CLASSNAME, CLASSNAME+"ValuesSet", This, extract::values, values); +} diff --git a/autogen/prototype/proto/c/src/v1.9/containers/XYs1d.h b/autogen/prototype/proto/c/src/v1.9/containers/XYs1d.h new file mode 100644 index 000000000..5d68b976b --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/containers/XYs1d.h @@ -0,0 +1,263 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// Interface for C +// This header file is designed to work with both C and C++ +// Function definitions are in this file's .cpp source + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// Instructions for Users +// +// Constructs you're MORE likely to care about are preceded with: +// // +++ comment +// Constructs you're LESS likely to care about are preceded with: +// // --- comment +// Anything not marked as above can be ignored by most users. +// +// XYs1d is the basic handle type in this file. Example: +// // Create a default XYs1d object: +// XYs1d handle = XYs1dDefault(); +// Functions involving XYs1d are declared throughout this file. +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// Preliminaries +// ----------------------------------------------------------------------------- + +#ifndef C_INTERFACE_PROTO_V1_9_CONTAINERS_XYS1D +#define C_INTERFACE_PROTO_V1_9_CONTAINERS_XYS1D + +#include "GNDStk.h" +#include "v1.9/containers/Axes.h" +#include "v1.9/containers/Values.h" + +#ifdef __cplusplus + #define extern_c extern "C" +#else + #define extern_c +#endif + +// Proxy C struct for the handled C++ class +struct XYs1dClass { }; + + +// ----------------------------------------------------------------------------- +// Handle types +// ----------------------------------------------------------------------------- + +// +++ XYs1d +// +++ General handle, suitable for most users. If you're not concerned about +// +++ strict "const correctness" in your C code, you can probably use this in +// +++ place of any function parameter of a const-aware handle type. +typedef struct XYs1dClass *XYs1d; + +// --- Const-aware handles. +typedef const struct XYs1dClass *const ConstHandle2ConstXYs1d; +typedef struct XYs1dClass *const ConstHandle2XYs1d; +typedef const struct XYs1dClass * Handle2ConstXYs1d; +typedef struct XYs1dClass * Handle2XYs1d; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// --- Create, default, const +extern_c Handle2ConstXYs1d +XYs1dDefaultConst(); + +// +++ Create, default +extern_c Handle2XYs1d +XYs1dDefault(); + +// --- Create, general, const +extern_c Handle2ConstXYs1d +XYs1dCreateConst( + const int index, + const enums::Interpolation interpolation, + const char *const label, + const double outerDomainValue, + ConstHandle2ConstAxes axes, + ConstHandle2ConstValues values +); + +// +++ Create, general +extern_c Handle2XYs1d +XYs1dCreate( + const int index, + const enums::Interpolation interpolation, + const char *const label, + const double outerDomainValue, + ConstHandle2ConstAxes axes, + ConstHandle2ConstValues values +); + +// +++ Assign +// +++ Use this to assign one handled object to another. Don't assign handles, +// +++ as with to = from. That has a meaning that you probably don't intend. +extern_c void +XYs1dAssign(ConstHandle2XYs1d This, ConstHandle2ConstXYs1d from); + +// +++ Delete +// +++ We'll attempt to remove no-longer-used objects automatically, but you +// +++ may improve performance if you delete them when you're done with them. +extern_c void +XYs1dDelete(ConstHandle2ConstXYs1d This); + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// +++ Read from file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll examine the file's contents to determine its type automatically. +extern_c int +XYs1dRead(ConstHandle2XYs1d This, const char *const filename); + +// +++ Write to file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll use filename's extension to determine the type you want written. +extern_c int +XYs1dWrite(ConstHandle2ConstXYs1d This, const char *const filename); + +// +++ Print to standard output, in our prettyprinting format +extern_c int +XYs1dPrint(ConstHandle2ConstXYs1d This); + +// +++ Print to standard output, as XML +extern_c int +XYs1dPrintXML(ConstHandle2ConstXYs1d This); + +// +++ Print to standard output, as JSON +extern_c int +XYs1dPrintJSON(ConstHandle2ConstXYs1d This); + + +// ----------------------------------------------------------------------------- +// Metadatum: index +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +XYs1dIndexHas(ConstHandle2ConstXYs1d This); + +// +++ Get +// +++ Returns by value +extern_c int +XYs1dIndexGet(ConstHandle2ConstXYs1d This); + +// +++ Set +extern_c void +XYs1dIndexSet(ConstHandle2XYs1d This, const int index); + + +// ----------------------------------------------------------------------------- +// Metadatum: interpolation +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +XYs1dInterpolationHas(ConstHandle2ConstXYs1d This); + +// +++ Get +// +++ Returns by value +extern_c enums::Interpolation +XYs1dInterpolationGet(ConstHandle2ConstXYs1d This); + +// +++ Set +extern_c void +XYs1dInterpolationSet(ConstHandle2XYs1d This, const enums::Interpolation interpolation); + + +// ----------------------------------------------------------------------------- +// Metadatum: label +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +XYs1dLabelHas(ConstHandle2ConstXYs1d This); + +// +++ Get +// +++ Returns by value +extern_c const char * +XYs1dLabelGet(ConstHandle2ConstXYs1d This); + +// +++ Set +extern_c void +XYs1dLabelSet(ConstHandle2XYs1d This, const char *const label); + + +// ----------------------------------------------------------------------------- +// Metadatum: outerDomainValue +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +XYs1dOuterDomainValueHas(ConstHandle2ConstXYs1d This); + +// +++ Get +// +++ Returns by value +extern_c double +XYs1dOuterDomainValueGet(ConstHandle2ConstXYs1d This); + +// +++ Set +extern_c void +XYs1dOuterDomainValueSet(ConstHandle2XYs1d This, const double outerDomainValue); + + +// ----------------------------------------------------------------------------- +// Child: axes +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +XYs1dAxesHas(ConstHandle2ConstXYs1d This); + +// --- Get, const +extern_c Handle2ConstAxes +XYs1dAxesGetConst(ConstHandle2ConstXYs1d This); + +// +++ Get, non-const +extern_c Handle2Axes +XYs1dAxesGet(ConstHandle2XYs1d This); + +// +++ Set +extern_c void +XYs1dAxesSet(ConstHandle2XYs1d This, ConstHandle2ConstAxes axes); + + +// ----------------------------------------------------------------------------- +// Child: values +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +XYs1dValuesHas(ConstHandle2ConstXYs1d This); + +// --- Get, const +extern_c Handle2ConstValues +XYs1dValuesGetConst(ConstHandle2ConstXYs1d This); + +// +++ Get, non-const +extern_c Handle2Values +XYs1dValuesGet(ConstHandle2XYs1d This); + +// +++ Set +extern_c void +XYs1dValuesSet(ConstHandle2XYs1d This, ConstHandle2ConstValues values); + + +// ----------------------------------------------------------------------------- +// Done +// ----------------------------------------------------------------------------- + +#undef extern_c +#endif diff --git a/autogen/prototype/proto/c/src/v1.9/transport/CrossSection.cpp b/autogen/prototype/proto/c/src/v1.9/transport/CrossSection.cpp new file mode 100644 index 000000000..f1c11694f --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/transport/CrossSection.cpp @@ -0,0 +1,133 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include "proto/v1_9/transport/CrossSection.hpp" +#include "CrossSection.h" + +using namespace njoy::GNDStk; +using namespace proto::v1_9; + +using C = CrossSectionClass; +using CPP = multigroup::CrossSection; + +static const std::string CLASSNAME = "CrossSection"; + +namespace extract { +} + +using CPPXYs1d = containers::XYs1d; +using CPPRegions1d = containers::Regions1d; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// Create, default, const +Handle2ConstCrossSection +CrossSectionDefaultConst() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"DefaultConst"); +} + +// Create, default +Handle2CrossSection +CrossSectionDefault() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"Default"); +} + +// Create, general, const +Handle2ConstCrossSection +CrossSectionCreateConst( +) { + ConstHandle2CrossSection handle = detail::createHandle( + CLASSNAME, CLASSNAME+"CreateConst" + ); + return handle; +} + +// Create, general +Handle2CrossSection +CrossSectionCreate( +) { + ConstHandle2CrossSection handle = detail::createHandle( + CLASSNAME, CLASSNAME+"Create" + ); + return handle; +} + +// Assign +// Use this to assign one handled object to another. Don't assign handles, +// as with to = from. That has a meaning that you probably don't intend. +void +CrossSectionAssign(ConstHandle2CrossSection This, ConstHandle2ConstCrossSection from) +{ + detail::assignHandle + (CLASSNAME, CLASSNAME+"Assign", This, from); +} + +// Delete +// We'll attempt to remove no-longer-used objects automatically, but you +// may improve performance if you delete them when you're done with them. +void +CrossSectionDelete(ConstHandle2ConstCrossSection This) +{ + detail::deleteHandle + (CLASSNAME, CLASSNAME+"Delete", This); +} + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// Read from file +// File can be XML, JSON, or HDF5. +// We'll examine the file's contents to determine its type automatically. +int +CrossSectionRead(ConstHandle2CrossSection This, const char *const filename) +{ + return detail::readHandle + (CLASSNAME, CLASSNAME+"Read", This, filename); +} + +// Write to file +// File can be XML, JSON, or HDF5. +// We'll use filename's extension to determine the type you want written. +int +CrossSectionWrite(ConstHandle2ConstCrossSection This, const char *const filename) +{ + return detail::writeHandle + (CLASSNAME, CLASSNAME+"Write", This, filename); +} + +// Print to standard output, in our prettyprinting format +int +CrossSectionPrint(ConstHandle2ConstCrossSection This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"Print", This); +} + +// Print to standard output, as XML +int +CrossSectionPrintXML(ConstHandle2ConstCrossSection This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintXML", This, "XML"); +} + +// Print to standard output, as JSON +int +CrossSectionPrintJSON(ConstHandle2ConstCrossSection This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintJSON", This, "JSON"); +} diff --git a/autogen/prototype/proto/c/src/v1.9/transport/CrossSection.h b/autogen/prototype/proto/c/src/v1.9/transport/CrossSection.h new file mode 100644 index 000000000..8c27b5ccc --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/transport/CrossSection.h @@ -0,0 +1,137 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// Interface for C +// This header file is designed to work with both C and C++ +// Function definitions are in this file's .cpp source + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// Instructions for Users +// +// Constructs you're MORE likely to care about are preceded with: +// // +++ comment +// Constructs you're LESS likely to care about are preceded with: +// // --- comment +// Anything not marked as above can be ignored by most users. +// +// CrossSection is the basic handle type in this file. Example: +// // Create a default CrossSection object: +// CrossSection handle = CrossSectionDefault(); +// Functions involving CrossSection are declared throughout this file. +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// Preliminaries +// ----------------------------------------------------------------------------- + +#ifndef C_INTERFACE_PROTO_V1_9_TRANSPORT_CROSSSECTION +#define C_INTERFACE_PROTO_V1_9_TRANSPORT_CROSSSECTION + +#include "GNDStk.h" +#include "v1.9/containers/XYs1d.h" +#include "v1.9/containers/Regions1d.h" + +#ifdef __cplusplus + #define extern_c extern "C" +#else + #define extern_c +#endif + +// Proxy C struct for the handled C++ class +struct CrossSectionClass { }; + + +// ----------------------------------------------------------------------------- +// Handle types +// ----------------------------------------------------------------------------- + +// +++ CrossSection +// +++ General handle, suitable for most users. If you're not concerned about +// +++ strict "const correctness" in your C code, you can probably use this in +// +++ place of any function parameter of a const-aware handle type. +typedef struct CrossSectionClass *CrossSection; + +// --- Const-aware handles. +typedef const struct CrossSectionClass *const ConstHandle2ConstCrossSection; +typedef struct CrossSectionClass *const ConstHandle2CrossSection; +typedef const struct CrossSectionClass * Handle2ConstCrossSection; +typedef struct CrossSectionClass * Handle2CrossSection; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// --- Create, default, const +extern_c Handle2ConstCrossSection +CrossSectionDefaultConst(); + +// +++ Create, default +extern_c Handle2CrossSection +CrossSectionDefault(); + +// --- Create, general, const +extern_c Handle2ConstCrossSection +CrossSectionCreateConst( +); + +// +++ Create, general +extern_c Handle2CrossSection +CrossSectionCreate( +); + +// +++ Assign +// +++ Use this to assign one handled object to another. Don't assign handles, +// +++ as with to = from. That has a meaning that you probably don't intend. +extern_c void +CrossSectionAssign(ConstHandle2CrossSection This, ConstHandle2ConstCrossSection from); + +// +++ Delete +// +++ We'll attempt to remove no-longer-used objects automatically, but you +// +++ may improve performance if you delete them when you're done with them. +extern_c void +CrossSectionDelete(ConstHandle2ConstCrossSection This); + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// +++ Read from file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll examine the file's contents to determine its type automatically. +extern_c int +CrossSectionRead(ConstHandle2CrossSection This, const char *const filename); + +// +++ Write to file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll use filename's extension to determine the type you want written. +extern_c int +CrossSectionWrite(ConstHandle2ConstCrossSection This, const char *const filename); + +// +++ Print to standard output, in our prettyprinting format +extern_c int +CrossSectionPrint(ConstHandle2ConstCrossSection This); + +// +++ Print to standard output, as XML +extern_c int +CrossSectionPrintXML(ConstHandle2ConstCrossSection This); + +// +++ Print to standard output, as JSON +extern_c int +CrossSectionPrintJSON(ConstHandle2ConstCrossSection This); + + +// ----------------------------------------------------------------------------- +// Done +// ----------------------------------------------------------------------------- + +#undef extern_c +#endif diff --git a/autogen/prototype/proto/c/src/v1.9/transport/Reaction.cpp b/autogen/prototype/proto/c/src/v1.9/transport/Reaction.cpp new file mode 100644 index 000000000..5d9476b2e --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/transport/Reaction.cpp @@ -0,0 +1,279 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include "proto/v1_9/transport/Reaction.hpp" +#include "Reaction.h" + +using namespace njoy::GNDStk; +using namespace proto::v1_9; + +using C = ReactionClass; +using CPP = multigroup::Reaction; + +static const std::string CLASSNAME = "Reaction"; + +namespace extract { + static auto ENDF_MT = [](auto &obj) { return &obj.ENDF_MT; }; + static auto fissionGenre = [](auto &obj) { return &obj.fissionGenre; }; + static auto label = [](auto &obj) { return &obj.label; }; + static auto crossSection = [](auto &obj) { return &obj.crossSection; }; +} + +using CPPCrossSection = transport::CrossSection; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// Create, default, const +Handle2ConstReaction +ReactionDefaultConst() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"DefaultConst"); +} + +// Create, default +Handle2Reaction +ReactionDefault() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"Default"); +} + +// Create, general, const +Handle2ConstReaction +ReactionCreateConst( + const int ENDF_MT, + const char *const fissionGenre, + const char *const label, + ConstHandle2ConstCrossSection crossSection +) { + ConstHandle2Reaction handle = detail::createHandle( + CLASSNAME, CLASSNAME+"CreateConst", + ENDF_MT, + fissionGenre, + label, + detail::tocpp(crossSection) + ); + return handle; +} + +// Create, general +Handle2Reaction +ReactionCreate( + const int ENDF_MT, + const char *const fissionGenre, + const char *const label, + ConstHandle2ConstCrossSection crossSection +) { + ConstHandle2Reaction handle = detail::createHandle( + CLASSNAME, CLASSNAME+"Create", + ENDF_MT, + fissionGenre, + label, + detail::tocpp(crossSection) + ); + return handle; +} + +// Assign +// Use this to assign one handled object to another. Don't assign handles, +// as with to = from. That has a meaning that you probably don't intend. +void +ReactionAssign(ConstHandle2Reaction This, ConstHandle2ConstReaction from) +{ + detail::assignHandle + (CLASSNAME, CLASSNAME+"Assign", This, from); +} + +// Delete +// We'll attempt to remove no-longer-used objects automatically, but you +// may improve performance if you delete them when you're done with them. +void +ReactionDelete(ConstHandle2ConstReaction This) +{ + detail::deleteHandle + (CLASSNAME, CLASSNAME+"Delete", This); +} + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// Read from file +// File can be XML, JSON, or HDF5. +// We'll examine the file's contents to determine its type automatically. +int +ReactionRead(ConstHandle2Reaction This, const char *const filename) +{ + return detail::readHandle + (CLASSNAME, CLASSNAME+"Read", This, filename); +} + +// Write to file +// File can be XML, JSON, or HDF5. +// We'll use filename's extension to determine the type you want written. +int +ReactionWrite(ConstHandle2ConstReaction This, const char *const filename) +{ + return detail::writeHandle + (CLASSNAME, CLASSNAME+"Write", This, filename); +} + +// Print to standard output, in our prettyprinting format +int +ReactionPrint(ConstHandle2ConstReaction This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"Print", This); +} + +// Print to standard output, as XML +int +ReactionPrintXML(ConstHandle2ConstReaction This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintXML", This, "XML"); +} + +// Print to standard output, as JSON +int +ReactionPrintJSON(ConstHandle2ConstReaction This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintJSON", This, "JSON"); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: ENDF_MT +// ----------------------------------------------------------------------------- + +// Has +int +ReactionENDFMTHas(ConstHandle2ConstReaction This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"ENDFMTHas", This, extract::ENDF_MT); +} + +// Get +// Returns by value +int +ReactionENDFMTGet(ConstHandle2ConstReaction This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"ENDFMTGet", This, extract::ENDF_MT); +} + +// Set +void +ReactionENDFMTSet(ConstHandle2Reaction This, const int ENDF_MT) +{ + detail::setField + (CLASSNAME, CLASSNAME+"ENDFMTSet", This, extract::ENDF_MT, ENDF_MT); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: fissionGenre +// ----------------------------------------------------------------------------- + +// Has +int +ReactionFissionGenreHas(ConstHandle2ConstReaction This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"FissionGenreHas", This, extract::fissionGenre); +} + +// Get +// Returns by value +const char * +ReactionFissionGenreGet(ConstHandle2ConstReaction This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"FissionGenreGet", This, extract::fissionGenre); +} + +// Set +void +ReactionFissionGenreSet(ConstHandle2Reaction This, const char *const fissionGenre) +{ + detail::setField + (CLASSNAME, CLASSNAME+"FissionGenreSet", This, extract::fissionGenre, fissionGenre); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: label +// ----------------------------------------------------------------------------- + +// Has +int +ReactionLabelHas(ConstHandle2ConstReaction This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"LabelHas", This, extract::label); +} + +// Get +// Returns by value +const char * +ReactionLabelGet(ConstHandle2ConstReaction This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"LabelGet", This, extract::label); +} + +// Set +void +ReactionLabelSet(ConstHandle2Reaction This, const char *const label) +{ + detail::setField + (CLASSNAME, CLASSNAME+"LabelSet", This, extract::label, label); +} + + +// ----------------------------------------------------------------------------- +// Child: crossSection +// ----------------------------------------------------------------------------- + +// Has +int +ReactionCrossSectionHas(ConstHandle2ConstReaction This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"CrossSectionHas", This, extract::crossSection); +} + +// Get, const +Handle2ConstCrossSection +ReactionCrossSectionGetConst(ConstHandle2ConstReaction This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"CrossSectionGetConst", This, extract::crossSection); +} + +// Get, non-const +Handle2CrossSection +ReactionCrossSectionGet(ConstHandle2Reaction This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"CrossSectionGet", This, extract::crossSection); +} + +// Set +void +ReactionCrossSectionSet(ConstHandle2Reaction This, ConstHandle2ConstCrossSection crossSection) +{ + detail::setField + (CLASSNAME, CLASSNAME+"CrossSectionSet", This, extract::crossSection, crossSection); +} diff --git a/autogen/prototype/proto/c/src/v1.9/transport/Reaction.h b/autogen/prototype/proto/c/src/v1.9/transport/Reaction.h new file mode 100644 index 000000000..6f76ae59b --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/transport/Reaction.h @@ -0,0 +1,219 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// Interface for C +// This header file is designed to work with both C and C++ +// Function definitions are in this file's .cpp source + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// Instructions for Users +// +// Constructs you're MORE likely to care about are preceded with: +// // +++ comment +// Constructs you're LESS likely to care about are preceded with: +// // --- comment +// Anything not marked as above can be ignored by most users. +// +// Reaction is the basic handle type in this file. Example: +// // Create a default Reaction object: +// Reaction handle = ReactionDefault(); +// Functions involving Reaction are declared throughout this file. +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// Preliminaries +// ----------------------------------------------------------------------------- + +#ifndef C_INTERFACE_PROTO_V1_9_TRANSPORT_REACTION +#define C_INTERFACE_PROTO_V1_9_TRANSPORT_REACTION + +#include "GNDStk.h" +#include "v1.9/transport/CrossSection.h" + +#ifdef __cplusplus + #define extern_c extern "C" +#else + #define extern_c +#endif + +// Proxy C struct for the handled C++ class +struct ReactionClass { }; + + +// ----------------------------------------------------------------------------- +// Handle types +// ----------------------------------------------------------------------------- + +// +++ Reaction +// +++ General handle, suitable for most users. If you're not concerned about +// +++ strict "const correctness" in your C code, you can probably use this in +// +++ place of any function parameter of a const-aware handle type. +typedef struct ReactionClass *Reaction; + +// --- Const-aware handles. +typedef const struct ReactionClass *const ConstHandle2ConstReaction; +typedef struct ReactionClass *const ConstHandle2Reaction; +typedef const struct ReactionClass * Handle2ConstReaction; +typedef struct ReactionClass * Handle2Reaction; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// --- Create, default, const +extern_c Handle2ConstReaction +ReactionDefaultConst(); + +// +++ Create, default +extern_c Handle2Reaction +ReactionDefault(); + +// --- Create, general, const +extern_c Handle2ConstReaction +ReactionCreateConst( + const int ENDF_MT, + const char *const fissionGenre, + const char *const label, + ConstHandle2ConstCrossSection crossSection +); + +// +++ Create, general +extern_c Handle2Reaction +ReactionCreate( + const int ENDF_MT, + const char *const fissionGenre, + const char *const label, + ConstHandle2ConstCrossSection crossSection +); + +// +++ Assign +// +++ Use this to assign one handled object to another. Don't assign handles, +// +++ as with to = from. That has a meaning that you probably don't intend. +extern_c void +ReactionAssign(ConstHandle2Reaction This, ConstHandle2ConstReaction from); + +// +++ Delete +// +++ We'll attempt to remove no-longer-used objects automatically, but you +// +++ may improve performance if you delete them when you're done with them. +extern_c void +ReactionDelete(ConstHandle2ConstReaction This); + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// +++ Read from file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll examine the file's contents to determine its type automatically. +extern_c int +ReactionRead(ConstHandle2Reaction This, const char *const filename); + +// +++ Write to file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll use filename's extension to determine the type you want written. +extern_c int +ReactionWrite(ConstHandle2ConstReaction This, const char *const filename); + +// +++ Print to standard output, in our prettyprinting format +extern_c int +ReactionPrint(ConstHandle2ConstReaction This); + +// +++ Print to standard output, as XML +extern_c int +ReactionPrintXML(ConstHandle2ConstReaction This); + +// +++ Print to standard output, as JSON +extern_c int +ReactionPrintJSON(ConstHandle2ConstReaction This); + + +// ----------------------------------------------------------------------------- +// Metadatum: ENDF_MT +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +ReactionENDFMTHas(ConstHandle2ConstReaction This); + +// +++ Get +// +++ Returns by value +extern_c int +ReactionENDFMTGet(ConstHandle2ConstReaction This); + +// +++ Set +extern_c void +ReactionENDFMTSet(ConstHandle2Reaction This, const int ENDF_MT); + + +// ----------------------------------------------------------------------------- +// Metadatum: fissionGenre +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +ReactionFissionGenreHas(ConstHandle2ConstReaction This); + +// +++ Get +// +++ Returns by value +extern_c const char * +ReactionFissionGenreGet(ConstHandle2ConstReaction This); + +// +++ Set +extern_c void +ReactionFissionGenreSet(ConstHandle2Reaction This, const char *const fissionGenre); + + +// ----------------------------------------------------------------------------- +// Metadatum: label +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +ReactionLabelHas(ConstHandle2ConstReaction This); + +// +++ Get +// +++ Returns by value +extern_c const char * +ReactionLabelGet(ConstHandle2ConstReaction This); + +// +++ Set +extern_c void +ReactionLabelSet(ConstHandle2Reaction This, const char *const label); + + +// ----------------------------------------------------------------------------- +// Child: crossSection +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +ReactionCrossSectionHas(ConstHandle2ConstReaction This); + +// --- Get, const +extern_c Handle2ConstCrossSection +ReactionCrossSectionGetConst(ConstHandle2ConstReaction This); + +// +++ Get, non-const +extern_c Handle2CrossSection +ReactionCrossSectionGet(ConstHandle2Reaction This); + +// +++ Set +extern_c void +ReactionCrossSectionSet(ConstHandle2Reaction This, ConstHandle2ConstCrossSection crossSection); + + +// ----------------------------------------------------------------------------- +// Done +// ----------------------------------------------------------------------------- + +#undef extern_c +#endif diff --git a/autogen/prototype/proto/c/src/v1.9/transport/ReactionSuite.cpp b/autogen/prototype/proto/c/src/v1.9/transport/ReactionSuite.cpp new file mode 100644 index 000000000..9deaf2a97 --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/transport/ReactionSuite.cpp @@ -0,0 +1,384 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include "proto/v1_9/transport/ReactionSuite.hpp" +#include "ReactionSuite.h" + +using namespace njoy::GNDStk; +using namespace proto::v1_9; + +using C = ReactionSuiteClass; +using CPP = multigroup::ReactionSuite; + +static const std::string CLASSNAME = "ReactionSuite"; + +namespace extract { + static auto evaluation = [](auto &obj) { return &obj.evaluation; }; + static auto format = [](auto &obj) { return &obj.format; }; + static auto projectile = [](auto &obj) { return &obj.projectile; }; + static auto projectileFrame = [](auto &obj) { return &obj.projectileFrame; }; + static auto target = [](auto &obj) { return &obj.target; }; + static auto interaction = [](auto &obj) { return &obj.interaction; }; + static auto reactions = [](auto &obj) { return &obj.reactions; }; +} + +using CPPReactions = transport::Reactions; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// Create, default, const +Handle2ConstReactionSuite +ReactionSuiteDefaultConst() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"DefaultConst"); +} + +// Create, default +Handle2ReactionSuite +ReactionSuiteDefault() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"Default"); +} + +// Create, general, const +Handle2ConstReactionSuite +ReactionSuiteCreateConst( + const char *const evaluation, + const char *const format, + const char *const projectile, + const enums::Frame projectileFrame, + const char *const target, + const enums::Interaction interaction, + ConstHandle2ConstReactions reactions +) { + ConstHandle2ReactionSuite handle = detail::createHandle( + CLASSNAME, CLASSNAME+"CreateConst", + evaluation, + format, + projectile, + projectileFrame, + target, + interaction, + detail::tocpp(reactions) + ); + return handle; +} + +// Create, general +Handle2ReactionSuite +ReactionSuiteCreate( + const char *const evaluation, + const char *const format, + const char *const projectile, + const enums::Frame projectileFrame, + const char *const target, + const enums::Interaction interaction, + ConstHandle2ConstReactions reactions +) { + ConstHandle2ReactionSuite handle = detail::createHandle( + CLASSNAME, CLASSNAME+"Create", + evaluation, + format, + projectile, + projectileFrame, + target, + interaction, + detail::tocpp(reactions) + ); + return handle; +} + +// Assign +// Use this to assign one handled object to another. Don't assign handles, +// as with to = from. That has a meaning that you probably don't intend. +void +ReactionSuiteAssign(ConstHandle2ReactionSuite This, ConstHandle2ConstReactionSuite from) +{ + detail::assignHandle + (CLASSNAME, CLASSNAME+"Assign", This, from); +} + +// Delete +// We'll attempt to remove no-longer-used objects automatically, but you +// may improve performance if you delete them when you're done with them. +void +ReactionSuiteDelete(ConstHandle2ConstReactionSuite This) +{ + detail::deleteHandle + (CLASSNAME, CLASSNAME+"Delete", This); +} + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// Read from file +// File can be XML, JSON, or HDF5. +// We'll examine the file's contents to determine its type automatically. +int +ReactionSuiteRead(ConstHandle2ReactionSuite This, const char *const filename) +{ + return detail::readHandle + (CLASSNAME, CLASSNAME+"Read", This, filename); +} + +// Write to file +// File can be XML, JSON, or HDF5. +// We'll use filename's extension to determine the type you want written. +int +ReactionSuiteWrite(ConstHandle2ConstReactionSuite This, const char *const filename) +{ + return detail::writeHandle + (CLASSNAME, CLASSNAME+"Write", This, filename); +} + +// Print to standard output, in our prettyprinting format +int +ReactionSuitePrint(ConstHandle2ConstReactionSuite This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"Print", This); +} + +// Print to standard output, as XML +int +ReactionSuitePrintXML(ConstHandle2ConstReactionSuite This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintXML", This, "XML"); +} + +// Print to standard output, as JSON +int +ReactionSuitePrintJSON(ConstHandle2ConstReactionSuite This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintJSON", This, "JSON"); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: evaluation +// ----------------------------------------------------------------------------- + +// Has +int +ReactionSuiteEvaluationHas(ConstHandle2ConstReactionSuite This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"EvaluationHas", This, extract::evaluation); +} + +// Get +// Returns by value +const char * +ReactionSuiteEvaluationGet(ConstHandle2ConstReactionSuite This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"EvaluationGet", This, extract::evaluation); +} + +// Set +void +ReactionSuiteEvaluationSet(ConstHandle2ReactionSuite This, const char *const evaluation) +{ + detail::setField + (CLASSNAME, CLASSNAME+"EvaluationSet", This, extract::evaluation, evaluation); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: format +// ----------------------------------------------------------------------------- + +// Has +int +ReactionSuiteFormatHas(ConstHandle2ConstReactionSuite This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"FormatHas", This, extract::format); +} + +// Get +// Returns by value +const char * +ReactionSuiteFormatGet(ConstHandle2ConstReactionSuite This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"FormatGet", This, extract::format); +} + +// Set +void +ReactionSuiteFormatSet(ConstHandle2ReactionSuite This, const char *const format) +{ + detail::setField + (CLASSNAME, CLASSNAME+"FormatSet", This, extract::format, format); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: projectile +// ----------------------------------------------------------------------------- + +// Has +int +ReactionSuiteProjectileHas(ConstHandle2ConstReactionSuite This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"ProjectileHas", This, extract::projectile); +} + +// Get +// Returns by value +const char * +ReactionSuiteProjectileGet(ConstHandle2ConstReactionSuite This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"ProjectileGet", This, extract::projectile); +} + +// Set +void +ReactionSuiteProjectileSet(ConstHandle2ReactionSuite This, const char *const projectile) +{ + detail::setField + (CLASSNAME, CLASSNAME+"ProjectileSet", This, extract::projectile, projectile); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: projectileFrame +// ----------------------------------------------------------------------------- + +// Has +int +ReactionSuiteProjectileFrameHas(ConstHandle2ConstReactionSuite This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"ProjectileFrameHas", This, extract::projectileFrame); +} + +// Get +// Returns by value +enums::Frame +ReactionSuiteProjectileFrameGet(ConstHandle2ConstReactionSuite This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"ProjectileFrameGet", This, extract::projectileFrame); +} + +// Set +void +ReactionSuiteProjectileFrameSet(ConstHandle2ReactionSuite This, const enums::Frame projectileFrame) +{ + detail::setField + (CLASSNAME, CLASSNAME+"ProjectileFrameSet", This, extract::projectileFrame, projectileFrame); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: target +// ----------------------------------------------------------------------------- + +// Has +int +ReactionSuiteTargetHas(ConstHandle2ConstReactionSuite This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"TargetHas", This, extract::target); +} + +// Get +// Returns by value +const char * +ReactionSuiteTargetGet(ConstHandle2ConstReactionSuite This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"TargetGet", This, extract::target); +} + +// Set +void +ReactionSuiteTargetSet(ConstHandle2ReactionSuite This, const char *const target) +{ + detail::setField + (CLASSNAME, CLASSNAME+"TargetSet", This, extract::target, target); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: interaction +// ----------------------------------------------------------------------------- + +// Has +int +ReactionSuiteInteractionHas(ConstHandle2ConstReactionSuite This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"InteractionHas", This, extract::interaction); +} + +// Get +// Returns by value +enums::Interaction +ReactionSuiteInteractionGet(ConstHandle2ConstReactionSuite This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"InteractionGet", This, extract::interaction); +} + +// Set +void +ReactionSuiteInteractionSet(ConstHandle2ReactionSuite This, const enums::Interaction interaction) +{ + detail::setField + (CLASSNAME, CLASSNAME+"InteractionSet", This, extract::interaction, interaction); +} + + +// ----------------------------------------------------------------------------- +// Child: reactions +// ----------------------------------------------------------------------------- + +// Has +int +ReactionSuiteReactionsHas(ConstHandle2ConstReactionSuite This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"ReactionsHas", This, extract::reactions); +} + +// Get, const +Handle2ConstReactions +ReactionSuiteReactionsGetConst(ConstHandle2ConstReactionSuite This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"ReactionsGetConst", This, extract::reactions); +} + +// Get, non-const +Handle2Reactions +ReactionSuiteReactionsGet(ConstHandle2ReactionSuite This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"ReactionsGet", This, extract::reactions); +} + +// Set +void +ReactionSuiteReactionsSet(ConstHandle2ReactionSuite This, ConstHandle2ConstReactions reactions) +{ + detail::setField + (CLASSNAME, CLASSNAME+"ReactionsSet", This, extract::reactions, reactions); +} diff --git a/autogen/prototype/proto/c/src/v1.9/transport/ReactionSuite.h b/autogen/prototype/proto/c/src/v1.9/transport/ReactionSuite.h new file mode 100644 index 000000000..e7a578052 --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/transport/ReactionSuite.h @@ -0,0 +1,279 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// Interface for C +// This header file is designed to work with both C and C++ +// Function definitions are in this file's .cpp source + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// Instructions for Users +// +// Constructs you're MORE likely to care about are preceded with: +// // +++ comment +// Constructs you're LESS likely to care about are preceded with: +// // --- comment +// Anything not marked as above can be ignored by most users. +// +// ReactionSuite is the basic handle type in this file. Example: +// // Create a default ReactionSuite object: +// ReactionSuite handle = ReactionSuiteDefault(); +// Functions involving ReactionSuite are declared throughout this file. +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// Preliminaries +// ----------------------------------------------------------------------------- + +#ifndef C_INTERFACE_PROTO_V1_9_TRANSPORT_REACTIONSUITE +#define C_INTERFACE_PROTO_V1_9_TRANSPORT_REACTIONSUITE + +#include "GNDStk.h" +#include "v1.9/transport/Reactions.h" + +#ifdef __cplusplus + #define extern_c extern "C" +#else + #define extern_c +#endif + +// Proxy C struct for the handled C++ class +struct ReactionSuiteClass { }; + + +// ----------------------------------------------------------------------------- +// Handle types +// ----------------------------------------------------------------------------- + +// +++ ReactionSuite +// +++ General handle, suitable for most users. If you're not concerned about +// +++ strict "const correctness" in your C code, you can probably use this in +// +++ place of any function parameter of a const-aware handle type. +typedef struct ReactionSuiteClass *ReactionSuite; + +// --- Const-aware handles. +typedef const struct ReactionSuiteClass *const ConstHandle2ConstReactionSuite; +typedef struct ReactionSuiteClass *const ConstHandle2ReactionSuite; +typedef const struct ReactionSuiteClass * Handle2ConstReactionSuite; +typedef struct ReactionSuiteClass * Handle2ReactionSuite; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// --- Create, default, const +extern_c Handle2ConstReactionSuite +ReactionSuiteDefaultConst(); + +// +++ Create, default +extern_c Handle2ReactionSuite +ReactionSuiteDefault(); + +// --- Create, general, const +extern_c Handle2ConstReactionSuite +ReactionSuiteCreateConst( + const char *const evaluation, + const char *const format, + const char *const projectile, + const enums::Frame projectileFrame, + const char *const target, + const enums::Interaction interaction, + ConstHandle2ConstReactions reactions +); + +// +++ Create, general +extern_c Handle2ReactionSuite +ReactionSuiteCreate( + const char *const evaluation, + const char *const format, + const char *const projectile, + const enums::Frame projectileFrame, + const char *const target, + const enums::Interaction interaction, + ConstHandle2ConstReactions reactions +); + +// +++ Assign +// +++ Use this to assign one handled object to another. Don't assign handles, +// +++ as with to = from. That has a meaning that you probably don't intend. +extern_c void +ReactionSuiteAssign(ConstHandle2ReactionSuite This, ConstHandle2ConstReactionSuite from); + +// +++ Delete +// +++ We'll attempt to remove no-longer-used objects automatically, but you +// +++ may improve performance if you delete them when you're done with them. +extern_c void +ReactionSuiteDelete(ConstHandle2ConstReactionSuite This); + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// +++ Read from file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll examine the file's contents to determine its type automatically. +extern_c int +ReactionSuiteRead(ConstHandle2ReactionSuite This, const char *const filename); + +// +++ Write to file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll use filename's extension to determine the type you want written. +extern_c int +ReactionSuiteWrite(ConstHandle2ConstReactionSuite This, const char *const filename); + +// +++ Print to standard output, in our prettyprinting format +extern_c int +ReactionSuitePrint(ConstHandle2ConstReactionSuite This); + +// +++ Print to standard output, as XML +extern_c int +ReactionSuitePrintXML(ConstHandle2ConstReactionSuite This); + +// +++ Print to standard output, as JSON +extern_c int +ReactionSuitePrintJSON(ConstHandle2ConstReactionSuite This); + + +// ----------------------------------------------------------------------------- +// Metadatum: evaluation +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +ReactionSuiteEvaluationHas(ConstHandle2ConstReactionSuite This); + +// +++ Get +// +++ Returns by value +extern_c const char * +ReactionSuiteEvaluationGet(ConstHandle2ConstReactionSuite This); + +// +++ Set +extern_c void +ReactionSuiteEvaluationSet(ConstHandle2ReactionSuite This, const char *const evaluation); + + +// ----------------------------------------------------------------------------- +// Metadatum: format +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +ReactionSuiteFormatHas(ConstHandle2ConstReactionSuite This); + +// +++ Get +// +++ Returns by value +extern_c const char * +ReactionSuiteFormatGet(ConstHandle2ConstReactionSuite This); + +// +++ Set +extern_c void +ReactionSuiteFormatSet(ConstHandle2ReactionSuite This, const char *const format); + + +// ----------------------------------------------------------------------------- +// Metadatum: projectile +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +ReactionSuiteProjectileHas(ConstHandle2ConstReactionSuite This); + +// +++ Get +// +++ Returns by value +extern_c const char * +ReactionSuiteProjectileGet(ConstHandle2ConstReactionSuite This); + +// +++ Set +extern_c void +ReactionSuiteProjectileSet(ConstHandle2ReactionSuite This, const char *const projectile); + + +// ----------------------------------------------------------------------------- +// Metadatum: projectileFrame +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +ReactionSuiteProjectileFrameHas(ConstHandle2ConstReactionSuite This); + +// +++ Get +// +++ Returns by value +extern_c enums::Frame +ReactionSuiteProjectileFrameGet(ConstHandle2ConstReactionSuite This); + +// +++ Set +extern_c void +ReactionSuiteProjectileFrameSet(ConstHandle2ReactionSuite This, const enums::Frame projectileFrame); + + +// ----------------------------------------------------------------------------- +// Metadatum: target +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +ReactionSuiteTargetHas(ConstHandle2ConstReactionSuite This); + +// +++ Get +// +++ Returns by value +extern_c const char * +ReactionSuiteTargetGet(ConstHandle2ConstReactionSuite This); + +// +++ Set +extern_c void +ReactionSuiteTargetSet(ConstHandle2ReactionSuite This, const char *const target); + + +// ----------------------------------------------------------------------------- +// Metadatum: interaction +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +ReactionSuiteInteractionHas(ConstHandle2ConstReactionSuite This); + +// +++ Get +// +++ Returns by value +extern_c enums::Interaction +ReactionSuiteInteractionGet(ConstHandle2ConstReactionSuite This); + +// +++ Set +extern_c void +ReactionSuiteInteractionSet(ConstHandle2ReactionSuite This, const enums::Interaction interaction); + + +// ----------------------------------------------------------------------------- +// Child: reactions +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +ReactionSuiteReactionsHas(ConstHandle2ConstReactionSuite This); + +// --- Get, const +extern_c Handle2ConstReactions +ReactionSuiteReactionsGetConst(ConstHandle2ConstReactionSuite This); + +// +++ Get, non-const +extern_c Handle2Reactions +ReactionSuiteReactionsGet(ConstHandle2ReactionSuite This); + +// +++ Set +extern_c void +ReactionSuiteReactionsSet(ConstHandle2ReactionSuite This, ConstHandle2ConstReactions reactions); + + +// ----------------------------------------------------------------------------- +// Done +// ----------------------------------------------------------------------------- + +#undef extern_c +#endif diff --git a/autogen/prototype/proto/c/src/v1.9/transport/Reactions.cpp b/autogen/prototype/proto/c/src/v1.9/transport/Reactions.cpp new file mode 100644 index 000000000..7b75118e5 --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/transport/Reactions.cpp @@ -0,0 +1,340 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include "proto/v1_9/transport/Reactions.hpp" +#include "Reactions.h" + +using namespace njoy::GNDStk; +using namespace proto::v1_9; + +using C = ReactionsClass; +using CPP = multigroup::Reactions; + +static const std::string CLASSNAME = "Reactions"; + +namespace extract { + static auto reaction = [](auto &obj) { return &obj.reaction; }; +} + +using CPPReaction = transport::Reaction; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// Create, default, const +Handle2ConstReactions +ReactionsDefaultConst() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"DefaultConst"); +} + +// Create, default +Handle2Reactions +ReactionsDefault() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"Default"); +} + +// Create, general, const +Handle2ConstReactions +ReactionsCreateConst( + ConstHandle2Reaction *const reaction, const size_t reactionSize +) { + ConstHandle2Reactions handle = detail::createHandle( + CLASSNAME, CLASSNAME+"CreateConst", + std::vector{} + ); + for (size_t ReactionN = 0; ReactionN < reactionSize; ++ReactionN) + ReactionsReactionAdd(handle, reaction[ReactionN]); + return handle; +} + +// Create, general +Handle2Reactions +ReactionsCreate( + ConstHandle2Reaction *const reaction, const size_t reactionSize +) { + ConstHandle2Reactions handle = detail::createHandle( + CLASSNAME, CLASSNAME+"Create", + std::vector{} + ); + for (size_t ReactionN = 0; ReactionN < reactionSize; ++ReactionN) + ReactionsReactionAdd(handle, reaction[ReactionN]); + return handle; +} + +// Assign +// Use this to assign one handled object to another. Don't assign handles, +// as with to = from. That has a meaning that you probably don't intend. +void +ReactionsAssign(ConstHandle2Reactions This, ConstHandle2ConstReactions from) +{ + detail::assignHandle + (CLASSNAME, CLASSNAME+"Assign", This, from); +} + +// Delete +// We'll attempt to remove no-longer-used objects automatically, but you +// may improve performance if you delete them when you're done with them. +void +ReactionsDelete(ConstHandle2ConstReactions This) +{ + detail::deleteHandle + (CLASSNAME, CLASSNAME+"Delete", This); +} + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// Read from file +// File can be XML, JSON, or HDF5. +// We'll examine the file's contents to determine its type automatically. +int +ReactionsRead(ConstHandle2Reactions This, const char *const filename) +{ + return detail::readHandle + (CLASSNAME, CLASSNAME+"Read", This, filename); +} + +// Write to file +// File can be XML, JSON, or HDF5. +// We'll use filename's extension to determine the type you want written. +int +ReactionsWrite(ConstHandle2ConstReactions This, const char *const filename) +{ + return detail::writeHandle + (CLASSNAME, CLASSNAME+"Write", This, filename); +} + +// Print to standard output, in our prettyprinting format +int +ReactionsPrint(ConstHandle2ConstReactions This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"Print", This); +} + +// Print to standard output, as XML +int +ReactionsPrintXML(ConstHandle2ConstReactions This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintXML", This, "XML"); +} + +// Print to standard output, as JSON +int +ReactionsPrintJSON(ConstHandle2ConstReactions This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintJSON", This, "JSON"); +} + + +// ----------------------------------------------------------------------------- +// Child: reaction +// ----------------------------------------------------------------------------- + +// Has +int +ReactionsReactionHas(ConstHandle2ConstReactions This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"ReactionHas", This, extract::reaction); +} + +// Clear +void +ReactionsReactionClear(ConstHandle2Reactions This) +{ + detail::clearContainer + (CLASSNAME, CLASSNAME+"ReactionClear", This, extract::reaction); +} + +// Size +size_t +ReactionsReactionSize(ConstHandle2ConstReactions This) +{ + return detail::sizeOfContainer + (CLASSNAME, CLASSNAME+"ReactionSize", This, extract::reaction); +} + +// Add +void +ReactionsReactionAdd(ConstHandle2Reactions This, ConstHandle2ConstReaction reaction) +{ + detail::addToContainer + (CLASSNAME, CLASSNAME+"ReactionAdd", This, extract::reaction, reaction); +} + +// Get, by index \in [0,size), const +Handle2ConstReaction +ReactionsReactionGetConst(ConstHandle2ConstReactions This, const size_t index_) +{ + return detail::getByIndex + (CLASSNAME, CLASSNAME+"ReactionGetConst", This, extract::reaction, index_); +} + +// Get, by index \in [0,size), non-const +Handle2Reaction +ReactionsReactionGet(ConstHandle2Reactions This, const size_t index_) +{ + return detail::getByIndex + (CLASSNAME, CLASSNAME+"ReactionGet", This, extract::reaction, index_); +} + +// Set, by index \in [0,size) +void +ReactionsReactionSet( + ConstHandle2Reactions This, + const size_t index_, + ConstHandle2ConstReaction reaction +) { + detail::setByIndex + (CLASSNAME, CLASSNAME+"ReactionSet", This, extract::reaction, index_, reaction); +} + +// Has, by ENDF_MT +int +ReactionsReactionHasByENDFMT( + ConstHandle2ConstReactions This, + const int ENDF_MT +) { + return detail::hasByMetadatum + (CLASSNAME, CLASSNAME+"ReactionHasByENDFMT", + This, extract::reaction, meta::ENDF_MT, ENDF_MT); +} + +// Get, by ENDF_MT, const +Handle2ConstReaction +ReactionsReactionGetByENDFMTConst( + ConstHandle2ConstReactions This, + const int ENDF_MT +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"ReactionGetByENDFMTConst", + This, extract::reaction, meta::ENDF_MT, ENDF_MT); +} + +// Get, by ENDF_MT, non-const +Handle2Reaction +ReactionsReactionGetByENDFMT( + ConstHandle2Reactions This, + const int ENDF_MT +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"ReactionGetByENDFMT", + This, extract::reaction, meta::ENDF_MT, ENDF_MT); +} + +// Set, by ENDF_MT +void +ReactionsReactionSetByENDFMT( + ConstHandle2Reactions This, + const int ENDF_MT, + ConstHandle2ConstReaction reaction +) { + detail::setByMetadatum + (CLASSNAME, CLASSNAME+"ReactionSetByENDFMT", + This, extract::reaction, meta::ENDF_MT, ENDF_MT, reaction); +} + +// Has, by fissionGenre +int +ReactionsReactionHasByFissionGenre( + ConstHandle2ConstReactions This, + const char *const fissionGenre +) { + return detail::hasByMetadatum + (CLASSNAME, CLASSNAME+"ReactionHasByFissionGenre", + This, extract::reaction, meta::fissionGenre, fissionGenre); +} + +// Get, by fissionGenre, const +Handle2ConstReaction +ReactionsReactionGetByFissionGenreConst( + ConstHandle2ConstReactions This, + const char *const fissionGenre +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"ReactionGetByFissionGenreConst", + This, extract::reaction, meta::fissionGenre, fissionGenre); +} + +// Get, by fissionGenre, non-const +Handle2Reaction +ReactionsReactionGetByFissionGenre( + ConstHandle2Reactions This, + const char *const fissionGenre +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"ReactionGetByFissionGenre", + This, extract::reaction, meta::fissionGenre, fissionGenre); +} + +// Set, by fissionGenre +void +ReactionsReactionSetByFissionGenre( + ConstHandle2Reactions This, + const char *const fissionGenre, + ConstHandle2ConstReaction reaction +) { + detail::setByMetadatum + (CLASSNAME, CLASSNAME+"ReactionSetByFissionGenre", + This, extract::reaction, meta::fissionGenre, fissionGenre, reaction); +} + +// Has, by label +int +ReactionsReactionHasByLabel( + ConstHandle2ConstReactions This, + const char *const label +) { + return detail::hasByMetadatum + (CLASSNAME, CLASSNAME+"ReactionHasByLabel", + This, extract::reaction, meta::label, label); +} + +// Get, by label, const +Handle2ConstReaction +ReactionsReactionGetByLabelConst( + ConstHandle2ConstReactions This, + const char *const label +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"ReactionGetByLabelConst", + This, extract::reaction, meta::label, label); +} + +// Get, by label, non-const +Handle2Reaction +ReactionsReactionGetByLabel( + ConstHandle2Reactions This, + const char *const label +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"ReactionGetByLabel", + This, extract::reaction, meta::label, label); +} + +// Set, by label +void +ReactionsReactionSetByLabel( + ConstHandle2Reactions This, + const char *const label, + ConstHandle2ConstReaction reaction +) { + detail::setByMetadatum + (CLASSNAME, CLASSNAME+"ReactionSetByLabel", + This, extract::reaction, meta::label, label, reaction); +} diff --git a/autogen/prototype/proto/c/src/v1.9/transport/Reactions.h b/autogen/prototype/proto/c/src/v1.9/transport/Reactions.h new file mode 100644 index 000000000..a3589a5ef --- /dev/null +++ b/autogen/prototype/proto/c/src/v1.9/transport/Reactions.h @@ -0,0 +1,262 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// Interface for C +// This header file is designed to work with both C and C++ +// Function definitions are in this file's .cpp source + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// Instructions for Users +// +// Constructs you're MORE likely to care about are preceded with: +// // +++ comment +// Constructs you're LESS likely to care about are preceded with: +// // --- comment +// Anything not marked as above can be ignored by most users. +// +// Reactions is the basic handle type in this file. Example: +// // Create a default Reactions object: +// Reactions handle = ReactionsDefault(); +// Functions involving Reactions are declared throughout this file. +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// Preliminaries +// ----------------------------------------------------------------------------- + +#ifndef C_INTERFACE_PROTO_V1_9_TRANSPORT_REACTIONS +#define C_INTERFACE_PROTO_V1_9_TRANSPORT_REACTIONS + +#include "GNDStk.h" +#include "v1.9/transport/Reaction.h" + +#ifdef __cplusplus + #define extern_c extern "C" +#else + #define extern_c +#endif + +// Proxy C struct for the handled C++ class +struct ReactionsClass { }; + + +// ----------------------------------------------------------------------------- +// Handle types +// ----------------------------------------------------------------------------- + +// +++ Reactions +// +++ General handle, suitable for most users. If you're not concerned about +// +++ strict "const correctness" in your C code, you can probably use this in +// +++ place of any function parameter of a const-aware handle type. +typedef struct ReactionsClass *Reactions; + +// --- Const-aware handles. +typedef const struct ReactionsClass *const ConstHandle2ConstReactions; +typedef struct ReactionsClass *const ConstHandle2Reactions; +typedef const struct ReactionsClass * Handle2ConstReactions; +typedef struct ReactionsClass * Handle2Reactions; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// --- Create, default, const +extern_c Handle2ConstReactions +ReactionsDefaultConst(); + +// +++ Create, default +extern_c Handle2Reactions +ReactionsDefault(); + +// --- Create, general, const +extern_c Handle2ConstReactions +ReactionsCreateConst( + ConstHandle2Reaction *const reaction, const size_t reactionSize +); + +// +++ Create, general +extern_c Handle2Reactions +ReactionsCreate( + ConstHandle2Reaction *const reaction, const size_t reactionSize +); + +// +++ Assign +// +++ Use this to assign one handled object to another. Don't assign handles, +// +++ as with to = from. That has a meaning that you probably don't intend. +extern_c void +ReactionsAssign(ConstHandle2Reactions This, ConstHandle2ConstReactions from); + +// +++ Delete +// +++ We'll attempt to remove no-longer-used objects automatically, but you +// +++ may improve performance if you delete them when you're done with them. +extern_c void +ReactionsDelete(ConstHandle2ConstReactions This); + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// +++ Read from file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll examine the file's contents to determine its type automatically. +extern_c int +ReactionsRead(ConstHandle2Reactions This, const char *const filename); + +// +++ Write to file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll use filename's extension to determine the type you want written. +extern_c int +ReactionsWrite(ConstHandle2ConstReactions This, const char *const filename); + +// +++ Print to standard output, in our prettyprinting format +extern_c int +ReactionsPrint(ConstHandle2ConstReactions This); + +// +++ Print to standard output, as XML +extern_c int +ReactionsPrintXML(ConstHandle2ConstReactions This); + +// +++ Print to standard output, as JSON +extern_c int +ReactionsPrintJSON(ConstHandle2ConstReactions This); + + +// ----------------------------------------------------------------------------- +// Child: reaction +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +ReactionsReactionHas(ConstHandle2ConstReactions This); + +// +++ Clear +extern_c void +ReactionsReactionClear(ConstHandle2Reactions This); + +// +++ Size +extern_c size_t +ReactionsReactionSize(ConstHandle2ConstReactions This); + +// +++ Add +extern_c void +ReactionsReactionAdd(ConstHandle2Reactions This, ConstHandle2ConstReaction reaction); + +// --- Get, by index \in [0,size), const +extern_c Handle2ConstReaction +ReactionsReactionGetConst(ConstHandle2ConstReactions This, const size_t index_); + +// +++ Get, by index \in [0,size), non-const +extern_c Handle2Reaction +ReactionsReactionGet(ConstHandle2Reactions This, const size_t index_); + +// +++ Set, by index \in [0,size) +extern_c void +ReactionsReactionSet( + ConstHandle2Reactions This, + const size_t index_, + ConstHandle2ConstReaction reaction +); + +// +++ Has, by ENDF_MT +extern_c int +ReactionsReactionHasByENDFMT( + ConstHandle2ConstReactions This, + const int ENDF_MT +); + +// --- Get, by ENDF_MT, const +extern_c Handle2ConstReaction +ReactionsReactionGetByENDFMTConst( + ConstHandle2ConstReactions This, + const int ENDF_MT +); + +// +++ Get, by ENDF_MT, non-const +extern_c Handle2Reaction +ReactionsReactionGetByENDFMT( + ConstHandle2Reactions This, + const int ENDF_MT +); + +// +++ Set, by ENDF_MT +extern_c void +ReactionsReactionSetByENDFMT( + ConstHandle2Reactions This, + const int ENDF_MT, + ConstHandle2ConstReaction reaction +); + +// +++ Has, by fissionGenre +extern_c int +ReactionsReactionHasByFissionGenre( + ConstHandle2ConstReactions This, + const char *const fissionGenre +); + +// --- Get, by fissionGenre, const +extern_c Handle2ConstReaction +ReactionsReactionGetByFissionGenreConst( + ConstHandle2ConstReactions This, + const char *const fissionGenre +); + +// +++ Get, by fissionGenre, non-const +extern_c Handle2Reaction +ReactionsReactionGetByFissionGenre( + ConstHandle2Reactions This, + const char *const fissionGenre +); + +// +++ Set, by fissionGenre +extern_c void +ReactionsReactionSetByFissionGenre( + ConstHandle2Reactions This, + const char *const fissionGenre, + ConstHandle2ConstReaction reaction +); + +// +++ Has, by label +extern_c int +ReactionsReactionHasByLabel( + ConstHandle2ConstReactions This, + const char *const label +); + +// --- Get, by label, const +extern_c Handle2ConstReaction +ReactionsReactionGetByLabelConst( + ConstHandle2ConstReactions This, + const char *const label +); + +// +++ Get, by label, non-const +extern_c Handle2Reaction +ReactionsReactionGetByLabel( + ConstHandle2Reactions This, + const char *const label +); + +// +++ Set, by label +extern_c void +ReactionsReactionSetByLabel( + ConstHandle2Reactions This, + const char *const label, + ConstHandle2ConstReaction reaction +); + + +// ----------------------------------------------------------------------------- +// Done +// ----------------------------------------------------------------------------- + +#undef extern_c +#endif diff --git a/autogen/prototype/proto/python/runtests.sh b/autogen/prototype/proto/python/runtests.sh new file mode 100755 index 000000000..449471762 --- /dev/null +++ b/autogen/prototype/proto/python/runtests.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# this script copies the dynamic library for the GNDStk python module +# and runs all the unit tests it can find + +rm GNDStk*.so +cp ../../../../build/GNDStk*.so . +python -m unittest discover -v -p "Test*" diff --git a/autogen/prototype/proto/python/src/v1.9/containers.python.cpp b/autogen/prototype/proto/python/src/v1.9/containers.python.cpp new file mode 100644 index 000000000..e04a6cd47 --- /dev/null +++ b/autogen/prototype/proto/python/src/v1.9/containers.python.cpp @@ -0,0 +1,43 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include +#include + +namespace python = pybind11; + +// v1.9 interface +namespace python_v1_9 { + +// containers declarations +namespace python_containers { + void wrapLink(python::module &); + void wrapAxis(python::module &); + void wrapValues(python::module &); + void wrapGrid(python::module &); + void wrapAxes(python::module &); + void wrapXYs1d(python::module &); + void wrapRegions1d(python::module &); +} // namespace python_containers + +// containers wrapper +void wrapContainers(python::module &module) +{ + // create the containers submodule + python::module submodule = module.def_submodule( + "containers", + "proto v1.9 containers" + ); + + // wrap containers components + python_containers::wrapLink(submodule); + python_containers::wrapAxis(submodule); + python_containers::wrapValues(submodule); + python_containers::wrapGrid(submodule); + python_containers::wrapAxes(submodule); + python_containers::wrapXYs1d(submodule); + python_containers::wrapRegions1d(submodule); +}; + +} // namespace python_v1_9 diff --git a/autogen/prototype/proto/python/src/v1.9/containers/Axes.python.cpp b/autogen/prototype/proto/python/src/v1.9/containers/Axes.python.cpp new file mode 100644 index 000000000..d8552bf0d --- /dev/null +++ b/autogen/prototype/proto/python/src/v1.9/containers/Axes.python.cpp @@ -0,0 +1,67 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "proto/v1.9/containers/Axes.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v1_9 { +namespace python_containers { + +// Axes wrapper +void wrapAxes(python::module &module) +{ + using namespace proto; + using namespace proto::v1_9; + + // type aliases + using Component = containers::Axes; + using axis_grid_t = std::variant< + containers::Axis, + containers::Grid + >; + + // create the component + python::class_ component( + module, + "Axes", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::vector & + >(), + python::arg("href") = std::nullopt, + python::arg("axis_grid"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + [](const Component &self) { return self.href(); }, + Component::documentation("href").data() + ) + .def_property_readonly( + "axis_grid", + [](const Component &self) { return self.axis_grid(); }, + Component::documentation("axis_grid").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v1_9 diff --git a/autogen/prototype/proto/python/src/v1.9/containers/Axis.python.cpp b/autogen/prototype/proto/python/src/v1.9/containers/Axis.python.cpp new file mode 100644 index 000000000..8fe13ac2c --- /dev/null +++ b/autogen/prototype/proto/python/src/v1.9/containers/Axis.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "proto/v1.9/containers/Axis.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v1_9 { +namespace python_containers { + +// Axis wrapper +void wrapAxis(python::module &module) +{ + using namespace proto; + using namespace proto::v1_9; + + // type aliases + using Component = containers::Axis; + + // create the component + python::class_ component( + module, + "Axis", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("index") = std::nullopt, + python::arg("label") = std::nullopt, + python::arg("unit") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "index", + [](const Component &self) { return self.index(); }, + Component::documentation("index").data() + ) + .def_property_readonly( + "label", + [](const Component &self) { return self.label(); }, + Component::documentation("label").data() + ) + .def_property_readonly( + "unit", + [](const Component &self) { return self.unit(); }, + Component::documentation("unit").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v1_9 diff --git a/autogen/prototype/proto/python/src/v1.9/containers/Grid.python.cpp b/autogen/prototype/proto/python/src/v1.9/containers/Grid.python.cpp new file mode 100644 index 000000000..eb10b1659 --- /dev/null +++ b/autogen/prototype/proto/python/src/v1.9/containers/Grid.python.cpp @@ -0,0 +1,105 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "proto/v1.9/containers/Grid.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v1_9 { +namespace python_containers { + +// Grid wrapper +void wrapGrid(python::module &module) +{ + using namespace proto; + using namespace proto::v1_9; + + // type aliases + using Component = containers::Grid; + using link_values_t = std::variant< + containers::Values, + containers::Link + >; + + // create the component + python::class_ component( + module, + "Grid", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const link_values_t & + >(), + python::arg("index") = std::nullopt, + python::arg("interpolation") = std::nullopt, + python::arg("label") = std::nullopt, + python::arg("style") = std::nullopt, + python::arg("unit") = std::nullopt, + python::arg("link_values"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "index", + [](const Component &self) { return self.index(); }, + Component::documentation("index").data() + ) + .def_property_readonly( + "interpolation", + [](const Component &self) { return self.interpolation().value(); }, + Component::documentation("interpolation").data() + ) + .def_property_readonly( + "label", + [](const Component &self) { return self.label(); }, + Component::documentation("label").data() + ) + .def_property_readonly( + "style", + [](const Component &self) { return self.style(); }, + Component::documentation("style").data() + ) + .def_property_readonly( + "unit", + [](const Component &self) { return self.unit(); }, + Component::documentation("unit").data() + ) + .def_property_readonly( + "values", + [](const Component &self) { return self.values(); }, + Component::documentation("values").data() + ) + .def_property_readonly( + "link", + [](const Component &self) { return self.link(); }, + Component::documentation("link").data() + ) + .def_property_readonly( + "link_values", + [](const Component &self) { return self.link_values(); }, + Component::documentation("link_values").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v1_9 diff --git a/autogen/prototype/proto/python/src/v1.9/containers/Link.python.cpp b/autogen/prototype/proto/python/src/v1.9/containers/Link.python.cpp new file mode 100644 index 000000000..5ac861835 --- /dev/null +++ b/autogen/prototype/proto/python/src/v1.9/containers/Link.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "proto/v1.9/containers/Link.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v1_9 { +namespace python_containers { + +// Link wrapper +void wrapLink(python::module &module) +{ + using namespace proto; + using namespace proto::v1_9; + + // type aliases + using Component = containers::Link; + + // create the component + python::class_ component( + module, + "Link", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string & + >(), + python::arg("href"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + [](const Component &self) { return self.href(); }, + Component::documentation("href").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v1_9 diff --git a/autogen/prototype/proto/python/src/v1.9/containers/Regions1d.python.cpp b/autogen/prototype/proto/python/src/v1.9/containers/Regions1d.python.cpp new file mode 100644 index 000000000..cca199b39 --- /dev/null +++ b/autogen/prototype/proto/python/src/v1.9/containers/Regions1d.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "proto/v1.9/containers/Regions1d.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v1_9 { +namespace python_containers { + +// Regions1d wrapper +void wrapRegions1d(python::module &module) +{ + using namespace proto; + using namespace proto::v1_9; + + // type aliases + using Component = containers::Regions1d; + + // create the component + python::class_ component( + module, + "Regions1d", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::vector & + >(), + python::arg("label") = std::nullopt, + python::arg("outer_domain_value") = std::nullopt, + python::arg("axes") = std::nullopt, + python::arg("xys1d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + [](const Component &self) { return self.label(); }, + Component::documentation("label").data() + ) + .def_property_readonly( + "outer_domain_value", + [](const Component &self) { return self.outerDomainValue(); }, + Component::documentation("outer_domain_value").data() + ) + .def_property_readonly( + "axes", + [](const Component &self) { return self.axes(); }, + Component::documentation("axes").data() + ) + .def_property_readonly( + "xys1d", + [](const Component &self) { return self.XYs1d(); }, + Component::documentation("xys1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v1_9 diff --git a/autogen/prototype/proto/python/src/v1.9/containers/Values.python.cpp b/autogen/prototype/proto/python/src/v1.9/containers/Values.python.cpp new file mode 100644 index 000000000..48f7f8f03 --- /dev/null +++ b/autogen/prototype/proto/python/src/v1.9/containers/Values.python.cpp @@ -0,0 +1,106 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "proto/v1.9/containers/Values.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v1_9 { +namespace python_containers { + +// Values wrapper +void wrapValues(python::module &module) +{ + using namespace proto; + using namespace proto::v1_9; + + // type aliases + using Component = containers::Values; + + // create the component + python::class_ component( + module, + "Values", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("value_type") = std::nullopt, + python::arg("start") = std::nullopt, + python::arg("length") = std::nullopt, + Component::documentation("constructor").data() + ) + .def( + python::init< + const std::vector & + >(), + python::arg("ints"), + Component::documentation("constructor").data() + ) + .def( + python::init< + const std::vector & + >(), + python::arg("doubles"), + Component::documentation("constructor").data() + ) + .def( + python::init< + const std::vector & + >(), + python::arg("strings"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "value_type", + [](const Component &self) { return self.valueType().value(); }, + Component::documentation("value_type").data() + ) + .def_property_readonly( + "start", + [](const Component &self) { return self.start().value(); }, + Component::documentation("start").data() + ) + .def_property_readonly( + "length", + [](const Component &self) { return self.length(); }, + Component::documentation("length").data() + ) + .def_property_readonly( + "ints", + [] (const Component &self) { return self.ints(); }, + Component::documentation("ints").data() + ) + .def_property_readonly( + "doubles", + [] (const Component &self) { return self.doubles(); }, + Component::documentation("doubles").data() + ) + .def_property_readonly( + "strings", + [] (const Component &self) { return self.strings(); }, + Component::documentation("strings").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v1_9 diff --git a/autogen/prototype/proto/python/src/v1.9/containers/XYs1d.python.cpp b/autogen/prototype/proto/python/src/v1.9/containers/XYs1d.python.cpp new file mode 100644 index 000000000..4fdc58900 --- /dev/null +++ b/autogen/prototype/proto/python/src/v1.9/containers/XYs1d.python.cpp @@ -0,0 +1,91 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "proto/v1.9/containers/XYs1d.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v1_9 { +namespace python_containers { + +// XYs1d wrapper +void wrapXYs1d(python::module &module) +{ + using namespace proto; + using namespace proto::v1_9; + + // type aliases + using Component = containers::XYs1d; + + // create the component + python::class_ component( + module, + "XYs1d", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const containers::Values & + >(), + python::arg("index") = std::nullopt, + python::arg("interpolation") = std::nullopt, + python::arg("label") = std::nullopt, + python::arg("outer_domain_value") = std::nullopt, + python::arg("axes") = std::nullopt, + python::arg("values"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "index", + [](const Component &self) { return self.index(); }, + Component::documentation("index").data() + ) + .def_property_readonly( + "interpolation", + [](const Component &self) { return self.interpolation().value(); }, + Component::documentation("interpolation").data() + ) + .def_property_readonly( + "label", + [](const Component &self) { return self.label(); }, + Component::documentation("label").data() + ) + .def_property_readonly( + "outer_domain_value", + [](const Component &self) { return self.outerDomainValue(); }, + Component::documentation("outer_domain_value").data() + ) + .def_property_readonly( + "axes", + [](const Component &self) { return self.axes(); }, + Component::documentation("axes").data() + ) + .def_property_readonly( + "values", + [](const Component &self) { return self.values(); }, + Component::documentation("values").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v1_9 diff --git a/python/src/v1.9/GNDS.python.cpp b/autogen/prototype/proto/python/src/v1.9/proto.python.cpp similarity index 100% rename from python/src/v1.9/GNDS.python.cpp rename to autogen/prototype/proto/python/src/v1.9/proto.python.cpp diff --git a/autogen/prototype/proto/python/src/v1.9/transport.python.cpp b/autogen/prototype/proto/python/src/v1.9/transport.python.cpp new file mode 100644 index 000000000..3e56ad225 --- /dev/null +++ b/autogen/prototype/proto/python/src/v1.9/transport.python.cpp @@ -0,0 +1,37 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include +#include + +namespace python = pybind11; + +// v1.9 interface +namespace python_v1_9 { + +// transport declarations +namespace python_transport { + void wrapCrossSection(python::module &); + void wrapReaction(python::module &); + void wrapReactions(python::module &); + void wrapReactionSuite(python::module &); +} // namespace python_transport + +// transport wrapper +void wrapTransport(python::module &module) +{ + // create the transport submodule + python::module submodule = module.def_submodule( + "transport", + "proto v1.9 transport" + ); + + // wrap transport components + python_transport::wrapCrossSection(submodule); + python_transport::wrapReaction(submodule); + python_transport::wrapReactions(submodule); + python_transport::wrapReactionSuite(submodule); +}; + +} // namespace python_v1_9 diff --git a/autogen/prototype/proto/python/src/v1.9/transport/CrossSection.python.cpp b/autogen/prototype/proto/python/src/v1.9/transport/CrossSection.python.cpp new file mode 100644 index 000000000..cff187581 --- /dev/null +++ b/autogen/prototype/proto/python/src/v1.9/transport/CrossSection.python.cpp @@ -0,0 +1,60 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "proto/v1.9/transport/CrossSection.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v1_9 { +namespace python_transport { + +// CrossSection wrapper +void wrapCrossSection(python::module &module) +{ + using namespace proto; + using namespace proto::v1_9; + + // type aliases + using Component = transport::CrossSection; + using XYs1d_regions1d_t = std::variant< + containers::XYs1d, + containers::Regions1d + >; + + // create the component + python::class_ component( + module, + "CrossSection", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("xys1d_regions1d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d_regions1d", + [](const Component &self) { return self.XYs1d_regions1d(); }, + Component::documentation("xys1d_regions1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v1_9 diff --git a/autogen/prototype/proto/python/src/v1.9/transport/Reaction.python.cpp b/autogen/prototype/proto/python/src/v1.9/transport/Reaction.python.cpp new file mode 100644 index 000000000..3d44fe5f7 --- /dev/null +++ b/autogen/prototype/proto/python/src/v1.9/transport/Reaction.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "proto/v1.9/transport/Reaction.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v1_9 { +namespace python_transport { + +// Reaction wrapper +void wrapReaction(python::module &module) +{ + using namespace proto; + using namespace proto::v1_9; + + // type aliases + using Component = transport::Reaction; + + // create the component + python::class_ component( + module, + "Reaction", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const int &, + const std::optional &, + const std::string &, + const transport::CrossSection & + >(), + python::arg("endf_mt"), + python::arg("fission_genre") = std::nullopt, + python::arg("label"), + python::arg("cross_section"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "endf_mt", + [](const Component &self) { return self.ENDF_MT(); }, + Component::documentation("endf_mt").data() + ) + .def_property_readonly( + "fission_genre", + [](const Component &self) { return self.fissionGenre(); }, + Component::documentation("fission_genre").data() + ) + .def_property_readonly( + "label", + [](const Component &self) { return self.label(); }, + Component::documentation("label").data() + ) + .def_property_readonly( + "cross_section", + [](const Component &self) { return self.crossSection(); }, + Component::documentation("cross_section").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v1_9 diff --git a/autogen/prototype/proto/python/src/v1.9/transport/ReactionSuite.python.cpp b/autogen/prototype/proto/python/src/v1.9/transport/ReactionSuite.python.cpp new file mode 100644 index 000000000..59bed563d --- /dev/null +++ b/autogen/prototype/proto/python/src/v1.9/transport/ReactionSuite.python.cpp @@ -0,0 +1,98 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "proto/v1.9/transport/ReactionSuite.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v1_9 { +namespace python_transport { + +// ReactionSuite wrapper +void wrapReactionSuite(python::module &module) +{ + using namespace proto; + using namespace proto::v1_9; + + // type aliases + using Component = transport::ReactionSuite; + + // create the component + python::class_ component( + module, + "ReactionSuite", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string &, + const std::string &, + const std::string &, + const enums::Frame &, + const std::string &, + const std::optional &, + const std::optional & + >(), + python::arg("evaluation"), + python::arg("format"), + python::arg("projectile"), + python::arg("projectile_frame"), + python::arg("target"), + python::arg("interaction") = std::nullopt, + python::arg("reactions") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "evaluation", + [](const Component &self) { return self.evaluation(); }, + Component::documentation("evaluation").data() + ) + .def_property_readonly( + "format", + [](const Component &self) { return self.format(); }, + Component::documentation("format").data() + ) + .def_property_readonly( + "projectile", + [](const Component &self) { return self.projectile(); }, + Component::documentation("projectile").data() + ) + .def_property_readonly( + "projectile_frame", + [](const Component &self) { return self.projectileFrame(); }, + Component::documentation("projectile_frame").data() + ) + .def_property_readonly( + "target", + [](const Component &self) { return self.target(); }, + Component::documentation("target").data() + ) + .def_property_readonly( + "interaction", + [](const Component &self) { return self.interaction(); }, + Component::documentation("interaction").data() + ) + .def_property_readonly( + "reactions", + [](const Component &self) { return self.reactions(); }, + Component::documentation("reactions").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v1_9 diff --git a/autogen/prototype/proto/python/src/v1.9/transport/Reactions.python.cpp b/autogen/prototype/proto/python/src/v1.9/transport/Reactions.python.cpp new file mode 100644 index 000000000..a8c04664f --- /dev/null +++ b/autogen/prototype/proto/python/src/v1.9/transport/Reactions.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "proto/v1.9/transport/Reactions.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v1_9 { +namespace python_transport { + +// Reactions wrapper +void wrapReactions(python::module &module) +{ + using namespace proto; + using namespace proto::v1_9; + + // type aliases + using Component = transport::Reactions; + + // create the component + python::class_ component( + module, + "Reactions", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("reaction"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "reaction", + [](const Component &self) { return self.reaction(); }, + Component::documentation("reaction").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v1_9 diff --git a/python/test/v1_9/__init__.py b/autogen/prototype/proto/python/test/v1.9/__init__.py similarity index 100% rename from python/test/v1_9/__init__.py rename to autogen/prototype/proto/python/test/v1.9/__init__.py diff --git a/autogen/prototype/proto/python/test/v1.9/__init__.pyc b/autogen/prototype/proto/python/test/v1.9/__init__.pyc new file mode 100644 index 000000000..fdd90207b Binary files /dev/null and b/autogen/prototype/proto/python/test/v1.9/__init__.pyc differ diff --git a/python/test/v1_9/containers/Test_GNDStk_v1_9_containers_Axis.py b/autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Axis.py similarity index 89% rename from python/test/v1_9/containers/Test_GNDStk_v1_9_containers_Axis.py rename to autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Axis.py index 4969f1ff9..6fc894786 100644 --- a/python/test/v1_9/containers/Test_GNDStk_v1_9_containers_Axis.py +++ b/autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Axis.py @@ -9,7 +9,7 @@ class Test_GNDStk_v1_9_containers_Axis( unittest.TestCase ) : """Unit test for the Section class.""" - chunk = ( '\n' ) + chunk = ( '' ) wrong = ( '' ) def test_component( self ) : @@ -32,17 +32,17 @@ def verify_chunk( self, chunk ) : # verify string self.assertEqual( self.chunk, chunk.to_xml_string() ) - # the data is given explicitly + # the data are given explicitly chunk = Axis( index = 1, label = 'energy_in', unit = 'eV' ) verify_chunk( self, chunk ) - # the data is read from a string + # the data are read from a string chunk = Axis.from_string( self.chunk ) verify_chunk( self, chunk ) - # the data is copied + # the data are copied copy = Axis( chunk ) verify_chunk( self, copy ) diff --git a/autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Axis.pyc b/autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Axis.pyc new file mode 100644 index 000000000..55dc979f1 Binary files /dev/null and b/autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Axis.pyc differ diff --git a/python/test/v1_9/containers/Test_GNDStk_v1_9_containers_Grid.py b/autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Grid.py similarity index 87% rename from python/test/v1_9/containers/Test_GNDStk_v1_9_containers_Grid.py rename to autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Grid.py index 133fdd77a..ed102cbc4 100644 --- a/python/test/v1_9/containers/Test_GNDStk_v1_9_containers_Grid.py +++ b/autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Grid.py @@ -12,14 +12,14 @@ class Test_GNDStk_v1_9_containers_Grid( unittest.TestCase ) : """Unit test for the Section class.""" chunk = ( '\n' - ' 1e-05 2e+07\n' - '\n' ) + ' 1e-05 2e+07\n' + '' ) chunkWithLink = ( '\n' ' \n' - '\n' ) + '' ) wrong = ( '\n' - ' 1e-05 2e+07\n' - '\n' ) + ' 1e-05 2e+07\n' + '' ) def test_component( self ) : @@ -57,19 +57,19 @@ def verify_chunk( self, chunk ) : # verify string self.assertEqual( self.chunk, chunk.to_xml_string() ) - # the data is given explicitly + # the data are given explicitly chunk = Grid( index = 2, label = "row_energy_bounds", unit = "eV", style = GridStyle.boundaries, link_values = Values( [ 1e-5, 2e7 ] ) ) verify_chunk( self, chunk ) - # the data is read from a string + # the data are read from a string chunk = Grid.from_string( self.chunk ) verify_chunk( self, chunk ) - # the data is copied + # the data are copied copy = Grid( chunk ) verify_chunk( self, copy ) diff --git a/autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Grid.pyc b/autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Grid.pyc new file mode 100644 index 000000000..07eb98480 Binary files /dev/null and b/autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Grid.pyc differ diff --git a/python/test/v1_9/containers/Test_GNDStk_v1_9_containers_Link.py b/autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Link.py similarity index 84% rename from python/test/v1_9/containers/Test_GNDStk_v1_9_containers_Link.py rename to autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Link.py index 9e28cc6ac..65a2fc61b 100644 --- a/python/test/v1_9/containers/Test_GNDStk_v1_9_containers_Link.py +++ b/autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Link.py @@ -9,8 +9,8 @@ class Test_GNDStk_v1_9_containers_Link( unittest.TestCase ) : """Unit test for the Section class.""" - chunk = ( '\n' ) - wrong = ( '\n' ) + chunk = ( '' ) + wrong = ( '' ) def test_component( self ) : @@ -22,17 +22,17 @@ def verify_chunk( self, chunk ) : # verify string self.assertEqual( self.chunk, chunk.to_xml_string() ) - # the data is given explicitly + # the data are given explicitly chunk = Link( href = '../../grid[@index=\'2\']/values' ) verify_chunk( self, chunk ) - # the data is read from a string + # the data are read from a string chunk = Link.from_string( self.chunk ) verify_chunk( self, chunk ) - # the data is copied + # the data are copied copy = Link( chunk ) verify_chunk( self, copy ) diff --git a/autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Link.pyc b/autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Link.pyc new file mode 100644 index 000000000..abb7681c7 Binary files /dev/null and b/autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Link.pyc differ diff --git a/python/test/v1_9/containers/Test_GNDStk_v1_9_containers_Values.py b/autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Values.py similarity index 80% rename from python/test/v1_9/containers/Test_GNDStk_v1_9_containers_Values.py rename to autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Values.py index 117ea1178..a64ae9db4 100644 --- a/python/test/v1_9/containers/Test_GNDStk_v1_9_containers_Values.py +++ b/autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Values.py @@ -9,10 +9,10 @@ class Test_GNDStk_v1_9_containers_Values( unittest.TestCase ) : """Unit test for the Section class.""" - chunk_doubles = ( '2500 8.9172 2550 8.9155\n' ) - chunk_ints = ( '2500 9 2550 9\n' ) - chunk_strings = ( '2500 8.9172 2550 8.9155\n' ) - wrong = ( '2500 8.9172 2550 8.9155\n' ) + chunk_doubles = ( '2500 8.9172 2550 8.9155' ) + chunk_ints = ( '2500 9 2550 9' ) + chunk_strings = ( '2500 8.9172 2550 8.9155' ) + wrong = ( '2500 8.9172 2550 8.9155' ) def test_component( self ) : @@ -67,47 +67,47 @@ def verify_chunk_strings( self, chunk ) : # verify string self.assertEqual( self.chunk_strings, chunk.to_xml_string() ) - # the data is given explicitly (doubles) + # the data are given explicitly (doubles) chunk = Values( doubles = [ 2500., 8.9172, 2550., 8.9155 ] ) verify_chunk_doubles( self, chunk ) - # the data is read from a string + # the data are read from a string chunk = Values.from_string( self.chunk_doubles ) verify_chunk_doubles( self, chunk ) - # the data is copied + # the data are copied copy = Values( chunk ) verify_chunk_doubles( self, copy ) - # the data is given explicitly (ints) + # the data are given explicitly (ints) chunk = Values( ints = [ 2500, 9, 2550, 9 ] ) verify_chunk_ints( self, chunk ) - # the data is read from a string + # the data are read from a string chunk = Values.from_string( self.chunk_ints ) verify_chunk_ints( self, chunk ) - # the data is copied + # the data are copied copy = Values( chunk ) verify_chunk_ints( self, copy ) - # the data is given explicitly (strings) + # the data are given explicitly (strings) chunk = Values( strings = [ "2500", "8.9172", "2550", "8.9155" ] ) verify_chunk_strings( self, chunk ) - # the data is read from a string + # the data are read from a string chunk = Values.from_string( self.chunk_strings ) verify_chunk_strings( self, chunk ) - # the data is copied + # the data are copied copy = Values( chunk ) verify_chunk_strings( self, copy ) diff --git a/autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Values.pyc b/autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Values.pyc new file mode 100644 index 000000000..30a1fd54f Binary files /dev/null and b/autogen/prototype/proto/python/test/v1.9/containers/Test_GNDStk_v1_9_containers_Values.pyc differ diff --git a/python/test/v1_9/containers/__init__.py b/autogen/prototype/proto/python/test/v1.9/containers/__init__.py similarity index 100% rename from python/test/v1_9/containers/__init__.py rename to autogen/prototype/proto/python/test/v1.9/containers/__init__.py diff --git a/autogen/prototype/proto/python/test/v1.9/containers/__init__.pyc b/autogen/prototype/proto/python/test/v1.9/containers/__init__.pyc new file mode 100644 index 000000000..56255e4e3 Binary files /dev/null and b/autogen/prototype/proto/python/test/v1.9/containers/__init__.pyc differ diff --git a/autogen/prototype/proto/src/proto/v1.9.hpp b/autogen/prototype/proto/src/proto/v1.9.hpp new file mode 100644 index 000000000..21ba864aa --- /dev/null +++ b/autogen/prototype/proto/src/proto/v1.9.hpp @@ -0,0 +1,21 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#ifndef PROTO_V1_9 +#define PROTO_V1_9 + +#include "proto/v1.9/containers/Link.hpp" +#include "proto/v1.9/containers/XYs1d.hpp" +#include "proto/v1.9/containers/Axes.hpp" +#include "proto/v1.9/containers/Axis.hpp" +#include "proto/v1.9/containers/Grid.hpp" +#include "proto/v1.9/containers/Values.hpp" +#include "proto/v1.9/containers/Regions1d.hpp" + +#include "proto/v1.9/transport/ReactionSuite.hpp" +#include "proto/v1.9/transport/Reactions.hpp" +#include "proto/v1.9/transport/Reaction.hpp" +#include "proto/v1.9/transport/CrossSection.hpp" + +#endif diff --git a/autogen/prototype/proto/src/proto/v1.9/containers/Axes.hpp b/autogen/prototype/proto/src/proto/v1.9/containers/Axes.hpp new file mode 100644 index 000000000..0bcfe439b --- /dev/null +++ b/autogen/prototype/proto/src/proto/v1.9/containers/Axes.hpp @@ -0,0 +1,123 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#ifndef PROTO_V1_9_CONTAINERS_AXES +#define PROTO_V1_9_CONTAINERS_AXES + +#include "proto/v1.9/containers/Axis.hpp" +#include "proto/v1.9/containers/Grid.hpp" + +namespace proto { +namespace v1_9 { +namespace containers { + +// ----------------------------------------------------------------------------- +// containers:: +// class Axes +// ----------------------------------------------------------------------------- + +class Axes : public Component { + friend class Component; + + using axis_grid_t = std::variant< + containers::Axis, + containers::Grid + >; + + // ------------------------ + // For Component + // ------------------------ + + // Names: this namespace, this class, a field/node of this type + static auto NAMESPACE() { return "containers"; } + static auto CLASS() { return "Axes"; } + static auto FIELD() { return "axes"; } + + // Core Interface multi-query to extract metadata and child nodes + static auto KEYS() + { + return + // metadata + std::optional{} + / Meta<>("href") | + // children + axis_grid_t{} + / ++(Child<>("axis") || Child<>("grid")) + ; + } + +public: + using Component::construct; + + // metadata + Field> href{this}; + + // children - variant + Field> axis_grid{this}; + FieldPart axis{axis_grid}; + FieldPart grid{axis_grid}; + + // ------------------------ + // Constructors + // ------------------------ + + #define GNDSTK_COMPONENT(blockdata) Component(blockdata, \ + this->href, \ + this->axis_grid) + + // default, and from fields + explicit Axes( + const wrapper> &href = {}, + const wrapper> &axis_grid = {} + ) : + GNDSTK_COMPONENT(BlockData{}), + href(this,href), + axis_grid(this,axis_grid) + { + Component::finish(); + } + + // from node + explicit Axes(const Node &node) : + GNDSTK_COMPONENT(BlockData{}) + { + Component::finish(node); + } + + // copy + Axes(const Axes &other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = other; + Component::finish(other); + } + + // move + Axes(Axes &&other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = std::move(other); + Component::finish(other); + } + + // ------------------------ + // Assignment operators + // ------------------------ + + Axes &operator=(const Axes &) = default; + Axes &operator=(Axes &&) = default; + + // ------------------------ + // Custom functionality + // ------------------------ + + #include "proto/v1.9/containers/Axes/src/custom.hpp" + #undef GNDSTK_COMPONENT +}; // class Axes + +} // namespace containers +} // namespace v1_9 +} // namespace proto + +#endif diff --git a/src/GNDStk/v1.9/containers/Axes/src/custom.hpp b/autogen/prototype/proto/src/proto/v1.9/containers/Axes/src/custom.hpp similarity index 100% rename from src/GNDStk/v1.9/containers/Axes/src/custom.hpp rename to autogen/prototype/proto/src/proto/v1.9/containers/Axes/src/custom.hpp diff --git a/autogen/prototype/proto/src/proto/v1.9/containers/Axes/test/Axes.test.cpp b/autogen/prototype/proto/src/proto/v1.9/containers/Axes/test/Axes.test.cpp new file mode 100644 index 000000000..ffa2a2ae5 --- /dev/null +++ b/autogen/prototype/proto/src/proto/v1.9/containers/Axes/test/Axes.test.cpp @@ -0,0 +1,330 @@ + +#define CATCH_CONFIG_MAIN + +#include "catch.hpp" +#include "proto/v1.9/containers/Axes.hpp" + +// other includes + +// convenience typedefs +using namespace njoy::GNDStk; +using namespace proto; + +using Axes = v1_9::containers::Axes; +using Axis = v1_9::containers::Axis; +using Grid = v1_9::containers::Grid; +using Values = v1_9::containers::Values; +using Link = v1_9::containers::Link; + +std::string chunk(); +void verifyChunk( const Axes& ); +std::string invalidName(); + +SCENARIO( "Axes" ) { + njoy::GNDStk::sort = true; + + GIVEN( "valid data for the component" ) { + + std::string string = chunk(); + + WHEN( "autogenerated constructor: the data are given explicitly" ) { + + std::vector< std::variant< Axis, Grid > > axis = { + + Axis( 1, "energy_in", "eV" ), + Axis( 0, "radius", "fm" ) + }; + + using agvector = std::vector>; + + THEN ( "Various getters work as expected" ) { + { + const Axes a1(std::nullopt, agvector{Axis(1)}); + Axes a2(std::nullopt, agvector{Axis(2)}); + const Axis *ptr1 = a1.axis.ptr(1); + Axis *ptr2 = a2.axis.ptr(2); + CHECK(ptr1 != nullptr); + CHECK(ptr2 != nullptr); + + const Axes a3(std::nullopt, agvector{Grid(1)}); + Axes a4(std::nullopt, agvector{Grid(2)}); + const Grid *ptr3 = a3.grid.ptr(1); + Grid *ptr4 = a4.grid.ptr(2); + CHECK(ptr3 != nullptr); + CHECK(ptr4 != nullptr); + } + + { + const Axes a1(std::nullopt, agvector{Axis(1)}); + Axes a2(std::nullopt, agvector{Axis(2)}); + const Grid *ptr1 = a1.grid.ptr(1); + Grid *ptr2 = a2.grid.ptr(2); + CHECK(ptr1 == nullptr); + CHECK(ptr2 == nullptr); + + const Axes a3(std::nullopt, agvector{Grid(1)}); + Axes a4(std::nullopt, agvector{Grid(2)}); + const Axis *ptr3 = a3.axis.ptr(1); + Axis *ptr4 = a4.axis.ptr(2); + CHECK(ptr3 == nullptr); + CHECK(ptr4 == nullptr); + } + } + + Axes chunk( std::nullopt, axis ); + + THEN( "the component can be constructed and members can be tested" ) { + + verifyChunk( chunk ); + } // THEN + + THEN( "it can be written in XML" ) { + + std::ostringstream out; + XML( Node( chunk ) ).write( out, false ); + + CHECK( out.str() == string ); + } // THEN + } // WHEN + + WHEN( "the data are constructed from a node" ) { + + Node node; + node << chunk(); + Axes chunk( node ); + + THEN( "the component can be constructed and members can be tested" ) { + + verifyChunk( chunk ); + } // THEN + + THEN( "it can be written in XML" ) { + + std::ostringstream out; + XML( Node( chunk ) ).write( out, false ); + + CHECK( out.str() == string ); + } // THEN + } // WHEN + } // GIVEN + + GIVEN( "a valid component instance" ) { + + WHEN( "the component is copied" ) { + + Node node; + node << chunk(); + Axes chunk( node ); + + // copy constructor + Axes copy( chunk ); + + // copy assignment + Axes assign; + assign = chunk; + + THEN( "the component can be constructed and members can be tested" ) { + + verifyChunk( copy ); + verifyChunk( assign ); + } // THEN + } // WHEN + + WHEN( "the data are moved" ) { + + Node node; + node << chunk(); + Axes chunk( node ); + Axes chunk2( node ); + + // move constructor + Axes move( std::move( chunk ) ); + + // move assignment + Axes assign; + assign = std::move( chunk2 ); + + THEN( "the component can be constructed and members can be tested" ) { + + verifyChunk( move ); + verifyChunk( assign ); + } // THEN + } // WHEN + } // GIVEN + + GIVEN( "invalid data" ) { + + WHEN( "when the wrong node is used" ) { + + Node node; + node << invalidName(); + + THEN( "an exception is thrown" ) { + + CHECK_THROWS( Axes( node ) ); + } // THEN + } // WHEN + } // GIVEN +} // SCENARIO + +std::string chunk() { + + return +R"***( + + +)***"; +} + +void verifyChunk( const Axes& component ) { + + CHECK( std::nullopt == component.href() ); + + CHECK( 2 == component.axis_grid().size() ); + CHECK( 2 == component.size() ); + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // indexing into the vector and accessing the variant directly + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + decltype(auto) axis_i0 = std::get< Axis >( component.axis_grid()[0] ); + + CHECK( std::nullopt != axis_i0.index() ); + CHECK( std::nullopt != axis_i0.label() ); + CHECK( std::nullopt != axis_i0.unit() ); + + CHECK( 0 == axis_i0.index().value() ); + CHECK( "radius" == axis_i0.label().value() ); + CHECK( "fm" == axis_i0.unit().value() ); + + decltype(auto) axis_i1 = std::get< Axis >( component.axis_grid()[1] ); + + CHECK( std::nullopt != axis_i1.index() ); + CHECK( std::nullopt != axis_i1.label() ); + CHECK( std::nullopt != axis_i1.unit() ); + + CHECK( 1 == axis_i1.index().value() ); + CHECK( "energy_in" == axis_i1.label().value() ); + CHECK( "eV" == axis_i1.unit().value() ); + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // using the index based axis_grid getter and accessing the variant directly + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + decltype(auto) axis_ii0 = std::get< Axis >( component.axis_grid( 0 ) ); + + CHECK( std::nullopt != axis_ii0.index() ); + CHECK( std::nullopt != axis_ii0.label() ); + CHECK( std::nullopt != axis_ii0.unit() ); + + CHECK( 0 == axis_ii0.index().value() ); + CHECK( "radius" == axis_ii0.label().value() ); + CHECK( "fm" == axis_ii0.unit().value() ); + + decltype(auto) axis_ii1 = std::get< Axis >( component.axis_grid( 1 ) ); + + CHECK( std::nullopt != axis_ii1.index() ); + CHECK( std::nullopt != axis_ii1.label() ); + CHECK( std::nullopt != axis_ii1.unit() ); + + CHECK( 1 == axis_ii1.index().value() ); + CHECK( "energy_in" == axis_ii1.label().value() ); + CHECK( "eV" == axis_ii1.unit().value() ); + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // using the label based axis_grid getter and accessing the variant directly + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + decltype(auto) axis_iii0 = std::get< Axis >(component.axis_grid("radius")); + + CHECK( std::nullopt != axis_iii0.index() ); + CHECK( std::nullopt != axis_iii0.label() ); + CHECK( std::nullopt != axis_iii0.unit() ); + + CHECK( 0 == axis_iii0.index().value() ); + CHECK( "radius" == axis_iii0.label().value() ); + CHECK( "fm" == axis_iii0.unit().value() ); + + decltype(auto) axis_iii1 = std::get< Axis >(component.axis_grid("energy_in")); + + CHECK( std::nullopt != axis_iii1.index() ); + CHECK( std::nullopt != axis_iii1.label() ); + CHECK( std::nullopt != axis_iii1.unit() ); + + CHECK( 1 == axis_iii1.index().value() ); + CHECK( "energy_in" == axis_iii1.label().value() ); + CHECK( "eV" == axis_iii1.unit().value() ); + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // using the index based axis getter + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + CHECK(component.axis(has(v1_9::index(0)))); + CHECK(component.axis.has(v1_9::index(0))); + CHECK(component.axis_grid.has(v1_9::index)); + CHECK(component.axis_grid.has(v1_9::index(0))); + decltype(auto) axis_iv0 = component.axis( 0 ); + + CHECK( std::nullopt != axis_iv0.index() ); + CHECK( std::nullopt != axis_iv0.label() ); + CHECK( std::nullopt != axis_iv0.unit() ); + + CHECK( 0 == axis_iv0.index().value() ); + CHECK( "radius" == axis_iv0.label().value() ); + CHECK( "fm" == axis_iv0.unit().value() ); + + CHECK(component.axis(has(v1_9::index(1)))); + CHECK(component.axis.has(v1_9::index(1)) ); + CHECK(component.axis_grid.has(v1_9::index)); + CHECK(component.axis_grid.has(v1_9::index(1))); + decltype(auto) axis_iv1 = component.axis( 1 ); + + CHECK( std::nullopt != axis_iv1.index() ); + CHECK( std::nullopt != axis_iv1.label() ); + CHECK( std::nullopt != axis_iv1.unit() ); + + CHECK( 1 == axis_iv1.index().value() ); + CHECK( "energy_in" == axis_iv1.label().value() ); + CHECK( "eV" == axis_iv1.unit().value() ); + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // using the label based axis getter + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + CHECK(component.axis(has(v1_9::label("radius")))); + CHECK(component.axis.has(v1_9::label("radius"))); + CHECK(component.axis_grid.has(v1_9::label)); + CHECK(component.axis_grid.has(v1_9::label("radius"))); + decltype(auto) axis_v0 = component.axis( "radius" ); + + CHECK( std::nullopt != axis_v0.index() ); + CHECK( std::nullopt != axis_v0.label() ); + CHECK( std::nullopt != axis_v0.unit() ); + + CHECK( 0 == axis_v0.index().value() ); + CHECK( "radius" == axis_v0.label().value() ); + CHECK( "fm" == axis_v0.unit().value() ); + + CHECK(component.axis(has(v1_9::label("energy_in")))); + CHECK(component.axis.has(v1_9::label("energy_in"))); + CHECK(component.axis_grid.has(v1_9::label)); + CHECK(component.axis_grid.has(v1_9::label("energy_in"))); + decltype(auto) axis_v1 = component.axis( "energy_in" ); + + CHECK( std::nullopt != axis_v1.index() ); + CHECK( std::nullopt != axis_v1.label() ); + CHECK( std::nullopt != axis_v1.unit() ); + + CHECK( 1 == axis_v1.index().value() ); + CHECK( "energy_in" == axis_v1.label().value() ); + CHECK( "eV" == axis_v1.unit().value() ); +} + +std::string invalidName() { + + // wrong name for the node + return +R"***( + + )***"; +} diff --git a/src/GNDStk/v1.9/containers/Axes/test/CMakeLists.txt b/autogen/prototype/proto/src/proto/v1.9/containers/Axes/test/CMakeLists.txt similarity index 100% rename from src/GNDStk/v1.9/containers/Axes/test/CMakeLists.txt rename to autogen/prototype/proto/src/proto/v1.9/containers/Axes/test/CMakeLists.txt diff --git a/autogen/prototype/proto/src/proto/v1.9/containers/Axis.hpp b/autogen/prototype/proto/src/proto/v1.9/containers/Axis.hpp new file mode 100644 index 000000000..792dba566 --- /dev/null +++ b/autogen/prototype/proto/src/proto/v1.9/containers/Axis.hpp @@ -0,0 +1,118 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#ifndef PROTO_V1_9_CONTAINERS_AXIS +#define PROTO_V1_9_CONTAINERS_AXIS + +#include "proto/v1.9/key.hpp" + +namespace proto { +namespace v1_9 { +namespace containers { + +// ----------------------------------------------------------------------------- +// containers:: +// class Axis +// ----------------------------------------------------------------------------- + +class Axis : public Component { + friend class Component; + + // ------------------------ + // For Component + // ------------------------ + + // Names: this namespace, this class, a field/node of this type + static auto NAMESPACE() { return "containers"; } + static auto CLASS() { return "Axis"; } + static auto FIELD() { return "axis"; } + + // Core Interface multi-query to extract metadata and child nodes + static auto KEYS() + { + return + // metadata + std::optional{} + / Meta<>("index") | + std::optional{} + / Meta<>("label") | + std::optional{} + / Meta<>("unit") + ; + } + +public: + using Component::construct; + + // metadata + Field> index{this}; + Field> label{this}; + Field> unit{this}; + + // ------------------------ + // Constructors + // ------------------------ + + #define GNDSTK_COMPONENT(blockdata) Component(blockdata, \ + this->index, \ + this->label, \ + this->unit) + + // default, and from fields + explicit Axis( + const wrapper> &index = {}, + const wrapper> &label = {}, + const wrapper> &unit = {} + ) : + GNDSTK_COMPONENT(BlockData{}), + index(this,index), + label(this,label), + unit(this,unit) + { + Component::finish(); + } + + // from node + explicit Axis(const Node &node) : + GNDSTK_COMPONENT(BlockData{}) + { + Component::finish(node); + } + + // copy + Axis(const Axis &other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = other; + Component::finish(other); + } + + // move + Axis(Axis &&other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = std::move(other); + Component::finish(other); + } + + // ------------------------ + // Assignment operators + // ------------------------ + + Axis &operator=(const Axis &) = default; + Axis &operator=(Axis &&) = default; + + // ------------------------ + // Custom functionality + // ------------------------ + + #include "proto/v1.9/containers/Axis/src/custom.hpp" + #undef GNDSTK_COMPONENT +}; // class Axis + +} // namespace containers +} // namespace v1_9 +} // namespace proto + +#endif diff --git a/autogen/prototype/proto/src/proto/v1.9/containers/Axis/src/custom.hpp b/autogen/prototype/proto/src/proto/v1.9/containers/Axis/src/custom.hpp new file mode 100644 index 000000000..94ea19739 --- /dev/null +++ b/autogen/prototype/proto/src/proto/v1.9/containers/Axis/src/custom.hpp @@ -0,0 +1,30 @@ + +private: + +static inline helpMap help = { + + { + "", + "A GNDS 1.9 basic container component: " + "an axis with an index, label and\n" + "optional unit\n\n" + "This component in used in the axes node, " + "which in turn is used in most\n" + "functional containers." + }, + + { + "constructor", + "Initialise the axis component\n\n" + "Arguments:\n" + " self the axis component\n" + " index the index of the axis component\n" + " label the label of the axis component\n" + " unit the unit of the axis component\n" + }, + + { "index", "The index of the axis component" }, + { "label", "The label of the axis component" }, + { "unit", "The unit of the axis component" } + +}; diff --git a/src/GNDStk/v1.9/containers/Axis/test/Axis.test.cpp b/autogen/prototype/proto/src/proto/v1.9/containers/Axis/test/Axis.test.cpp similarity index 88% rename from src/GNDStk/v1.9/containers/Axis/test/Axis.test.cpp rename to autogen/prototype/proto/src/proto/v1.9/containers/Axis/test/Axis.test.cpp index dd5adb194..878d83299 100644 --- a/src/GNDStk/v1.9/containers/Axis/test/Axis.test.cpp +++ b/autogen/prototype/proto/src/proto/v1.9/containers/Axis/test/Axis.test.cpp @@ -1,12 +1,15 @@ + #define CATCH_CONFIG_MAIN #include "catch.hpp" -#include "GNDStk/v1.9/containers/Axis.hpp" +#include "proto/v1.9/containers/Axis.hpp" // other includes // convenience typedefs using namespace njoy::GNDStk; +using namespace proto; + using Axis = v1_9::containers::Axis; std::string chunk(); @@ -19,9 +22,9 @@ SCENARIO( "Axis" ) { std::string string = chunk(); - WHEN( "autogenerated constructor: the data is given explicitly" ) { + WHEN( "autogenerated constructor: the data are given explicitly" ) { - unsigned int index = 1; + unsigned index = 1; std::string label = "energy_in"; std::string unit = "eV"; @@ -41,7 +44,7 @@ SCENARIO( "Axis" ) { } // THEN } // WHEN - WHEN( "the data is constructed from a node" ) { + WHEN( "the data are constructed from a node" ) { Node node; node << chunk(); @@ -84,7 +87,7 @@ SCENARIO( "Axis" ) { } // THEN } // WHEN - WHEN( "the data is moved" ) { + WHEN( "the data are moved" ) { Node node; node << chunk(); @@ -124,8 +127,7 @@ SCENARIO( "Axis" ) { std::string chunk() { return -R"***( -)***"; +R"***()***"; } void verifyChunk( const Axis& component ) { @@ -147,6 +149,5 @@ std::string invalidName() { // wrong name for the node return -R"***( -)***"; +R"***()***"; } diff --git a/src/GNDStk/v1.9/containers/Axis/test/CMakeLists.txt b/autogen/prototype/proto/src/proto/v1.9/containers/Axis/test/CMakeLists.txt similarity index 100% rename from src/GNDStk/v1.9/containers/Axis/test/CMakeLists.txt rename to autogen/prototype/proto/src/proto/v1.9/containers/Axis/test/CMakeLists.txt diff --git a/autogen/prototype/proto/src/proto/v1.9/containers/Grid.hpp b/autogen/prototype/proto/src/proto/v1.9/containers/Grid.hpp new file mode 100644 index 000000000..7aa17ef95 --- /dev/null +++ b/autogen/prototype/proto/src/proto/v1.9/containers/Grid.hpp @@ -0,0 +1,153 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#ifndef PROTO_V1_9_CONTAINERS_GRID +#define PROTO_V1_9_CONTAINERS_GRID + +#include "proto/v1.9/containers/Values.hpp" +#include "proto/v1.9/containers/Link.hpp" + +namespace proto { +namespace v1_9 { +namespace containers { + +// ----------------------------------------------------------------------------- +// containers:: +// class Grid +// ----------------------------------------------------------------------------- + +class Grid : public Component { + friend class Component; + + using link_values_t = std::variant< + containers::Values, + containers::Link + >; + + // ------------------------ + // For Component + // ------------------------ + + // Names: this namespace, this class, a field/node of this type + static auto NAMESPACE() { return "containers"; } + static auto CLASS() { return "Grid"; } + static auto FIELD() { return "grid"; } + + // Core Interface multi-query to extract metadata and child nodes + static auto KEYS() + { + return + // metadata + std::optional{} + / Meta<>("index") | + Defaulted{enums::Interpolation::linlin} + / Meta<>("interpolation") | + std::optional{} + / Meta<>("label") | + std::optional{} + / Meta<>("style") | + std::optional{} + / Meta<>("unit") | + // children + link_values_t{} + / --(Child<>("values") || Child<>("link")) + ; + } + +public: + using Component::construct; + + // defaults + static inline const struct Defaults { + static inline const enums::Interpolation interpolation = enums::Interpolation::linlin; + } defaults; + + // metadata + Field> index{this}; + Field> interpolation{this,defaults.interpolation}; + Field> label{this}; + Field> style{this}; + Field> unit{this}; + + // children - variant + Field link_values{this}; + FieldPart values{link_values}; + FieldPart link{link_values}; + + // ------------------------ + // Constructors + // ------------------------ + + #define GNDSTK_COMPONENT(blockdata) Component(blockdata, \ + this->index, \ + this->interpolation, \ + this->label, \ + this->style, \ + this->unit, \ + this->link_values) + + // default, and from fields + // std::optional replaces Defaulted; this class knows the default(s) + explicit Grid( + const wrapper> &index = {}, + const wrapper> &interpolation = {}, + const wrapper> &label = {}, + const wrapper> &style = {}, + const wrapper> &unit = {}, + const wrapper &link_values = {} + ) : + GNDSTK_COMPONENT(BlockData{}), + index(this,index), + interpolation(this,defaults.interpolation,interpolation), + label(this,label), + style(this,style), + unit(this,unit), + link_values(this,link_values) + { + Component::finish(); + } + + // from node + explicit Grid(const Node &node) : + GNDSTK_COMPONENT(BlockData{}) + { + Component::finish(node); + } + + // copy + Grid(const Grid &other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = other; + Component::finish(other); + } + + // move + Grid(Grid &&other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = std::move(other); + Component::finish(other); + } + + // ------------------------ + // Assignment operators + // ------------------------ + + Grid &operator=(const Grid &) = default; + Grid &operator=(Grid &&) = default; + + // ------------------------ + // Custom functionality + // ------------------------ + + #include "proto/v1.9/containers/Grid/src/custom.hpp" + #undef GNDSTK_COMPONENT +}; // class Grid + +} // namespace containers +} // namespace v1_9 +} // namespace proto + +#endif diff --git a/src/GNDStk/v1.9/containers/Grid/src/custom.hpp b/autogen/prototype/proto/src/proto/v1.9/containers/Grid/src/custom.hpp similarity index 100% rename from src/GNDStk/v1.9/containers/Grid/src/custom.hpp rename to autogen/prototype/proto/src/proto/v1.9/containers/Grid/src/custom.hpp diff --git a/src/GNDStk/v1.9/containers/Grid/test/CMakeLists.txt b/autogen/prototype/proto/src/proto/v1.9/containers/Grid/test/CMakeLists.txt similarity index 100% rename from src/GNDStk/v1.9/containers/Grid/test/CMakeLists.txt rename to autogen/prototype/proto/src/proto/v1.9/containers/Grid/test/CMakeLists.txt diff --git a/autogen/prototype/proto/src/proto/v1.9/containers/Grid/test/Grid.test.cpp b/autogen/prototype/proto/src/proto/v1.9/containers/Grid/test/Grid.test.cpp new file mode 100644 index 000000000..1a98ebcec --- /dev/null +++ b/autogen/prototype/proto/src/proto/v1.9/containers/Grid/test/Grid.test.cpp @@ -0,0 +1,310 @@ + +#define CATCH_CONFIG_MAIN + +#include "catch.hpp" +#include "proto/v1.9/containers/Grid.hpp" + +// other includes + +// convenience typedefs +using namespace njoy::GNDStk; +using namespace proto; + +using Values = v1_9::containers::Values; +using Link = v1_9::containers::Link; +using Grid = v1_9::containers::Grid; + +std::string chunk(); +void verifyChunk( const Grid& ); +std::string chunkWithLink(); +void verifyChunkWithLink( const Grid& ); +std::string invalidName(); + +SCENARIO( "Grid" ) { + + GIVEN( "valid data for the component with a Values component" ) { + + std::string string = chunk(); + + WHEN( "autogenerated constructor: the data are given explicitly" ) { + + unsigned index = 2; + std::string label = "row_energy_bounds"; + std::string unit = "eV"; + enums::GridStyle style = enums::GridStyle::boundaries; + std::vector< double > values = { 1e-5, 2e7 }; + + THEN ( "Various getters work as expected" ) { + { + const Grid g1(index,std::nullopt,label,style,unit,Values(values)); + Grid g2(index,std::nullopt,label,style,unit,Values(values)); + const Values *ptr1 = g1.values.ptr(); + Values *ptr2 = g2.values.ptr(); + CHECK(ptr1 != nullptr); + CHECK(ptr2 != nullptr); + + const Grid g3(index,std::nullopt,label,style,unit,Link("mylink")); + Grid g4(index,std::nullopt,label,style,unit,Link("mylink")); + const Link *ptr3 = g3.link.ptr(); + Link *ptr4 = g4.link.ptr(); + CHECK(ptr3 != nullptr); + CHECK(ptr4 != nullptr); + } + + { + const Grid g1(index,std::nullopt,label,style,unit,Values(values)); + Grid g2(index,std::nullopt,label,style,unit,Values(values)); + const Values *ptr1 = g1.values; + Values *ptr2 = g2.values; + const Values &ref1 = g1.values; + Values &ref2 = g2.values; + CHECK(ptr1 != nullptr); + CHECK(ptr2 != nullptr); + + const Grid g3(index,std::nullopt,label,style,unit,Link("mylink")); + Grid g4(index,std::nullopt,label,style,unit,Link("mylink")); + const Link *ptr3 = g3.link; + Link *ptr4 = g4.link; + const Link &ref3 = g3.link; + Link &ref4 = g4.link; + CHECK(ptr3 != nullptr); + CHECK(ptr4 != nullptr); + } + + { + const Grid g1(index,std::nullopt,label,style,unit,Values(values)); + Grid g2(index,std::nullopt,label,style,unit,Values(values)); + const Link *ptr1 = g1.link.ptr(); + Link *ptr2 = g2.link.ptr(); + CHECK(ptr1 == nullptr); + CHECK(ptr2 == nullptr); + + const Grid g3(index,std::nullopt,label,style,unit,Link("mylink")); + Grid g4(index,std::nullopt,label,style,unit,Link("mylink")); + const Values *ptr3 = g3.values.ptr(); + Values *ptr4 = g4.values.ptr(); + CHECK(ptr3 == nullptr); + CHECK(ptr4 == nullptr); + } + } + + Grid chunk( index, std::nullopt, label, style, unit, Values( values ) ); + + THEN( "the component can be constructed and members can be tested" ) { + + verifyChunk( chunk ); + } // THEN + + THEN( "it can be written in XML" ) { + + std::ostringstream out; + XML( Node( chunk ) ).write( out, false ); + + CHECK( out.str() == string ); + } // THEN + } // WHEN + + WHEN( "the data are constructed from a node" ) { + + Node node; + node << chunk(); + Grid chunk( node ); + + THEN( "the component can be constructed and members can be tested" ) { + + verifyChunk( chunk ); + } // THEN + + THEN( "it can be written in XML" ) { + + std::ostringstream out; + XML( Node( chunk ) ).write( out, false ); + + CHECK( out.str() == string ); + } // THEN + } // WHEN + } // GIVEN + + GIVEN( "valid data for the component with a Link component" ) { + + std::string string = chunkWithLink(); + + WHEN( "autogenerated constructor: the data are given explicitly" ) { + + unsigned index = 1; + std::string label = "column_energy_bounds"; + std::string unit = "eV"; + enums::GridStyle style = enums::GridStyle::link; + std::string href = "../../grid[@index='2']/values"; + + Grid chunk( index, std::nullopt, label, style, unit, + Link( href ) ); + + THEN( "the component can be constructed and members can be tested" ) { + + verifyChunkWithLink( chunk ); + } // THEN + + THEN( "it can be written in XML" ) { + + std::ostringstream out; + XML( Node( chunk ) ).write( out, false ); + + CHECK( out.str() == string ); + } // THEN + } // WHEN + + WHEN( "the data are constructed from a node" ) { + + Node node; + node << chunkWithLink(); + Grid chunk( node ); + + THEN( "the component can be constructed and members can be tested" ) { + + verifyChunkWithLink( chunk ); + } // THEN + + THEN( "it can be written in XML" ) { + + std::ostringstream out; + XML( Node( chunk ) ).write( out, false ); + + CHECK( out.str() == string ); + } // THEN + } // WHEN + } // GIVEN + + GIVEN( "a valid component instance" ) { + + WHEN( "the component is copied" ) { + + Node node; + node << chunk(); + Grid chunk( node ); + + // copy constructor + Grid copy( chunk ); + + // copy assignment + Grid assign; + assign = chunk; + + THEN( "the component can be constructed and members can be tested" ) { + + verifyChunk( copy ); + verifyChunk( assign ); + } // THEN + } // WHEN + + WHEN( "the data are moved" ) { + + Node node; + node << chunk(); + Grid chunk( node ); + Grid chunk2( node ); + + // move constructor + Grid move( std::move( chunk ) ); + + // move assignment + Grid assign; + assign = std::move( chunk2 ); + + THEN( "the component can be constructed and members can be tested" ) { + + verifyChunk( move ); + verifyChunk( assign ); + } // THEN + } // WHEN + } // GIVEN + + GIVEN( "invalid data" ) { + + WHEN( "when the wrong node is used" ) { + + Node node; + node << invalidName(); + + THEN( "an exception is thrown" ) { + + CHECK_THROWS( Grid( node ) ); + } // THEN + } // WHEN + } // GIVEN +} // SCENARIO + +std::string chunk() { + + return +R"***( + 1e-05 2e+07 +)***"; +} + +void verifyChunk( const Grid& component ) { + + CHECK( std::nullopt != component.index() ); + CHECK( std::nullopt != component.label() ); + CHECK( std::nullopt != component.style() ); + CHECK( std::nullopt != component.unit() ); + + CHECK( 2 == component.index().value() ); + CHECK( "row_energy_bounds" == component.label().value() ); + CHECK( "eV" == component.unit().value() ); + CHECK( enums::GridStyle::boundaries == component.style().value() ); + + CHECK( 2 == component.index() ); + CHECK( "row_energy_bounds" == component.label() ); + CHECK( "eV" == component.unit() ); + CHECK( enums::GridStyle::boundaries == component.style() ); + + decltype(auto) values = std::get< Values >( component.link_values() ); + CHECK( 2 == values.length() ); + CHECK( 0 == values.start() ); + CHECK( "Float64" == values.valueType().value() ); + + CHECK( 2 == values.size() ); + CHECK( 2 == values.doubles().size() ); + + CHECK( 1e-5 == Approx( values.doubles()[0] ) ); + CHECK( 2e+7 == Approx( values.doubles()[1] ) ); +} + +std::string chunkWithLink() { + + return +R"***( + +)***"; +} + +void verifyChunkWithLink( const Grid& component ) { + + CHECK( std::nullopt != component.index() ); + CHECK( std::nullopt != component.label() ); + CHECK( std::nullopt != component.style() ); + CHECK( std::nullopt != component.unit() ); + + CHECK( 1 == component.index().value() ); + CHECK( "column_energy_bounds" == component.label().value() ); + CHECK( "eV" == component.unit().value() ); + CHECK( enums::GridStyle::link == component.style().value() ); + + CHECK( 1 == component.index() ); + CHECK( "column_energy_bounds" == component.label() ); + CHECK( "eV" == component.unit() ); + CHECK( enums::GridStyle::link == component.style() ); + + decltype(auto) link = std::get< Link >( component.link_values() ); + CHECK( "../../grid[@index='2']/values" == link.href() ); +} + +std::string invalidName() { + + // wrong name for the node + return +R"***( + +)***"; +} diff --git a/autogen/prototype/proto/src/proto/v1.9/containers/Link.hpp b/autogen/prototype/proto/src/proto/v1.9/containers/Link.hpp new file mode 100644 index 000000000..5b996fdd8 --- /dev/null +++ b/autogen/prototype/proto/src/proto/v1.9/containers/Link.hpp @@ -0,0 +1,106 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#ifndef PROTO_V1_9_CONTAINERS_LINK +#define PROTO_V1_9_CONTAINERS_LINK + +#include "proto/v1.9/key.hpp" + +namespace proto { +namespace v1_9 { +namespace containers { + +// ----------------------------------------------------------------------------- +// containers:: +// class Link +// ----------------------------------------------------------------------------- + +class Link : public Component { + friend class Component; + + // ------------------------ + // For Component + // ------------------------ + + // Names: this namespace, this class, a field/node of this type + static auto NAMESPACE() { return "containers"; } + static auto CLASS() { return "Link"; } + static auto FIELD() { return "link"; } + + // Core Interface multi-query to extract metadata and child nodes + static auto KEYS() + { + return + // metadata + std::string{} + / Meta<>("href") + ; + } + +public: + using Component::construct; + + // metadata + Field href{this}; + + // ------------------------ + // Constructors + // ------------------------ + + #define GNDSTK_COMPONENT(blockdata) Component(blockdata, \ + this->href) + + // default, and from fields + explicit Link( + const wrapper &href = {} + ) : + GNDSTK_COMPONENT(BlockData{}), + href(this,href) + { + Component::finish(); + } + + // from node + explicit Link(const Node &node) : + GNDSTK_COMPONENT(BlockData{}) + { + Component::finish(node); + } + + // copy + Link(const Link &other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = other; + Component::finish(other); + } + + // move + Link(Link &&other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = std::move(other); + Component::finish(other); + } + + // ------------------------ + // Assignment operators + // ------------------------ + + Link &operator=(const Link &) = default; + Link &operator=(Link &&) = default; + + // ------------------------ + // Custom functionality + // ------------------------ + + #include "proto/v1.9/containers/Link/src/custom.hpp" + #undef GNDSTK_COMPONENT +}; // class Link + +} // namespace containers +} // namespace v1_9 +} // namespace proto + +#endif diff --git a/src/GNDStk/v1.9/containers/Link/src/custom.hpp b/autogen/prototype/proto/src/proto/v1.9/containers/Link/src/custom.hpp similarity index 100% rename from src/GNDStk/v1.9/containers/Link/src/custom.hpp rename to autogen/prototype/proto/src/proto/v1.9/containers/Link/src/custom.hpp diff --git a/src/GNDStk/v1.9/containers/Link/test/CMakeLists.txt b/autogen/prototype/proto/src/proto/v1.9/containers/Link/test/CMakeLists.txt similarity index 100% rename from src/GNDStk/v1.9/containers/Link/test/CMakeLists.txt rename to autogen/prototype/proto/src/proto/v1.9/containers/Link/test/CMakeLists.txt diff --git a/src/GNDStk/v1.9/containers/Link/test/Link.test.cpp b/autogen/prototype/proto/src/proto/v1.9/containers/Link/test/Link.test.cpp similarity index 87% rename from src/GNDStk/v1.9/containers/Link/test/Link.test.cpp rename to autogen/prototype/proto/src/proto/v1.9/containers/Link/test/Link.test.cpp index a0c5d544c..c1534e6c5 100644 --- a/src/GNDStk/v1.9/containers/Link/test/Link.test.cpp +++ b/autogen/prototype/proto/src/proto/v1.9/containers/Link/test/Link.test.cpp @@ -1,12 +1,15 @@ + #define CATCH_CONFIG_MAIN #include "catch.hpp" -#include "GNDStk/v1.9/containers/Link.hpp" +#include "proto/v1.9/containers/Link.hpp" // other includes // convenience typedefs using namespace njoy::GNDStk; +using namespace proto; + using Link = v1_9::containers::Link; std::string chunk(); @@ -19,7 +22,7 @@ SCENARIO( "Link" ) { std::string string = chunk(); - WHEN( "autogenerated constructor: the data is given explicitly" ) { + WHEN( "autogenerated constructor: the data are given explicitly" ) { std::string href = "../../grid[@index='2']/values"; @@ -39,7 +42,7 @@ SCENARIO( "Link" ) { } // THEN } // WHEN - WHEN( "the data is constructed from a node" ) { + WHEN( "the data are constructed from a node" ) { Node node; node << chunk(); @@ -82,7 +85,7 @@ SCENARIO( "Link" ) { } // THEN } // WHEN - WHEN( "the data is moved" ) { + WHEN( "the data are moved" ) { Node node; node << chunk(); @@ -122,8 +125,7 @@ SCENARIO( "Link" ) { std::string chunk() { return -R"***( -)***"; +R"***()***"; } void verifyChunk( const Link& component ) { @@ -135,6 +137,5 @@ std::string invalidName() { // wrong name for the node return -R"***( -)***"; +R"***()***"; } diff --git a/autogen/prototype/proto/src/proto/v1.9/containers/Regions1d.hpp b/autogen/prototype/proto/src/proto/v1.9/containers/Regions1d.hpp new file mode 100644 index 000000000..4e793c232 --- /dev/null +++ b/autogen/prototype/proto/src/proto/v1.9/containers/Regions1d.hpp @@ -0,0 +1,128 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#ifndef PROTO_V1_9_CONTAINERS_REGIONS1D +#define PROTO_V1_9_CONTAINERS_REGIONS1D + +#include "proto/v1.9/containers/Axes.hpp" +#include "proto/v1.9/containers/XYs1d.hpp" + +namespace proto { +namespace v1_9 { +namespace containers { + +// ----------------------------------------------------------------------------- +// containers:: +// class Regions1d +// ----------------------------------------------------------------------------- + +class Regions1d : public Component { + friend class Component; + + // ------------------------ + // For Component + // ------------------------ + + // Names: this namespace, this class, a field/node of this type + static auto NAMESPACE() { return "containers"; } + static auto CLASS() { return "Regions1d"; } + static auto FIELD() { return "regions1d"; } + + // Core Interface multi-query to extract metadata and child nodes + static auto KEYS() + { + return + // metadata + std::optional{} + / Meta<>("label") | + std::optional{} + / Meta<>("outerDomainValue") | + // children + std::optional{} + / --Child<>("axes") | + containers::XYs1d{} + / ++Child<>("XYs1d") + ; + } + +public: + using Component::construct; + + // metadata + Field> label{this}; + Field> outerDomainValue{this}; + + // children + Field> axes{this}; + Field> XYs1d{this}; + + // ------------------------ + // Constructors + // ------------------------ + + #define GNDSTK_COMPONENT(blockdata) Component(blockdata, \ + this->label, \ + this->outerDomainValue, \ + this->axes, \ + this->XYs1d) + + // default, and from fields + explicit Regions1d( + const wrapper> &label = {}, + const wrapper> &outerDomainValue = {}, + const wrapper> &axes = {}, + const wrapper> &XYs1d = {} + ) : + GNDSTK_COMPONENT(BlockData{}), + label(this,label), + outerDomainValue(this,outerDomainValue), + axes(this,axes), + XYs1d(this,XYs1d) + { + Component::finish(); + } + + // from node + explicit Regions1d(const Node &node) : + GNDSTK_COMPONENT(BlockData{}) + { + Component::finish(node); + } + + // copy + Regions1d(const Regions1d &other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = other; + Component::finish(other); + } + + // move + Regions1d(Regions1d &&other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = std::move(other); + Component::finish(other); + } + + // ------------------------ + // Assignment operators + // ------------------------ + + Regions1d &operator=(const Regions1d &) = default; + Regions1d &operator=(Regions1d &&) = default; + + // ------------------------ + // Custom functionality + // ------------------------ + + #include "proto/v1.9/containers/Regions1d/src/custom.hpp" + #undef GNDSTK_COMPONENT +}; // class Regions1d + +} // namespace containers +} // namespace v1_9 +} // namespace proto + +#endif diff --git a/src/GNDStk/v1.9/containers/Regions1d/src/custom.hpp b/autogen/prototype/proto/src/proto/v1.9/containers/Regions1d/src/custom.hpp similarity index 100% rename from src/GNDStk/v1.9/containers/Regions1d/src/custom.hpp rename to autogen/prototype/proto/src/proto/v1.9/containers/Regions1d/src/custom.hpp diff --git a/src/GNDStk/v1.9/containers/Regions1d/test/CMakeLists.txt b/autogen/prototype/proto/src/proto/v1.9/containers/Regions1d/test/CMakeLists.txt similarity index 100% rename from src/GNDStk/v1.9/containers/Regions1d/test/CMakeLists.txt rename to autogen/prototype/proto/src/proto/v1.9/containers/Regions1d/test/CMakeLists.txt diff --git a/src/GNDStk/v1.9/containers/Regions1d/test/Regions1d.test.cpp b/autogen/prototype/proto/src/proto/v1.9/containers/Regions1d/test/Regions1d.test.cpp similarity index 83% rename from src/GNDStk/v1.9/containers/Regions1d/test/Regions1d.test.cpp rename to autogen/prototype/proto/src/proto/v1.9/containers/Regions1d/test/Regions1d.test.cpp index f8d93ec35..3175fa715 100644 --- a/src/GNDStk/v1.9/containers/Regions1d/test/Regions1d.test.cpp +++ b/autogen/prototype/proto/src/proto/v1.9/containers/Regions1d/test/Regions1d.test.cpp @@ -1,12 +1,15 @@ + #define CATCH_CONFIG_MAIN #include "catch.hpp" -#include "GNDStk/v1.9/containers/Regions1d.hpp" +#include "proto/v1.9/containers/Regions1d.hpp" // other includes // convenience typedefs using namespace njoy::GNDStk; +using namespace proto; + using Regions1d = v1_9::containers::Regions1d; using XYs1d = v1_9::containers::XYs1d; using Axes = v1_9::containers::Axes; @@ -20,29 +23,32 @@ void verifyChunk( const Regions1d& ); std::string invalidName(); SCENARIO( "Regions1d" ) { + njoy::GNDStk::sort = true; GIVEN( "valid data for the component" ) { std::string string = chunk(); - WHEN( "autogenerated constructor: the data is given explicitly" ) { + WHEN( "autogenerated constructor: the data are given explicitly" ) { Regions1d chunk( - std::nullopt, // optional label - std::nullopt, // optional outer domain value + std::nullopt, // optional label + std::nullopt, // optional outer domain value + Axes( std::nullopt, + std::vector< std::variant< Axis, Grid > >{ + Axis( 1, "energy_in", "eV" ), + Axis( 0, "crossSection", "b" ) } ), // optional axes std::vector< XYs1d >{ XYs1d( 0, std::nullopt, std::nullopt, std::nullopt, std::nullopt, - Values( std::vector< double >{ 0.0253, 4.34057, 30000, 1.62386 } ) ), + Values( std::vector< double >{ + 0.0253, 4.34057, 30000, 1.62386 } ) ), XYs1d( 1, std::nullopt, std::nullopt, std::nullopt, std::nullopt, - Values( std::vector< double >{ 30000, 1.65691, 2e+7, 2.35696 } ) ) - }, // vector of 1D functions - Axes( std::nullopt, - std::vector< std::variant< Axis, Grid > >{ - Axis( 1, "energy_in", "eV" ), - Axis( 0, "crossSection", "b" ) } ) // optional axes + Values( std::vector< double >{ + 30000, 1.65691, 2e+7, 2.35696 } ) ) + } // vector of 1D functions ); THEN( "the component can be constructed and members can be tested" ) { @@ -59,7 +65,7 @@ SCENARIO( "Regions1d" ) { } // THEN } // WHEN - WHEN( "the data is constructed from a node" ) { + WHEN( "the data are constructed from a node" ) { Node node; node << chunk(); @@ -102,7 +108,7 @@ SCENARIO( "Regions1d" ) { } // THEN } // WHEN - WHEN( "the data is moved" ) { + WHEN( "the data are moved" ) { Node node; node << chunk(); @@ -143,18 +149,17 @@ std::string chunk() { return R"***( - - 0.0253 4.34057 30000 1.62386 - - - 30000 1.65691 2e+07 2.35696 - - -)***"; + + 0.0253 4.34057 30000 1.62386 + + + 30000 1.65691 2e+07 2.35696 + +)***"; } void verifyChunk( const Regions1d& component ) { @@ -166,7 +171,8 @@ void verifyChunk( const Regions1d& component ) { // axes data CHECK( 2 == component.axes().value().axis_grid().size() ); - decltype(auto) axis0 = std::get< Axis >( component.axes().value().axis_grid()[0] ); + decltype(auto) axis0 = + std::get< Axis >( component.axes().value().axis_grid()[0] ); CHECK( std::nullopt != axis0.index() ); CHECK( std::nullopt != axis0.label() ); CHECK( std::nullopt != axis0.unit() ); @@ -174,7 +180,8 @@ void verifyChunk( const Regions1d& component ) { CHECK( "crossSection" == axis0.label().value() ); CHECK( "b" == axis0.unit().value() ); - decltype(auto) axis1 = std::get< Axis >( component.axes().value().axis_grid()[1] ); + decltype(auto) axis1 = + std::get< Axis >( component.axes().value().axis_grid()[1] ); CHECK( std::nullopt != axis1.index() ); CHECK( std::nullopt != axis1.label() ); CHECK( std::nullopt != axis1.unit() ); @@ -224,15 +231,14 @@ std::string invalidName() { return R"***( - 0.0253 4.34057 30000 1.62386 + 0.0253 4.34057 30000 1.62386 - 30000 1.65691 2e+07 2.35696 + 30000 1.65691 2e+07 2.35696 - -)***"; +)***"; } diff --git a/autogen/prototype/proto/src/proto/v1.9/containers/Values.hpp b/autogen/prototype/proto/src/proto/v1.9/containers/Values.hpp new file mode 100644 index 000000000..90584176e --- /dev/null +++ b/autogen/prototype/proto/src/proto/v1.9/containers/Values.hpp @@ -0,0 +1,134 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#ifndef PROTO_V1_9_CONTAINERS_VALUES +#define PROTO_V1_9_CONTAINERS_VALUES + +#include "proto/v1.9/key.hpp" + +namespace proto { +namespace v1_9 { +namespace containers { + +// ----------------------------------------------------------------------------- +// containers:: +// class Values +// ----------------------------------------------------------------------------- + +class Values : public Component { + friend class Component; + + // ------------------------ + // For Component + // ------------------------ + + // Names: this namespace, this class, a field/node of this type + static auto NAMESPACE() { return "containers"; } + static auto CLASS() { return "Values"; } + static auto FIELD() { return "values"; } + + // Core Interface multi-query to extract metadata and child nodes + static auto KEYS() + { + return + // metadata + Defaulted{"double"} + / Meta<>("valueType") | + Defaulted{0} + / Meta<>("start") | + std::optional{} + / Meta<>("length") + ; + } + +public: + using Component::construct; + using BlockData::operator=; + + // defaults + static inline const struct Defaults { + static inline const std::string valueType = "double"; + static inline const int start = 0; + } defaults; + + // metadata + mutable Field> valueType{this,defaults.valueType}; + mutable Field> start{this,defaults.start}; + mutable Field> length{this}; + + // ------------------------ + // Constructors + // ------------------------ + + #define GNDSTK_COMPONENT(blockdata) Component(blockdata, \ + this->valueType, \ + this->start, \ + this->length) + + // default, and from fields + // std::optional replaces Defaulted; this class knows the default(s) + explicit Values( + const wrapper> &valueType = {}, + const wrapper> &start = {}, + const wrapper> &length = {} + ) : + GNDSTK_COMPONENT(BlockData{}), + valueType(this,defaults.valueType,valueType), + start(this,defaults.start,start), + length(this,length) + { + Component::finish(); + } + + // from node + explicit Values(const Node &node) : + GNDSTK_COMPONENT(BlockData{}) + { + Component::finish(node); + } + + // from vector + template>> + Values(const std::vector &vector) : + GNDSTK_COMPONENT(BlockData{}) + { + Component::finish(vector); + } + + // copy + Values(const Values &other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = other; + Component::finish(other); + } + + // move + Values(Values &&other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = std::move(other); + Component::finish(other); + } + + // ------------------------ + // Assignment operators + // ------------------------ + + Values &operator=(const Values &) = default; + Values &operator=(Values &&) = default; + + // ------------------------ + // Custom functionality + // ------------------------ + + #include "proto/v1.9/containers/Values/src/custom.hpp" + #undef GNDSTK_COMPONENT +}; // class Values + +} // namespace containers +} // namespace v1_9 +} // namespace proto + +#endif diff --git a/autogen/prototype/proto/src/proto/v1.9/containers/Values/src/custom.hpp b/autogen/prototype/proto/src/proto/v1.9/containers/Values/src/custom.hpp new file mode 100644 index 000000000..ccf86f6b5 --- /dev/null +++ b/autogen/prototype/proto/src/proto/v1.9/containers/Values/src/custom.hpp @@ -0,0 +1,54 @@ +private: + + static inline helpMap help = { + + { "", "A GNDS basic component: a list of values\n\n" + "This component is used in the nodes like XYs1D or the grid node." }, + { "constructor", "Initialise the values component\n\n" + "Arguments:\n" + " self the values component\n" + " values the values\n" + " start the starting index of the values\n" + " value_type the value type\n" }, + { "length", "The length of the values" }, + { "start", "The starting index of the values (default = 0)" }, + { "value_type", "The value type (default = 'Float64')" }, + { "doubles", "The underlying values" } + }; + + /** + * Custom construct function + */ + void construct() { + + if ( this->length() != std::nullopt ) { + + if ( this->length() != this->size() + this->start() ) { + + log::error( "Inconsistent size for \"values\" array" ); + log::info( "start: {}", this->start() ); + log::info( "length: {}", this->length().value() ); + log::info( "number of values: {}", this->size() ); + throw std::exception(); + } + } + } + +public: + + template < typename T, + typename = std::enable_if_t< + detail::isAlternative< T, VariantOfScalars > > > + Values( const std::optional< int >& length, + const std::optional< int >& start, + const std::optional< std::string >& valueType, + const std::vector< T >& values ) : + GNDSTK_COMPONENT(BlockData{}), + valueType(this,defaults.valueType,valueType), + start(this,defaults.start,start), + length(this,length) + { + + *this = values; + Component::finish(); // ensure that construct() gets called + } diff --git a/src/GNDStk/v1.9/containers/Values/test/CMakeLists.txt b/autogen/prototype/proto/src/proto/v1.9/containers/Values/test/CMakeLists.txt similarity index 100% rename from src/GNDStk/v1.9/containers/Values/test/CMakeLists.txt rename to autogen/prototype/proto/src/proto/v1.9/containers/Values/test/CMakeLists.txt diff --git a/src/GNDStk/v1.9/containers/Values/test/Values.test.cpp b/autogen/prototype/proto/src/proto/v1.9/containers/Values/test/Values.test.cpp similarity index 87% rename from src/GNDStk/v1.9/containers/Values/test/Values.test.cpp rename to autogen/prototype/proto/src/proto/v1.9/containers/Values/test/Values.test.cpp index d8e132d5d..d2912e4a7 100644 --- a/src/GNDStk/v1.9/containers/Values/test/Values.test.cpp +++ b/autogen/prototype/proto/src/proto/v1.9/containers/Values/test/Values.test.cpp @@ -1,12 +1,15 @@ + #define CATCH_CONFIG_MAIN #include "catch.hpp" -#include "GNDStk/v1.9/containers/Values.hpp" +#include "proto/v1.9/containers/Values.hpp" // other includes // convenience typedefs using namespace njoy::GNDStk; +using namespace proto; + using Values = v1_9::containers::Values; std::string chunk(); @@ -23,7 +26,7 @@ SCENARIO( "Values" ) { std::string string = chunk(); - WHEN( "autogenerated constructor: the data is given explicitly" ) { + WHEN( "autogenerated constructor: the data are given explicitly" ) { std::vector< double > values = { 2500., 8.9172, 2550., 8.9155 }; @@ -43,7 +46,7 @@ SCENARIO( "Values" ) { } // THEN } // WHEN - WHEN( "the data is constructed from a node" ) { + WHEN( "the data are constructed from a node" ) { Node node; node << chunk(); @@ -68,7 +71,7 @@ SCENARIO( "Values" ) { std::string string = chunkInts(); - WHEN( "autogenerated constructor: the data is given explicitly" ) { + WHEN( "autogenerated constructor: the data are given explicitly" ) { std::vector< Integer32 > values = { 2500, 9, 2550, 9 }; @@ -88,7 +91,7 @@ SCENARIO( "Values" ) { } // THEN } // WHEN - WHEN( "the data is constructed from a node" ) { + WHEN( "the data are constructed from a node" ) { Node node; node << chunkInts(); @@ -113,7 +116,7 @@ SCENARIO( "Values" ) { std::string string = chunkStrings(); - WHEN( "autogenerated constructor: the data is given explicitly" ) { + WHEN( "autogenerated constructor: the data are given explicitly" ) { std::vector< UTF8Text > values = { "2500", "8.9172", "2550", "8.9155" }; @@ -133,7 +136,7 @@ SCENARIO( "Values" ) { } // THEN } // WHEN - WHEN( "the data is constructed from a node" ) { + WHEN( "the data are constructed from a node" ) { Node node; node << chunkStrings(); @@ -176,7 +179,7 @@ SCENARIO( "Values" ) { } // THEN } // WHEN - WHEN( "the data is moved" ) { + WHEN( "the data are moved" ) { Node node; node << chunk(); @@ -216,8 +219,7 @@ SCENARIO( "Values" ) { std::string chunk() { return -R"***(2500 8.9172 2550 8.9155 -)***"; +R"***(2500 8.9172 2550 8.9155)***"; } void verifyChunk( const Values& component ) { @@ -238,8 +240,7 @@ void verifyChunk( const Values& component ) { std::string chunkInts() { return -R"***(2500 9 2550 9 -)***"; +R"***(2500 9 2550 9)***"; } void verifyChunkInts( const Values& component ) { @@ -260,8 +261,7 @@ void verifyChunkInts( const Values& component ) { std::string chunkStrings() { return -R"***(2500 8.9172 2550 8.9155 -)***"; +R"***(2500 8.9172 2550 8.9155)***"; } void verifyChunkStrings( const Values& component ) { @@ -283,6 +283,5 @@ std::string invalidName() { // wrong name for the node return -R"***(2500 8.9172 2550 8.9155 -)***"; +R"***(2500 8.9172 2550 8.9155)***"; } diff --git a/autogen/prototype/proto/src/proto/v1.9/containers/XYs1d.hpp b/autogen/prototype/proto/src/proto/v1.9/containers/XYs1d.hpp new file mode 100644 index 000000000..c07fa4667 --- /dev/null +++ b/autogen/prototype/proto/src/proto/v1.9/containers/XYs1d.hpp @@ -0,0 +1,146 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#ifndef PROTO_V1_9_CONTAINERS_XYS1D +#define PROTO_V1_9_CONTAINERS_XYS1D + +#include "proto/v1.9/containers/Axes.hpp" +#include "proto/v1.9/containers/Values.hpp" + +namespace proto { +namespace v1_9 { +namespace containers { + +// ----------------------------------------------------------------------------- +// containers:: +// class XYs1d +// ----------------------------------------------------------------------------- + +class XYs1d : public Component { + friend class Component; + + // ------------------------ + // For Component + // ------------------------ + + // Names: this namespace, this class, a field/node of this type + static auto NAMESPACE() { return "containers"; } + static auto CLASS() { return "XYs1d"; } + static auto FIELD() { return "XYs1d"; } + + // Core Interface multi-query to extract metadata and child nodes + static auto KEYS() + { + return + // metadata + std::optional{} + / Meta<>("index") | + Defaulted{enums::Interpolation::linlin} + / Meta<>("interpolation") | + std::optional{} + / Meta<>("label") | + std::optional{} + / Meta<>("outerDomainValue") | + // children + std::optional{} + / --Child<>("axes") | + containers::Values{} + / --Child<>("values") + ; + } + +public: + using Component::construct; + + // defaults + static inline const struct Defaults { + static inline const enums::Interpolation interpolation = enums::Interpolation::linlin; + } defaults; + + // metadata + Field> index{this}; + Field> interpolation{this,defaults.interpolation}; + Field> label{this}; + Field> outerDomainValue{this}; + + // children + Field> axes{this}; + Field values{this}; + + // ------------------------ + // Constructors + // ------------------------ + + #define GNDSTK_COMPONENT(blockdata) Component(blockdata, \ + this->index, \ + this->interpolation, \ + this->label, \ + this->outerDomainValue, \ + this->axes, \ + this->values) + + // default, and from fields + // std::optional replaces Defaulted; this class knows the default(s) + explicit XYs1d( + const wrapper> &index = {}, + const wrapper> &interpolation = {}, + const wrapper> &label = {}, + const wrapper> &outerDomainValue = {}, + const wrapper> &axes = {}, + const wrapper &values = {} + ) : + GNDSTK_COMPONENT(BlockData{}), + index(this,index), + interpolation(this,defaults.interpolation,interpolation), + label(this,label), + outerDomainValue(this,outerDomainValue), + axes(this,axes), + values(this,values) + { + Component::finish(); + } + + // from node + explicit XYs1d(const Node &node) : + GNDSTK_COMPONENT(BlockData{}) + { + Component::finish(node); + } + + // copy + XYs1d(const XYs1d &other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = other; + Component::finish(other); + } + + // move + XYs1d(XYs1d &&other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = std::move(other); + Component::finish(other); + } + + // ------------------------ + // Assignment operators + // ------------------------ + + XYs1d &operator=(const XYs1d &) = default; + XYs1d &operator=(XYs1d &&) = default; + + // ------------------------ + // Custom functionality + // ------------------------ + + #include "proto/v1.9/containers/XYs1d/src/custom.hpp" + #undef GNDSTK_COMPONENT +}; // class XYs1d + +} // namespace containers +} // namespace v1_9 +} // namespace proto + +#endif diff --git a/src/GNDStk/v1.9/containers/XYs1d/src/custom.hpp b/autogen/prototype/proto/src/proto/v1.9/containers/XYs1d/src/custom.hpp similarity index 100% rename from src/GNDStk/v1.9/containers/XYs1d/src/custom.hpp rename to autogen/prototype/proto/src/proto/v1.9/containers/XYs1d/src/custom.hpp diff --git a/src/GNDStk/v1.9/containers/XYs1d/test/CMakeLists.txt b/autogen/prototype/proto/src/proto/v1.9/containers/XYs1d/test/CMakeLists.txt similarity index 100% rename from src/GNDStk/v1.9/containers/XYs1d/test/CMakeLists.txt rename to autogen/prototype/proto/src/proto/v1.9/containers/XYs1d/test/CMakeLists.txt diff --git a/src/GNDStk/v1.9/containers/XYs1d/test/XYs1d.test.cpp b/autogen/prototype/proto/src/proto/v1.9/containers/XYs1d/test/XYs1d.test.cpp similarity index 87% rename from src/GNDStk/v1.9/containers/XYs1d/test/XYs1d.test.cpp rename to autogen/prototype/proto/src/proto/v1.9/containers/XYs1d/test/XYs1d.test.cpp index 05c427b6a..1429a2a15 100644 --- a/src/GNDStk/v1.9/containers/XYs1d/test/XYs1d.test.cpp +++ b/autogen/prototype/proto/src/proto/v1.9/containers/XYs1d/test/XYs1d.test.cpp @@ -1,12 +1,15 @@ + #define CATCH_CONFIG_MAIN #include "catch.hpp" -#include "GNDStk/v1.9/containers/XYs1d.hpp" +#include "proto/v1.9/containers/XYs1d.hpp" // other includes // convenience typedefs using namespace njoy::GNDStk; +using namespace proto; + using XYs1d = v1_9::containers::XYs1d; using Axes = v1_9::containers::Axes; using Axis = v1_9::containers::Axis; @@ -19,19 +22,21 @@ void verifyChunk( const XYs1d& ); std::string invalidName(); SCENARIO( "XYs1d" ) { + njoy::GNDStk::sort = true; GIVEN( "valid data for the component" ) { std::string string = chunk(); - WHEN( "autogenerated constructor: the data is given explicitly" ) { + WHEN( "autogenerated constructor: the data are given explicitly" ) { XYs1d chunk( std::nullopt, std::nullopt, std::nullopt, std::nullopt, Axes( std::nullopt, std::vector< std::variant< Axis, Grid > >{ Axis( 1, "energy_in", "eV" ), Axis( 0, "crossSection", "b" ) } ), - Values( std::vector< double >{ 1e-05, 1., 2.53e-2, 2., 2.5e+3, 3. } ) ); + Values( std::vector< double > + { 1e-05, 1., 2.53e-2, 2., 2.5e+3, 3. } ) ); THEN( "the component can be constructed and members can be tested" ) { @@ -47,7 +52,7 @@ SCENARIO( "XYs1d" ) { } // THEN } // WHEN - WHEN( "the data is constructed from a node" ) { + WHEN( "the data are constructed from a node" ) { Node node; node << chunk(); @@ -90,7 +95,7 @@ SCENARIO( "XYs1d" ) { } // THEN } // WHEN - WHEN( "the data is moved" ) { + WHEN( "the data are moved" ) { Node node; node << chunk(); @@ -135,9 +140,8 @@ R"***( - 1e-05 1 0.0253 2 2500 3 - -)***"; + 1e-05 1 0.0253 2 2500 3 +)***"; } void verifyChunk( const XYs1d& component ) { @@ -150,7 +154,8 @@ void verifyChunk( const XYs1d& component ) { CHECK( enums::Interpolation::linlin == component.interpolation() ); // axes data - decltype(auto) axis0 = std::get< Axis >( component.axes().value().axis_grid()[0] ); + decltype(auto) axis0 = + std::get< Axis >( component.axes().value().axis_grid()[0] ); CHECK( std::nullopt != axis0.index() ); CHECK( std::nullopt != axis0.label() ); @@ -160,7 +165,8 @@ void verifyChunk( const XYs1d& component ) { CHECK( "crossSection" == axis0.label().value() ); CHECK( "b" == axis0.unit().value() ); - decltype(auto) axis1 = std::get< Axis >( component.axes().value().axis_grid()[1] ); + decltype(auto) axis1 = + std::get< Axis >( component.axes().value().axis_grid()[1] ); CHECK( std::nullopt != axis1.index() ); CHECK( std::nullopt != axis1.label() ); @@ -196,6 +202,5 @@ R"***( 1e-05 1. 2.53e-2 2. 2.5e+3 3. - -)***"; +)***"; } diff --git a/autogen/prototype/proto/src/proto/v1.9/key.hpp b/autogen/prototype/proto/src/proto/v1.9/key.hpp new file mode 100644 index 000000000..ea18ab901 --- /dev/null +++ b/autogen/prototype/proto/src/proto/v1.9/key.hpp @@ -0,0 +1,113 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#ifndef PROTO_V1_9_KEY +#define PROTO_V1_9_KEY + +// GNDStk Core Interface +#include "GNDStk.hpp" + +namespace proto { +namespace v1_9 { + +using namespace njoy::GNDStk; + + +// ----------------------------------------------------------------------------- +// meta:: +// ----------------------------------------------------------------------------- + +namespace meta { + +#define GNDSTK_MAKE_LOOKUP(nameField,nameGNDS) \ + inline const auto nameField = makeLookup( \ + [](const auto &obj) -> decltype(obj.nameField()) \ + { return obj.nameField(); }, \ + #nameGNDS \ + ) +// nameField vs. nameGNDS: for, e.g., Double vs. double in GNDS + +GNDSTK_MAKE_LOOKUP(ENDF_MT,ENDF_MT); +GNDSTK_MAKE_LOOKUP(evaluation,evaluation); +GNDSTK_MAKE_LOOKUP(fissionGenre,fissionGenre); +GNDSTK_MAKE_LOOKUP(format,format); +GNDSTK_MAKE_LOOKUP(href,href); +GNDSTK_MAKE_LOOKUP(index,index); +GNDSTK_MAKE_LOOKUP(interaction,interaction); +GNDSTK_MAKE_LOOKUP(interpolation,interpolation); +GNDSTK_MAKE_LOOKUP(label,label); +GNDSTK_MAKE_LOOKUP(length,length); +GNDSTK_MAKE_LOOKUP(outerDomainValue,outerDomainValue); +GNDSTK_MAKE_LOOKUP(projectile,projectile); +GNDSTK_MAKE_LOOKUP(projectileFrame,projectileFrame); +GNDSTK_MAKE_LOOKUP(start,start); +GNDSTK_MAKE_LOOKUP(style,style); +GNDSTK_MAKE_LOOKUP(target,target); +GNDSTK_MAKE_LOOKUP(unit,unit); +GNDSTK_MAKE_LOOKUP(valueType,valueType); + +#undef GNDSTK_MAKE_LOOKUP + +} // namespace meta + + +// ----------------------------------------------------------------------------- +// containers::child:: +// ----------------------------------------------------------------------------- + +namespace containers { +namespace child { + +inline const Child<> XYs1d("XYs1d"); +inline const Child<> axes("axes"); +inline const Child<> axis("axis"); +inline const Child<> grid("grid"); +inline const Child<> link("link"); +inline const Child<> regions1d("regions1d"); +inline const Child<> values("values"); + +} // namespace child +using namespace child; +} // namespace containers + + +// ----------------------------------------------------------------------------- +// transport::child:: +// ----------------------------------------------------------------------------- + +namespace transport { +namespace child { + +inline const Child<> crossSection("crossSection"); +inline const Child<> reaction("reaction"); +inline const Child<> reactionSuite("reactionSuite"); +inline const Child<> reactions("reactions"); + +} // namespace child +using namespace child; +} // namespace transport + + +// ----------------------------------------------------------------------------- +// For convenience: using directives +// ----------------------------------------------------------------------------- + +namespace key { + using namespace meta; + using namespace containers::child; + using namespace transport::child; +} // namespace key + +using namespace key; +using namespace containers; +using namespace transport; + + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + +} // namespace v1_9 +} // namespace proto + +#endif diff --git a/autogen/prototype/proto/src/proto/v1.9/transport/CrossSection.hpp b/autogen/prototype/proto/src/proto/v1.9/transport/CrossSection.hpp new file mode 100644 index 000000000..d407fa49c --- /dev/null +++ b/autogen/prototype/proto/src/proto/v1.9/transport/CrossSection.hpp @@ -0,0 +1,114 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#ifndef PROTO_V1_9_TRANSPORT_CROSSSECTION +#define PROTO_V1_9_TRANSPORT_CROSSSECTION + +#include "proto/v1.9/containers/XYs1d.hpp" +#include "proto/v1.9/containers/Regions1d.hpp" + +namespace proto { +namespace v1_9 { +namespace transport { + +// ----------------------------------------------------------------------------- +// transport:: +// class CrossSection +// ----------------------------------------------------------------------------- + +class CrossSection : public Component { + friend class Component; + + using XYs1d_regions1d_t = std::variant< + containers::XYs1d, + containers::Regions1d + >; + + // ------------------------ + // For Component + // ------------------------ + + // Names: this namespace, this class, a field/node of this type + static auto NAMESPACE() { return "transport"; } + static auto CLASS() { return "CrossSection"; } + static auto FIELD() { return "crossSection"; } + + // Core Interface multi-query to extract metadata and child nodes + static auto KEYS() + { + return + // children + XYs1d_regions1d_t{} + / ++(Child<>("XYs1d") || Child<>("regions1d")) + ; + } + +public: + using Component::construct; + + // children - variant + Field> XYs1d_regions1d{this}; + FieldPart XYs1d{XYs1d_regions1d}; + FieldPart regions1d{XYs1d_regions1d}; + + // ------------------------ + // Constructors + // ------------------------ + + #define GNDSTK_COMPONENT(blockdata) Component(blockdata, \ + this->XYs1d_regions1d) + + // default, and from fields + explicit CrossSection( + const wrapper> &XYs1d_regions1d = {} + ) : + GNDSTK_COMPONENT(BlockData{}), + XYs1d_regions1d(this,XYs1d_regions1d) + { + Component::finish(); + } + + // from node + explicit CrossSection(const Node &node) : + GNDSTK_COMPONENT(BlockData{}) + { + Component::finish(node); + } + + // copy + CrossSection(const CrossSection &other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = other; + Component::finish(other); + } + + // move + CrossSection(CrossSection &&other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = std::move(other); + Component::finish(other); + } + + // ------------------------ + // Assignment operators + // ------------------------ + + CrossSection &operator=(const CrossSection &) = default; + CrossSection &operator=(CrossSection &&) = default; + + // ------------------------ + // Custom functionality + // ------------------------ + + #include "proto/v1.9/transport/CrossSection/src/custom.hpp" + #undef GNDSTK_COMPONENT +}; // class CrossSection + +} // namespace transport +} // namespace v1_9 +} // namespace proto + +#endif diff --git a/src/GNDStk/v1.9/transport/CrossSection/src/custom.hpp b/autogen/prototype/proto/src/proto/v1.9/transport/CrossSection/src/custom.hpp similarity index 100% rename from src/GNDStk/v1.9/transport/CrossSection/src/custom.hpp rename to autogen/prototype/proto/src/proto/v1.9/transport/CrossSection/src/custom.hpp diff --git a/autogen/prototype/proto/src/proto/v1.9/transport/Reaction.hpp b/autogen/prototype/proto/src/proto/v1.9/transport/Reaction.hpp new file mode 100644 index 000000000..6456d7cf4 --- /dev/null +++ b/autogen/prototype/proto/src/proto/v1.9/transport/Reaction.hpp @@ -0,0 +1,127 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#ifndef PROTO_V1_9_TRANSPORT_REACTION +#define PROTO_V1_9_TRANSPORT_REACTION + +#include "proto/v1.9/transport/CrossSection.hpp" + +namespace proto { +namespace v1_9 { +namespace transport { + +// ----------------------------------------------------------------------------- +// transport:: +// class Reaction +// ----------------------------------------------------------------------------- + +class Reaction : public Component { + friend class Component; + + // ------------------------ + // For Component + // ------------------------ + + // Names: this namespace, this class, a field/node of this type + static auto NAMESPACE() { return "transport"; } + static auto CLASS() { return "Reaction"; } + static auto FIELD() { return "reaction"; } + + // Core Interface multi-query to extract metadata and child nodes + static auto KEYS() + { + return + // metadata + int{} + / Meta<>("ENDF_MT") | + std::optional{} + / Meta<>("fissionGenre") | + std::string{} + / Meta<>("label") | + // children + transport::CrossSection{} + / --Child<>("crossSection") + ; + } + +public: + using Component::construct; + + // metadata + Field ENDF_MT{this}; + Field> fissionGenre{this}; + Field label{this}; + + // children + Field crossSection{this}; + + // ------------------------ + // Constructors + // ------------------------ + + #define GNDSTK_COMPONENT(blockdata) Component(blockdata, \ + this->ENDF_MT, \ + this->fissionGenre, \ + this->label, \ + this->crossSection) + + // default, and from fields + explicit Reaction( + const wrapper &ENDF_MT = {}, + const wrapper> &fissionGenre = {}, + const wrapper &label = {}, + const wrapper &crossSection = {} + ) : + GNDSTK_COMPONENT(BlockData{}), + ENDF_MT(this,ENDF_MT), + fissionGenre(this,fissionGenre), + label(this,label), + crossSection(this,crossSection) + { + Component::finish(); + } + + // from node + explicit Reaction(const Node &node) : + GNDSTK_COMPONENT(BlockData{}) + { + Component::finish(node); + } + + // copy + Reaction(const Reaction &other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = other; + Component::finish(other); + } + + // move + Reaction(Reaction &&other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = std::move(other); + Component::finish(other); + } + + // ------------------------ + // Assignment operators + // ------------------------ + + Reaction &operator=(const Reaction &) = default; + Reaction &operator=(Reaction &&) = default; + + // ------------------------ + // Custom functionality + // ------------------------ + + #include "proto/v1.9/transport/Reaction/src/custom.hpp" + #undef GNDSTK_COMPONENT +}; // class Reaction + +} // namespace transport +} // namespace v1_9 +} // namespace proto + +#endif diff --git a/src/GNDStk/v1.9/transport/Reaction/src/custom.hpp b/autogen/prototype/proto/src/proto/v1.9/transport/Reaction/src/custom.hpp similarity index 100% rename from src/GNDStk/v1.9/transport/Reaction/src/custom.hpp rename to autogen/prototype/proto/src/proto/v1.9/transport/Reaction/src/custom.hpp diff --git a/autogen/prototype/proto/src/proto/v1.9/transport/ReactionSuite.hpp b/autogen/prototype/proto/src/proto/v1.9/transport/ReactionSuite.hpp new file mode 100644 index 000000000..f5490ef94 --- /dev/null +++ b/autogen/prototype/proto/src/proto/v1.9/transport/ReactionSuite.hpp @@ -0,0 +1,145 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#ifndef PROTO_V1_9_TRANSPORT_REACTIONSUITE +#define PROTO_V1_9_TRANSPORT_REACTIONSUITE + +#include "proto/v1.9/transport/Reactions.hpp" + +namespace proto { +namespace v1_9 { +namespace transport { + +// ----------------------------------------------------------------------------- +// transport:: +// class ReactionSuite +// ----------------------------------------------------------------------------- + +class ReactionSuite : public Component { + friend class Component; + + // ------------------------ + // For Component + // ------------------------ + + // Names: this namespace, this class, a field/node of this type + static auto NAMESPACE() { return "transport"; } + static auto CLASS() { return "ReactionSuite"; } + static auto FIELD() { return "reactionSuite"; } + + // Core Interface multi-query to extract metadata and child nodes + static auto KEYS() + { + return + // metadata + std::string{} + / Meta<>("evaluation") | + std::string{} + / Meta<>("format") | + std::string{} + / Meta<>("projectile") | + enums::Frame{} + / Meta<>("projectileFrame") | + std::string{} + / Meta<>("target") | + std::optional{} + / Meta<>("interaction") | + // children + std::optional{} + / --Child<>("reactions") + ; + } + +public: + using Component::construct; + + // metadata + Field evaluation{this}; + Field format{this}; + Field projectile{this}; + Field projectileFrame{this}; + Field target{this}; + Field> interaction{this}; + + // children + Field> reactions{this}; + + // ------------------------ + // Constructors + // ------------------------ + + #define GNDSTK_COMPONENT(blockdata) Component(blockdata, \ + this->evaluation, \ + this->format, \ + this->projectile, \ + this->projectileFrame, \ + this->target, \ + this->interaction, \ + this->reactions) + + // default, and from fields + explicit ReactionSuite( + const wrapper &evaluation = {}, + const wrapper &format = {}, + const wrapper &projectile = {}, + const wrapper &projectileFrame = {}, + const wrapper &target = {}, + const wrapper> &interaction = {}, + const wrapper> &reactions = {} + ) : + GNDSTK_COMPONENT(BlockData{}), + evaluation(this,evaluation), + format(this,format), + projectile(this,projectile), + projectileFrame(this,projectileFrame), + target(this,target), + interaction(this,interaction), + reactions(this,reactions) + { + Component::finish(); + } + + // from node + explicit ReactionSuite(const Node &node) : + GNDSTK_COMPONENT(BlockData{}) + { + Component::finish(node); + } + + // copy + ReactionSuite(const ReactionSuite &other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = other; + Component::finish(other); + } + + // move + ReactionSuite(ReactionSuite &&other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = std::move(other); + Component::finish(other); + } + + // ------------------------ + // Assignment operators + // ------------------------ + + ReactionSuite &operator=(const ReactionSuite &) = default; + ReactionSuite &operator=(ReactionSuite &&) = default; + + // ------------------------ + // Custom functionality + // ------------------------ + + #include "proto/v1.9/transport/ReactionSuite/src/custom.hpp" + #undef GNDSTK_COMPONENT +}; // class ReactionSuite + +} // namespace transport +} // namespace v1_9 +} // namespace proto + +#endif diff --git a/src/GNDStk/v1.9/transport/ReactionSuite/src/custom.hpp b/autogen/prototype/proto/src/proto/v1.9/transport/ReactionSuite/src/custom.hpp similarity index 100% rename from src/GNDStk/v1.9/transport/ReactionSuite/src/custom.hpp rename to autogen/prototype/proto/src/proto/v1.9/transport/ReactionSuite/src/custom.hpp diff --git a/autogen/prototype/proto/src/proto/v1.9/transport/Reactions.hpp b/autogen/prototype/proto/src/proto/v1.9/transport/Reactions.hpp new file mode 100644 index 000000000..ef3406833 --- /dev/null +++ b/autogen/prototype/proto/src/proto/v1.9/transport/Reactions.hpp @@ -0,0 +1,106 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#ifndef PROTO_V1_9_TRANSPORT_REACTIONS +#define PROTO_V1_9_TRANSPORT_REACTIONS + +#include "proto/v1.9/transport/Reaction.hpp" + +namespace proto { +namespace v1_9 { +namespace transport { + +// ----------------------------------------------------------------------------- +// transport:: +// class Reactions +// ----------------------------------------------------------------------------- + +class Reactions : public Component { + friend class Component; + + // ------------------------ + // For Component + // ------------------------ + + // Names: this namespace, this class, a field/node of this type + static auto NAMESPACE() { return "transport"; } + static auto CLASS() { return "Reactions"; } + static auto FIELD() { return "reactions"; } + + // Core Interface multi-query to extract metadata and child nodes + static auto KEYS() + { + return + // children + transport::Reaction{} + / ++Child<>("reaction") + ; + } + +public: + using Component::construct; + + // children + Field> reaction{this}; + + // ------------------------ + // Constructors + // ------------------------ + + #define GNDSTK_COMPONENT(blockdata) Component(blockdata, \ + this->reaction) + + // default, and from fields + explicit Reactions( + const wrapper> &reaction = {} + ) : + GNDSTK_COMPONENT(BlockData{}), + reaction(this,reaction) + { + Component::finish(); + } + + // from node + explicit Reactions(const Node &node) : + GNDSTK_COMPONENT(BlockData{}) + { + Component::finish(node); + } + + // copy + Reactions(const Reactions &other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = other; + Component::finish(other); + } + + // move + Reactions(Reactions &&other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = std::move(other); + Component::finish(other); + } + + // ------------------------ + // Assignment operators + // ------------------------ + + Reactions &operator=(const Reactions &) = default; + Reactions &operator=(Reactions &&) = default; + + // ------------------------ + // Custom functionality + // ------------------------ + + #include "proto/v1.9/transport/Reactions/src/custom.hpp" + #undef GNDSTK_COMPONENT +}; // class Reactions + +} // namespace transport +} // namespace v1_9 +} // namespace proto + +#endif diff --git a/src/GNDStk/v1.9/transport/Reactions/src/custom.hpp b/autogen/prototype/proto/src/proto/v1.9/transport/Reactions/src/custom.hpp similarity index 100% rename from src/GNDStk/v1.9/transport/Reactions/src/custom.hpp rename to autogen/prototype/proto/src/proto/v1.9/transport/Reactions/src/custom.hpp diff --git a/autogen/prototype/prototype.json b/autogen/prototype/prototype.json new file mode 100644 index 000000000..80d813dfc --- /dev/null +++ b/autogen/prototype/prototype.json @@ -0,0 +1,36 @@ +{ + "comment" : [ + "Path", + " Path to the Project directory.", + " Optional (defaults to .).", + "", + "Project", + " Base project directory into which the code generator should", + " place files. IMPORTANT: this should be a **plain** name only,", + " without any directory path. Use Path for that, if it's needed.", + " Optional (defaults to GNDStk).", + "", + "Version", + " Version number for this project.", + "", + "JSONDir", + " Directory in which the .json input files are located.", + "", + "JSONFiles", + " The .json input files.", + "", + "Do NOT end directories with a /" + ], + + "Path": ".", + "Project": "proto", + "Version": "v1.9", + + "JSONDir": ".", + "JSONFiles": [ + "generalPurpose.json", + "reactionSuite.json" + ], + + "Changes": "../changes.json" +} diff --git a/autogen/prototype/reactionSuite.json b/autogen/prototype/reactionSuite.json index 56280918b..814478bae 100644 --- a/autogen/prototype/reactionSuite.json +++ b/autogen/prototype/reactionSuite.json @@ -30,7 +30,7 @@ }, "children": { "reactions": { - "occurrence": "1", + "times": "1", "required": false } } @@ -40,7 +40,7 @@ "metadata": {}, "children": { "reaction": { - "occurrence": "1+", + "times": "1+", "required": true } } @@ -63,7 +63,7 @@ }, "children": { "crossSection": { - "occurrence": "1", + "times": "1", "required": true } } @@ -73,12 +73,12 @@ "metadata": {}, "children": { "XYs1d": { - "occurrence": "choice+", + "times": "choice+", "variant": "XYs1d_regions1d", "required": false }, "regions1d": { - "occurrence": "choice+", + "times": "choice+", "variant": "XYs1d_regions1d", "required": false } diff --git a/autogen/simple/.gitignore b/autogen/simple/.gitignore new file mode 100644 index 000000000..05d6da7a4 --- /dev/null +++ b/autogen/simple/.gitignore @@ -0,0 +1,20 @@ + +[a-z] +[0-9] +*.o +*~ + +*.h +*.hh +*.cc + +*.exe + +file.h5 +file.json +file.xml +out +foobar.xml +foobar.json +foobar.h5 +m diff --git a/autogen/simple/clean b/autogen/simple/clean new file mode 100755 index 000000000..a4eb9d408 --- /dev/null +++ b/autogen/simple/clean @@ -0,0 +1,3 @@ +#!/bin/bash + +/bin/rm -f *.o *.exe out *~ diff --git a/autogen/simple/compile-c b/autogen/simple/compile-c new file mode 100755 index 000000000..d6e8efc30 --- /dev/null +++ b/autogen/simple/compile-c @@ -0,0 +1,47 @@ +#!/bin/bash + +# C++ compilation command +COMPILE=" + clang++ -std=c++17 + -I../../../GNDStk/src + -I../../../GNDStk/c/src + -Imulti/src + -Imulti/c/src + -I../../../GNDStk/build/_deps/pugixml-adapter-src/src/src + -I../../../GNDStk/build/_deps/hdf5-src/include + -I../../../GNDStk/build/_deps/json-src/include + -I../../../GNDStk/build/_deps/json-src/include/nlohmann + -I../../../GNDStk/build/_deps/log-src/src + -I../../../GNDStk/build/_deps/spdlog-src/include + -I/usr/include/hdf5/serial + -DHIGHFIVE_USE_BOOST=OFF + -L/usr/lib/x86_64-linux-gnu/hdf5/serial + -lhdf5 + -fno-show-column + -Wno-unused-command-line-argument + -Wall -Wextra -Wpedantic " + +# pugixml +if [ ! -f "pugixml.o" ]; then + $COMPILE ../../../GNDStk/build/_deps/pugixml-adapter-src/src/src/pugixml.cpp -c & +fi + +# Compile C++ +$COMPILE -c ../../../GNDStk/c/src/GNDStk.cpp & +$COMPILE -c multi/c/src/v1/multigroup/Foobar.cpp & +$COMPILE -c multi/c/src/v1/multigroup/Isotope.cpp & +$COMPILE -c multi/c/src/v1/multigroup/Element.cpp & +$COMPILE -c multi/c/src/v1/multigroup/Library.cpp & +$COMPILE -c multi/c/src/v1/multigroup/Multigroup.cpp & + +wait $(jobs -p) + +# Compile C +clang \ + -I../../../GNDStk/c/src \ + -Imulti/c/src \ + example-01.c \ + *.o \ + -L/usr/lib/x86_64-linux-gnu/hdf5/serial \ + -lstdc++ -lm -lhdf5 \ + -o c.exe diff --git a/autogen/simple/compile-cpp b/autogen/simple/compile-cpp new file mode 100755 index 000000000..7411e1bba --- /dev/null +++ b/autogen/simple/compile-cpp @@ -0,0 +1,31 @@ +#!/bin/bash + +# C++ compilation command +COMPILE=" + clang++ -std=c++17 + -I../../../GNDStk/src + -Imulti/src + -I../../../GNDStk/build/_deps/pugixml-adapter-src/src/src + -I../../../GNDStk/build/_deps/hdf5-src/include + -I../../../GNDStk/build/_deps/json-src/include + -I../../../GNDStk/build/_deps/json-src/include/nlohmann + -I../../../GNDStk/build/_deps/log-src/src + -I../../../GNDStk/build/_deps/spdlog-src/include + -I/usr/include/hdf5/serial + -DHIGHFIVE_USE_BOOST=OFF + -L/usr/lib/x86_64-linux-gnu/hdf5/serial + -lhdf5 + -fno-show-column + -Wno-unused-command-line-argument + -Wall -Wextra -Wpedantic " + +# pugixml +if [ ! -f "pugixml.o" ]; then +$COMPILE ../../../GNDStk/build/_deps/pugixml-adapter-src/src/src/pugixml.cpp -c +fi + +# Compile +$COMPILE example-01.cpp pugixml.o -o cpp-01.exe & +$COMPILE example-02.cpp pugixml.o -o cpp-02.exe & + +wait $(jobs -p) diff --git a/autogen/simple/example-01.c b/autogen/simple/example-01.c new file mode 100644 index 000000000..6c27db3ec --- /dev/null +++ b/autogen/simple/example-01.c @@ -0,0 +1,17 @@ + +#include +#include "v1.h" + +int main() +{ + // colorize diagnostics and prettyprinting + color(1); + + Foobar one = FoobarDefault(); + Foobar two = FoobarDefault(); + + FoobarAssign(one,two); + FoobarPrint(one); + FoobarPrintXML(one); + FoobarPrintJSON(one); +} diff --git a/autogen/simple/example-01.cpp b/autogen/simple/example-01.cpp new file mode 100644 index 000000000..80950cf96 --- /dev/null +++ b/autogen/simple/example-01.cpp @@ -0,0 +1,73 @@ + +#include "multi/v1.hpp" +using namespace multi::v1; + +int main() +{ + color = true; + + // Make some elements. We can make elements ("outer + // objects") first, then add isotopes ("inner objects"). + Element H ("H", 1); + Element He("He",2); + Element Li("Li",3); + Element Be("Be",4); + + // Add some isotopes. With this short notation, we + // get vector push_back()s into an Element's vector + // of Isotopes. + H += Isotope(1); + H += Isotope(2); + H += Isotope(3); + + He += Isotope(3); + He += Isotope(4); + // ... + + // for fun... + He.isotope.replace(mass_number(4),Isotope(4)); + He. replace(mass_number(4),Isotope(4)); + + He.foobar = Foobar{}; + + // Make a couple of libraries. Here, we'll give them + // (vectors of) elements immediately. (Alternatively, + // those could have been added later, like we did for + // adding isotopes above.) + Library first("first library", {H,He}); + Library second("second library", {Li,Be}); + + // Make a multigroup object. + Multigroup multi("projectile name", {first,second}); + + // Example: use a basic getter to get the vector of + // elements from the second library. Getters are + // flexible (the good) but mean we have to require + // the "()" syntax (the ugly). :-/ + std::vector elems = second.element(); + assert(elems[0].symbol() == "Li"); + assert(elems[1].symbol() == "Be"); + + // Example: look stuff up by metadatum value. + Isotope deu = H.isotope(mass_number(2)); + Isotope tri = H.isotope(mass_number(3)); + + // If we instead write isotope() with no arguments + // to the getter, we get a vector of Isotope objects. + std::vector iso = H.isotope(); + + // Slightly fancier lookup, starting all the way up + // at the Multigroup object. + Isotope i = + multi.library(name("first library")) + .element(symbol("He")) + .isotope(mass_number(3)); + + // Write as XML, JSON, and HDF5. + multi.write("file.xml"); + multi.write("file.json"); + multi.write("file.h5"); + + // Prettyprint. + multi.print(); +} diff --git a/autogen/simple/example-02.cpp b/autogen/simple/example-02.cpp new file mode 100644 index 000000000..b5b38bca7 --- /dev/null +++ b/autogen/simple/example-02.cpp @@ -0,0 +1,35 @@ + +#include "multi/v1.hpp" +using namespace multi::v1; + +int main() +{ + color = true; + + // Try a Foobar all by itself + { + Foobar f(std::vector{ 1, 2, 3, 4, 5 }); + f.write("foobar.xml"); + f.write("foobar.json"); + f.write("foobar.h5"); + f.print(); + + // read from xml + std::cout << "\nTrying to read XML:" << std::endl; + f.read("foobar.xml"); + std::cout << "Back from XML:" << std::endl; + f.print(); + + // read from json + std::cout << "\nTrying to read JSON:" << std::endl; + f.read("foobar.json"); + std::cout << "Back from JSON:" << std::endl; + f.print(); + + // read from h5 + std::cout << "\nTrying to read H5:" << std::endl; + f.read("foobar.h5"); + std::cout << "Back from H5:" << std::endl; + f.print(); + } +} diff --git a/autogen/simple/multi-classes.json b/autogen/simple/multi-classes.json new file mode 100644 index 000000000..eeabd8395 --- /dev/null +++ b/autogen/simple/multi-classes.json @@ -0,0 +1,79 @@ +{ + "namespace": "multigroup", + + "multigroup": { + "metadata": { + "projectile": { + "type": "string", + "required": true + } + }, + "children": { + "library": { + "times": "1+", + "required": true + } + } + }, + + "library": { + "metadata": { + "name": { + "type": "string", + "required": true + } + }, + "children": { + "element": { + "times": "1+", + "required": true + } + } + }, + + + "element": { + "metadata": { + "symbol": { + "type": "string", + "required": false + }, + "atomic_number": { + "type": "int", + "required": true + } + }, + "children": { + "isotope": { + "times": "1+", + "required": true + }, + "foobar": { + "times": "1", + "required": false + } + } + }, + + "isotope": { + "metadata": { + "mass_number": { + "type": "int", + "required": true + } + }, + "children": { + } + }, + + "foobar": { + "metadata": { + "value": { + "type": "string", + "required": true + } + }, + "children": { }, + "data": "double" + } +} diff --git a/autogen/simple/multi.json b/autogen/simple/multi.json new file mode 100644 index 000000000..f7f5dbbf0 --- /dev/null +++ b/autogen/simple/multi.json @@ -0,0 +1,9 @@ +{ + "Project": "multi", + "Version": "v1", + + "JSONDir": ".", + "JSONFiles": [ + "multi-classes.json" + ] +} diff --git a/autogen/simple/multi/c/src/v1.cpp b/autogen/simple/multi/c/src/v1.cpp new file mode 100644 index 000000000..3980cc696 --- /dev/null +++ b/autogen/simple/multi/c/src/v1.cpp @@ -0,0 +1,2 @@ + +#include "v1.h" diff --git a/autogen/simple/multi/c/src/v1.h b/autogen/simple/multi/c/src/v1.h new file mode 100644 index 000000000..d69c0f08b --- /dev/null +++ b/autogen/simple/multi/c/src/v1.h @@ -0,0 +1,25 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// ----------------------------------------------------------------------------- +// This header file is designed to work with both C and C++ +// ----------------------------------------------------------------------------- + +#ifndef C_INTERFACE_MULTI_V1 +#define C_INTERFACE_MULTI_V1 + +#include "GNDStk.h" + +#ifdef __cplusplus + // For C++ + #include "multi/v1.hpp" +#endif + +#include "v1/multigroup/Multigroup.h" +#include "v1/multigroup/Library.h" +#include "v1/multigroup/Element.h" +#include "v1/multigroup/Isotope.h" +#include "v1/multigroup/Foobar.h" + +#endif diff --git a/autogen/simple/multi/c/src/v1/multigroup/Element.cpp b/autogen/simple/multi/c/src/v1/multigroup/Element.cpp new file mode 100644 index 000000000..82f796f0f --- /dev/null +++ b/autogen/simple/multi/c/src/v1/multigroup/Element.cpp @@ -0,0 +1,363 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include "multi/v1/multigroup/Element.hpp" +#include "Element.h" + +using namespace njoy::GNDStk; +using namespace multi::v1; + +using C = ElementClass; +using CPP = multigroup::Element; + +static const std::string CLASSNAME = "Element"; + +namespace extract { + static auto symbol = [](auto &obj) { return &obj.symbol; }; + static auto atomic_number = [](auto &obj) { return &obj.atomic_number; }; + static auto isotope = [](auto &obj) { return &obj.isotope; }; + static auto foobar = [](auto &obj) { return &obj.foobar; }; +} + +using CPPIsotope = multigroup::Isotope; +using CPPFoobar = multigroup::Foobar; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// Create, default, const +Handle2ConstElement +ElementDefaultConst() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"DefaultConst"); +} + +// Create, default +Handle2Element +ElementDefault() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"Default"); +} + +// Create, general, const +Handle2ConstElement +ElementCreateConst( + const char *const symbol, + const int atomic_number, + ConstHandle2Isotope *const isotope, const size_t isotopeSize, + ConstHandle2ConstFoobar foobar +) { + ConstHandle2Element handle = detail::createHandle( + CLASSNAME, CLASSNAME+"CreateConst", + symbol, + atomic_number, + std::vector{}, + detail::tocpp(foobar) + ); + for (size_t IsotopeN = 0; IsotopeN < isotopeSize; ++IsotopeN) + ElementIsotopeAdd(handle, isotope[IsotopeN]); + return handle; +} + +// Create, general +Handle2Element +ElementCreate( + const char *const symbol, + const int atomic_number, + ConstHandle2Isotope *const isotope, const size_t isotopeSize, + ConstHandle2ConstFoobar foobar +) { + ConstHandle2Element handle = detail::createHandle( + CLASSNAME, CLASSNAME+"Create", + symbol, + atomic_number, + std::vector{}, + detail::tocpp(foobar) + ); + for (size_t IsotopeN = 0; IsotopeN < isotopeSize; ++IsotopeN) + ElementIsotopeAdd(handle, isotope[IsotopeN]); + return handle; +} + +// Assign +// Use this to assign one handled object to another. Don't assign handles, +// as with to = from. That has a meaning that you probably don't intend. +void +ElementAssign(ConstHandle2Element This, ConstHandle2ConstElement from) +{ + detail::assignHandle + (CLASSNAME, CLASSNAME+"Assign", This, from); +} + +// Delete +// We'll attempt to remove no-longer-used objects automatically, but you +// may improve performance if you delete them when you're done with them. +void +ElementDelete(ConstHandle2ConstElement This) +{ + detail::deleteHandle + (CLASSNAME, CLASSNAME+"Delete", This); +} + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// Read from file +// File can be XML, JSON, or HDF5. +// We'll examine the file's contents to determine its type automatically. +int +ElementRead(ConstHandle2Element This, const char *const filename) +{ + return detail::readHandle + (CLASSNAME, CLASSNAME+"Read", This, filename); +} + +// Write to file +// File can be XML, JSON, or HDF5. +// We'll use filename's extension to determine the type you want written. +int +ElementWrite(ConstHandle2ConstElement This, const char *const filename) +{ + return detail::writeHandle + (CLASSNAME, CLASSNAME+"Write", This, filename); +} + +// Print to standard output, in our prettyprinting format +int +ElementPrint(ConstHandle2ConstElement This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"Print", This); +} + +// Print to standard output, as XML +int +ElementPrintXML(ConstHandle2ConstElement This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintXML", This, "XML"); +} + +// Print to standard output, as JSON +int +ElementPrintJSON(ConstHandle2ConstElement This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintJSON", This, "JSON"); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: symbol +// ----------------------------------------------------------------------------- + +// Has +int +ElementSymbolHas(ConstHandle2ConstElement This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"SymbolHas", This, extract::symbol); +} + +// Get +// Returns by value +const char * +ElementSymbolGet(ConstHandle2ConstElement This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"SymbolGet", This, extract::symbol); +} + +// Set +void +ElementSymbolSet(ConstHandle2Element This, const char *const symbol) +{ + detail::setField + (CLASSNAME, CLASSNAME+"SymbolSet", This, extract::symbol, symbol); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: atomic_number +// ----------------------------------------------------------------------------- + +// Has +int +ElementAtomicNumberHas(ConstHandle2ConstElement This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"AtomicNumberHas", This, extract::atomic_number); +} + +// Get +// Returns by value +int +ElementAtomicNumberGet(ConstHandle2ConstElement This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"AtomicNumberGet", This, extract::atomic_number); +} + +// Set +void +ElementAtomicNumberSet(ConstHandle2Element This, const int atomic_number) +{ + detail::setField + (CLASSNAME, CLASSNAME+"AtomicNumberSet", This, extract::atomic_number, atomic_number); +} + + +// ----------------------------------------------------------------------------- +// Child: isotope +// ----------------------------------------------------------------------------- + +// Has +int +ElementIsotopeHas(ConstHandle2ConstElement This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"IsotopeHas", This, extract::isotope); +} + +// Clear +void +ElementIsotopeClear(ConstHandle2Element This) +{ + detail::clearContainer + (CLASSNAME, CLASSNAME+"IsotopeClear", This, extract::isotope); +} + +// Size +size_t +ElementIsotopeSize(ConstHandle2ConstElement This) +{ + return detail::sizeOfContainer + (CLASSNAME, CLASSNAME+"IsotopeSize", This, extract::isotope); +} + +// Add +void +ElementIsotopeAdd(ConstHandle2Element This, ConstHandle2ConstIsotope isotope) +{ + detail::addToContainer + (CLASSNAME, CLASSNAME+"IsotopeAdd", This, extract::isotope, isotope); +} + +// Get, by index \in [0,size), const +Handle2ConstIsotope +ElementIsotopeGetConst(ConstHandle2ConstElement This, const size_t index_) +{ + return detail::getByIndex + (CLASSNAME, CLASSNAME+"IsotopeGetConst", This, extract::isotope, index_); +} + +// Get, by index \in [0,size), non-const +Handle2Isotope +ElementIsotopeGet(ConstHandle2Element This, const size_t index_) +{ + return detail::getByIndex + (CLASSNAME, CLASSNAME+"IsotopeGet", This, extract::isotope, index_); +} + +// Set, by index \in [0,size) +void +ElementIsotopeSet( + ConstHandle2Element This, + const size_t index_, + ConstHandle2ConstIsotope isotope +) { + detail::setByIndex + (CLASSNAME, CLASSNAME+"IsotopeSet", This, extract::isotope, index_, isotope); +} + +// Has, by mass_number +int +ElementIsotopeHasByMassNumber( + ConstHandle2ConstElement This, + const int mass_number +) { + return detail::hasByMetadatum + (CLASSNAME, CLASSNAME+"IsotopeHasByMassNumber", + This, extract::isotope, meta::mass_number, mass_number); +} + +// Get, by mass_number, const +Handle2ConstIsotope +ElementIsotopeGetByMassNumberConst( + ConstHandle2ConstElement This, + const int mass_number +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"IsotopeGetByMassNumberConst", + This, extract::isotope, meta::mass_number, mass_number); +} + +// Get, by mass_number, non-const +Handle2Isotope +ElementIsotopeGetByMassNumber( + ConstHandle2Element This, + const int mass_number +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"IsotopeGetByMassNumber", + This, extract::isotope, meta::mass_number, mass_number); +} + +// Set, by mass_number +void +ElementIsotopeSetByMassNumber( + ConstHandle2Element This, + const int mass_number, + ConstHandle2ConstIsotope isotope +) { + detail::setByMetadatum + (CLASSNAME, CLASSNAME+"IsotopeSetByMassNumber", + This, extract::isotope, meta::mass_number, mass_number, isotope); +} + + +// ----------------------------------------------------------------------------- +// Child: foobar +// ----------------------------------------------------------------------------- + +// Has +int +ElementFoobarHas(ConstHandle2ConstElement This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"FoobarHas", This, extract::foobar); +} + +// Get, const +Handle2ConstFoobar +ElementFoobarGetConst(ConstHandle2ConstElement This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"FoobarGetConst", This, extract::foobar); +} + +// Get, non-const +Handle2Foobar +ElementFoobarGet(ConstHandle2Element This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"FoobarGet", This, extract::foobar); +} + +// Set +void +ElementFoobarSet(ConstHandle2Element This, ConstHandle2ConstFoobar foobar) +{ + detail::setField + (CLASSNAME, CLASSNAME+"FoobarSet", This, extract::foobar, foobar); +} diff --git a/autogen/simple/multi/c/src/v1/multigroup/Element.h b/autogen/simple/multi/c/src/v1/multigroup/Element.h new file mode 100644 index 000000000..117db37d0 --- /dev/null +++ b/autogen/simple/multi/c/src/v1/multigroup/Element.h @@ -0,0 +1,268 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// Interface for C +// This header file is designed to work with both C and C++ +// Function definitions are in this file's .cpp source + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// Instructions for Users +// +// Constructs you're MORE likely to care about are preceded with: +// // +++ comment +// Constructs you're LESS likely to care about are preceded with: +// // --- comment +// Anything not marked as above can be ignored by most users. +// +// Element is the basic handle type in this file. Example: +// // Create a default Element object: +// Element handle = ElementDefault(); +// Functions involving Element are declared throughout this file. +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// Preliminaries +// ----------------------------------------------------------------------------- + +#ifndef C_INTERFACE_MULTI_V1_MULTIGROUP_ELEMENT +#define C_INTERFACE_MULTI_V1_MULTIGROUP_ELEMENT + +#include "GNDStk.h" +#include "v1/multigroup/Isotope.h" +#include "v1/multigroup/Foobar.h" + +#ifdef __cplusplus + #define extern_c extern "C" +#else + #define extern_c +#endif + +// Proxy C struct for the handled C++ class +struct ElementClass { }; + + +// ----------------------------------------------------------------------------- +// Handle types +// ----------------------------------------------------------------------------- + +// +++ Element +// +++ General handle, suitable for most users. If you're not concerned about +// +++ strict "const correctness" in your C code, you can probably use this in +// +++ place of any function parameter of a const-aware handle type. +typedef struct ElementClass *Element; + +// --- Const-aware handles. +typedef const struct ElementClass *const ConstHandle2ConstElement; +typedef struct ElementClass *const ConstHandle2Element; +typedef const struct ElementClass * Handle2ConstElement; +typedef struct ElementClass * Handle2Element; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// --- Create, default, const +extern_c Handle2ConstElement +ElementDefaultConst(); + +// +++ Create, default +extern_c Handle2Element +ElementDefault(); + +// --- Create, general, const +extern_c Handle2ConstElement +ElementCreateConst( + const char *const symbol, + const int atomic_number, + ConstHandle2Isotope *const isotope, const size_t isotopeSize, + ConstHandle2ConstFoobar foobar +); + +// +++ Create, general +extern_c Handle2Element +ElementCreate( + const char *const symbol, + const int atomic_number, + ConstHandle2Isotope *const isotope, const size_t isotopeSize, + ConstHandle2ConstFoobar foobar +); + +// +++ Assign +// +++ Use this to assign one handled object to another. Don't assign handles, +// +++ as with to = from. That has a meaning that you probably don't intend. +extern_c void +ElementAssign(ConstHandle2Element This, ConstHandle2ConstElement from); + +// +++ Delete +// +++ We'll attempt to remove no-longer-used objects automatically, but you +// +++ may improve performance if you delete them when you're done with them. +extern_c void +ElementDelete(ConstHandle2ConstElement This); + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// +++ Read from file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll examine the file's contents to determine its type automatically. +extern_c int +ElementRead(ConstHandle2Element This, const char *const filename); + +// +++ Write to file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll use filename's extension to determine the type you want written. +extern_c int +ElementWrite(ConstHandle2ConstElement This, const char *const filename); + +// +++ Print to standard output, in our prettyprinting format +extern_c int +ElementPrint(ConstHandle2ConstElement This); + +// +++ Print to standard output, as XML +extern_c int +ElementPrintXML(ConstHandle2ConstElement This); + +// +++ Print to standard output, as JSON +extern_c int +ElementPrintJSON(ConstHandle2ConstElement This); + + +// ----------------------------------------------------------------------------- +// Metadatum: symbol +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +ElementSymbolHas(ConstHandle2ConstElement This); + +// +++ Get +// +++ Returns by value +extern_c const char * +ElementSymbolGet(ConstHandle2ConstElement This); + +// +++ Set +extern_c void +ElementSymbolSet(ConstHandle2Element This, const char *const symbol); + + +// ----------------------------------------------------------------------------- +// Metadatum: atomic_number +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +ElementAtomicNumberHas(ConstHandle2ConstElement This); + +// +++ Get +// +++ Returns by value +extern_c int +ElementAtomicNumberGet(ConstHandle2ConstElement This); + +// +++ Set +extern_c void +ElementAtomicNumberSet(ConstHandle2Element This, const int atomic_number); + + +// ----------------------------------------------------------------------------- +// Child: isotope +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +ElementIsotopeHas(ConstHandle2ConstElement This); + +// +++ Clear +extern_c void +ElementIsotopeClear(ConstHandle2Element This); + +// +++ Size +extern_c size_t +ElementIsotopeSize(ConstHandle2ConstElement This); + +// +++ Add +extern_c void +ElementIsotopeAdd(ConstHandle2Element This, ConstHandle2ConstIsotope isotope); + +// --- Get, by index \in [0,size), const +extern_c Handle2ConstIsotope +ElementIsotopeGetConst(ConstHandle2ConstElement This, const size_t index_); + +// +++ Get, by index \in [0,size), non-const +extern_c Handle2Isotope +ElementIsotopeGet(ConstHandle2Element This, const size_t index_); + +// +++ Set, by index \in [0,size) +extern_c void +ElementIsotopeSet( + ConstHandle2Element This, + const size_t index_, + ConstHandle2ConstIsotope isotope +); + +// +++ Has, by mass_number +extern_c int +ElementIsotopeHasByMassNumber( + ConstHandle2ConstElement This, + const int mass_number +); + +// --- Get, by mass_number, const +extern_c Handle2ConstIsotope +ElementIsotopeGetByMassNumberConst( + ConstHandle2ConstElement This, + const int mass_number +); + +// +++ Get, by mass_number, non-const +extern_c Handle2Isotope +ElementIsotopeGetByMassNumber( + ConstHandle2Element This, + const int mass_number +); + +// +++ Set, by mass_number +extern_c void +ElementIsotopeSetByMassNumber( + ConstHandle2Element This, + const int mass_number, + ConstHandle2ConstIsotope isotope +); + + +// ----------------------------------------------------------------------------- +// Child: foobar +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +ElementFoobarHas(ConstHandle2ConstElement This); + +// --- Get, const +extern_c Handle2ConstFoobar +ElementFoobarGetConst(ConstHandle2ConstElement This); + +// +++ Get, non-const +extern_c Handle2Foobar +ElementFoobarGet(ConstHandle2Element This); + +// +++ Set +extern_c void +ElementFoobarSet(ConstHandle2Element This, ConstHandle2ConstFoobar foobar); + + +// ----------------------------------------------------------------------------- +// Done +// ----------------------------------------------------------------------------- + +#undef extern_c +#endif diff --git a/autogen/simple/multi/c/src/v1/multigroup/Foobar.cpp b/autogen/simple/multi/c/src/v1/multigroup/Foobar.cpp new file mode 100644 index 000000000..82eabc01d --- /dev/null +++ b/autogen/simple/multi/c/src/v1/multigroup/Foobar.cpp @@ -0,0 +1,228 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include "multi/v1/multigroup/Foobar.hpp" +#include "Foobar.h" + +using namespace njoy::GNDStk; +using namespace multi::v1; + +using C = FoobarClass; +using CPP = multigroup::Foobar; + +static const std::string CLASSNAME = "Foobar"; + +namespace extract { + static auto value = [](auto &obj) { return &obj.value; }; +} + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// Create, default, const +Handle2ConstFoobar +FoobarDefaultConst() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"DefaultConst"); +} + +// Create, default +Handle2Foobar +FoobarDefault() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"Default"); +} + +// Create, general, const +Handle2ConstFoobar +FoobarCreateConst( + const char *const value +) { + ConstHandle2Foobar handle = detail::createHandle( + CLASSNAME, CLASSNAME+"CreateConst", + value + ); + return handle; +} + +// Create, general +Handle2Foobar +FoobarCreate( + const char *const value +) { + ConstHandle2Foobar handle = detail::createHandle( + CLASSNAME, CLASSNAME+"Create", + value + ); + return handle; +} + +// Assign +// Use this to assign one handled object to another. Don't assign handles, +// as with to = from. That has a meaning that you probably don't intend. +void +FoobarAssign(ConstHandle2Foobar This, ConstHandle2ConstFoobar from) +{ + detail::assignHandle + (CLASSNAME, CLASSNAME+"Assign", This, from); +} + +// Delete +// We'll attempt to remove no-longer-used objects automatically, but you +// may improve performance if you delete them when you're done with them. +void +FoobarDelete(ConstHandle2ConstFoobar This) +{ + detail::deleteHandle + (CLASSNAME, CLASSNAME+"Delete", This); +} + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// Read from file +// File can be XML, JSON, or HDF5. +// We'll examine the file's contents to determine its type automatically. +int +FoobarRead(ConstHandle2Foobar This, const char *const filename) +{ + return detail::readHandle + (CLASSNAME, CLASSNAME+"Read", This, filename); +} + +// Write to file +// File can be XML, JSON, or HDF5. +// We'll use filename's extension to determine the type you want written. +int +FoobarWrite(ConstHandle2ConstFoobar This, const char *const filename) +{ + return detail::writeHandle + (CLASSNAME, CLASSNAME+"Write", This, filename); +} + +// Print to standard output, in our prettyprinting format +int +FoobarPrint(ConstHandle2ConstFoobar This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"Print", This); +} + +// Print to standard output, as XML +int +FoobarPrintXML(ConstHandle2ConstFoobar This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintXML", This, "XML"); +} + +// Print to standard output, as JSON +int +FoobarPrintJSON(ConstHandle2ConstFoobar This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintJSON", This, "JSON"); +} + + +// ----------------------------------------------------------------------------- +// Data vector +// ----------------------------------------------------------------------------- + +// Clear +void +FoobarDoublesClear(ConstHandle2Foobar This) +{ + detail::vectorClear + (CLASSNAME, CLASSNAME+"DoublesClear", This); +} + +// Get size +size_t +FoobarDoublesSize(ConstHandle2ConstFoobar This) +{ + return detail::vectorSize + (CLASSNAME, CLASSNAME+"DoublesSize", This); +} + +// Get value +// By index \in [0,size) +double +FoobarDoublesGet(ConstHandle2ConstFoobar This, const size_t index) +{ + return detail::vectorGet + (CLASSNAME, CLASSNAME+"DoublesGet", This, index); +} + +// Set value +// By index \in [0,size) +void +FoobarDoublesSet(ConstHandle2Foobar This, const size_t index, const double value) +{ + detail::vectorSet + (CLASSNAME, CLASSNAME+"DoublesSet", This, index, value); +} + +// Get pointer to existing values, const +const double * +FoobarDoublesGetArrayConst(ConstHandle2ConstFoobar This) +{ + return detail::vectorGet + (CLASSNAME, CLASSNAME+"DoublesGetArrayConst", This); +} + +// Get pointer to existing values, non-const +double * +FoobarDoublesGetArray(ConstHandle2Foobar This) +{ + return detail::vectorGet + (CLASSNAME, CLASSNAME+"DoublesGetArray", This); +} + +// Set completely new values and size +void +FoobarDoublesSetArray(ConstHandle2Foobar This, const double *const values, const size_t size) +{ + return detail::vectorSet + (CLASSNAME, CLASSNAME+"DoublesSetArray", This, size, values); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: value +// ----------------------------------------------------------------------------- + +// Has +int +FoobarValueHas(ConstHandle2ConstFoobar This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"ValueHas", This, extract::value); +} + +// Get +// Returns by value +const char * +FoobarValueGet(ConstHandle2ConstFoobar This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"ValueGet", This, extract::value); +} + +// Set +void +FoobarValueSet(ConstHandle2Foobar This, const char *const value) +{ + detail::setField + (CLASSNAME, CLASSNAME+"ValueSet", This, extract::value, value); +} diff --git a/autogen/simple/multi/c/src/v1/multigroup/Foobar.h b/autogen/simple/multi/c/src/v1/multigroup/Foobar.h new file mode 100644 index 000000000..055a0adae --- /dev/null +++ b/autogen/simple/multi/c/src/v1/multigroup/Foobar.h @@ -0,0 +1,190 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// Interface for C +// This header file is designed to work with both C and C++ +// Function definitions are in this file's .cpp source + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// Instructions for Users +// +// Constructs you're MORE likely to care about are preceded with: +// // +++ comment +// Constructs you're LESS likely to care about are preceded with: +// // --- comment +// Anything not marked as above can be ignored by most users. +// +// Foobar is the basic handle type in this file. Example: +// // Create a default Foobar object: +// Foobar handle = FoobarDefault(); +// Functions involving Foobar are declared throughout this file. +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// Preliminaries +// ----------------------------------------------------------------------------- + +#ifndef C_INTERFACE_MULTI_V1_MULTIGROUP_FOOBAR +#define C_INTERFACE_MULTI_V1_MULTIGROUP_FOOBAR + +#include "GNDStk.h" + +#ifdef __cplusplus + #define extern_c extern "C" +#else + #define extern_c +#endif + +// Proxy C struct for the handled C++ class +struct FoobarClass { }; + + +// ----------------------------------------------------------------------------- +// Handle types +// ----------------------------------------------------------------------------- + +// +++ Foobar +// +++ General handle, suitable for most users. If you're not concerned about +// +++ strict "const correctness" in your C code, you can probably use this in +// +++ place of any function parameter of a const-aware handle type. +typedef struct FoobarClass *Foobar; + +// --- Const-aware handles. +typedef const struct FoobarClass *const ConstHandle2ConstFoobar; +typedef struct FoobarClass *const ConstHandle2Foobar; +typedef const struct FoobarClass * Handle2ConstFoobar; +typedef struct FoobarClass * Handle2Foobar; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// --- Create, default, const +extern_c Handle2ConstFoobar +FoobarDefaultConst(); + +// +++ Create, default +extern_c Handle2Foobar +FoobarDefault(); + +// --- Create, general, const +extern_c Handle2ConstFoobar +FoobarCreateConst( + const char *const value +); + +// +++ Create, general +extern_c Handle2Foobar +FoobarCreate( + const char *const value +); + +// +++ Assign +// +++ Use this to assign one handled object to another. Don't assign handles, +// +++ as with to = from. That has a meaning that you probably don't intend. +extern_c void +FoobarAssign(ConstHandle2Foobar This, ConstHandle2ConstFoobar from); + +// +++ Delete +// +++ We'll attempt to remove no-longer-used objects automatically, but you +// +++ may improve performance if you delete them when you're done with them. +extern_c void +FoobarDelete(ConstHandle2ConstFoobar This); + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// +++ Read from file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll examine the file's contents to determine its type automatically. +extern_c int +FoobarRead(ConstHandle2Foobar This, const char *const filename); + +// +++ Write to file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll use filename's extension to determine the type you want written. +extern_c int +FoobarWrite(ConstHandle2ConstFoobar This, const char *const filename); + +// +++ Print to standard output, in our prettyprinting format +extern_c int +FoobarPrint(ConstHandle2ConstFoobar This); + +// +++ Print to standard output, as XML +extern_c int +FoobarPrintXML(ConstHandle2ConstFoobar This); + +// +++ Print to standard output, as JSON +extern_c int +FoobarPrintJSON(ConstHandle2ConstFoobar This); + + +// ----------------------------------------------------------------------------- +// Data vector +// ----------------------------------------------------------------------------- + +// +++ Clear +extern_c void +FoobarDoublesClear(ConstHandle2Foobar This); + +// +++ Get size +extern_c size_t +FoobarDoublesSize(ConstHandle2ConstFoobar This); + +// +++ Get value +// +++ By index \in [0,size) +extern_c double +FoobarDoublesGet(ConstHandle2ConstFoobar This, const size_t index); + +// +++ Set value +// +++ By index \in [0,size) +extern_c void +FoobarDoublesSet(ConstHandle2Foobar This, const size_t index, const double value); + +// --- Get pointer to existing values, const +extern_c const double * +FoobarDoublesGetArrayConst(ConstHandle2ConstFoobar This); + +// +++ Get pointer to existing values, non-const +extern_c double * +FoobarDoublesGetArray(ConstHandle2Foobar This); + +// +++ Set completely new values and size +extern_c void +FoobarDoublesSetArray(ConstHandle2Foobar This, const double *const values, const size_t size); + + +// ----------------------------------------------------------------------------- +// Metadatum: value +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +FoobarValueHas(ConstHandle2ConstFoobar This); + +// +++ Get +// +++ Returns by value +extern_c const char * +FoobarValueGet(ConstHandle2ConstFoobar This); + +// +++ Set +extern_c void +FoobarValueSet(ConstHandle2Foobar This, const char *const value); + + +// ----------------------------------------------------------------------------- +// Done +// ----------------------------------------------------------------------------- + +#undef extern_c +#endif diff --git a/autogen/simple/multi/c/src/v1/multigroup/Isotope.cpp b/autogen/simple/multi/c/src/v1/multigroup/Isotope.cpp new file mode 100644 index 000000000..70087fbe9 --- /dev/null +++ b/autogen/simple/multi/c/src/v1/multigroup/Isotope.cpp @@ -0,0 +1,165 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include "multi/v1/multigroup/Isotope.hpp" +#include "Isotope.h" + +using namespace njoy::GNDStk; +using namespace multi::v1; + +using C = IsotopeClass; +using CPP = multigroup::Isotope; + +static const std::string CLASSNAME = "Isotope"; + +namespace extract { + static auto mass_number = [](auto &obj) { return &obj.mass_number; }; +} + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// Create, default, const +Handle2ConstIsotope +IsotopeDefaultConst() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"DefaultConst"); +} + +// Create, default +Handle2Isotope +IsotopeDefault() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"Default"); +} + +// Create, general, const +Handle2ConstIsotope +IsotopeCreateConst( + const int mass_number +) { + ConstHandle2Isotope handle = detail::createHandle( + CLASSNAME, CLASSNAME+"CreateConst", + mass_number + ); + return handle; +} + +// Create, general +Handle2Isotope +IsotopeCreate( + const int mass_number +) { + ConstHandle2Isotope handle = detail::createHandle( + CLASSNAME, CLASSNAME+"Create", + mass_number + ); + return handle; +} + +// Assign +// Use this to assign one handled object to another. Don't assign handles, +// as with to = from. That has a meaning that you probably don't intend. +void +IsotopeAssign(ConstHandle2Isotope This, ConstHandle2ConstIsotope from) +{ + detail::assignHandle + (CLASSNAME, CLASSNAME+"Assign", This, from); +} + +// Delete +// We'll attempt to remove no-longer-used objects automatically, but you +// may improve performance if you delete them when you're done with them. +void +IsotopeDelete(ConstHandle2ConstIsotope This) +{ + detail::deleteHandle + (CLASSNAME, CLASSNAME+"Delete", This); +} + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// Read from file +// File can be XML, JSON, or HDF5. +// We'll examine the file's contents to determine its type automatically. +int +IsotopeRead(ConstHandle2Isotope This, const char *const filename) +{ + return detail::readHandle + (CLASSNAME, CLASSNAME+"Read", This, filename); +} + +// Write to file +// File can be XML, JSON, or HDF5. +// We'll use filename's extension to determine the type you want written. +int +IsotopeWrite(ConstHandle2ConstIsotope This, const char *const filename) +{ + return detail::writeHandle + (CLASSNAME, CLASSNAME+"Write", This, filename); +} + +// Print to standard output, in our prettyprinting format +int +IsotopePrint(ConstHandle2ConstIsotope This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"Print", This); +} + +// Print to standard output, as XML +int +IsotopePrintXML(ConstHandle2ConstIsotope This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintXML", This, "XML"); +} + +// Print to standard output, as JSON +int +IsotopePrintJSON(ConstHandle2ConstIsotope This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintJSON", This, "JSON"); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: mass_number +// ----------------------------------------------------------------------------- + +// Has +int +IsotopeMassNumberHas(ConstHandle2ConstIsotope This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"MassNumberHas", This, extract::mass_number); +} + +// Get +// Returns by value +int +IsotopeMassNumberGet(ConstHandle2ConstIsotope This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"MassNumberGet", This, extract::mass_number); +} + +// Set +void +IsotopeMassNumberSet(ConstHandle2Isotope This, const int mass_number) +{ + detail::setField + (CLASSNAME, CLASSNAME+"MassNumberSet", This, extract::mass_number, mass_number); +} diff --git a/autogen/simple/multi/c/src/v1/multigroup/Isotope.h b/autogen/simple/multi/c/src/v1/multigroup/Isotope.h new file mode 100644 index 000000000..a2e88aebd --- /dev/null +++ b/autogen/simple/multi/c/src/v1/multigroup/Isotope.h @@ -0,0 +1,155 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// Interface for C +// This header file is designed to work with both C and C++ +// Function definitions are in this file's .cpp source + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// Instructions for Users +// +// Constructs you're MORE likely to care about are preceded with: +// // +++ comment +// Constructs you're LESS likely to care about are preceded with: +// // --- comment +// Anything not marked as above can be ignored by most users. +// +// Isotope is the basic handle type in this file. Example: +// // Create a default Isotope object: +// Isotope handle = IsotopeDefault(); +// Functions involving Isotope are declared throughout this file. +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// Preliminaries +// ----------------------------------------------------------------------------- + +#ifndef C_INTERFACE_MULTI_V1_MULTIGROUP_ISOTOPE +#define C_INTERFACE_MULTI_V1_MULTIGROUP_ISOTOPE + +#include "GNDStk.h" + +#ifdef __cplusplus + #define extern_c extern "C" +#else + #define extern_c +#endif + +// Proxy C struct for the handled C++ class +struct IsotopeClass { }; + + +// ----------------------------------------------------------------------------- +// Handle types +// ----------------------------------------------------------------------------- + +// +++ Isotope +// +++ General handle, suitable for most users. If you're not concerned about +// +++ strict "const correctness" in your C code, you can probably use this in +// +++ place of any function parameter of a const-aware handle type. +typedef struct IsotopeClass *Isotope; + +// --- Const-aware handles. +typedef const struct IsotopeClass *const ConstHandle2ConstIsotope; +typedef struct IsotopeClass *const ConstHandle2Isotope; +typedef const struct IsotopeClass * Handle2ConstIsotope; +typedef struct IsotopeClass * Handle2Isotope; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// --- Create, default, const +extern_c Handle2ConstIsotope +IsotopeDefaultConst(); + +// +++ Create, default +extern_c Handle2Isotope +IsotopeDefault(); + +// --- Create, general, const +extern_c Handle2ConstIsotope +IsotopeCreateConst( + const int mass_number +); + +// +++ Create, general +extern_c Handle2Isotope +IsotopeCreate( + const int mass_number +); + +// +++ Assign +// +++ Use this to assign one handled object to another. Don't assign handles, +// +++ as with to = from. That has a meaning that you probably don't intend. +extern_c void +IsotopeAssign(ConstHandle2Isotope This, ConstHandle2ConstIsotope from); + +// +++ Delete +// +++ We'll attempt to remove no-longer-used objects automatically, but you +// +++ may improve performance if you delete them when you're done with them. +extern_c void +IsotopeDelete(ConstHandle2ConstIsotope This); + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// +++ Read from file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll examine the file's contents to determine its type automatically. +extern_c int +IsotopeRead(ConstHandle2Isotope This, const char *const filename); + +// +++ Write to file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll use filename's extension to determine the type you want written. +extern_c int +IsotopeWrite(ConstHandle2ConstIsotope This, const char *const filename); + +// +++ Print to standard output, in our prettyprinting format +extern_c int +IsotopePrint(ConstHandle2ConstIsotope This); + +// +++ Print to standard output, as XML +extern_c int +IsotopePrintXML(ConstHandle2ConstIsotope This); + +// +++ Print to standard output, as JSON +extern_c int +IsotopePrintJSON(ConstHandle2ConstIsotope This); + + +// ----------------------------------------------------------------------------- +// Metadatum: mass_number +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +IsotopeMassNumberHas(ConstHandle2ConstIsotope This); + +// +++ Get +// +++ Returns by value +extern_c int +IsotopeMassNumberGet(ConstHandle2ConstIsotope This); + +// +++ Set +extern_c void +IsotopeMassNumberSet(ConstHandle2Isotope This, const int mass_number); + + +// ----------------------------------------------------------------------------- +// Done +// ----------------------------------------------------------------------------- + +#undef extern_c +#endif diff --git a/autogen/simple/multi/c/src/v1/multigroup/Library.cpp b/autogen/simple/multi/c/src/v1/multigroup/Library.cpp new file mode 100644 index 000000000..494a4ce09 --- /dev/null +++ b/autogen/simple/multi/c/src/v1/multigroup/Library.cpp @@ -0,0 +1,330 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include "multi/v1/multigroup/Library.hpp" +#include "Library.h" + +using namespace njoy::GNDStk; +using namespace multi::v1; + +using C = LibraryClass; +using CPP = multigroup::Library; + +static const std::string CLASSNAME = "Library"; + +namespace extract { + static auto name = [](auto &obj) { return &obj.name; }; + static auto element = [](auto &obj) { return &obj.element; }; +} + +using CPPElement = multigroup::Element; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// Create, default, const +Handle2ConstLibrary +LibraryDefaultConst() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"DefaultConst"); +} + +// Create, default +Handle2Library +LibraryDefault() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"Default"); +} + +// Create, general, const +Handle2ConstLibrary +LibraryCreateConst( + const char *const name, + ConstHandle2Element *const element, const size_t elementSize +) { + ConstHandle2Library handle = detail::createHandle( + CLASSNAME, CLASSNAME+"CreateConst", + name, + std::vector{} + ); + for (size_t ElementN = 0; ElementN < elementSize; ++ElementN) + LibraryElementAdd(handle, element[ElementN]); + return handle; +} + +// Create, general +Handle2Library +LibraryCreate( + const char *const name, + ConstHandle2Element *const element, const size_t elementSize +) { + ConstHandle2Library handle = detail::createHandle( + CLASSNAME, CLASSNAME+"Create", + name, + std::vector{} + ); + for (size_t ElementN = 0; ElementN < elementSize; ++ElementN) + LibraryElementAdd(handle, element[ElementN]); + return handle; +} + +// Assign +// Use this to assign one handled object to another. Don't assign handles, +// as with to = from. That has a meaning that you probably don't intend. +void +LibraryAssign(ConstHandle2Library This, ConstHandle2ConstLibrary from) +{ + detail::assignHandle + (CLASSNAME, CLASSNAME+"Assign", This, from); +} + +// Delete +// We'll attempt to remove no-longer-used objects automatically, but you +// may improve performance if you delete them when you're done with them. +void +LibraryDelete(ConstHandle2ConstLibrary This) +{ + detail::deleteHandle + (CLASSNAME, CLASSNAME+"Delete", This); +} + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// Read from file +// File can be XML, JSON, or HDF5. +// We'll examine the file's contents to determine its type automatically. +int +LibraryRead(ConstHandle2Library This, const char *const filename) +{ + return detail::readHandle + (CLASSNAME, CLASSNAME+"Read", This, filename); +} + +// Write to file +// File can be XML, JSON, or HDF5. +// We'll use filename's extension to determine the type you want written. +int +LibraryWrite(ConstHandle2ConstLibrary This, const char *const filename) +{ + return detail::writeHandle + (CLASSNAME, CLASSNAME+"Write", This, filename); +} + +// Print to standard output, in our prettyprinting format +int +LibraryPrint(ConstHandle2ConstLibrary This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"Print", This); +} + +// Print to standard output, as XML +int +LibraryPrintXML(ConstHandle2ConstLibrary This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintXML", This, "XML"); +} + +// Print to standard output, as JSON +int +LibraryPrintJSON(ConstHandle2ConstLibrary This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintJSON", This, "JSON"); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: name +// ----------------------------------------------------------------------------- + +// Has +int +LibraryNameHas(ConstHandle2ConstLibrary This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"NameHas", This, extract::name); +} + +// Get +// Returns by value +const char * +LibraryNameGet(ConstHandle2ConstLibrary This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"NameGet", This, extract::name); +} + +// Set +void +LibraryNameSet(ConstHandle2Library This, const char *const name) +{ + detail::setField + (CLASSNAME, CLASSNAME+"NameSet", This, extract::name, name); +} + + +// ----------------------------------------------------------------------------- +// Child: element +// ----------------------------------------------------------------------------- + +// Has +int +LibraryElementHas(ConstHandle2ConstLibrary This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"ElementHas", This, extract::element); +} + +// Clear +void +LibraryElementClear(ConstHandle2Library This) +{ + detail::clearContainer + (CLASSNAME, CLASSNAME+"ElementClear", This, extract::element); +} + +// Size +size_t +LibraryElementSize(ConstHandle2ConstLibrary This) +{ + return detail::sizeOfContainer + (CLASSNAME, CLASSNAME+"ElementSize", This, extract::element); +} + +// Add +void +LibraryElementAdd(ConstHandle2Library This, ConstHandle2ConstElement element) +{ + detail::addToContainer + (CLASSNAME, CLASSNAME+"ElementAdd", This, extract::element, element); +} + +// Get, by index \in [0,size), const +Handle2ConstElement +LibraryElementGetConst(ConstHandle2ConstLibrary This, const size_t index_) +{ + return detail::getByIndex + (CLASSNAME, CLASSNAME+"ElementGetConst", This, extract::element, index_); +} + +// Get, by index \in [0,size), non-const +Handle2Element +LibraryElementGet(ConstHandle2Library This, const size_t index_) +{ + return detail::getByIndex + (CLASSNAME, CLASSNAME+"ElementGet", This, extract::element, index_); +} + +// Set, by index \in [0,size) +void +LibraryElementSet( + ConstHandle2Library This, + const size_t index_, + ConstHandle2ConstElement element +) { + detail::setByIndex + (CLASSNAME, CLASSNAME+"ElementSet", This, extract::element, index_, element); +} + +// Has, by symbol +int +LibraryElementHasBySymbol( + ConstHandle2ConstLibrary This, + const char *const symbol +) { + return detail::hasByMetadatum + (CLASSNAME, CLASSNAME+"ElementHasBySymbol", + This, extract::element, meta::symbol, symbol); +} + +// Get, by symbol, const +Handle2ConstElement +LibraryElementGetBySymbolConst( + ConstHandle2ConstLibrary This, + const char *const symbol +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"ElementGetBySymbolConst", + This, extract::element, meta::symbol, symbol); +} + +// Get, by symbol, non-const +Handle2Element +LibraryElementGetBySymbol( + ConstHandle2Library This, + const char *const symbol +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"ElementGetBySymbol", + This, extract::element, meta::symbol, symbol); +} + +// Set, by symbol +void +LibraryElementSetBySymbol( + ConstHandle2Library This, + const char *const symbol, + ConstHandle2ConstElement element +) { + detail::setByMetadatum + (CLASSNAME, CLASSNAME+"ElementSetBySymbol", + This, extract::element, meta::symbol, symbol, element); +} + +// Has, by atomic_number +int +LibraryElementHasByAtomicNumber( + ConstHandle2ConstLibrary This, + const int atomic_number +) { + return detail::hasByMetadatum + (CLASSNAME, CLASSNAME+"ElementHasByAtomicNumber", + This, extract::element, meta::atomic_number, atomic_number); +} + +// Get, by atomic_number, const +Handle2ConstElement +LibraryElementGetByAtomicNumberConst( + ConstHandle2ConstLibrary This, + const int atomic_number +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"ElementGetByAtomicNumberConst", + This, extract::element, meta::atomic_number, atomic_number); +} + +// Get, by atomic_number, non-const +Handle2Element +LibraryElementGetByAtomicNumber( + ConstHandle2Library This, + const int atomic_number +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"ElementGetByAtomicNumber", + This, extract::element, meta::atomic_number, atomic_number); +} + +// Set, by atomic_number +void +LibraryElementSetByAtomicNumber( + ConstHandle2Library This, + const int atomic_number, + ConstHandle2ConstElement element +) { + detail::setByMetadatum + (CLASSNAME, CLASSNAME+"ElementSetByAtomicNumber", + This, extract::element, meta::atomic_number, atomic_number, element); +} diff --git a/autogen/simple/multi/c/src/v1/multigroup/Library.h b/autogen/simple/multi/c/src/v1/multigroup/Library.h new file mode 100644 index 000000000..f1171929f --- /dev/null +++ b/autogen/simple/multi/c/src/v1/multigroup/Library.h @@ -0,0 +1,253 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// Interface for C +// This header file is designed to work with both C and C++ +// Function definitions are in this file's .cpp source + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// Instructions for Users +// +// Constructs you're MORE likely to care about are preceded with: +// // +++ comment +// Constructs you're LESS likely to care about are preceded with: +// // --- comment +// Anything not marked as above can be ignored by most users. +// +// Library is the basic handle type in this file. Example: +// // Create a default Library object: +// Library handle = LibraryDefault(); +// Functions involving Library are declared throughout this file. +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// Preliminaries +// ----------------------------------------------------------------------------- + +#ifndef C_INTERFACE_MULTI_V1_MULTIGROUP_LIBRARY +#define C_INTERFACE_MULTI_V1_MULTIGROUP_LIBRARY + +#include "GNDStk.h" +#include "v1/multigroup/Element.h" + +#ifdef __cplusplus + #define extern_c extern "C" +#else + #define extern_c +#endif + +// Proxy C struct for the handled C++ class +struct LibraryClass { }; + + +// ----------------------------------------------------------------------------- +// Handle types +// ----------------------------------------------------------------------------- + +// +++ Library +// +++ General handle, suitable for most users. If you're not concerned about +// +++ strict "const correctness" in your C code, you can probably use this in +// +++ place of any function parameter of a const-aware handle type. +typedef struct LibraryClass *Library; + +// --- Const-aware handles. +typedef const struct LibraryClass *const ConstHandle2ConstLibrary; +typedef struct LibraryClass *const ConstHandle2Library; +typedef const struct LibraryClass * Handle2ConstLibrary; +typedef struct LibraryClass * Handle2Library; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// --- Create, default, const +extern_c Handle2ConstLibrary +LibraryDefaultConst(); + +// +++ Create, default +extern_c Handle2Library +LibraryDefault(); + +// --- Create, general, const +extern_c Handle2ConstLibrary +LibraryCreateConst( + const char *const name, + ConstHandle2Element *const element, const size_t elementSize +); + +// +++ Create, general +extern_c Handle2Library +LibraryCreate( + const char *const name, + ConstHandle2Element *const element, const size_t elementSize +); + +// +++ Assign +// +++ Use this to assign one handled object to another. Don't assign handles, +// +++ as with to = from. That has a meaning that you probably don't intend. +extern_c void +LibraryAssign(ConstHandle2Library This, ConstHandle2ConstLibrary from); + +// +++ Delete +// +++ We'll attempt to remove no-longer-used objects automatically, but you +// +++ may improve performance if you delete them when you're done with them. +extern_c void +LibraryDelete(ConstHandle2ConstLibrary This); + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// +++ Read from file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll examine the file's contents to determine its type automatically. +extern_c int +LibraryRead(ConstHandle2Library This, const char *const filename); + +// +++ Write to file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll use filename's extension to determine the type you want written. +extern_c int +LibraryWrite(ConstHandle2ConstLibrary This, const char *const filename); + +// +++ Print to standard output, in our prettyprinting format +extern_c int +LibraryPrint(ConstHandle2ConstLibrary This); + +// +++ Print to standard output, as XML +extern_c int +LibraryPrintXML(ConstHandle2ConstLibrary This); + +// +++ Print to standard output, as JSON +extern_c int +LibraryPrintJSON(ConstHandle2ConstLibrary This); + + +// ----------------------------------------------------------------------------- +// Metadatum: name +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +LibraryNameHas(ConstHandle2ConstLibrary This); + +// +++ Get +// +++ Returns by value +extern_c const char * +LibraryNameGet(ConstHandle2ConstLibrary This); + +// +++ Set +extern_c void +LibraryNameSet(ConstHandle2Library This, const char *const name); + + +// ----------------------------------------------------------------------------- +// Child: element +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +LibraryElementHas(ConstHandle2ConstLibrary This); + +// +++ Clear +extern_c void +LibraryElementClear(ConstHandle2Library This); + +// +++ Size +extern_c size_t +LibraryElementSize(ConstHandle2ConstLibrary This); + +// +++ Add +extern_c void +LibraryElementAdd(ConstHandle2Library This, ConstHandle2ConstElement element); + +// --- Get, by index \in [0,size), const +extern_c Handle2ConstElement +LibraryElementGetConst(ConstHandle2ConstLibrary This, const size_t index_); + +// +++ Get, by index \in [0,size), non-const +extern_c Handle2Element +LibraryElementGet(ConstHandle2Library This, const size_t index_); + +// +++ Set, by index \in [0,size) +extern_c void +LibraryElementSet( + ConstHandle2Library This, + const size_t index_, + ConstHandle2ConstElement element +); + +// +++ Has, by symbol +extern_c int +LibraryElementHasBySymbol( + ConstHandle2ConstLibrary This, + const char *const symbol +); + +// --- Get, by symbol, const +extern_c Handle2ConstElement +LibraryElementGetBySymbolConst( + ConstHandle2ConstLibrary This, + const char *const symbol +); + +// +++ Get, by symbol, non-const +extern_c Handle2Element +LibraryElementGetBySymbol( + ConstHandle2Library This, + const char *const symbol +); + +// +++ Set, by symbol +extern_c void +LibraryElementSetBySymbol( + ConstHandle2Library This, + const char *const symbol, + ConstHandle2ConstElement element +); + +// +++ Has, by atomic_number +extern_c int +LibraryElementHasByAtomicNumber( + ConstHandle2ConstLibrary This, + const int atomic_number +); + +// --- Get, by atomic_number, const +extern_c Handle2ConstElement +LibraryElementGetByAtomicNumberConst( + ConstHandle2ConstLibrary This, + const int atomic_number +); + +// +++ Get, by atomic_number, non-const +extern_c Handle2Element +LibraryElementGetByAtomicNumber( + ConstHandle2Library This, + const int atomic_number +); + +// +++ Set, by atomic_number +extern_c void +LibraryElementSetByAtomicNumber( + ConstHandle2Library This, + const int atomic_number, + ConstHandle2ConstElement element +); + + +// ----------------------------------------------------------------------------- +// Done +// ----------------------------------------------------------------------------- + +#undef extern_c +#endif diff --git a/autogen/simple/multi/c/src/v1/multigroup/Multigroup.cpp b/autogen/simple/multi/c/src/v1/multigroup/Multigroup.cpp new file mode 100644 index 000000000..c34ccd936 --- /dev/null +++ b/autogen/simple/multi/c/src/v1/multigroup/Multigroup.cpp @@ -0,0 +1,285 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include "multi/v1/multigroup/Multigroup.hpp" +#include "Multigroup.h" + +using namespace njoy::GNDStk; +using namespace multi::v1; + +using C = MultigroupClass; +using CPP = multigroup::Multigroup; + +static const std::string CLASSNAME = "Multigroup"; + +namespace extract { + static auto projectile = [](auto &obj) { return &obj.projectile; }; + static auto library = [](auto &obj) { return &obj.library; }; +} + +using CPPLibrary = multigroup::Library; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// Create, default, const +Handle2ConstMultigroup +MultigroupDefaultConst() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"DefaultConst"); +} + +// Create, default +Handle2Multigroup +MultigroupDefault() +{ + return detail::createHandle + (CLASSNAME, CLASSNAME+"Default"); +} + +// Create, general, const +Handle2ConstMultigroup +MultigroupCreateConst( + const char *const projectile, + ConstHandle2Library *const library, const size_t librarySize +) { + ConstHandle2Multigroup handle = detail::createHandle( + CLASSNAME, CLASSNAME+"CreateConst", + projectile, + std::vector{} + ); + for (size_t LibraryN = 0; LibraryN < librarySize; ++LibraryN) + MultigroupLibraryAdd(handle, library[LibraryN]); + return handle; +} + +// Create, general +Handle2Multigroup +MultigroupCreate( + const char *const projectile, + ConstHandle2Library *const library, const size_t librarySize +) { + ConstHandle2Multigroup handle = detail::createHandle( + CLASSNAME, CLASSNAME+"Create", + projectile, + std::vector{} + ); + for (size_t LibraryN = 0; LibraryN < librarySize; ++LibraryN) + MultigroupLibraryAdd(handle, library[LibraryN]); + return handle; +} + +// Assign +// Use this to assign one handled object to another. Don't assign handles, +// as with to = from. That has a meaning that you probably don't intend. +void +MultigroupAssign(ConstHandle2Multigroup This, ConstHandle2ConstMultigroup from) +{ + detail::assignHandle + (CLASSNAME, CLASSNAME+"Assign", This, from); +} + +// Delete +// We'll attempt to remove no-longer-used objects automatically, but you +// may improve performance if you delete them when you're done with them. +void +MultigroupDelete(ConstHandle2ConstMultigroup This) +{ + detail::deleteHandle + (CLASSNAME, CLASSNAME+"Delete", This); +} + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// Read from file +// File can be XML, JSON, or HDF5. +// We'll examine the file's contents to determine its type automatically. +int +MultigroupRead(ConstHandle2Multigroup This, const char *const filename) +{ + return detail::readHandle + (CLASSNAME, CLASSNAME+"Read", This, filename); +} + +// Write to file +// File can be XML, JSON, or HDF5. +// We'll use filename's extension to determine the type you want written. +int +MultigroupWrite(ConstHandle2ConstMultigroup This, const char *const filename) +{ + return detail::writeHandle + (CLASSNAME, CLASSNAME+"Write", This, filename); +} + +// Print to standard output, in our prettyprinting format +int +MultigroupPrint(ConstHandle2ConstMultigroup This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"Print", This); +} + +// Print to standard output, as XML +int +MultigroupPrintXML(ConstHandle2ConstMultigroup This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintXML", This, "XML"); +} + +// Print to standard output, as JSON +int +MultigroupPrintJSON(ConstHandle2ConstMultigroup This) +{ + return detail::printHandle + (CLASSNAME, CLASSNAME+"PrintJSON", This, "JSON"); +} + + +// ----------------------------------------------------------------------------- +// Metadatum: projectile +// ----------------------------------------------------------------------------- + +// Has +int +MultigroupProjectileHas(ConstHandle2ConstMultigroup This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"ProjectileHas", This, extract::projectile); +} + +// Get +// Returns by value +const char * +MultigroupProjectileGet(ConstHandle2ConstMultigroup This) +{ + return detail::getField + (CLASSNAME, CLASSNAME+"ProjectileGet", This, extract::projectile); +} + +// Set +void +MultigroupProjectileSet(ConstHandle2Multigroup This, const char *const projectile) +{ + detail::setField + (CLASSNAME, CLASSNAME+"ProjectileSet", This, extract::projectile, projectile); +} + + +// ----------------------------------------------------------------------------- +// Child: library +// ----------------------------------------------------------------------------- + +// Has +int +MultigroupLibraryHas(ConstHandle2ConstMultigroup This) +{ + return detail::hasField + (CLASSNAME, CLASSNAME+"LibraryHas", This, extract::library); +} + +// Clear +void +MultigroupLibraryClear(ConstHandle2Multigroup This) +{ + detail::clearContainer + (CLASSNAME, CLASSNAME+"LibraryClear", This, extract::library); +} + +// Size +size_t +MultigroupLibrarySize(ConstHandle2ConstMultigroup This) +{ + return detail::sizeOfContainer + (CLASSNAME, CLASSNAME+"LibrarySize", This, extract::library); +} + +// Add +void +MultigroupLibraryAdd(ConstHandle2Multigroup This, ConstHandle2ConstLibrary library) +{ + detail::addToContainer + (CLASSNAME, CLASSNAME+"LibraryAdd", This, extract::library, library); +} + +// Get, by index \in [0,size), const +Handle2ConstLibrary +MultigroupLibraryGetConst(ConstHandle2ConstMultigroup This, const size_t index_) +{ + return detail::getByIndex + (CLASSNAME, CLASSNAME+"LibraryGetConst", This, extract::library, index_); +} + +// Get, by index \in [0,size), non-const +Handle2Library +MultigroupLibraryGet(ConstHandle2Multigroup This, const size_t index_) +{ + return detail::getByIndex + (CLASSNAME, CLASSNAME+"LibraryGet", This, extract::library, index_); +} + +// Set, by index \in [0,size) +void +MultigroupLibrarySet( + ConstHandle2Multigroup This, + const size_t index_, + ConstHandle2ConstLibrary library +) { + detail::setByIndex + (CLASSNAME, CLASSNAME+"LibrarySet", This, extract::library, index_, library); +} + +// Has, by name +int +MultigroupLibraryHasByName( + ConstHandle2ConstMultigroup This, + const char *const name +) { + return detail::hasByMetadatum + (CLASSNAME, CLASSNAME+"LibraryHasByName", + This, extract::library, meta::name, name); +} + +// Get, by name, const +Handle2ConstLibrary +MultigroupLibraryGetByNameConst( + ConstHandle2ConstMultigroup This, + const char *const name +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"LibraryGetByNameConst", + This, extract::library, meta::name, name); +} + +// Get, by name, non-const +Handle2Library +MultigroupLibraryGetByName( + ConstHandle2Multigroup This, + const char *const name +) { + return detail::getByMetadatum + (CLASSNAME, CLASSNAME+"LibraryGetByName", + This, extract::library, meta::name, name); +} + +// Set, by name +void +MultigroupLibrarySetByName( + ConstHandle2Multigroup This, + const char *const name, + ConstHandle2ConstLibrary library +) { + detail::setByMetadatum + (CLASSNAME, CLASSNAME+"LibrarySetByName", + This, extract::library, meta::name, name, library); +} diff --git a/autogen/simple/multi/c/src/v1/multigroup/Multigroup.h b/autogen/simple/multi/c/src/v1/multigroup/Multigroup.h new file mode 100644 index 000000000..0057d43fb --- /dev/null +++ b/autogen/simple/multi/c/src/v1/multigroup/Multigroup.h @@ -0,0 +1,224 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// Interface for C +// This header file is designed to work with both C and C++ +// Function definitions are in this file's .cpp source + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// Instructions for Users +// +// Constructs you're MORE likely to care about are preceded with: +// // +++ comment +// Constructs you're LESS likely to care about are preceded with: +// // --- comment +// Anything not marked as above can be ignored by most users. +// +// Multigroup is the basic handle type in this file. Example: +// // Create a default Multigroup object: +// Multigroup handle = MultigroupDefault(); +// Functions involving Multigroup are declared throughout this file. +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// Preliminaries +// ----------------------------------------------------------------------------- + +#ifndef C_INTERFACE_MULTI_V1_MULTIGROUP_MULTIGROUP +#define C_INTERFACE_MULTI_V1_MULTIGROUP_MULTIGROUP + +#include "GNDStk.h" +#include "v1/multigroup/Library.h" + +#ifdef __cplusplus + #define extern_c extern "C" +#else + #define extern_c +#endif + +// Proxy C struct for the handled C++ class +struct MultigroupClass { }; + + +// ----------------------------------------------------------------------------- +// Handle types +// ----------------------------------------------------------------------------- + +// +++ Multigroup +// +++ General handle, suitable for most users. If you're not concerned about +// +++ strict "const correctness" in your C code, you can probably use this in +// +++ place of any function parameter of a const-aware handle type. +typedef struct MultigroupClass *Multigroup; + +// --- Const-aware handles. +typedef const struct MultigroupClass *const ConstHandle2ConstMultigroup; +typedef struct MultigroupClass *const ConstHandle2Multigroup; +typedef const struct MultigroupClass * Handle2ConstMultigroup; +typedef struct MultigroupClass * Handle2Multigroup; + + +// ----------------------------------------------------------------------------- +// Basics +// Create, Assign, Delete +// ----------------------------------------------------------------------------- + +// --- Create, default, const +extern_c Handle2ConstMultigroup +MultigroupDefaultConst(); + +// +++ Create, default +extern_c Handle2Multigroup +MultigroupDefault(); + +// --- Create, general, const +extern_c Handle2ConstMultigroup +MultigroupCreateConst( + const char *const projectile, + ConstHandle2Library *const library, const size_t librarySize +); + +// +++ Create, general +extern_c Handle2Multigroup +MultigroupCreate( + const char *const projectile, + ConstHandle2Library *const library, const size_t librarySize +); + +// +++ Assign +// +++ Use this to assign one handled object to another. Don't assign handles, +// +++ as with to = from. That has a meaning that you probably don't intend. +extern_c void +MultigroupAssign(ConstHandle2Multigroup This, ConstHandle2ConstMultigroup from); + +// +++ Delete +// +++ We'll attempt to remove no-longer-used objects automatically, but you +// +++ may improve performance if you delete them when you're done with them. +extern_c void +MultigroupDelete(ConstHandle2ConstMultigroup This); + + +// ----------------------------------------------------------------------------- +// I/O +// Read, Write, Print +// Each returns 0 if failure, 1 if success. +// ----------------------------------------------------------------------------- + +// +++ Read from file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll examine the file's contents to determine its type automatically. +extern_c int +MultigroupRead(ConstHandle2Multigroup This, const char *const filename); + +// +++ Write to file +// +++ File can be XML, JSON, or HDF5. +// +++ We'll use filename's extension to determine the type you want written. +extern_c int +MultigroupWrite(ConstHandle2ConstMultigroup This, const char *const filename); + +// +++ Print to standard output, in our prettyprinting format +extern_c int +MultigroupPrint(ConstHandle2ConstMultigroup This); + +// +++ Print to standard output, as XML +extern_c int +MultigroupPrintXML(ConstHandle2ConstMultigroup This); + +// +++ Print to standard output, as JSON +extern_c int +MultigroupPrintJSON(ConstHandle2ConstMultigroup This); + + +// ----------------------------------------------------------------------------- +// Metadatum: projectile +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +MultigroupProjectileHas(ConstHandle2ConstMultigroup This); + +// +++ Get +// +++ Returns by value +extern_c const char * +MultigroupProjectileGet(ConstHandle2ConstMultigroup This); + +// +++ Set +extern_c void +MultigroupProjectileSet(ConstHandle2Multigroup This, const char *const projectile); + + +// ----------------------------------------------------------------------------- +// Child: library +// ----------------------------------------------------------------------------- + +// +++ Has +extern_c int +MultigroupLibraryHas(ConstHandle2ConstMultigroup This); + +// +++ Clear +extern_c void +MultigroupLibraryClear(ConstHandle2Multigroup This); + +// +++ Size +extern_c size_t +MultigroupLibrarySize(ConstHandle2ConstMultigroup This); + +// +++ Add +extern_c void +MultigroupLibraryAdd(ConstHandle2Multigroup This, ConstHandle2ConstLibrary library); + +// --- Get, by index \in [0,size), const +extern_c Handle2ConstLibrary +MultigroupLibraryGetConst(ConstHandle2ConstMultigroup This, const size_t index_); + +// +++ Get, by index \in [0,size), non-const +extern_c Handle2Library +MultigroupLibraryGet(ConstHandle2Multigroup This, const size_t index_); + +// +++ Set, by index \in [0,size) +extern_c void +MultigroupLibrarySet( + ConstHandle2Multigroup This, + const size_t index_, + ConstHandle2ConstLibrary library +); + +// +++ Has, by name +extern_c int +MultigroupLibraryHasByName( + ConstHandle2ConstMultigroup This, + const char *const name +); + +// --- Get, by name, const +extern_c Handle2ConstLibrary +MultigroupLibraryGetByNameConst( + ConstHandle2ConstMultigroup This, + const char *const name +); + +// +++ Get, by name, non-const +extern_c Handle2Library +MultigroupLibraryGetByName( + ConstHandle2Multigroup This, + const char *const name +); + +// +++ Set, by name +extern_c void +MultigroupLibrarySetByName( + ConstHandle2Multigroup This, + const char *const name, + ConstHandle2ConstLibrary library +); + + +// ----------------------------------------------------------------------------- +// Done +// ----------------------------------------------------------------------------- + +#undef extern_c +#endif diff --git a/autogen/simple/multi/python/src/v1/multigroup.python.cpp b/autogen/simple/multi/python/src/v1/multigroup.python.cpp new file mode 100644 index 000000000..57d970039 --- /dev/null +++ b/autogen/simple/multi/python/src/v1/multigroup.python.cpp @@ -0,0 +1,39 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include +#include + +namespace python = pybind11; + +// v1 interface +namespace python_v1 { + +// multigroup declarations +namespace python_multigroup { + void wrapIsotope(python::module &); + void wrapFoobar(python::module &); + void wrapElement(python::module &); + void wrapLibrary(python::module &); + void wrapMultigroup(python::module &); +} // namespace python_multigroup + +// multigroup wrapper +void wrapMultigroup(python::module &module) +{ + // create the multigroup submodule + python::module submodule = module.def_submodule( + "multigroup", + "multi v1 multigroup" + ); + + // wrap multigroup components + python_multigroup::wrapIsotope(submodule); + python_multigroup::wrapFoobar(submodule); + python_multigroup::wrapElement(submodule); + python_multigroup::wrapLibrary(submodule); + python_multigroup::wrapMultigroup(submodule); +}; + +} // namespace python_v1 diff --git a/autogen/simple/multi/python/src/v1/multigroup/Element.python.cpp b/autogen/simple/multi/python/src/v1/multigroup/Element.python.cpp new file mode 100644 index 000000000..f2897c1cf --- /dev/null +++ b/autogen/simple/multi/python/src/v1/multigroup/Element.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "multi/v1/multigroup/Element.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v1 { +namespace python_multigroup { + +// Element wrapper +void wrapElement(python::module &module) +{ + using namespace multi; + using namespace multi::v1; + + // type aliases + using Component = multigroup::Element; + + // create the component + python::class_ component( + module, + "Element", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const int &, + const std::vector &, + const std::optional & + >(), + python::arg("symbol") = std::nullopt, + python::arg("atomic_number"), + python::arg("isotope"), + python::arg("foobar") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "symbol", + [](const Component &self) { return self.symbol(); }, + Component::documentation("symbol").data() + ) + .def_property_readonly( + "atomic_number", + [](const Component &self) { return self.atomic_number(); }, + Component::documentation("atomic_number").data() + ) + .def_property_readonly( + "isotope", + [](const Component &self) { return self.isotope(); }, + Component::documentation("isotope").data() + ) + .def_property_readonly( + "foobar", + [](const Component &self) { return self.foobar(); }, + Component::documentation("foobar").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_multigroup +} // namespace python_v1 diff --git a/autogen/simple/multi/python/src/v1/multigroup/Foobar.python.cpp b/autogen/simple/multi/python/src/v1/multigroup/Foobar.python.cpp new file mode 100644 index 000000000..4ab4891cf --- /dev/null +++ b/autogen/simple/multi/python/src/v1/multigroup/Foobar.python.cpp @@ -0,0 +1,68 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "multi/v1/multigroup/Foobar.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v1 { +namespace python_multigroup { + +// Foobar wrapper +void wrapFoobar(python::module &module) +{ + using namespace multi; + using namespace multi::v1; + + // type aliases + using Component = multigroup::Foobar; + + // create the component + python::class_ component( + module, + "Foobar", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string & + >(), + python::arg("value"), + Component::documentation("constructor").data() + ) + .def( + python::init< + const std::vector & + >(), + python::arg("doubles"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "value", + [](const Component &self) { return self.value(); }, + Component::documentation("value").data() + ) + .def_property_readonly( + "doubles", + [] (const Component &self) { return self.doubles(); }, + Component::documentation("doubles").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_multigroup +} // namespace python_v1 diff --git a/autogen/simple/multi/python/src/v1/multigroup/Isotope.python.cpp b/autogen/simple/multi/python/src/v1/multigroup/Isotope.python.cpp new file mode 100644 index 000000000..d74c2f1a1 --- /dev/null +++ b/autogen/simple/multi/python/src/v1/multigroup/Isotope.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "multi/v1/multigroup/Isotope.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v1 { +namespace python_multigroup { + +// Isotope wrapper +void wrapIsotope(python::module &module) +{ + using namespace multi; + using namespace multi::v1; + + // type aliases + using Component = multigroup::Isotope; + + // create the component + python::class_ component( + module, + "Isotope", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const int & + >(), + python::arg("mass_number"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "mass_number", + [](const Component &self) { return self.mass_number(); }, + Component::documentation("mass_number").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_multigroup +} // namespace python_v1 diff --git a/autogen/simple/multi/python/src/v1/multigroup/Library.python.cpp b/autogen/simple/multi/python/src/v1/multigroup/Library.python.cpp new file mode 100644 index 000000000..f464efd43 --- /dev/null +++ b/autogen/simple/multi/python/src/v1/multigroup/Library.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "multi/v1/multigroup/Library.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v1 { +namespace python_multigroup { + +// Library wrapper +void wrapLibrary(python::module &module) +{ + using namespace multi; + using namespace multi::v1; + + // type aliases + using Component = multigroup::Library; + + // create the component + python::class_ component( + module, + "Library", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string &, + const std::vector & + >(), + python::arg("name"), + python::arg("element"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "name", + [](const Component &self) { return self.name(); }, + Component::documentation("name").data() + ) + .def_property_readonly( + "element", + [](const Component &self) { return self.element(); }, + Component::documentation("element").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_multigroup +} // namespace python_v1 diff --git a/autogen/simple/multi/python/src/v1/multigroup/Multigroup.python.cpp b/autogen/simple/multi/python/src/v1/multigroup/Multigroup.python.cpp new file mode 100644 index 000000000..677cb082d --- /dev/null +++ b/autogen/simple/multi/python/src/v1/multigroup/Multigroup.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "multi/v1/multigroup/Multigroup.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v1 { +namespace python_multigroup { + +// Multigroup wrapper +void wrapMultigroup(python::module &module) +{ + using namespace multi; + using namespace multi::v1; + + // type aliases + using Component = multigroup::Multigroup; + + // create the component + python::class_ component( + module, + "Multigroup", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string &, + const std::vector & + >(), + python::arg("projectile"), + python::arg("library"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "projectile", + [](const Component &self) { return self.projectile(); }, + Component::documentation("projectile").data() + ) + .def_property_readonly( + "library", + [](const Component &self) { return self.library(); }, + Component::documentation("library").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_multigroup +} // namespace python_v1 diff --git a/autogen/simple/multi/src/multi/v1.hpp b/autogen/simple/multi/src/multi/v1.hpp new file mode 100644 index 000000000..12086f923 --- /dev/null +++ b/autogen/simple/multi/src/multi/v1.hpp @@ -0,0 +1,14 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#ifndef MULTI_V1 +#define MULTI_V1 + +#include "multi/v1/multigroup/Multigroup.hpp" +#include "multi/v1/multigroup/Library.hpp" +#include "multi/v1/multigroup/Element.hpp" +#include "multi/v1/multigroup/Isotope.hpp" +#include "multi/v1/multigroup/Foobar.hpp" + +#endif diff --git a/autogen/simple/multi/src/multi/v1/key.hpp b/autogen/simple/multi/src/multi/v1/key.hpp new file mode 100644 index 000000000..fa64a18da --- /dev/null +++ b/autogen/simple/multi/src/multi/v1/key.hpp @@ -0,0 +1,80 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#ifndef MULTI_V1_KEY +#define MULTI_V1_KEY + +// GNDStk Core Interface +#include "GNDStk.hpp" + +namespace multi { +namespace v1 { + +using namespace njoy::GNDStk; + + +// ----------------------------------------------------------------------------- +// meta:: +// ----------------------------------------------------------------------------- + +namespace meta { + +#define GNDSTK_MAKE_LOOKUP(nameField,nameGNDS) \ + inline const auto nameField = makeLookup( \ + [](const auto &obj) -> decltype(obj.nameField()) \ + { return obj.nameField(); }, \ + #nameGNDS \ + ) +// nameField vs. nameGNDS: for, e.g., Double vs. double in GNDS + +GNDSTK_MAKE_LOOKUP(atomic_number,atomic_number); +GNDSTK_MAKE_LOOKUP(mass_number,mass_number); +GNDSTK_MAKE_LOOKUP(name,name); +GNDSTK_MAKE_LOOKUP(projectile,projectile); +GNDSTK_MAKE_LOOKUP(symbol,symbol); +GNDSTK_MAKE_LOOKUP(value,value); + +#undef GNDSTK_MAKE_LOOKUP + +} // namespace meta + + +// ----------------------------------------------------------------------------- +// multigroup::child:: +// ----------------------------------------------------------------------------- + +namespace multigroup { +namespace child { + +inline const Child<> element("element"); +inline const Child<> foobar("foobar"); +inline const Child<> isotope("isotope"); +inline const Child<> library("library"); +inline const Child<> multigroup("multigroup"); + +} // namespace child +using namespace child; +} // namespace multigroup + + +// ----------------------------------------------------------------------------- +// For convenience: using directives +// ----------------------------------------------------------------------------- + +namespace key { + using namespace meta; + using namespace multigroup::child; +} // namespace key + +using namespace key; +using namespace multigroup; + + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + +} // namespace v1 +} // namespace multi + +#endif diff --git a/autogen/simple/multi/src/multi/v1/multigroup/Element.hpp b/autogen/simple/multi/src/multi/v1/multigroup/Element.hpp new file mode 100644 index 000000000..c87342dae --- /dev/null +++ b/autogen/simple/multi/src/multi/v1/multigroup/Element.hpp @@ -0,0 +1,128 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#ifndef MULTI_V1_MULTIGROUP_ELEMENT +#define MULTI_V1_MULTIGROUP_ELEMENT + +#include "multi/v1/multigroup/Isotope.hpp" +#include "multi/v1/multigroup/Foobar.hpp" + +namespace multi { +namespace v1 { +namespace multigroup { + +// ----------------------------------------------------------------------------- +// multigroup:: +// class Element +// ----------------------------------------------------------------------------- + +class Element : public Component { + friend class Component; + + // ------------------------ + // For Component + // ------------------------ + + // Names: this namespace, this class, a field/node of this type + static auto NAMESPACE() { return "multigroup"; } + static auto CLASS() { return "Element"; } + static auto FIELD() { return "element"; } + + // Core Interface multi-query to extract metadata and child nodes + static auto KEYS() + { + return + // metadata + std::optional{} + / Meta<>("symbol") | + int{} + / Meta<>("atomic_number") | + // children + multigroup::Isotope{} + / ++Child<>("isotope") | + std::optional{} + / --Child<>("foobar") + ; + } + +public: + using Component::construct; + + // metadata + Field> symbol{this}; + Field atomic_number{this}; + + // children + Field> isotope{this}; + Field> foobar{this}; + + // ------------------------ + // Constructors + // ------------------------ + + #define GNDSTK_COMPONENT(blockdata) Component(blockdata, \ + this->symbol, \ + this->atomic_number, \ + this->isotope, \ + this->foobar) + + // default, and from fields + explicit Element( + const wrapper> &symbol = {}, + const wrapper &atomic_number = {}, + const wrapper> &isotope = {}, + const wrapper> &foobar = {} + ) : + GNDSTK_COMPONENT(BlockData{}), + symbol(this,symbol), + atomic_number(this,atomic_number), + isotope(this,isotope), + foobar(this,foobar) + { + Component::finish(); + } + + // from node + explicit Element(const Node &node) : + GNDSTK_COMPONENT(BlockData{}) + { + Component::finish(node); + } + + // copy + Element(const Element &other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = other; + Component::finish(other); + } + + // move + Element(Element &&other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = std::move(other); + Component::finish(other); + } + + // ------------------------ + // Assignment operators + // ------------------------ + + Element &operator=(const Element &) = default; + Element &operator=(Element &&) = default; + + // ------------------------ + // Custom functionality + // ------------------------ + + #include "multi/v1/multigroup/Element/src/custom.hpp" + #undef GNDSTK_COMPONENT +}; // class Element + +} // namespace multigroup +} // namespace v1 +} // namespace multi + +#endif diff --git a/autogen/simple/multi/src/multi/v1/multigroup/Element/src/custom.hpp b/autogen/simple/multi/src/multi/v1/multigroup/Element/src/custom.hpp new file mode 100644 index 000000000..b944fbfe2 --- /dev/null +++ b/autogen/simple/multi/src/multi/v1/multigroup/Element/src/custom.hpp @@ -0,0 +1,28 @@ + +private: + + static inline helpMap help = {}; + +public: + + // Custom 2-argument print() function. + // In order to be called by Component::print(), this function must be public, + // and must have the exact signature shown here, including both the constness + // of the second parameter, and of the function itself. + std::ostream &print(std::ostream &os, const int level) const + { + // When Component::print() calls a custom print() that takes indentation + // level (as opposed to a custom print() that takes only a std::ostream), + // it assumes that the custom print() takes care of its own indentation. + // So, prefer this print() over a std::ostream-only print() - for which + // Component::print() indents as it believes is appropriate - ONLY if you + // wish to do something nonstandard with indentation. + + // Here, we'll indent as GNDStk does: using GNDStk::indent*level spaces. + // GNDStk::indentTo() creates an appropriate std::string for that purpose. + os << indentTo(level) << "*** Custom Element print(), line 1\n"; + os << indentTo(level) << "*** Custom Element print(), line 2\n"; + os << indentTo(level) << "*** Custom Element print(), line 3"; + + return os; + } diff --git a/autogen/simple/multi/src/multi/v1/multigroup/Foobar.hpp b/autogen/simple/multi/src/multi/v1/multigroup/Foobar.hpp new file mode 100644 index 000000000..85a319bea --- /dev/null +++ b/autogen/simple/multi/src/multi/v1/multigroup/Foobar.hpp @@ -0,0 +1,115 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#ifndef MULTI_V1_MULTIGROUP_FOOBAR +#define MULTI_V1_MULTIGROUP_FOOBAR + +#include "multi/v1/key.hpp" + +namespace multi { +namespace v1 { +namespace multigroup { + +// ----------------------------------------------------------------------------- +// multigroup:: +// class Foobar +// ----------------------------------------------------------------------------- + +class Foobar : public Component { + friend class Component; + + // ------------------------ + // For Component + // ------------------------ + + // Names: this namespace, this class, a field/node of this type + static auto NAMESPACE() { return "multigroup"; } + static auto CLASS() { return "Foobar"; } + static auto FIELD() { return "foobar"; } + + // Core Interface multi-query to extract metadata and child nodes + static auto KEYS() + { + return + // metadata + std::string{} + / Meta<>("value") + ; + } + +public: + using Component::construct; + using BlockData::operator=; + + // metadata + Field value{this}; + + // ------------------------ + // Constructors + // ------------------------ + + #define GNDSTK_COMPONENT(blockdata) Component(blockdata, \ + this->value) + + // default, and from fields + explicit Foobar( + const wrapper &value = {} + ) : + GNDSTK_COMPONENT(BlockData{}), + value(this,value) + { + Component::finish(); + } + + // from node + explicit Foobar(const Node &node) : + GNDSTK_COMPONENT(BlockData{}) + { + Component::finish(node); + } + + // from vector + template>> + Foobar(const std::vector &vector) : + GNDSTK_COMPONENT(BlockData{}) + { + Component::finish(vector); + } + + // copy + Foobar(const Foobar &other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = other; + Component::finish(other); + } + + // move + Foobar(Foobar &&other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = std::move(other); + Component::finish(other); + } + + // ------------------------ + // Assignment operators + // ------------------------ + + Foobar &operator=(const Foobar &) = default; + Foobar &operator=(Foobar &&) = default; + + // ------------------------ + // Custom functionality + // ------------------------ + + #include "multi/v1/multigroup/Foobar/src/custom.hpp" + #undef GNDSTK_COMPONENT +}; // class Foobar + +} // namespace multigroup +} // namespace v1 +} // namespace multi + +#endif diff --git a/autogen/simple/multi/src/multi/v1/multigroup/Foobar/src/custom.hpp b/autogen/simple/multi/src/multi/v1/multigroup/Foobar/src/custom.hpp new file mode 100644 index 000000000..9bf4b251a --- /dev/null +++ b/autogen/simple/multi/src/multi/v1/multigroup/Foobar/src/custom.hpp @@ -0,0 +1,4 @@ + +private: + + static inline helpMap help = {}; diff --git a/autogen/simple/multi/src/multi/v1/multigroup/Isotope.hpp b/autogen/simple/multi/src/multi/v1/multigroup/Isotope.hpp new file mode 100644 index 000000000..37f7cca31 --- /dev/null +++ b/autogen/simple/multi/src/multi/v1/multigroup/Isotope.hpp @@ -0,0 +1,106 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#ifndef MULTI_V1_MULTIGROUP_ISOTOPE +#define MULTI_V1_MULTIGROUP_ISOTOPE + +#include "multi/v1/key.hpp" + +namespace multi { +namespace v1 { +namespace multigroup { + +// ----------------------------------------------------------------------------- +// multigroup:: +// class Isotope +// ----------------------------------------------------------------------------- + +class Isotope : public Component { + friend class Component; + + // ------------------------ + // For Component + // ------------------------ + + // Names: this namespace, this class, a field/node of this type + static auto NAMESPACE() { return "multigroup"; } + static auto CLASS() { return "Isotope"; } + static auto FIELD() { return "isotope"; } + + // Core Interface multi-query to extract metadata and child nodes + static auto KEYS() + { + return + // metadata + int{} + / Meta<>("mass_number") + ; + } + +public: + using Component::construct; + + // metadata + Field mass_number{this}; + + // ------------------------ + // Constructors + // ------------------------ + + #define GNDSTK_COMPONENT(blockdata) Component(blockdata, \ + this->mass_number) + + // default, and from fields + explicit Isotope( + const wrapper &mass_number = {} + ) : + GNDSTK_COMPONENT(BlockData{}), + mass_number(this,mass_number) + { + Component::finish(); + } + + // from node + explicit Isotope(const Node &node) : + GNDSTK_COMPONENT(BlockData{}) + { + Component::finish(node); + } + + // copy + Isotope(const Isotope &other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = other; + Component::finish(other); + } + + // move + Isotope(Isotope &&other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = std::move(other); + Component::finish(other); + } + + // ------------------------ + // Assignment operators + // ------------------------ + + Isotope &operator=(const Isotope &) = default; + Isotope &operator=(Isotope &&) = default; + + // ------------------------ + // Custom functionality + // ------------------------ + + #include "multi/v1/multigroup/Isotope/src/custom.hpp" + #undef GNDSTK_COMPONENT +}; // class Isotope + +} // namespace multigroup +} // namespace v1 +} // namespace multi + +#endif diff --git a/autogen/simple/multi/src/multi/v1/multigroup/Isotope/src/custom.hpp b/autogen/simple/multi/src/multi/v1/multigroup/Isotope/src/custom.hpp new file mode 100644 index 000000000..758ac991d --- /dev/null +++ b/autogen/simple/multi/src/multi/v1/multigroup/Isotope/src/custom.hpp @@ -0,0 +1,25 @@ + +private: + + static inline helpMap help = {}; + +public: + + // If a custom 1-argument print() function *and* a custom 2-argument print() + // function are both given, and both with the correct signature, then + // Component::print() will call the 2-argument version, and ignore the other. + + std::ostream &print(std::ostream &os) const + { + assert(false); // shouldn't happen, because the below print() is used! + return os; + } + + std::ostream &print(std::ostream &os, const int level) const + { + os << indentTo(level) << "*** Custom Isotope print(), line 1\n"; + os << indentTo(level) << "*** Custom Isotope print(), line 2\n"; + os << indentTo(level) << "*** Custom Isotope print(), line 3"; + + return os; + } diff --git a/autogen/simple/multi/src/multi/v1/multigroup/Library.hpp b/autogen/simple/multi/src/multi/v1/multigroup/Library.hpp new file mode 100644 index 000000000..d7461a925 --- /dev/null +++ b/autogen/simple/multi/src/multi/v1/multigroup/Library.hpp @@ -0,0 +1,115 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#ifndef MULTI_V1_MULTIGROUP_LIBRARY +#define MULTI_V1_MULTIGROUP_LIBRARY + +#include "multi/v1/multigroup/Element.hpp" + +namespace multi { +namespace v1 { +namespace multigroup { + +// ----------------------------------------------------------------------------- +// multigroup:: +// class Library +// ----------------------------------------------------------------------------- + +class Library : public Component { + friend class Component; + + // ------------------------ + // For Component + // ------------------------ + + // Names: this namespace, this class, a field/node of this type + static auto NAMESPACE() { return "multigroup"; } + static auto CLASS() { return "Library"; } + static auto FIELD() { return "library"; } + + // Core Interface multi-query to extract metadata and child nodes + static auto KEYS() + { + return + // metadata + std::string{} + / Meta<>("name") | + // children + multigroup::Element{} + / ++Child<>("element") + ; + } + +public: + using Component::construct; + + // metadata + Field name{this}; + + // children + Field> element{this}; + + // ------------------------ + // Constructors + // ------------------------ + + #define GNDSTK_COMPONENT(blockdata) Component(blockdata, \ + this->name, \ + this->element) + + // default, and from fields + explicit Library( + const wrapper &name = {}, + const wrapper> &element = {} + ) : + GNDSTK_COMPONENT(BlockData{}), + name(this,name), + element(this,element) + { + Component::finish(); + } + + // from node + explicit Library(const Node &node) : + GNDSTK_COMPONENT(BlockData{}) + { + Component::finish(node); + } + + // copy + Library(const Library &other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = other; + Component::finish(other); + } + + // move + Library(Library &&other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = std::move(other); + Component::finish(other); + } + + // ------------------------ + // Assignment operators + // ------------------------ + + Library &operator=(const Library &) = default; + Library &operator=(Library &&) = default; + + // ------------------------ + // Custom functionality + // ------------------------ + + #include "multi/v1/multigroup/Library/src/custom.hpp" + #undef GNDSTK_COMPONENT +}; // class Library + +} // namespace multigroup +} // namespace v1 +} // namespace multi + +#endif diff --git a/autogen/simple/multi/src/multi/v1/multigroup/Library/src/custom.hpp b/autogen/simple/multi/src/multi/v1/multigroup/Library/src/custom.hpp new file mode 100644 index 000000000..3382adeec --- /dev/null +++ b/autogen/simple/multi/src/multi/v1/multigroup/Library/src/custom.hpp @@ -0,0 +1,19 @@ + +private: + + static inline helpMap help = {}; + +public: + + // Custom 1-argument print() function. + // In order to be called by Component::print(), this function must be public, + // and must have the exact signature shown here, including the constness of + // the function itself. + std::ostream &print(std::ostream &os) const + { + os << "*** Custom Library print(), line 1\n"; + os << "*** Custom Library print(), line 2\n"; + os << "*** Custom Library print(), line 3"; + + return os; + } diff --git a/autogen/simple/multi/src/multi/v1/multigroup/Multigroup.hpp b/autogen/simple/multi/src/multi/v1/multigroup/Multigroup.hpp new file mode 100644 index 000000000..1e0d5e5ac --- /dev/null +++ b/autogen/simple/multi/src/multi/v1/multigroup/Multigroup.hpp @@ -0,0 +1,115 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#ifndef MULTI_V1_MULTIGROUP_MULTIGROUP +#define MULTI_V1_MULTIGROUP_MULTIGROUP + +#include "multi/v1/multigroup/Library.hpp" + +namespace multi { +namespace v1 { +namespace multigroup { + +// ----------------------------------------------------------------------------- +// multigroup:: +// class Multigroup +// ----------------------------------------------------------------------------- + +class Multigroup : public Component { + friend class Component; + + // ------------------------ + // For Component + // ------------------------ + + // Names: this namespace, this class, a field/node of this type + static auto NAMESPACE() { return "multigroup"; } + static auto CLASS() { return "Multigroup"; } + static auto FIELD() { return "multigroup"; } + + // Core Interface multi-query to extract metadata and child nodes + static auto KEYS() + { + return + // metadata + std::string{} + / Meta<>("projectile") | + // children + multigroup::Library{} + / ++Child<>("library") + ; + } + +public: + using Component::construct; + + // metadata + Field projectile{this}; + + // children + Field> library{this}; + + // ------------------------ + // Constructors + // ------------------------ + + #define GNDSTK_COMPONENT(blockdata) Component(blockdata, \ + this->projectile, \ + this->library) + + // default, and from fields + explicit Multigroup( + const wrapper &projectile = {}, + const wrapper> &library = {} + ) : + GNDSTK_COMPONENT(BlockData{}), + projectile(this,projectile), + library(this,library) + { + Component::finish(); + } + + // from node + explicit Multigroup(const Node &node) : + GNDSTK_COMPONENT(BlockData{}) + { + Component::finish(node); + } + + // copy + Multigroup(const Multigroup &other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = other; + Component::finish(other); + } + + // move + Multigroup(Multigroup &&other) : + GNDSTK_COMPONENT(other.baseBlockData()) + { + *this = std::move(other); + Component::finish(other); + } + + // ------------------------ + // Assignment operators + // ------------------------ + + Multigroup &operator=(const Multigroup &) = default; + Multigroup &operator=(Multigroup &&) = default; + + // ------------------------ + // Custom functionality + // ------------------------ + + #include "multi/v1/multigroup/Multigroup/src/custom.hpp" + #undef GNDSTK_COMPONENT +}; // class Multigroup + +} // namespace multigroup +} // namespace v1 +} // namespace multi + +#endif diff --git a/autogen/simple/multi/src/multi/v1/multigroup/Multigroup/src/custom.hpp b/autogen/simple/multi/src/multi/v1/multigroup/Multigroup/src/custom.hpp new file mode 100644 index 000000000..9bf4b251a --- /dev/null +++ b/autogen/simple/multi/src/multi/v1/multigroup/Multigroup/src/custom.hpp @@ -0,0 +1,4 @@ + +private: + + static inline helpMap help = {}; diff --git a/autogen/v1.9/summary_documentation.json b/autogen/v1.9/summary_documentation.json index 393100fc7..fd3d5f64e 100644 --- a/autogen/v1.9/summary_documentation.json +++ b/autogen/v1.9/summary_documentation.json @@ -176,7 +176,7 @@ }, "affiliations": { "__class__": "nodes.ChildNode", - "description": "Institutional affilation(s) of the author", + "description": "Institutional affiliation(s) of the author", "name": "affiliations", "occurrence": "1", "required": false @@ -240,7 +240,7 @@ "affiliation": { "__class__": "nodes.ChildNode", "description": "Each affiliation is described in an \\element{affiliation} element.", - "name": "affilation", + "name": "affiliation", "occurrence": "1+", "required": true } diff --git a/autogen/v1.9.json b/autogen/v1.9/v1.9.json similarity index 85% rename from autogen/v1.9.json rename to autogen/v1.9/v1.9.json index 87bde7140..c178ac324 100644 --- a/autogen/v1.9.json +++ b/autogen/v1.9/v1.9.json @@ -1,5 +1,9 @@ { - "JSONDir": "v1.9", + "Path": ".", + "Project": "GNDStk", + "Version": "v1.9", + + "JSONDir": ".", "JSONFiles": [ "summary_abstract.json", "summary_appData.json", @@ -19,7 +23,5 @@ "summary_tsl.json" ], - "GNDSDir": "test", - "Version": "v1.9", - "Changes": "changes.json" + "Changes": "../changes.json" } diff --git a/c/src/GNDStk.cpp b/c/src/GNDStk.cpp new file mode 100644 index 000000000..696946dad --- /dev/null +++ b/c/src/GNDStk.cpp @@ -0,0 +1,88 @@ + +// ----------------------------------------------------------------------------- +// Interface for C +// Definitions +// ----------------------------------------------------------------------------- + +#include "GNDStk.h" + + +// ----------------------------------------------------------------------------- +// Some basic flags +// In C++, these are available via inline variables. +// For C, we make them functions. +// ----------------------------------------------------------------------------- + +// ------------------------ +// General +// ------------------------ + +void indent(const int value) +{ + njoy::GNDStk::indent = value; +} + +void align(const int value) +{ + njoy::GNDStk::align = bool(value); +} + +void color(const int value) +{ + njoy::GNDStk::color = bool(value); +} + +// ------------------------ +// Re: Component printing +// ------------------------ + +void comments(const int value) +{ + njoy::GNDStk::comments = bool(value); +} + +void columns(const long value) +{ + njoy::GNDStk::columns = value; +} + +// A function name of truncate (for access to our C++ [inline long truncate] +// variable) appears to conflict, here in our C language interface functions, +// with a truncate function in unistd.h. So, we'll give it a different name. +void truncation(const long value) +{ + njoy::GNDStk::truncate = value; +} + +// ------------------------ +// Re: GNDStk diagnostics +// ------------------------ + +void note(const int value) +{ + njoy::GNDStk::info = bool(value); +} + +void warning(const int value) +{ + njoy::GNDStk::warning = bool(value); +} + +void debug(const int value) +{ + njoy::GNDStk::debug = bool(value); +} + +void context(const int value) +{ + njoy::GNDStk::context = bool(value); +} + +// ------------------------ +// Re: OpenMP +// ------------------------ + +void threads(const int value) +{ + njoy::GNDStk::threads = value; +} diff --git a/c/src/GNDStk.h b/c/src/GNDStk.h new file mode 100644 index 000000000..0eed6655c --- /dev/null +++ b/c/src/GNDStk.h @@ -0,0 +1,55 @@ + +// ----------------------------------------------------------------------------- +// Interface for C +// Declarations +// ----------------------------------------------------------------------------- + +#ifndef C_INTERFACE_GNDSTK +#define C_INTERFACE_GNDSTK + +// This file works in both C++ and C +#ifdef __cplusplus + // For C++ + #include "GNDStk.hpp" + #define extern_C extern "C" +#else + // For C + #define extern_C +#endif + + +// ----------------------------------------------------------------------------- +// Function declarations +// Definitions are in this file's .cpp +// ----------------------------------------------------------------------------- + +extern_C void indent(const int); +extern_C void align(const int); +extern_C void color(const int); + +extern_C void comments(const int); +extern_C void columns(const long); +extern_C void truncation(const long); + +extern_C void note(const int); +extern_C void warning(const int); +extern_C void debug(const int); +extern_C void context(const int); + +extern_C void threads(const int); + +// todo +// Obviously, we'll want much more here. I'll probably add additional +// C-style interfaces to GNDStk's C++ code gradually, as we discover what +// our C language users want. Note that we're speaking here about the C +// interface to the overarching GNDStk library, not a C interface to some +// particular set of generated C++ classes that somebody might have created +// with our code generator. Those C interfaces are (or will be) created +// automatically, by the code generator, just as the C++ classes are. + + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + +#undef extern_C +#endif diff --git a/cmake/GNDStk_dependencies.cmake b/cmake/GNDStk_dependencies.cmake index 46c409ac9..a355119b4 100644 --- a/cmake/GNDStk_dependencies.cmake +++ b/cmake/GNDStk_dependencies.cmake @@ -10,28 +10,28 @@ include( FetchContent ) # Declare project dependencies ######################################################################## -FetchContent_Declare( catch-adapter - GIT_REPOSITORY http://github.com/njoy/catch-adapter - GIT_TAG origin/master - GIT_SHALLOW TRUE +FetchContent_Declare(catch-adapter + GIT_REPOSITORY http://github.com/njoy/catch-adapter + GIT_TAG origin/master + GIT_SHALLOW TRUE ) -FetchContent_Declare( Log - GIT_REPOSITORY http://github.com/njoy/Log - GIT_TAG origin/build/fetchcontent - GIT_SHALLOW TRUE +FetchContent_Declare(Log + GIT_REPOSITORY http://github.com/njoy/Log + GIT_TAG origin/master + GIT_SHALLOW TRUE ) -FetchContent_Declare( pugixml-adapter - GIT_REPOSITORY http://github.com/njoy/pugixml-adapter - GIT_TAG origin/master - GIT_SHALLOW TRUE +FetchContent_Declare(pugixml-adapter + GIT_REPOSITORY http://github.com/njoy/pugixml-adapter + GIT_TAG origin/master + GIT_SHALLOW TRUE ) FetchContent_Declare(json - GIT_REPOSITORY https://github.com/nlohmann/json.git - GIT_TAG v3.7.3 - GIT_SHALLOW true + GIT_REPOSITORY https://github.com/nlohmann/json.git + GIT_TAG origin/master + GIT_SHALLOW TRUE ) FetchContent_GetProperties(json) @@ -41,10 +41,19 @@ if(NOT json_POPULATED) add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL) endif() -FetchContent_Declare( pybind11 - GIT_REPOSITORY https://github.com/pybind/pybind11 - GIT_TAG v2.6.1 - GIT_SHALLOW TRUE +FetchContent_Declare(hdf5 + GIT_REPOSITORY https://github.com/BlueBrain/HighFive.git + GIT_TAG v2.3.1 + GIT_SHALLOW TRUE + ) +set( HIGHFIVE_USE_BOOST OFF CACHE INTERNAL "" ) +set( HIGHFIVE_UNIT_TESTS OFF CACHE INTERNAL "" ) +set( HIGHFIVE_EXAMPLES OFF CACHE INTERNAL "" ) + +FetchContent_Declare(pybind11 + GIT_REPOSITORY https://github.com/pybind/pybind11 + GIT_TAG v2.6.1 + GIT_SHALLOW TRUE ) @@ -57,5 +66,6 @@ FetchContent_MakeAvailable( Log pugixml-adapter json + hdf5 pybind11 ) diff --git a/cmake/unit_testing.cmake b/cmake/unit_testing.cmake index bf5bacd44..9573a46de 100644 --- a/cmake/unit_testing.cmake +++ b/cmake/unit_testing.cmake @@ -10,7 +10,6 @@ enable_testing() # Unit testing directories ####################################################################### -add_subdirectory( src/GNDStk/test ) add_subdirectory( src/GNDStk/Defaulted/test ) add_subdirectory( src/GNDStk/Tree/test ) add_subdirectory( src/GNDStk/type2string/test ) @@ -20,28 +19,37 @@ add_subdirectory( src/GNDStk/string2type/test ) add_subdirectory( src/GNDStk/Meta/test ) add_subdirectory( src/GNDStk/XML/test ) add_subdirectory( src/GNDStk/JSON/test ) +add_subdirectory( src/GNDStk/HDF5/test ) add_subdirectory( src/GNDStk/Node/test ) -add_subdirectory( src/GNDStk/keyword/test ) add_subdirectory( src/GNDStk/Child/test ) add_subdirectory( src/GNDStk/convert/test ) add_subdirectory( src/GNDStk/utility/test ) add_subdirectory( src/GNDStk/Component/test ) -add_subdirectory( src/GNDStk/BodyText/test ) +add_subdirectory( src/GNDStk/BlockData/test ) add_subdirectory( src/GNDStk/precision/test ) -add_subdirectory( src/GNDStk/enums/Encoding/test ) +add_subdirectory( src/GNDStk/enums/DateType/test ) +add_subdirectory( src/GNDStk/enums/ContributorType/test ) +add_subdirectory( src/GNDStk/enums/RelationType/test ) +add_subdirectory( src/GNDStk/enums/Parity/test ) add_subdirectory( src/GNDStk/enums/Frame/test ) +add_subdirectory( src/GNDStk/enums/Interpolation/test ) +add_subdirectory( src/GNDStk/enums/InterpolationQualifier/test ) +add_subdirectory( src/GNDStk/enums/HashAlgorithm/test ) +add_subdirectory( src/GNDStk/enums/DecayType/test ) add_subdirectory( src/GNDStk/enums/GridStyle/test ) +add_subdirectory( src/GNDStk/enums/BoundaryCondition/test ) + +add_subdirectory( src/GNDStk/enums/Encoding/test ) add_subdirectory( src/GNDStk/enums/Interaction/test ) -add_subdirectory( src/GNDStk/enums/Interpolation/test ) add_subdirectory( src/GNDStk/enums/StorageOrder/test ) add_subdirectory( src/GNDStk/enums/units/Energy/test ) add_subdirectory( src/GNDStk/enums/units/Length/test ) -add_subdirectory( src/GNDStk/v1.9/containers/Values/test ) -add_subdirectory( src/GNDStk/v1.9/containers/Axis/test ) -add_subdirectory( src/GNDStk/v1.9/containers/Link/test ) -add_subdirectory( src/GNDStk/v1.9/containers/Grid/test ) -add_subdirectory( src/GNDStk/v1.9/containers/Axes/test ) -add_subdirectory( src/GNDStk/v1.9/containers/XYs1d/test ) -add_subdirectory( src/GNDStk/v1.9/containers/Regions1d/test ) +add_subdirectory( autogen/prototype/proto/src/proto/v1.9/containers/Values/test ) +add_subdirectory( autogen/prototype/proto/src/proto/v1.9/containers/Axis/test ) +add_subdirectory( autogen/prototype/proto/src/proto/v1.9/containers/Link/test ) +add_subdirectory( autogen/prototype/proto/src/proto/v1.9/containers/Grid/test ) +add_subdirectory( autogen/prototype/proto/src/proto/v1.9/containers/Axes/test ) +add_subdirectory( autogen/prototype/proto/src/proto/v1.9/containers/XYs1d/test ) +add_subdirectory( autogen/prototype/proto/src/proto/v1.9/containers/Regions1d/test ) diff --git a/docs/build.rst b/docs/build.rst index 89d8e30de..0d4848f59 100644 --- a/docs/build.rst +++ b/docs/build.rst @@ -78,7 +78,7 @@ it depends -- automatically. The *bad* news is that the download may, for the same reason, take quite some time. Resist the temptation to terminate the command, perhaps believing that your computer has hung, and consider starting ``cmake ..`` before lunch hour if you have a slow Internet connection. The main -culprit appears to be the "nlohmann json" library, +culprit appears to be the `nlohmann/json` library, https://github.com/nlohmann/json. An excellent library, by all accounts, and invaluable as the workhorse for GNDStk's JSON capabilities; but responsible, at the time of the writing, for over 400MB -- about 95% -- of diff --git a/docs/files/code-tables/node-add-child.cc b/docs/files/code-tables/node-add-child.cc index 820bb982b..97dd3372c 100644 --- a/docs/files/code-tables/node-add-child.cc +++ b/docs/files/code-tables/node-add-child.cc @@ -1,6 +1,6 @@ // string -Node &add( const string &name = "" ); +Node &add( const string &name = emptyNodeName ); // value Node &add( const T &val ); diff --git a/docs/files/code-tables/node-multi.cc b/docs/files/code-tables/node-multi.cc index 9b3fe048a..2d9090a6e 100644 --- a/docs/files/code-tables/node-multi.cc +++ b/docs/files/code-tables/node-multi.cc @@ -1,3 +1,3 @@ -auto operator()( const KeywordTup &kwds ) const; -auto operator()( const KeywordTup &kwds ); +auto operator()( const KeyTuple &keytup ) const; +auto operator()( const KeyTuple &keytup ); diff --git a/docs/primer.rst b/docs/primer.rst index 724fb8f2b..fb7863db5 100644 --- a/docs/primer.rst +++ b/docs/primer.rst @@ -207,7 +207,7 @@ Here's a simple code that reads the XML format GNDS file named Obviously, but worth a reminder, this assumes that the file resides right there, in the directory from which this code is run. If it doesn't, include a suitable -absolute or relative path in the file name string. We, and no doubt everyone +absolute or relative path in the file name. We, and no doubt everyone reading this, have probably made this mistake often enough over the years. ``Tree`` is GNDStk's data structure for holding an entire GNDS hierarchy, a.k.a. @@ -262,8 +262,6 @@ or can be a direct string: ``"xml"``, etc. A direct string is shorter and slightly easier to type -- but, if mistyped, would lead to a run-time error, not a compile-time error, if that matters to you in this simple context. -**HDF5 is not supported at this time!** Just XML and JSON. - *You should seldom, if ever, need to provide the second argument*. Absent the second argument, **GNDStk determines the file type automatically**, and we doubt that you'll have any objections to that. If you do choose provide the second @@ -276,9 +274,9 @@ as we attempt to read the file pursuant to the (incorrect) forced format. GNDStk uses the "file magic number," not the file name, to determine file type automatically. The file magic number really means the first byte, or bytes, -of the file. XML files always begin with a ``<`` character. HDF files (not -supported yet) begin with ASCII 137 and a few other specific bytes. If the -first byte is neither of those values, then GNDStk assumes JSON format. +of the file. XML files always begin with a ``<`` character. HDF5 files begin +with ASCII 137 and a few other specific bytes. If the first byte is neither +of those values, then GNDStk assumes JSON format. A nice thing about using the file magic number, not the file name, is that it works for ``std::istream``, for which a "file name" isn't even available. @@ -325,7 +323,7 @@ then GNDStk will write file ``pu239.xml`` in JSON format, as you asked for in the second argument, but will warn that the file extension is inconsistent with the format you asked for. -What if the file name extension isn't given, or isn't recognized, *and* a format +What if the file extension isn't given, or isn't recognized, *and* a format isn't forced with a second argument? That is, what if we wrote, for example, ``pu239.write("pu239")``? In that case, ``write`` writes the ``Tree`` into a simple output format that we created largely for debugging purposes. You @@ -406,7 +404,7 @@ Several remarks are in order here. The comparison operator for ``Tree`` compares the two GNDS trees in an *order-agnostic* manner. GNDS fundamentally provides data in two places: nodes (think XML "elements") in its overall tree structure, and metadata (think XML -"attributes"). The GNDS standard does not, however, consider ordering to be +attributes). The GNDS standard does not, however, consider ordering to be important. One tree node's child nodes or metadata, anywhere or everywhere throughout the entire tree structure, could be reordered arbitrarily, but if each remains equivalent -- in the same respect that we consider two mathematical @@ -492,14 +490,31 @@ with what XML is able to represent. the node. For example, in HDF5 the attribute ``nodeIndex`` could be added to each child in a group. -For (1), GNDStk does the first suggested action: it groups all of a node's -attributes under a child node called ``attributes``. We consider that to be -cleaner than using an ``_attr`` suffix. - -For (2), GNDStk does exactly as illustrated: multiple elements of the same name -are suffixed with ``0``, ``1``, etc. And, then, a JSON name/value pair with the -name ``nodeName``, as suggested, is created in order to preserve the original -*unsuffixed* element's name. +For (1), GNDStk does largely the first suggested action (which we think is +somewhat cleaner than using an ``_attr`` suffix), but with a slight twist, +along with our preferred terminology of ``metadata`` in place of ``attributes``. +It groups a node's metadata -- attributes -- under a child node +called ``#metadata``. + +The ``#`` prefix is something we use in node names throughout GNDStk, +if and where +the nodes so named represent special things -- with special meaning, and needing +special treatment. The extra character allows special nodes to be identified +easily, in both the GNDStk code base itself or in files produced by GNDStk. +Moreover, one could imagine that a future GNDS version might -- just might -- +have a normal node with the name ``metadata``, or with some other name that +we might wish to use for a special purpose. If and where such situations occur, +our use of a special prefix character allows for an unambiguous interpretation. +(As an aside: in principle, we'd have preferred to use the S-like dollar sign, +``$``, to inside S for "special" node. Unfortunately, ``$`` has a particular +meaning in the C++ regular-expression library. As such, ``$`` is unsuitable +for use in identifying special nodes, as our various node-finding capabilities +support the use of regular expressions.) + +For (2), GNDStk does as suggested, except again with the ``#`` terminology as +described above, and an all-lowercase name. Multiple elements of the same name +are suffixed with ``0``, ``1``, etc. Then, a JSON name/value pair with the +name ``#nodename`` is created. Its value preserves the original element's name. For (3), GNDStk does nothing in particular right now. Our understanding of GNDS is that it's designed so that elements -- nodes -- can appear in any order. @@ -509,7 +524,7 @@ GNDS file that we've been using for our examples: .. literalinclude:: tutorial/xml-axes-fragment.xml :language: xml -Those ``axis`` child nodes already contain a 0-based ``index`` attribute, so +Those ``axis`` child nodes already contain a 0-based ``index`` metadatum, so perhaps the specification's admonishment #3 is something we can consider to have been satisfied already by whomever has created an existing, valid GNDS file (so that no further treatment is required); or something that *we* must satisfy if @@ -549,8 +564,8 @@ node. (Valid GNDS top-level nodes, per the standard, are ``reactionSuite``, about it for now. Naturally, GNDStk reverses the modifications when we *read* from a JSON file -into our internal format. Specifically: values in an ``attributes`` block are -transformed into metadata in the enclosing node, and values from ``nodeName`` +into our internal format. Specifically: values in a ``#metadata`` block are +transformed into metadata in the enclosing node, and values from ``#nodename`` name/value pairs replace index-suffixed names. At this time, GNDStk provides no other options, such as the ``_attr`` suffix @@ -560,7 +575,7 @@ We're not aware, at the time of this writing, of the existence any official JSON-format GNDS files. If and when such files come into existence, and if such files use a different scheme than we do for addressing the issues described above, then we'll provide capabilities at least for reading those -files, and perhaps for writing them in that manner as well. +files, and perhaps for writing files in that manner as well. @@ -770,7 +785,7 @@ the top of the ``n-094_Pu_239.xml`` GNDS file: :language: xml Here, an outer ``evaluated`` node (XML "element") contains four metadata -key/value pairs (XML "attributes") and two child elements. The first child +key/value pairs (XML attributes) and two child elements. The first child element, ``temperature``, contains two metadata pairs but no further child nodes. The second child element, ``projectileEnergyDomain``, contains three metadata pairs but no further child nodes. diff --git a/docs/ref-core.rst b/docs/ref-core.rst index 76058e2da..a427144bd 100644 --- a/docs/ref-core.rst +++ b/docs/ref-core.rst @@ -28,5 +28,5 @@ Child ======================================== ======================================== -KeywordTup +KeyTuple ======================================== diff --git a/docs/tutorial/employees.json b/docs/tutorial/employees.json index 37bb8442b..98371f024 100644 --- a/docs/tutorial/employees.json +++ b/docs/tutorial/employees.json @@ -2,30 +2,30 @@ "employees": { "employee0": { "name": { - "attributes": { + "#metadata": { "first": "Doc", "last": "Jones" } }, - "nodeName": "employee" + "#nodename": "employee" }, "employee1": { "name": { - "attributes": { + "#metadata": { "first": "Grumpy", "last": "Smith" } }, - "nodeName": "employee" + "#nodename": "employee" }, "employee2": { "name": { - "attributes": { + "#metadata": { "first": "Happy", "last": "Earp" } }, - "nodeName": "employee" + "#nodename": "employee" } } -} \ No newline at end of file +} diff --git a/docs/tutorial/file-types.hpp b/docs/tutorial/file-types.hpp index df64dc575..1106d833b 100644 --- a/docs/tutorial/file-types.hpp +++ b/docs/tutorial/file-types.hpp @@ -1,6 +1,6 @@ enum class FileType { - null, // Default, automagick, etc. - tree, // <== DON't use this for reading; just writing + guess, // Default, automagick, etc. + debug, // <== DON't use this for reading; just writing // Generally use one of these: xml, XML = xml, json, JSON = json, diff --git a/python/runtests.sh b/python/runtests.sh index c94247071..00d375d4e 100755 --- a/python/runtests.sh +++ b/python/runtests.sh @@ -3,6 +3,6 @@ # this script copies the dynamic library for the GNDStk python module # and runs all the unit tests it can find -rm GNDStk.*.so -cp ../build/GNDStk.*.so . +rm GNDStk*.so +cp ../build/GNDStk*.so . python -m unittest discover -v -p "Test*" diff --git a/python/src/BoundaryCondition.python.cpp b/python/src/BoundaryCondition.python.cpp new file mode 100644 index 000000000..cee60c334 --- /dev/null +++ b/python/src/BoundaryCondition.python.cpp @@ -0,0 +1,37 @@ +// system includes +#include +#include + +// local includes +#include "GNDStk.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace core { + +void wrapBoundaryCondition( python::module& module ) { + + // type aliases + using Component = njoy::GNDStk::enums::BoundaryCondition; + + // wrap views created by this component + + // create the component + python::enum_< Component > component( + + module, + "BoundaryCondition", + "Enumeration class giving acceptable boundary condition values", + python::arithmetic() + ); + + // wrap the component + component + .value( "EliminateShiftFunction", Component::EliminateShiftFunction ) + .value( "NegativeOrbitalMomentum", Component::NegativeOrbitalMomentum ) + .value( "Brune", Component::Brune ) + .value( "Given", Component::Given ); +} + +} // namespace core diff --git a/python/src/ContributorType.python.cpp b/python/src/ContributorType.python.cpp new file mode 100644 index 000000000..23e12e45a --- /dev/null +++ b/python/src/ContributorType.python.cpp @@ -0,0 +1,54 @@ +// system includes +#include +#include + +// local includes +#include "GNDStk.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace core { + +void wrapContributorType( python::module& module ) { + + // type aliases + using Component = njoy::GNDStk::enums::ContributorType; + + // wrap views created by this component + + // create the component + python::enum_< Component > component( + + module, + "ContributorType", + "Enumeration class giving acceptable contributor type values", + python::arithmetic() + ); + + // wrap the component + component + .value( "ContactPerson", Component::ContactPerson ) + .value( "DataCollector", Component::DataCollector ) + .value( "DataCurator", Component::DataCurator ) + .value( "DataManager", Component::DataManager ) + .value( "Distributor", Component::Distributor ) + .value( "Editor", Component::Editor ) + .value( "HostingInstitution", Component::HostingInstitution ) + .value( "Producer", Component::Producer ) + .value( "ProjectLeader", Component::ProjectLeader ) + .value( "ProjectManager", Component::ProjectManager ) + .value( "ProjectMember", Component::ProjectMember ) + .value( "RegistrationAgency", Component::RegistrationAgency ) + .value( "RegistrationAuthority", Component::RegistrationAuthority ) + .value( "RelatedPerson", Component::RelatedPerson ) + .value( "Researcher", Component::Researcher ) + .value( "ResearchGroup", Component::ResearchGroup ) + .value( "RightsHolder", Component::RightsHolder ) + .value( "Sponsor", Component::Sponsor ) + .value( "Supervisor", Component::Supervisor ) + .value( "WorkPackageLeader", Component::WorkPackageLeader ) + .value( "Other", Component::Other ); +} + +} // namespace core diff --git a/python/src/DateType.python.cpp b/python/src/DateType.python.cpp new file mode 100644 index 000000000..8d3d7964f --- /dev/null +++ b/python/src/DateType.python.cpp @@ -0,0 +1,43 @@ +// system includes +#include +#include + +// local includes +#include "GNDStk.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace core { + +void wrapDateType( python::module& module ) { + + // type aliases + using Component = njoy::GNDStk::enums::DateType; + + // wrap views created by this component + + // create the component + python::enum_< Component > component( + + module, + "DateType", + "Enumeration class giving acceptable date type values", + python::arithmetic() + ); + + // wrap the component + component + .value( "accepted", Component::accepted ) + .value( "available", Component::available ) + .value( "copyrighted", Component::copyrighted ) + .value( "collected", Component::collected ) + .value( "created", Component::created ) + .value( "issued", Component::issued ) + .value( "submitted", Component::submitted ) + .value( "updated", Component::updated ) + .value( "valid", Component::valid ) + .value( "withdrawn", Component::withdrawn ); +} + +} // namespace core diff --git a/python/src/DecayType.python.cpp b/python/src/DecayType.python.cpp new file mode 100644 index 000000000..19d837a40 --- /dev/null +++ b/python/src/DecayType.python.cpp @@ -0,0 +1,45 @@ +// system includes +#include +#include + +// local includes +#include "GNDStk.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace core { + +void wrapDecayType( python::module& module ) { + + // type aliases + using Component = njoy::GNDStk::enums::DecayType; + + // wrap views created by this component + + // create the component + python::enum_< Component > component( + + module, + "DecayType", + "Enumeration class giving acceptable decay type values", + python::arithmetic() + ); + + // wrap the component + component + .value( "SF", Component::SpontaneousFission ) + .value( "beta-", Component::BetaMinus ) + .value( "beta+", Component::BetaPlus ) + .value( "EC", Component::ElectronCapture ) + .value( "electroMagnetic", Component::ElectroMagnetic ) + .value( "IT", Component::IsomericTransition ) + .value( "n", Component::Neutron ) + .value( "p", Component::Proton ) + .value( "d", Component::Deuteron ) + .value( "t", Component::Triton ) + .value( "alpha", Component::Alpha ) + .value( "atomicRelaxation", Component::AtomicRelaxation ); +} + +} // namespace core diff --git a/python/src/Frame.python.cpp b/python/src/Frame.python.cpp new file mode 100644 index 000000000..8585f03f8 --- /dev/null +++ b/python/src/Frame.python.cpp @@ -0,0 +1,35 @@ +// system includes +#include +#include + +// local includes +#include "GNDStk.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace core { + +void wrapFrame( python::module& module ) { + + // type aliases + using Component = njoy::GNDStk::enums::Frame; + + // wrap views created by this component + + // create the component + python::enum_< Component > component( + + module, + "Frame", + "Enumeration class giving acceptable reference frame values", + python::arithmetic() + ); + + // wrap the component + component + .value( "lab", Component::lab ) + .value( "centerOfMass", Component::centerOfMass ); +} + +} // namespace core diff --git a/python/src/GNDStk.python.cpp b/python/src/GNDStk.python.cpp index 2a0ec7ad4..4cba436ab 100644 --- a/python/src/GNDStk.python.cpp +++ b/python/src/GNDStk.python.cpp @@ -12,8 +12,18 @@ namespace core { void wrapNode( python::module& ); + void wrapContributorType( python::module& ); + void wrapDateType( python::module& ); + void wrapDecayType( python::module& ); + void wrapFrame( python::module& ); void wrapGridStyle( python::module& ); + void wrapHashAlgorithm( python::module& ); + void wrapInteraction( python::module& ); void wrapInterpolation( python::module& ); + void wrapInterpolationQualifier( python::module& ); + void wrapParity( python::module& ); + void wrapRelationType( python::module& ); + void wrapBoundaryCondition( python::module& ); } // v1.9 interface declarations @@ -22,6 +32,12 @@ namespace python_v1_9 { void wrapGNDS( python::module& ); } +// v2.0 interface declarations +namespace python_v2_0 { + + void wrapGNDS( python::module& ); +} + /** * @brief GNDStk python bindings * @@ -41,9 +57,22 @@ PYBIND11_MODULE( GNDStk, module ) { core::wrapNode( submodule ); // enumerations (in the GNDStk module) + core::wrapContributorType( module ); + core::wrapDateType( module ); + core::wrapDecayType( module ); + core::wrapFrame( module ); core::wrapGridStyle( module ); + core::wrapHashAlgorithm( module ); + core::wrapInteraction( module ); core::wrapInterpolation( module ); + core::wrapInterpolationQualifier( module ); + core::wrapParity( module ); + core::wrapRelationType( module ); + core::wrapBoundaryCondition( module ); // v1.9 components (in the v1_9 module, created in this function) python_v1_9::wrapGNDS( module ); + + // v2.0 components (in the v2_0 module, created in this function) + python_v2_0::wrapGNDS( module ); } diff --git a/python/src/HashAlgorithm.python.cpp b/python/src/HashAlgorithm.python.cpp new file mode 100644 index 000000000..e453fb3f9 --- /dev/null +++ b/python/src/HashAlgorithm.python.cpp @@ -0,0 +1,35 @@ +// system includes +#include +#include + +// local includes +#include "GNDStk.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace core { + +void wrapHashAlgorithm( python::module& module ) { + + // type aliases + using Component = njoy::GNDStk::enums::HashAlgorithm; + + // wrap views created by this component + + // create the component + python::enum_< Component > component( + + module, + "HashAlgorithm", + "Enumeration class giving acceptable hash algorithm values", + python::arithmetic() + ); + + // wrap the component + component + .value( "md5", Component::md5 ) + .value( "sha1", Component::sha1 ); +} + +} // namespace core diff --git a/python/src/Interaction.python.cpp b/python/src/Interaction.python.cpp new file mode 100644 index 000000000..693f60f45 --- /dev/null +++ b/python/src/Interaction.python.cpp @@ -0,0 +1,36 @@ +// system includes +#include +#include + +// local includes +#include "GNDStk.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace core { + +void wrapInteraction( python::module& module ) { + + // type aliases + using Component = njoy::GNDStk::enums::Interaction; + + // wrap views created by this component + + // create the component + python::enum_< Component > component( + + module, + "Interaction", + "Enumeration class giving acceptable interaction type values", + python::arithmetic() + ); + + // wrap the component + component + .value( "nuclear", Component::nuclear ) + .value( "atomic", Component::atomic ) + .value( "thermalNeutronScatteringLaw", Component::thermalNeutronScatteringLaw ); +} + +} // namespace core diff --git a/python/src/InterpolationQualifier.python.cpp b/python/src/InterpolationQualifier.python.cpp new file mode 100644 index 000000000..ef1148e6f --- /dev/null +++ b/python/src/InterpolationQualifier.python.cpp @@ -0,0 +1,37 @@ +// system includes +#include +#include + +// local includes +#include "GNDStk.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace core { + +void wrapInterpolationQualifier( python::module& module ) { + + // type aliases + using Component = njoy::GNDStk::enums::InterpolationQualifier; + + // wrap views created by this component + + // create the component + python::enum_< Component > component( + + module, + "InterpolationQualifier", + "Enumeration class giving acceptable interpolation qualifier values", + python::arithmetic() + ); + + // wrap the component + component + .value( "direct", Component::direct ) + .value( "unitBase", Component::unitBase ) + .value( "correspondingEnergies", Component::correspondingEnergies ) + .value( "correspondingPoints", Component::correspondingPoints ); +} + +} // namespace core diff --git a/python/src/Parity.python.cpp b/python/src/Parity.python.cpp new file mode 100644 index 000000000..001109c90 --- /dev/null +++ b/python/src/Parity.python.cpp @@ -0,0 +1,35 @@ +// system includes +#include +#include + +// local includes +#include "GNDStk.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace core { + +void wrapParity( python::module& module ) { + + // type aliases + using Component = njoy::GNDStk::enums::Parity; + + // wrap views created by this component + + // create the component + python::enum_< Component > component( + + module, + "Parity", + "Enumeration class giving acceptable parity values", + python::arithmetic() + ); + + // wrap the component + component + .value( "minus", Component::minus ) + .value( "plus", Component::plus ); +} + +} // namespace core diff --git a/python/src/RelationType.python.cpp b/python/src/RelationType.python.cpp new file mode 100644 index 000000000..068442a18 --- /dev/null +++ b/python/src/RelationType.python.cpp @@ -0,0 +1,67 @@ +// system includes +#include +#include + +// local includes +#include "GNDStk.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace core { + +void wrapRelationType( python::module& module ) { + + // type aliases + using Component = njoy::GNDStk::enums::RelationType; + + // wrap views created by this component + + // create the component + python::enum_< Component > component( + + module, + "RelationType", + "Enumeration class giving acceptable relation type values", + python::arithmetic() + ); + + // wrap the component + component + .value( "IsCitedBy", Component::IsCitedBy ) + .value( "Cites", Component::Cites ) + .value( "IsSupplementTo", Component::IsSupplementTo ) + .value( "IsSupplementedBy", Component::IsSupplementedBy ) + .value( "IsContinuedBy", Component::IsContinuedBy ) + .value( "Continues", Component::Continues ) + .value( "Describes", Component::Describes ) + .value( "IsDescribedBy", Component::IsDescribedBy ) + .value( "HasMetadata", Component::HasMetadata ) + .value( "IsMetadataFor", Component::IsMetadataFor ) + .value( "HasVersion", Component::HasVersion ) + .value( "IsVersionOf", Component::IsVersionOf ) + .value( "IsNewVersionOf", Component::IsNewVersionOf ) + .value( "IsPreviousVersionOf", Component::IsPreviousVersionOf ) + .value( "IsPartOf", Component::IsPartOf ) + .value( "HasPart", Component::HasPart ) + .value( "IsPublishedIn", Component::IsPublishedIn ) + .value( "IsReferencedBy", Component::IsReferencedBy ) + .value( "References", Component::References ) + .value( "IsDocumentedBy", Component::IsDocumentedBy ) + .value( "Documents", Component::Documents ) + .value( "IsCompiledBy", Component::IsCompiledBy ) + .value( "Compiles", Component::Compiles ) + .value( "IsVariantFormOf", Component::IsVariantFormOf ) + .value( "IsOriginalFormOf", Component::IsOriginalFormOf ) + .value( "IsIdenticalTo", Component::IsIdenticalTo ) + .value( "IsReviewedBy", Component::IsReviewedBy ) + .value( "Reviews", Component::Reviews ) + .value( "IsDerivedFrom", Component::IsDerivedFrom ) + .value( "IsSourceOf", Component::IsSourceOf ) + .value( "IsRequiredBy", Component::IsRequiredBy ) + .value( "Requires", Component::Requires ) + .value( "Obsoletes", Component::Obsoletes ) + .value( "IsObsoletedBy", Component::IsObsoletedBy ); +} + +} // namespace core diff --git a/python/src/core/Node.python.cpp b/python/src/core/Node.python.cpp index ff2e7f377..05a6d677a 100644 --- a/python/src/core/Node.python.cpp +++ b/python/src/core/Node.python.cpp @@ -13,7 +13,7 @@ namespace core { void wrapNode( python::module& module ) { // type aliases - using Component = njoy::GNDStk::core::Node; + using Component = njoy::GNDStk::Node; using ConstRefComponent = std::reference_wrapper< const Component >; // create the core component diff --git a/python/src/definitions.hpp b/python/src/definitions.hpp index 230bd1d99..8e9b91e7a 100644 --- a/python/src/definitions.hpp +++ b/python/src/definitions.hpp @@ -37,7 +37,7 @@ void addStandardComponentDefinitions( PythonClass& component ) { "from_string", [] ( const std::string& string ) -> Component { - using namespace njoy::GNDStk::core; + using namespace njoy::GNDStk; Node node; node << string; @@ -45,7 +45,7 @@ void addStandardComponentDefinitions( PythonClass& component ) { return Component( node ); }, python::arg( "string" ), - "Read the component from an XML or json string\n\n" + "Read the component from an XML or JSON string\n\n" "An exception is raised if something goes wrong while reading the\n" "component\n\n" "Arguments:\n" @@ -56,7 +56,7 @@ void addStandardComponentDefinitions( PythonClass& component ) { "to_xml_string", [] ( const Component& self ) -> std::string { - using namespace njoy::GNDStk::core; + using namespace njoy::GNDStk; std::ostringstream out; XML( Node( self ) ).write( out, false ); @@ -72,7 +72,7 @@ void addStandardComponentDefinitions( PythonClass& component ) { "to_xml_file", [] ( const Component& self, const std::string& fileName ) { - using namespace njoy::GNDStk::core; + using namespace njoy::GNDStk; XML( Node( self ) ).write( fileName ); }, diff --git a/python/src/v1.9/containers.python.cpp b/python/src/v1.9/containers.python.cpp deleted file mode 100644 index 31ab9e593..000000000 --- a/python/src/v1.9/containers.python.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// THIS FILE WAS AUTOGENERATED! -// DO NOT MODIFY! - -#include -#include - -namespace python = pybind11; - -// v1.9 interface -namespace python_v1_9 { - -// containers declarations -namespace python_containers { - void wrapAxis(python::module &); - void wrapLink(python::module &); - void wrapValues(python::module &); - void wrapGrid(python::module &); - void wrapAxes(python::module &); - void wrapXYs1d(python::module &); - void wrapRegions1d(python::module &); -} // namespace python_containers - -// containers wrapper -void wrapContainers(python::module &module) -{ - // create the containers submodule - python::module submodule = module.def_submodule( - "containers", - "GNDS v1.9 containers" - ); - - // wrap containers components - python_containers::wrapAxis(submodule); - python_containers::wrapLink(submodule); - python_containers::wrapValues(submodule); - python_containers::wrapGrid(submodule); - python_containers::wrapAxes(submodule); - python_containers::wrapXYs1d(submodule); - python_containers::wrapRegions1d(submodule); -}; - -} // namespace python_v1_9 diff --git a/python/src/v1.9/containers/Axes.python.cpp b/python/src/v1.9/containers/Axes.python.cpp deleted file mode 100644 index b3bebd4f9..000000000 --- a/python/src/v1.9/containers/Axes.python.cpp +++ /dev/null @@ -1,67 +0,0 @@ - -// THIS FILE WAS AUTOGENERATED! -// DO NOT MODIFY! - -// system includes -#include -#include - -// local includes -#include "GNDStk/v1.9/containers/Axes.hpp" -#include "definitions.hpp" - -// namespace aliases -namespace python = pybind11; - -namespace python_v1_9 { -namespace python_containers { - -// Axes wrapper -void wrapAxes(python::module &module) -{ - using namespace njoy::GNDStk; - using namespace njoy::GNDStk::v1_9; - - // type aliases - using Component = containers::Axes; - using axis_grid_t = std::variant< - containers::Axis, - containers::Grid - >; - - // create the component - python::class_ component( - module, - "Axes", - Component::documentation().data() - ); - - // wrap the component - component - .def( - python::init< - const std::optional &, - const std::vector & - >(), - python::arg("href") = std::nullopt, - python::arg("axis_grid"), - Component::documentation("constructor").data() - ) - .def_property_readonly( - "href", - &Component::href, - Component::documentation("href").data() - ) - .def_property_readonly( - "axis_grid", - python::overload_cast<>(&Component::axis_grid), - Component::documentation("axis_grid").data() - ) - ; - - // add standard component definitions - addStandardComponentDefinitions< Component >( component ); -} - -} // namespace python_containers -} // namespace python_v1_9 diff --git a/python/src/v1.9/containers/Axis.python.cpp b/python/src/v1.9/containers/Axis.python.cpp deleted file mode 100644 index 9fe2bd62f..000000000 --- a/python/src/v1.9/containers/Axis.python.cpp +++ /dev/null @@ -1,70 +0,0 @@ - -// THIS FILE WAS AUTOGENERATED! -// DO NOT MODIFY! - -// system includes -#include -#include - -// local includes -#include "GNDStk/v1.9/containers/Axis.hpp" -#include "definitions.hpp" - -// namespace aliases -namespace python = pybind11; - -namespace python_v1_9 { -namespace python_containers { - -// Axis wrapper -void wrapAxis(python::module &module) -{ - using namespace njoy::GNDStk; - using namespace njoy::GNDStk::v1_9; - - // type aliases - using Component = containers::Axis; - - // create the component - python::class_ component( - module, - "Axis", - Component::documentation().data() - ); - - // wrap the component - component - .def( - python::init< - const std::optional &, - const std::optional &, - const std::optional & - >(), - python::arg("index") = std::nullopt, - python::arg("label") = std::nullopt, - python::arg("unit") = std::nullopt, - Component::documentation("constructor").data() - ) - .def_property_readonly( - "index", - &Component::index, - Component::documentation("index").data() - ) - .def_property_readonly( - "label", - &Component::label, - Component::documentation("label").data() - ) - .def_property_readonly( - "unit", - &Component::unit, - Component::documentation("unit").data() - ) - ; - - // add standard component definitions - addStandardComponentDefinitions< Component >( component ); -} - -} // namespace python_containers -} // namespace python_v1_9 diff --git a/python/src/v1.9/containers/Grid.python.cpp b/python/src/v1.9/containers/Grid.python.cpp deleted file mode 100644 index e8556d74e..000000000 --- a/python/src/v1.9/containers/Grid.python.cpp +++ /dev/null @@ -1,105 +0,0 @@ - -// THIS FILE WAS AUTOGENERATED! -// DO NOT MODIFY! - -// system includes -#include -#include - -// local includes -#include "GNDStk/v1.9/containers/Grid.hpp" -#include "definitions.hpp" - -// namespace aliases -namespace python = pybind11; - -namespace python_v1_9 { -namespace python_containers { - -// Grid wrapper -void wrapGrid(python::module &module) -{ - using namespace njoy::GNDStk; - using namespace njoy::GNDStk::v1_9; - - // type aliases - using Component = containers::Grid; - using link_values_t = std::variant< - containers::Link, - containers::Values - >; - - // create the component - python::class_ component( - module, - "Grid", - Component::documentation().data() - ); - - // wrap the component - component - .def( - python::init< - const std::optional &, - const std::optional &, - const std::optional &, - const std::optional &, - const std::optional &, - const link_values_t & - >(), - python::arg("index") = std::nullopt, - python::arg("interpolation") = std::nullopt, - python::arg("label") = std::nullopt, - python::arg("style") = std::nullopt, - python::arg("unit") = std::nullopt, - python::arg("link_values"), - Component::documentation("constructor").data() - ) - .def_property_readonly( - "index", - &Component::index, - Component::documentation("index").data() - ) - .def_property_readonly( - "interpolation", - [](const Component &self) { return self.interpolation().value(); }, - Component::documentation("interpolation").data() - ) - .def_property_readonly( - "label", - &Component::label, - Component::documentation("label").data() - ) - .def_property_readonly( - "style", - &Component::style, - Component::documentation("style").data() - ) - .def_property_readonly( - "unit", - &Component::unit, - Component::documentation("unit").data() - ) - .def_property_readonly( - "link", - python::overload_cast<>(&Component::link), - Component::documentation("link").data() - ) - .def_property_readonly( - "values", - python::overload_cast<>(&Component::values), - Component::documentation("values").data() - ) - .def_property_readonly( - "link_values", - python::overload_cast<>(&Component::link_values), - Component::documentation("link_values").data() - ) - ; - - // add standard component definitions - addStandardComponentDefinitions< Component >( component ); -} - -} // namespace python_containers -} // namespace python_v1_9 diff --git a/python/src/v1.9/containers/Link.python.cpp b/python/src/v1.9/containers/Link.python.cpp deleted file mode 100644 index fd9ea1411..000000000 --- a/python/src/v1.9/containers/Link.python.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -// THIS FILE WAS AUTOGENERATED! -// DO NOT MODIFY! - -// system includes -#include -#include - -// local includes -#include "GNDStk/v1.9/containers/Link.hpp" -#include "definitions.hpp" - -// namespace aliases -namespace python = pybind11; - -namespace python_v1_9 { -namespace python_containers { - -// Link wrapper -void wrapLink(python::module &module) -{ - using namespace njoy::GNDStk; - using namespace njoy::GNDStk::v1_9; - - // type aliases - using Component = containers::Link; - - // create the component - python::class_ component( - module, - "Link", - Component::documentation().data() - ); - - // wrap the component - component - .def( - python::init< - const std::string & - >(), - python::arg("href"), - Component::documentation("constructor").data() - ) - .def_property_readonly( - "href", - &Component::href, - Component::documentation("href").data() - ) - ; - - // add standard component definitions - addStandardComponentDefinitions< Component >( component ); -} - -} // namespace python_containers -} // namespace python_v1_9 diff --git a/python/src/v1.9/containers/Regions1d.python.cpp b/python/src/v1.9/containers/Regions1d.python.cpp deleted file mode 100644 index 35ab3052f..000000000 --- a/python/src/v1.9/containers/Regions1d.python.cpp +++ /dev/null @@ -1,77 +0,0 @@ - -// THIS FILE WAS AUTOGENERATED! -// DO NOT MODIFY! - -// system includes -#include -#include - -// local includes -#include "GNDStk/v1.9/containers/Regions1d.hpp" -#include "definitions.hpp" - -// namespace aliases -namespace python = pybind11; - -namespace python_v1_9 { -namespace python_containers { - -// Regions1d wrapper -void wrapRegions1d(python::module &module) -{ - using namespace njoy::GNDStk; - using namespace njoy::GNDStk::v1_9; - - // type aliases - using Component = containers::Regions1d; - - // create the component - python::class_ component( - module, - "Regions1d", - Component::documentation().data() - ); - - // wrap the component - component - .def( - python::init< - const std::optional &, - const std::optional &, - const std::vector &, - const std::optional & - >(), - python::arg("label") = std::nullopt, - python::arg("outer_domain_value") = std::nullopt, - python::arg("xys1d"), - python::arg("axes") = std::nullopt, - Component::documentation("constructor").data() - ) - .def_property_readonly( - "label", - &Component::label, - Component::documentation("label").data() - ) - .def_property_readonly( - "outer_domain_value", - &Component::outerDomainValue, - Component::documentation("outer_domain_value").data() - ) - .def_property_readonly( - "xys1d", - python::overload_cast<>(&Component::XYs1d), - Component::documentation("xys1d").data() - ) - .def_property_readonly( - "axes", - python::overload_cast<>(&Component::axes), - Component::documentation("axes").data() - ) - ; - - // add standard component definitions - addStandardComponentDefinitions< Component >( component ); -} - -} // namespace python_containers -} // namespace python_v1_9 diff --git a/python/src/v1.9/containers/Values.python.cpp b/python/src/v1.9/containers/Values.python.cpp deleted file mode 100644 index b9c28e406..000000000 --- a/python/src/v1.9/containers/Values.python.cpp +++ /dev/null @@ -1,106 +0,0 @@ - -// THIS FILE WAS AUTOGENERATED! -// DO NOT MODIFY! - -// system includes -#include -#include - -// local includes -#include "GNDStk/v1.9/containers/Values.hpp" -#include "definitions.hpp" - -// namespace aliases -namespace python = pybind11; - -namespace python_v1_9 { -namespace python_containers { - -// Values wrapper -void wrapValues(python::module &module) -{ - using namespace njoy::GNDStk; - using namespace njoy::GNDStk::v1_9; - - // type aliases - using Component = containers::Values; - - // create the component - python::class_ component( - module, - "Values", - Component::documentation().data() - ); - - // wrap the component - component - .def( - python::init< - const std::optional &, - const std::optional &, - const std::optional & - >(), - python::arg("length") = std::nullopt, - python::arg("start") = std::nullopt, - python::arg("value_type") = std::nullopt, - Component::documentation("constructor").data() - ) - .def( - python::init< - const std::vector & - >(), - python::arg("ints"), - Component::documentation("constructor").data() - ) - .def( - python::init< - const std::vector & - >(), - python::arg("doubles"), - Component::documentation("constructor").data() - ) - .def( - python::init< - const std::vector & - >(), - python::arg("strings"), - Component::documentation("constructor").data() - ) - .def_property_readonly( - "length", - &Component::length, - Component::documentation("length").data() - ) - .def_property_readonly( - "start", - [](const Component &self) { return self.start().value(); }, - Component::documentation("start").data() - ) - .def_property_readonly( - "value_type", - [](const Component &self) { return self.valueType().value(); }, - Component::documentation("value_type").data() - ) - .def_property_readonly( - "ints", - [] (const Component &self) { return self.ints(); }, - Component::documentation("ints").data() - ) - .def_property_readonly( - "doubles", - [] (const Component &self) { return self.doubles(); }, - Component::documentation("doubles").data() - ) - .def_property_readonly( - "strings", - [] (const Component &self) { return self.strings(); }, - Component::documentation("strings").data() - ) - ; - - // add standard component definitions - addStandardComponentDefinitions< Component >( component ); -} - -} // namespace python_containers -} // namespace python_v1_9 diff --git a/python/src/v1.9/containers/XYs1d.python.cpp b/python/src/v1.9/containers/XYs1d.python.cpp deleted file mode 100644 index 9f231399f..000000000 --- a/python/src/v1.9/containers/XYs1d.python.cpp +++ /dev/null @@ -1,91 +0,0 @@ - -// THIS FILE WAS AUTOGENERATED! -// DO NOT MODIFY! - -// system includes -#include -#include - -// local includes -#include "GNDStk/v1.9/containers/XYs1d.hpp" -#include "definitions.hpp" - -// namespace aliases -namespace python = pybind11; - -namespace python_v1_9 { -namespace python_containers { - -// XYs1d wrapper -void wrapXYs1d(python::module &module) -{ - using namespace njoy::GNDStk; - using namespace njoy::GNDStk::v1_9; - - // type aliases - using Component = containers::XYs1d; - - // create the component - python::class_ component( - module, - "XYs1d", - Component::documentation().data() - ); - - // wrap the component - component - .def( - python::init< - const std::optional &, - const std::optional &, - const std::optional &, - const std::optional &, - const std::optional &, - const containers::Values & - >(), - python::arg("index") = std::nullopt, - python::arg("interpolation") = std::nullopt, - python::arg("label") = std::nullopt, - python::arg("outer_domain_value") = std::nullopt, - python::arg("axes") = std::nullopt, - python::arg("values"), - Component::documentation("constructor").data() - ) - .def_property_readonly( - "index", - &Component::index, - Component::documentation("index").data() - ) - .def_property_readonly( - "interpolation", - [](const Component &self) { return self.interpolation().value(); }, - Component::documentation("interpolation").data() - ) - .def_property_readonly( - "label", - &Component::label, - Component::documentation("label").data() - ) - .def_property_readonly( - "outer_domain_value", - &Component::outerDomainValue, - Component::documentation("outer_domain_value").data() - ) - .def_property_readonly( - "axes", - python::overload_cast<>(&Component::axes), - Component::documentation("axes").data() - ) - .def_property_readonly( - "values", - python::overload_cast<>(&Component::values), - Component::documentation("values").data() - ) - ; - - // add standard component definitions - addStandardComponentDefinitions< Component >( component ); -} - -} // namespace python_containers -} // namespace python_v1_9 diff --git a/python/src/v1.9/transport.python.cpp b/python/src/v1.9/transport.python.cpp deleted file mode 100644 index 631a859bf..000000000 --- a/python/src/v1.9/transport.python.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -// THIS FILE WAS AUTOGENERATED! -// DO NOT MODIFY! - -#include -#include - -namespace python = pybind11; - -// v1.9 interface -namespace python_v1_9 { - -// transport declarations -namespace python_transport { - void wrapCrossSection(python::module &); - void wrapReaction(python::module &); - void wrapReactions(python::module &); - void wrapReactionSuite(python::module &); -} // namespace python_transport - -// transport wrapper -void wrapTransport(python::module &module) -{ - // create the transport submodule - python::module submodule = module.def_submodule( - "transport", - "GNDS v1.9 transport" - ); - - // wrap transport components - python_transport::wrapCrossSection(submodule); - python_transport::wrapReaction(submodule); - python_transport::wrapReactions(submodule); - python_transport::wrapReactionSuite(submodule); -}; - -} // namespace python_v1_9 diff --git a/python/src/v1.9/transport/CrossSection.python.cpp b/python/src/v1.9/transport/CrossSection.python.cpp deleted file mode 100644 index 4bb4c39c2..000000000 --- a/python/src/v1.9/transport/CrossSection.python.cpp +++ /dev/null @@ -1,60 +0,0 @@ - -// THIS FILE WAS AUTOGENERATED! -// DO NOT MODIFY! - -// system includes -#include -#include - -// local includes -#include "GNDStk/v1.9/transport/CrossSection.hpp" -#include "definitions.hpp" - -// namespace aliases -namespace python = pybind11; - -namespace python_v1_9 { -namespace python_transport { - -// CrossSection wrapper -void wrapCrossSection(python::module &module) -{ - using namespace njoy::GNDStk; - using namespace njoy::GNDStk::v1_9; - - // type aliases - using Component = transport::CrossSection; - using XYs1d_regions1d_t = std::variant< - containers::XYs1d, - containers::Regions1d - >; - - // create the component - python::class_ component( - module, - "CrossSection", - Component::documentation().data() - ); - - // wrap the component - component - .def( - python::init< - const std::vector & - >(), - python::arg("xys1d_regions1d"), - Component::documentation("constructor").data() - ) - .def_property_readonly( - "xys1d_regions1d", - python::overload_cast<>(&Component::XYs1d_regions1d), - Component::documentation("xys1d_regions1d").data() - ) - ; - - // add standard component definitions - addStandardComponentDefinitions< Component >( component ); -} - -} // namespace python_transport -} // namespace python_v1_9 diff --git a/python/src/v1.9/transport/Reaction.python.cpp b/python/src/v1.9/transport/Reaction.python.cpp deleted file mode 100644 index c034610a2..000000000 --- a/python/src/v1.9/transport/Reaction.python.cpp +++ /dev/null @@ -1,77 +0,0 @@ - -// THIS FILE WAS AUTOGENERATED! -// DO NOT MODIFY! - -// system includes -#include -#include - -// local includes -#include "GNDStk/v1.9/transport/Reaction.hpp" -#include "definitions.hpp" - -// namespace aliases -namespace python = pybind11; - -namespace python_v1_9 { -namespace python_transport { - -// Reaction wrapper -void wrapReaction(python::module &module) -{ - using namespace njoy::GNDStk; - using namespace njoy::GNDStk::v1_9; - - // type aliases - using Component = transport::Reaction; - - // create the component - python::class_ component( - module, - "Reaction", - Component::documentation().data() - ); - - // wrap the component - component - .def( - python::init< - const int &, - const std::optional &, - const std::string &, - const transport::CrossSection & - >(), - python::arg("endf_mt"), - python::arg("fission_genre") = std::nullopt, - python::arg("label"), - python::arg("cross_section"), - Component::documentation("constructor").data() - ) - .def_property_readonly( - "endf_mt", - &Component::ENDF_MT, - Component::documentation("endf_mt").data() - ) - .def_property_readonly( - "fission_genre", - &Component::fissionGenre, - Component::documentation("fission_genre").data() - ) - .def_property_readonly( - "label", - &Component::label, - Component::documentation("label").data() - ) - .def_property_readonly( - "cross_section", - python::overload_cast<>(&Component::crossSection), - Component::documentation("cross_section").data() - ) - ; - - // add standard component definitions - addStandardComponentDefinitions< Component >( component ); -} - -} // namespace python_transport -} // namespace python_v1_9 diff --git a/python/src/v1.9/transport/ReactionSuite.python.cpp b/python/src/v1.9/transport/ReactionSuite.python.cpp deleted file mode 100644 index 664310fc2..000000000 --- a/python/src/v1.9/transport/ReactionSuite.python.cpp +++ /dev/null @@ -1,115 +0,0 @@ - -// THIS FILE WAS AUTOGENERATED! -// DO NOT MODIFY! - -// system includes -#include -#include - -// local includes -#include "GNDStk/v1.9/transport/ReactionSuite.hpp" -#include "definitions.hpp" - -// namespace aliases -namespace python = pybind11; - -namespace python_v1_9 { -namespace python_transport { - -// ReactionSuite wrapper -void wrapReactionSuite(python::module &module) -{ - using namespace njoy::GNDStk; - using namespace njoy::GNDStk::v1_9; - - // type aliases - using Component = transport::ReactionSuite; - - // create the component - python::class_ component( - module, - "ReactionSuite", - Component::documentation().data() - ); - - // wrap the component - component - .def( - python::init< - const std::string &, - const std::string &, - const std::optional &, - const std::string &, - const enums::Frame &, - const std::string &, - const std::optional & - >(), - python::arg("evaluation"), - python::arg("format"), - python::arg("interaction") = std::nullopt, - python::arg("projectile"), - python::arg("projectile_frame"), - python::arg("target"), - python::arg("reactions") = std::nullopt, - Component::documentation("constructor").data() - ) - .def_property_readonly( - "evaluation", - &Component::evaluation, - Component::documentation("evaluation").data() - ) - .def_property_readonly( - "format", - &Component::format, - Component::documentation("format").data() - ) - .def_property_readonly( - "interaction", - &Component::interaction, - Component::documentation("interaction").data() - ) - .def_property_readonly( - "projectile", - &Component::projectile, - Component::documentation("projectile").data() - ) - .def_property_readonly( - "projectile_frame", - &Component::projectileFrame, - Component::documentation("projectile_frame").data() - ) - .def_property_readonly( - "target", - &Component::target, - Component::documentation("target").data() - ) - .def_property_readonly( - "reactions", - python::overload_cast<>(&Component::reactions), - Component::documentation("reactions").data() - ) - .def_static( - - "from_file", - [] ( const std::string& filename ) -> Component { - - using namespace njoy::GNDStk::core; - Tree tree( filename ); - - return Component( tree( child::reactionSuite ) ); - }, - python::arg( "filename" ), - "Read a reaction suite from an XML or json file\n\n" - "An exception is raised if something goes wrong while reading the\n" - "component\n\n" - "Arguments:\n" - " filename the name of the file" - ) - ; - - // add standard component definitions - addStandardComponentDefinitions< Component >( component ); -} - -} // namespace python_transport -} // namespace python_v1_9 diff --git a/python/src/v1.9/transport/Reactions.python.cpp b/python/src/v1.9/transport/Reactions.python.cpp deleted file mode 100644 index a32c28b59..000000000 --- a/python/src/v1.9/transport/Reactions.python.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -// THIS FILE WAS AUTOGENERATED! -// DO NOT MODIFY! - -// system includes -#include -#include - -// local includes -#include "GNDStk/v1.9/transport/Reactions.hpp" -#include "definitions.hpp" - -// namespace aliases -namespace python = pybind11; - -namespace python_v1_9 { -namespace python_transport { - -// Reactions wrapper -void wrapReactions(python::module &module) -{ - using namespace njoy::GNDStk; - using namespace njoy::GNDStk::v1_9; - - // type aliases - using Component = transport::Reactions; - - // create the component - python::class_ component( - module, - "Reactions", - Component::documentation().data() - ); - - // wrap the component - component - .def( - python::init< - const std::vector & - >(), - python::arg("reaction"), - Component::documentation("constructor").data() - ) - .def_property_readonly( - "reaction", - python::overload_cast<>(&Component::reaction), - Component::documentation("reaction").data() - ) - ; - - // add standard component definitions - addStandardComponentDefinitions< Component >( component ); -} - -} // namespace python_transport -} // namespace python_v1_9 diff --git a/python/src/v2.0/GNDS.python.cpp b/python/src/v2.0/GNDS.python.cpp new file mode 100644 index 000000000..ea02d1ce9 --- /dev/null +++ b/python/src/v2.0/GNDS.python.cpp @@ -0,0 +1,37 @@ +// system includes +#include +#include + +// other includes + +// namespace aliases +namespace python = pybind11; + +// v2.0 interface declarations +namespace python_v2_0 { + + void wrapContainers( python::module& ); + void wrapFpy( python::module& ); + void wrapFissionFragmentData( python::module& ); + void wrapPops( python::module& ); + void wrapResonances( python::module& ); +} + +namespace python_v2_0 { + + void wrapGNDS( python::module& module ) { + + // create the core submodule + python::module submodule = module.def_submodule( + + "v2_0", + "GNDS 2.0 standard components" + ); + + python_v2_0::wrapContainers( submodule ); + python_v2_0::wrapFpy( submodule ); + python_v2_0::wrapFissionFragmentData( submodule ); + python_v2_0::wrapPops( submodule ); + python_v2_0::wrapResonances( submodule ); + } +} // v2_0 namespace diff --git a/python/src/v2.0/abstract.python.cpp b/python/src/v2.0/abstract.python.cpp new file mode 100644 index 000000000..b159ad793 --- /dev/null +++ b/python/src/v2.0/abstract.python.cpp @@ -0,0 +1,37 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include +#include + +namespace python = pybind11; + +// v2.0 interface +namespace python_v2_0 { + +// abstract declarations +namespace python_abstract { + void wrapFunctional(python::module &); + void wrapLabel(python::module &); + void wrapPhysicalQuantity(python::module &); + void wrapText(python::module &); +} // namespace python_abstract + +// abstract wrapper +void wrapAbstract(python::module &module) +{ + // create the abstract submodule + python::module submodule = module.def_submodule( + "abstract", + "GNDS v2.0 abstract" + ); + + // wrap abstract components + python_abstract::wrapFunctional(submodule); + python_abstract::wrapLabel(submodule); + python_abstract::wrapPhysicalQuantity(submodule); + python_abstract::wrapText(submodule); +}; + +} // namespace python_v2_0 diff --git a/python/src/v2.0/abstract/Functional.python.cpp b/python/src/v2.0/abstract/Functional.python.cpp new file mode 100644 index 000000000..39dd179ba --- /dev/null +++ b/python/src/v2.0/abstract/Functional.python.cpp @@ -0,0 +1,98 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/abstract/Functional.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_abstract { + +// Functional wrapper +void wrapFunctional(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = abstract::Functional; + using _t = std::variant< + abstract::Functional, + containers::Values + >; + + // create the component + python::class_ component( + module, + "Functional", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const containers::Axes &, + const std::optional &, + const _t & + >(), + python::arg("label") = std::nullopt, + python::arg("outer_domain_value") = std::nullopt, + python::arg("axes"), + python::arg("uncertainty") = std::nullopt, + python::arg("_functionalvalues"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "outer_domain_value", + &Component::outerDomainValue, + Component::documentation("outer_domain_value").data() + ) + .def_property_readonly( + "axes", + python::overload_cast<>(&Component::axes), + Component::documentation("axes").data() + ) + .def_property_readonly( + "uncertainty", + python::overload_cast<>(&Component::uncertainty), + Component::documentation("uncertainty").data() + ) + .def_property_readonly( + "functional", + python::overload_cast<>(&Component::functional), + Component::documentation("functional").data() + ) + .def_property_readonly( + "values", + python::overload_cast<>(&Component::values), + Component::documentation("values").data() + ) + .def_property_readonly( + "_functionalvalues", + python::overload_cast<>(&Component::_functionalvalues), + Component::documentation("_functionalvalues").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_abstract +} // namespace python_v2_0 diff --git a/python/src/v2.0/abstract/Label.python.cpp b/python/src/v2.0/abstract/Label.python.cpp new file mode 100644 index 000000000..5c9a2d544 --- /dev/null +++ b/python/src/v2.0/abstract/Label.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/abstract/Label.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_abstract { + +// Label wrapper +void wrapLabel(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = abstract::Label; + + // create the component + python::class_ component( + module, + "Label", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName & + >(), + python::arg("label"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_abstract +} // namespace python_v2_0 diff --git a/python/src/v2.0/abstract/PhysicalQuantity.python.cpp b/python/src/v2.0/abstract/PhysicalQuantity.python.cpp new file mode 100644 index 000000000..722a31ca3 --- /dev/null +++ b/python/src/v2.0/abstract/PhysicalQuantity.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/abstract/PhysicalQuantity.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_abstract { + +// PhysicalQuantity wrapper +void wrapPhysicalQuantity(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = abstract::PhysicalQuantity; + + // create the component + python::class_ component( + module, + "PhysicalQuantity", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const std::optional &, + const XMLName &, + const std::optional &, + const std::optional & + >(), + python::arg("label"), + python::arg("unit") = std::nullopt, + python::arg("value"), + python::arg("documentation") = std::nullopt, + python::arg("uncertainty") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + .def_property_readonly( + "documentation", + python::overload_cast<>(&Component::documentation), + Component::documentation("documentation").data() + ) + .def_property_readonly( + "uncertainty", + python::overload_cast<>(&Component::uncertainty), + Component::documentation("uncertainty").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_abstract +} // namespace python_v2_0 diff --git a/python/src/v2.0/abstract/Text.python.cpp b/python/src/v2.0/abstract/Text.python.cpp new file mode 100644 index 000000000..fdca89ed1 --- /dev/null +++ b/python/src/v2.0/abstract/Text.python.cpp @@ -0,0 +1,106 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/abstract/Text.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_abstract { + +// Text wrapper +void wrapText(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = abstract::Text; + + // create the component + python::class_ component( + module, + "Text", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("encoding") = std::nullopt, + python::arg("label") = std::nullopt, + python::arg("markup") = std::nullopt, + Component::documentation("constructor").data() + ) + .def( + python::init< + const std::vector & + >(), + python::arg("ints"), + Component::documentation("constructor").data() + ) + .def( + python::init< + const std::vector & + >(), + python::arg("doubles"), + Component::documentation("constructor").data() + ) + .def( + python::init< + const std::vector & + >(), + python::arg("strings"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "encoding", + [](const Component &self) { return self.encoding().value(); }, + Component::documentation("encoding").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "markup", + [](const Component &self) { return self.markup().value(); }, + Component::documentation("markup").data() + ) + .def_property_readonly( + "ints", + [] (const Component &self) { return self.ints(); }, + Component::documentation("ints").data() + ) + .def_property_readonly( + "doubles", + [] (const Component &self) { return self.doubles(); }, + Component::documentation("doubles").data() + ) + .def_property_readonly( + "strings", + [] (const Component &self) { return self.strings(); }, + Component::documentation("strings").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_abstract +} // namespace python_v2_0 diff --git a/python/src/v2.0/appData.python.cpp b/python/src/v2.0/appData.python.cpp new file mode 100644 index 000000000..d666c02a2 --- /dev/null +++ b/python/src/v2.0/appData.python.cpp @@ -0,0 +1,37 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include +#include + +namespace python = pybind11; + +// v2.0 interface +namespace python_v2_0 { + +// appData declarations +namespace python_appData { + void wrapConversion(python::module &); + void wrapENDFconversionFlags(python::module &); + void wrapInstitution(python::module &); + void wrapApplicationData(python::module &); +} // namespace python_appData + +// appData wrapper +void wrapAppData(python::module &module) +{ + // create the appData submodule + python::module submodule = module.def_submodule( + "appData", + "GNDS v2.0 appData" + ); + + // wrap appData components + python_appData::wrapConversion(submodule); + python_appData::wrapENDFconversionFlags(submodule); + python_appData::wrapInstitution(submodule); + python_appData::wrapApplicationData(submodule); +}; + +} // namespace python_v2_0 diff --git a/python/src/v2.0/appData/ApplicationData.python.cpp b/python/src/v2.0/appData/ApplicationData.python.cpp new file mode 100644 index 000000000..e7750a1b8 --- /dev/null +++ b/python/src/v2.0/appData/ApplicationData.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/appData/ApplicationData.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_appData { + +// ApplicationData wrapper +void wrapApplicationData(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = appData::ApplicationData; + + // create the component + python::class_ component( + module, + "ApplicationData", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("institution") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "institution", + python::overload_cast<>(&Component::institution), + Component::documentation("institution").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_appData +} // namespace python_v2_0 diff --git a/python/src/v2.0/appData/Conversion.python.cpp b/python/src/v2.0/appData/Conversion.python.cpp new file mode 100644 index 000000000..613eb720f --- /dev/null +++ b/python/src/v2.0/appData/Conversion.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/appData/Conversion.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_appData { + +// Conversion wrapper +void wrapConversion(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = appData::Conversion; + + // create the component + python::class_ component( + module, + "Conversion", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("flags") = std::nullopt, + python::arg("href") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "flags", + &Component::flags, + Component::documentation("flags").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_appData +} // namespace python_v2_0 diff --git a/python/src/v2.0/appData/ENDFconversionFlags.python.cpp b/python/src/v2.0/appData/ENDFconversionFlags.python.cpp new file mode 100644 index 000000000..81c47b7ef --- /dev/null +++ b/python/src/v2.0/appData/ENDFconversionFlags.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/appData/ENDFconversionFlags.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_appData { + +// ENDFconversionFlags wrapper +void wrapENDFconversionFlags(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = appData::ENDFconversionFlags; + + // create the component + python::class_ component( + module, + "ENDFconversionFlags", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("conversion") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "conversion", + python::overload_cast<>(&Component::conversion), + Component::documentation("conversion").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_appData +} // namespace python_v2_0 diff --git a/python/src/v2.0/appData/Institution.python.cpp b/python/src/v2.0/appData/Institution.python.cpp new file mode 100644 index 000000000..c40959734 --- /dev/null +++ b/python/src/v2.0/appData/Institution.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/appData/Institution.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_appData { + +// Institution wrapper +void wrapInstitution(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = appData::Institution; + + // create the component + python::class_ component( + module, + "Institution", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("label") = std::nullopt, + python::arg("endfconversion_flags") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "endfconversion_flags", + python::overload_cast<>(&Component::ENDFconversionFlags), + Component::documentation("endfconversion_flags").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_appData +} // namespace python_v2_0 diff --git a/python/src/v2.0/atomic.python.cpp b/python/src/v2.0/atomic.python.cpp new file mode 100644 index 000000000..f3df7e33d --- /dev/null +++ b/python/src/v2.0/atomic.python.cpp @@ -0,0 +1,41 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include +#include + +namespace python = pybind11; + +// v2.0 interface +namespace python_v2_0 { + +// atomic declarations +namespace python_atomic { + void wrapFormFactor(python::module &); + void wrapImaginaryAnomalousFactor(python::module &); + void wrapRealAnomalousFactor(python::module &); + void wrapCoherentPhotonScattering(python::module &); + void wrapScatteringFactor(python::module &); + void wrapIncoherentPhotonScattering(python::module &); +} // namespace python_atomic + +// atomic wrapper +void wrapAtomic(python::module &module) +{ + // create the atomic submodule + python::module submodule = module.def_submodule( + "atomic", + "GNDS v2.0 atomic" + ); + + // wrap atomic components + python_atomic::wrapFormFactor(submodule); + python_atomic::wrapImaginaryAnomalousFactor(submodule); + python_atomic::wrapRealAnomalousFactor(submodule); + python_atomic::wrapCoherentPhotonScattering(submodule); + python_atomic::wrapScatteringFactor(submodule); + python_atomic::wrapIncoherentPhotonScattering(submodule); +}; + +} // namespace python_v2_0 diff --git a/python/src/v2.0/atomic/CoherentPhotonScattering.python.cpp b/python/src/v2.0/atomic/CoherentPhotonScattering.python.cpp new file mode 100644 index 000000000..3a5eea3f7 --- /dev/null +++ b/python/src/v2.0/atomic/CoherentPhotonScattering.python.cpp @@ -0,0 +1,98 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/atomic/CoherentPhotonScattering.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_atomic { + +// CoherentPhotonScattering wrapper +void wrapCoherentPhotonScattering(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = atomic::CoherentPhotonScattering; + + // create the component + python::class_ component( + module, + "CoherentPhotonScattering", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const enums::Frame &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("href") = std::nullopt, + python::arg("label") = std::nullopt, + python::arg("pid") = std::nullopt, + python::arg("product_frame"), + python::arg("form_factor") = std::nullopt, + python::arg("imaginary_anomalous_factor") = std::nullopt, + python::arg("real_anomalous_factor") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "pid", + &Component::pid, + Component::documentation("pid").data() + ) + .def_property_readonly( + "product_frame", + &Component::productFrame, + Component::documentation("product_frame").data() + ) + .def_property_readonly( + "form_factor", + python::overload_cast<>(&Component::formFactor), + Component::documentation("form_factor").data() + ) + .def_property_readonly( + "imaginary_anomalous_factor", + python::overload_cast<>(&Component::imaginaryAnomalousFactor), + Component::documentation("imaginary_anomalous_factor").data() + ) + .def_property_readonly( + "real_anomalous_factor", + python::overload_cast<>(&Component::realAnomalousFactor), + Component::documentation("real_anomalous_factor").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_atomic +} // namespace python_v2_0 diff --git a/python/src/v2.0/atomic/FormFactor.python.cpp b/python/src/v2.0/atomic/FormFactor.python.cpp new file mode 100644 index 000000000..b07a2bd47 --- /dev/null +++ b/python/src/v2.0/atomic/FormFactor.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/atomic/FormFactor.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_atomic { + +// FormFactor wrapper +void wrapFormFactor(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = atomic::FormFactor; + + // create the component + python::class_ component( + module, + "FormFactor", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("xys1d") = std::nullopt, + python::arg("regions1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "regions1d", + python::overload_cast<>(&Component::regions1d), + Component::documentation("regions1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_atomic +} // namespace python_v2_0 diff --git a/python/src/v2.0/atomic/ImaginaryAnomalousFactor.python.cpp b/python/src/v2.0/atomic/ImaginaryAnomalousFactor.python.cpp new file mode 100644 index 000000000..89b16ac22 --- /dev/null +++ b/python/src/v2.0/atomic/ImaginaryAnomalousFactor.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/atomic/ImaginaryAnomalousFactor.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_atomic { + +// ImaginaryAnomalousFactor wrapper +void wrapImaginaryAnomalousFactor(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = atomic::ImaginaryAnomalousFactor; + + // create the component + python::class_ component( + module, + "ImaginaryAnomalousFactor", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("xys1d") = std::nullopt, + python::arg("regions1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "regions1d", + python::overload_cast<>(&Component::regions1d), + Component::documentation("regions1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_atomic +} // namespace python_v2_0 diff --git a/python/src/v2.0/atomic/IncoherentPhotonScattering.python.cpp b/python/src/v2.0/atomic/IncoherentPhotonScattering.python.cpp new file mode 100644 index 000000000..55582d6e3 --- /dev/null +++ b/python/src/v2.0/atomic/IncoherentPhotonScattering.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/atomic/IncoherentPhotonScattering.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_atomic { + +// IncoherentPhotonScattering wrapper +void wrapIncoherentPhotonScattering(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = atomic::IncoherentPhotonScattering; + + // create the component + python::class_ component( + module, + "IncoherentPhotonScattering", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const enums::Frame &, + const std::optional & + >(), + python::arg("href") = std::nullopt, + python::arg("label") = std::nullopt, + python::arg("pid") = std::nullopt, + python::arg("product_frame"), + python::arg("scattering_factor") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "pid", + &Component::pid, + Component::documentation("pid").data() + ) + .def_property_readonly( + "product_frame", + &Component::productFrame, + Component::documentation("product_frame").data() + ) + .def_property_readonly( + "scattering_factor", + python::overload_cast<>(&Component::scatteringFactor), + Component::documentation("scattering_factor").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_atomic +} // namespace python_v2_0 diff --git a/python/src/v2.0/atomic/RealAnomalousFactor.python.cpp b/python/src/v2.0/atomic/RealAnomalousFactor.python.cpp new file mode 100644 index 000000000..86d6a902f --- /dev/null +++ b/python/src/v2.0/atomic/RealAnomalousFactor.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/atomic/RealAnomalousFactor.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_atomic { + +// RealAnomalousFactor wrapper +void wrapRealAnomalousFactor(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = atomic::RealAnomalousFactor; + + // create the component + python::class_ component( + module, + "RealAnomalousFactor", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("xys1d") = std::nullopt, + python::arg("regions1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "regions1d", + python::overload_cast<>(&Component::regions1d), + Component::documentation("regions1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_atomic +} // namespace python_v2_0 diff --git a/python/src/v2.0/atomic/ScatteringFactor.python.cpp b/python/src/v2.0/atomic/ScatteringFactor.python.cpp new file mode 100644 index 000000000..44236cddc --- /dev/null +++ b/python/src/v2.0/atomic/ScatteringFactor.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/atomic/ScatteringFactor.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_atomic { + +// ScatteringFactor wrapper +void wrapScatteringFactor(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = atomic::ScatteringFactor; + + // create the component + python::class_ component( + module, + "ScatteringFactor", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("xys1d") = std::nullopt, + python::arg("regions1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "regions1d", + python::overload_cast<>(&Component::regions1d), + Component::documentation("regions1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_atomic +} // namespace python_v2_0 diff --git a/python/src/v2.0/common.python.cpp b/python/src/v2.0/common.python.cpp new file mode 100644 index 000000000..268e13fcc --- /dev/null +++ b/python/src/v2.0/common.python.cpp @@ -0,0 +1,47 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include +#include + +namespace python = pybind11; + +// v2.0 interface +namespace python_v2_0 { + +// common declarations +namespace python_common { + void wrapQ(python::module &); + void wrapEnergy(python::module &); + void wrapExternalFile(python::module &); + void wrapExternalFiles(python::module &); + void wrapMass(python::module &); + void wrapProbability(python::module &); + void wrapProduct(python::module &); + void wrapProducts(python::module &); + void wrapTemperature(python::module &); +} // namespace python_common + +// common wrapper +void wrapCommon(python::module &module) +{ + // create the common submodule + python::module submodule = module.def_submodule( + "common", + "GNDS v2.0 common" + ); + + // wrap common components + python_common::wrapQ(submodule); + python_common::wrapEnergy(submodule); + python_common::wrapExternalFile(submodule); + python_common::wrapExternalFiles(submodule); + python_common::wrapMass(submodule); + python_common::wrapProbability(submodule); + python_common::wrapProduct(submodule); + python_common::wrapProducts(submodule); + python_common::wrapTemperature(submodule); +}; + +} // namespace python_v2_0 diff --git a/python/src/v2.0/common/Energy.python.cpp b/python/src/v2.0/common/Energy.python.cpp new file mode 100644 index 000000000..763197fb2 --- /dev/null +++ b/python/src/v2.0/common/Energy.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/common/Energy.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_common { + +// Energy wrapper +void wrapEnergy(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = common::Energy; + + // create the component + python::class_ component( + module, + "Energy", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("double"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "double", + python::overload_cast<>(&Component::Double), + Component::documentation("double").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_common +} // namespace python_v2_0 diff --git a/python/src/v2.0/common/ExternalFile.python.cpp b/python/src/v2.0/common/ExternalFile.python.cpp new file mode 100644 index 000000000..e441778ed --- /dev/null +++ b/python/src/v2.0/common/ExternalFile.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/common/ExternalFile.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_common { + +// ExternalFile wrapper +void wrapExternalFile(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = common::ExternalFile; + + // create the component + python::class_ component( + module, + "ExternalFile", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const XMLName &, + const XMLName & + >(), + python::arg("algorithm") = std::nullopt, + python::arg("checksum") = std::nullopt, + python::arg("label"), + python::arg("path"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "algorithm", + &Component::algorithm, + Component::documentation("algorithm").data() + ) + .def_property_readonly( + "checksum", + &Component::checksum, + Component::documentation("checksum").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "path", + &Component::path, + Component::documentation("path").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_common +} // namespace python_v2_0 diff --git a/python/src/v2.0/common/ExternalFiles.python.cpp b/python/src/v2.0/common/ExternalFiles.python.cpp new file mode 100644 index 000000000..a07d48218 --- /dev/null +++ b/python/src/v2.0/common/ExternalFiles.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/common/ExternalFiles.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_common { + +// ExternalFiles wrapper +void wrapExternalFiles(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = common::ExternalFiles; + + // create the component + python::class_ component( + module, + "ExternalFiles", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("external_file"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "external_file", + python::overload_cast<>(&Component::externalFile), + Component::documentation("external_file").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_common +} // namespace python_v2_0 diff --git a/python/src/v2.0/common/Mass.python.cpp b/python/src/v2.0/common/Mass.python.cpp new file mode 100644 index 000000000..a39795673 --- /dev/null +++ b/python/src/v2.0/common/Mass.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/common/Mass.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_common { + +// Mass wrapper +void wrapMass(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = common::Mass; + + // create the component + python::class_ component( + module, + "Mass", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("double"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "double", + python::overload_cast<>(&Component::Double), + Component::documentation("double").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_common +} // namespace python_v2_0 diff --git a/python/src/v2.0/common/Probability.python.cpp b/python/src/v2.0/common/Probability.python.cpp new file mode 100644 index 000000000..eaa4a8398 --- /dev/null +++ b/python/src/v2.0/common/Probability.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/common/Probability.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_common { + +// Probability wrapper +void wrapProbability(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = common::Probability; + + // create the component + python::class_ component( + module, + "Probability", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("double") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "double", + python::overload_cast<>(&Component::Double), + Component::documentation("double").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_common +} // namespace python_v2_0 diff --git a/python/src/v2.0/common/Product.python.cpp b/python/src/v2.0/common/Product.python.cpp new file mode 100644 index 000000000..3033c0de9 --- /dev/null +++ b/python/src/v2.0/common/Product.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/common/Product.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_common { + +// Product wrapper +void wrapProduct(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = common::Product; + + // create the component + python::class_ component( + module, + "Product", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const XMLName &, + const transport::Distribution &, + const transport::Multiplicity &, + const std::optional & + >(), + python::arg("label"), + python::arg("pid"), + python::arg("distribution"), + python::arg("multiplicity"), + python::arg("output_channel") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "pid", + &Component::pid, + Component::documentation("pid").data() + ) + .def_property_readonly( + "distribution", + python::overload_cast<>(&Component::distribution), + Component::documentation("distribution").data() + ) + .def_property_readonly( + "multiplicity", + python::overload_cast<>(&Component::multiplicity), + Component::documentation("multiplicity").data() + ) + .def_property_readonly( + "output_channel", + python::overload_cast<>(&Component::outputChannel), + Component::documentation("output_channel").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_common +} // namespace python_v2_0 diff --git a/python/src/v2.0/common/Products.python.cpp b/python/src/v2.0/common/Products.python.cpp new file mode 100644 index 000000000..25d69fcc2 --- /dev/null +++ b/python/src/v2.0/common/Products.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/common/Products.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_common { + +// Products wrapper +void wrapProducts(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = common::Products; + + // create the component + python::class_ component( + module, + "Products", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional> & + >(), + python::arg("product") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "product", + python::overload_cast<>(&Component::product), + Component::documentation("product").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_common +} // namespace python_v2_0 diff --git a/python/src/v2.0/common/Q.python.cpp b/python/src/v2.0/common/Q.python.cpp new file mode 100644 index 000000000..7ef93a75e --- /dev/null +++ b/python/src/v2.0/common/Q.python.cpp @@ -0,0 +1,88 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/common/Q.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_common { + +// Q wrapper +void wrapQ(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = common::Q; + using _t = std::variant< + containers::XYs1d, + containers::Constant1d, + containers::Gridded1d, + containers::Polynomial1d, + containers::Regions1d + >; + + // create the component + python::class_ component( + module, + "Q", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const _t & + >(), + python::arg("_xys1dconstant1dgridded1dpolynomial1dregions1d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "constant1d", + python::overload_cast<>(&Component::constant1d), + Component::documentation("constant1d").data() + ) + .def_property_readonly( + "gridded1d", + python::overload_cast<>(&Component::gridded1d), + Component::documentation("gridded1d").data() + ) + .def_property_readonly( + "polynomial1d", + python::overload_cast<>(&Component::polynomial1d), + Component::documentation("polynomial1d").data() + ) + .def_property_readonly( + "regions1d", + python::overload_cast<>(&Component::regions1d), + Component::documentation("regions1d").data() + ) + .def_property_readonly( + "_xys1dconstant1dgridded1dpolynomial1dregions1d", + python::overload_cast<>(&Component::_XYs1dconstant1dgridded1dpolynomial1dregions1d), + Component::documentation("_xys1dconstant1dgridded1dpolynomial1dregions1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_common +} // namespace python_v2_0 diff --git a/python/src/v2.0/common/Temperature.python.cpp b/python/src/v2.0/common/Temperature.python.cpp new file mode 100644 index 000000000..f139892a2 --- /dev/null +++ b/python/src/v2.0/common/Temperature.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/common/Temperature.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_common { + +// Temperature wrapper +void wrapTemperature(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = common::Temperature; + + // create the component + python::class_ component( + module, + "Temperature", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("unit") = std::nullopt, + python::arg("value") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_common +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers.python.cpp b/python/src/v2.0/containers.python.cpp new file mode 100644 index 000000000..dd02d5077 --- /dev/null +++ b/python/src/v2.0/containers.python.cpp @@ -0,0 +1,89 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include +#include + +namespace python = pybind11; + +// v2.0 interface +namespace python_v2_0 { + +// containers declarations +namespace python_containers { + void wrapAxis(python::module &); + void wrapLink(python::module &); + void wrapValues(python::module &); + void wrapGrid(python::module &); + void wrapAxes(python::module &); + void wrapXYs1d(python::module &); + void wrapLegendre(python::module &); + void wrapConstant1d(python::module &); + void wrapArray(python::module &); + void wrapGridded1d(python::module &); + void wrapPolynomial1d(python::module &); + void wrapFunction1ds(python::module &); + void wrapRegions1d(python::module &); + void wrapDouble(python::module &); + void wrapXYs2d(python::module &); + void wrapGridded2d(python::module &); + void wrapFunction2ds(python::module &); + void wrapRegions2d(python::module &); + void wrapYs1d(python::module &); + void wrapXYs3d(python::module &); + void wrapGridded3d(python::module &); + void wrapString(python::module &); + void wrapColumn(python::module &); + void wrapColumnHeaders(python::module &); + void wrapData(python::module &); + void wrapFraction(python::module &); + void wrapFunction3ds(python::module &); + void wrapInteger(python::module &); + void wrapRegions3d(python::module &); + void wrapTable(python::module &); +} // namespace python_containers + +// containers wrapper +void wrapContainers(python::module &module) +{ + // create the containers submodule + python::module submodule = module.def_submodule( + "containers", + "GNDS v2.0 containers" + ); + + // wrap containers components + python_containers::wrapAxis(submodule); + python_containers::wrapLink(submodule); + python_containers::wrapValues(submodule); + python_containers::wrapGrid(submodule); + python_containers::wrapAxes(submodule); + python_containers::wrapXYs1d(submodule); + python_containers::wrapLegendre(submodule); + python_containers::wrapConstant1d(submodule); + python_containers::wrapArray(submodule); + python_containers::wrapGridded1d(submodule); + python_containers::wrapPolynomial1d(submodule); + python_containers::wrapFunction1ds(submodule); + python_containers::wrapRegions1d(submodule); + python_containers::wrapDouble(submodule); + python_containers::wrapXYs2d(submodule); + python_containers::wrapGridded2d(submodule); + python_containers::wrapFunction2ds(submodule); + python_containers::wrapRegions2d(submodule); + python_containers::wrapYs1d(submodule); + python_containers::wrapXYs3d(submodule); + python_containers::wrapGridded3d(submodule); + python_containers::wrapString(submodule); + python_containers::wrapColumn(submodule); + python_containers::wrapColumnHeaders(submodule); + python_containers::wrapData(submodule); + python_containers::wrapFraction(submodule); + python_containers::wrapFunction3ds(submodule); + python_containers::wrapInteger(submodule); + python_containers::wrapRegions3d(submodule); + python_containers::wrapTable(submodule); +}; + +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Array.python.cpp b/python/src/v2.0/containers/Array.python.cpp new file mode 100644 index 000000000..88621ba67 --- /dev/null +++ b/python/src/v2.0/containers/Array.python.cpp @@ -0,0 +1,105 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Array.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Array wrapper +void wrapArray(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Array; + + // create the component + python::class_ component( + module, + "Array", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const IntegerTuple &, + const std::optional &, + const std::optional &, + const std::optional> &, + const std::optional> & + >(), + python::arg("compression") = std::nullopt, + python::arg("offset") = std::nullopt, + python::arg("permutation") = std::nullopt, + python::arg("shape"), + python::arg("storage_order") = std::nullopt, + python::arg("symmetry") = std::nullopt, + python::arg("array") = std::nullopt, + python::arg("values") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "compression", + [](const Component &self) { return self.compression().value(); }, + Component::documentation("compression").data() + ) + .def_property_readonly( + "offset", + &Component::offset, + Component::documentation("offset").data() + ) + .def_property_readonly( + "permutation", + [](const Component &self) { return self.permutation().value(); }, + Component::documentation("permutation").data() + ) + .def_property_readonly( + "shape", + &Component::shape, + Component::documentation("shape").data() + ) + .def_property_readonly( + "storage_order", + [](const Component &self) { return self.storageOrder().value(); }, + Component::documentation("storage_order").data() + ) + .def_property_readonly( + "symmetry", + [](const Component &self) { return self.symmetry().value(); }, + Component::documentation("symmetry").data() + ) + .def_property_readonly( + "array", + python::overload_cast<>(&Component::array), + Component::documentation("array").data() + ) + .def_property_readonly( + "values", + python::overload_cast<>(&Component::values), + Component::documentation("values").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Axes.python.cpp b/python/src/v2.0/containers/Axes.python.cpp new file mode 100644 index 000000000..bc2c6c773 --- /dev/null +++ b/python/src/v2.0/containers/Axes.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Axes.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Axes wrapper +void wrapAxes(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Axes; + + // create the component + python::class_ component( + module, + "Axes", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional> &, + const std::optional> & + >(), + python::arg("href") = std::nullopt, + python::arg("axis") = std::nullopt, + python::arg("grid") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + .def_property_readonly( + "axis", + python::overload_cast<>(&Component::axis), + Component::documentation("axis").data() + ) + .def_property_readonly( + "grid", + python::overload_cast<>(&Component::grid), + Component::documentation("grid").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Axis.python.cpp b/python/src/v2.0/containers/Axis.python.cpp new file mode 100644 index 000000000..5d19b1fb9 --- /dev/null +++ b/python/src/v2.0/containers/Axis.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Axis.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Axis wrapper +void wrapAxis(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Axis; + + // create the component + python::class_ component( + module, + "Axis", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("index") = std::nullopt, + python::arg("label") = std::nullopt, + python::arg("unit") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "index", + &Component::index, + Component::documentation("index").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Column.python.cpp b/python/src/v2.0/containers/Column.python.cpp new file mode 100644 index 000000000..3829a96cd --- /dev/null +++ b/python/src/v2.0/containers/Column.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Column.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Column wrapper +void wrapColumn(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Column; + + // create the component + python::class_ component( + module, + "Column", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const Integer32 &, + const XMLName &, + const std::optional &, + const std::optional & + >(), + python::arg("index"), + python::arg("name"), + python::arg("types") = std::nullopt, + python::arg("unit") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "index", + &Component::index, + Component::documentation("index").data() + ) + .def_property_readonly( + "name", + &Component::name, + Component::documentation("name").data() + ) + .def_property_readonly( + "types", + &Component::types, + Component::documentation("types").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/ColumnHeaders.python.cpp b/python/src/v2.0/containers/ColumnHeaders.python.cpp new file mode 100644 index 000000000..27ff66229 --- /dev/null +++ b/python/src/v2.0/containers/ColumnHeaders.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/ColumnHeaders.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// ColumnHeaders wrapper +void wrapColumnHeaders(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::ColumnHeaders; + + // create the component + python::class_ component( + module, + "ColumnHeaders", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("column"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "column", + python::overload_cast<>(&Component::column), + Component::documentation("column").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Constant1d.python.cpp b/python/src/v2.0/containers/Constant1d.python.cpp new file mode 100644 index 000000000..114a529e0 --- /dev/null +++ b/python/src/v2.0/containers/Constant1d.python.cpp @@ -0,0 +1,91 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Constant1d.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Constant1d wrapper +void wrapConstant1d(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Constant1d; + + // create the component + python::class_ component( + module, + "Constant1d", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const containers::Axes & + >(), + python::arg("domain_max") = std::nullopt, + python::arg("domain_min") = std::nullopt, + python::arg("label") = std::nullopt, + python::arg("outer_domain_value") = std::nullopt, + python::arg("value") = std::nullopt, + python::arg("axes"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "domain_max", + &Component::domainMax, + Component::documentation("domain_max").data() + ) + .def_property_readonly( + "domain_min", + &Component::domainMin, + Component::documentation("domain_min").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "outer_domain_value", + &Component::outerDomainValue, + Component::documentation("outer_domain_value").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + .def_property_readonly( + "axes", + python::overload_cast<>(&Component::axes), + Component::documentation("axes").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Data.python.cpp b/python/src/v2.0/containers/Data.python.cpp new file mode 100644 index 000000000..25555de02 --- /dev/null +++ b/python/src/v2.0/containers/Data.python.cpp @@ -0,0 +1,92 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Data.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Data wrapper +void wrapData(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Data; + + // create the component + python::class_ component( + module, + "Data", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("sep") = std::nullopt, + Component::documentation("constructor").data() + ) + .def( + python::init< + const std::vector & + >(), + python::arg("ints"), + Component::documentation("constructor").data() + ) + .def( + python::init< + const std::vector & + >(), + python::arg("doubles"), + Component::documentation("constructor").data() + ) + .def( + python::init< + const std::vector & + >(), + python::arg("strings"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "sep", + [](const Component &self) { return self.sep().value(); }, + Component::documentation("sep").data() + ) + .def_property_readonly( + "ints", + [] (const Component &self) { return self.ints(); }, + Component::documentation("ints").data() + ) + .def_property_readonly( + "doubles", + [] (const Component &self) { return self.doubles(); }, + Component::documentation("doubles").data() + ) + .def_property_readonly( + "strings", + [] (const Component &self) { return self.strings(); }, + Component::documentation("strings").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Double.python.cpp b/python/src/v2.0/containers/Double.python.cpp new file mode 100644 index 000000000..783c2029d --- /dev/null +++ b/python/src/v2.0/containers/Double.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Double.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Double wrapper +void wrapDouble(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Double; + + // create the component + python::class_ component( + module, + "Double", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const Float64 & + >(), + python::arg("label") = std::nullopt, + python::arg("unit") = std::nullopt, + python::arg("value"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Fraction.python.cpp b/python/src/v2.0/containers/Fraction.python.cpp new file mode 100644 index 000000000..6c20d5221 --- /dev/null +++ b/python/src/v2.0/containers/Fraction.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Fraction.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Fraction wrapper +void wrapFraction(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Fraction; + + // create the component + python::class_ component( + module, + "Fraction", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const Fraction32 & + >(), + python::arg("label") = std::nullopt, + python::arg("unit") = std::nullopt, + python::arg("value"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Function1ds.python.cpp b/python/src/v2.0/containers/Function1ds.python.cpp new file mode 100644 index 000000000..b60b9be90 --- /dev/null +++ b/python/src/v2.0/containers/Function1ds.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Function1ds.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Function1ds wrapper +void wrapFunction1ds(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Function1ds; + using _t = std::variant< + containers::Legendre, + containers::XYs1d, + containers::Constant1d, + containers::Gridded1d, + containers::Polynomial1d + >; + + // create the component + python::class_ component( + module, + "Function1ds", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector<_t> & + >(), + python::arg("_legendre_xys1dconstant1dgridded1dpolynomial1d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "_legendre_xys1dconstant1dgridded1dpolynomial1d", + python::overload_cast<>(&Component::_LegendreXYs1dconstant1dgridded1dpolynomial1d), + Component::documentation("_legendre_xys1dconstant1dgridded1dpolynomial1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Function2ds.python.cpp b/python/src/v2.0/containers/Function2ds.python.cpp new file mode 100644 index 000000000..f227d07f0 --- /dev/null +++ b/python/src/v2.0/containers/Function2ds.python.cpp @@ -0,0 +1,60 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Function2ds.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Function2ds wrapper +void wrapFunction2ds(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Function2ds; + using _t = std::variant< + containers::XYs2d, + containers::Gridded2d + >; + + // create the component + python::class_ component( + module, + "Function2ds", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector<_t> & + >(), + python::arg("_xys2dgridded2d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "_xys2dgridded2d", + python::overload_cast<>(&Component::_XYs2dgridded2d), + Component::documentation("_xys2dgridded2d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Function3ds.python.cpp b/python/src/v2.0/containers/Function3ds.python.cpp new file mode 100644 index 000000000..2350092aa --- /dev/null +++ b/python/src/v2.0/containers/Function3ds.python.cpp @@ -0,0 +1,60 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Function3ds.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Function3ds wrapper +void wrapFunction3ds(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Function3ds; + using _t = std::variant< + containers::XYs3d, + containers::Gridded3d + >; + + // create the component + python::class_ component( + module, + "Function3ds", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector<_t> & + >(), + python::arg("_xys3dgridded3d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "_xys3dgridded3d", + python::overload_cast<>(&Component::_XYs3dgridded3d), + Component::documentation("_xys3dgridded3d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Grid.python.cpp b/python/src/v2.0/containers/Grid.python.cpp new file mode 100644 index 000000000..602ad3d60 --- /dev/null +++ b/python/src/v2.0/containers/Grid.python.cpp @@ -0,0 +1,105 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Grid.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Grid wrapper +void wrapGrid(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Grid; + using _t = std::variant< + containers::Link, + containers::Values + >; + + // create the component + python::class_ component( + module, + "Grid", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const _t & + >(), + python::arg("index") = std::nullopt, + python::arg("interpolation") = std::nullopt, + python::arg("label") = std::nullopt, + python::arg("style") = std::nullopt, + python::arg("unit") = std::nullopt, + python::arg("_linkvalues"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "index", + &Component::index, + Component::documentation("index").data() + ) + .def_property_readonly( + "interpolation", + [](const Component &self) { return self.interpolation().value(); }, + Component::documentation("interpolation").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "style", + &Component::style, + Component::documentation("style").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + .def_property_readonly( + "link", + python::overload_cast<>(&Component::link), + Component::documentation("link").data() + ) + .def_property_readonly( + "values", + python::overload_cast<>(&Component::values), + Component::documentation("values").data() + ) + .def_property_readonly( + "_linkvalues", + python::overload_cast<>(&Component::_linkvalues), + Component::documentation("_linkvalues").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Gridded1d.python.cpp b/python/src/v2.0/containers/Gridded1d.python.cpp new file mode 100644 index 000000000..3ce9c5bd7 --- /dev/null +++ b/python/src/v2.0/containers/Gridded1d.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Gridded1d.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Gridded1d wrapper +void wrapGridded1d(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Gridded1d; + + // create the component + python::class_ component( + module, + "Gridded1d", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const containers::Array &, + const containers::Axes & + >(), + python::arg("label") = std::nullopt, + python::arg("array"), + python::arg("axes"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "array", + python::overload_cast<>(&Component::array), + Component::documentation("array").data() + ) + .def_property_readonly( + "axes", + python::overload_cast<>(&Component::axes), + Component::documentation("axes").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Gridded2d.python.cpp b/python/src/v2.0/containers/Gridded2d.python.cpp new file mode 100644 index 000000000..22a05b606 --- /dev/null +++ b/python/src/v2.0/containers/Gridded2d.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Gridded2d.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Gridded2d wrapper +void wrapGridded2d(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Gridded2d; + + // create the component + python::class_ component( + module, + "Gridded2d", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const containers::Array &, + const containers::Axes & + >(), + python::arg("label") = std::nullopt, + python::arg("array"), + python::arg("axes"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "array", + python::overload_cast<>(&Component::array), + Component::documentation("array").data() + ) + .def_property_readonly( + "axes", + python::overload_cast<>(&Component::axes), + Component::documentation("axes").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Gridded3d.python.cpp b/python/src/v2.0/containers/Gridded3d.python.cpp new file mode 100644 index 000000000..2afb0c8a1 --- /dev/null +++ b/python/src/v2.0/containers/Gridded3d.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Gridded3d.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Gridded3d wrapper +void wrapGridded3d(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Gridded3d; + + // create the component + python::class_ component( + module, + "Gridded3d", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const containers::Array &, + const containers::Axes & + >(), + python::arg("label") = std::nullopt, + python::arg("array"), + python::arg("axes"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "array", + python::overload_cast<>(&Component::array), + Component::documentation("array").data() + ) + .def_property_readonly( + "axes", + python::overload_cast<>(&Component::axes), + Component::documentation("axes").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Integer.python.cpp b/python/src/v2.0/containers/Integer.python.cpp new file mode 100644 index 000000000..35ac60981 --- /dev/null +++ b/python/src/v2.0/containers/Integer.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Integer.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Integer wrapper +void wrapInteger(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Integer; + + // create the component + python::class_ component( + module, + "Integer", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const Integer32 & + >(), + python::arg("label") = std::nullopt, + python::arg("unit") = std::nullopt, + python::arg("value"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Legendre.python.cpp b/python/src/v2.0/containers/Legendre.python.cpp new file mode 100644 index 000000000..55d64b096 --- /dev/null +++ b/python/src/v2.0/containers/Legendre.python.cpp @@ -0,0 +1,91 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Legendre.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Legendre wrapper +void wrapLegendre(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Legendre; + + // create the component + python::class_ component( + module, + "Legendre", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const containers::Values & + >(), + python::arg("domain_max") = std::nullopt, + python::arg("domain_min") = std::nullopt, + python::arg("label") = std::nullopt, + python::arg("lower_index") = std::nullopt, + python::arg("outer_domain_value") = std::nullopt, + python::arg("values"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "domain_max", + [](const Component &self) { return self.domainMax().value(); }, + Component::documentation("domain_max").data() + ) + .def_property_readonly( + "domain_min", + [](const Component &self) { return self.domainMin().value(); }, + Component::documentation("domain_min").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "lower_index", + [](const Component &self) { return self.lowerIndex().value(); }, + Component::documentation("lower_index").data() + ) + .def_property_readonly( + "outer_domain_value", + &Component::outerDomainValue, + Component::documentation("outer_domain_value").data() + ) + .def_property_readonly( + "values", + python::overload_cast<>(&Component::values), + Component::documentation("values").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Link.python.cpp b/python/src/v2.0/containers/Link.python.cpp new file mode 100644 index 000000000..d33ab3fe1 --- /dev/null +++ b/python/src/v2.0/containers/Link.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Link.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Link wrapper +void wrapLink(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Link; + + // create the component + python::class_ component( + module, + "Link", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("href") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Polynomial1d.python.cpp b/python/src/v2.0/containers/Polynomial1d.python.cpp new file mode 100644 index 000000000..bd2907a84 --- /dev/null +++ b/python/src/v2.0/containers/Polynomial1d.python.cpp @@ -0,0 +1,98 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Polynomial1d.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Polynomial1d wrapper +void wrapPolynomial1d(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Polynomial1d; + + // create the component + python::class_ component( + module, + "Polynomial1d", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const containers::Axes &, + const containers::Values & + >(), + python::arg("domain_max") = std::nullopt, + python::arg("domain_min") = std::nullopt, + python::arg("label") = std::nullopt, + python::arg("lower_index") = std::nullopt, + python::arg("outer_domain_value") = std::nullopt, + python::arg("axes"), + python::arg("values"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "domain_max", + &Component::domainMax, + Component::documentation("domain_max").data() + ) + .def_property_readonly( + "domain_min", + &Component::domainMin, + Component::documentation("domain_min").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "lower_index", + [](const Component &self) { return self.lowerIndex().value(); }, + Component::documentation("lower_index").data() + ) + .def_property_readonly( + "outer_domain_value", + &Component::outerDomainValue, + Component::documentation("outer_domain_value").data() + ) + .def_property_readonly( + "axes", + python::overload_cast<>(&Component::axes), + Component::documentation("axes").data() + ) + .def_property_readonly( + "values", + python::overload_cast<>(&Component::values), + Component::documentation("values").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Regions1d.python.cpp b/python/src/v2.0/containers/Regions1d.python.cpp new file mode 100644 index 000000000..7a360511f --- /dev/null +++ b/python/src/v2.0/containers/Regions1d.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Regions1d.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Regions1d wrapper +void wrapRegions1d(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Regions1d; + + // create the component + python::class_ component( + module, + "Regions1d", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const containers::Function1ds & + >(), + python::arg("label") = std::nullopt, + python::arg("outer_domain_value") = std::nullopt, + python::arg("axes") = std::nullopt, + python::arg("function1ds"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "outer_domain_value", + &Component::outerDomainValue, + Component::documentation("outer_domain_value").data() + ) + .def_property_readonly( + "axes", + python::overload_cast<>(&Component::axes), + Component::documentation("axes").data() + ) + .def_property_readonly( + "function1ds", + python::overload_cast<>(&Component::function1ds), + Component::documentation("function1ds").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Regions2d.python.cpp b/python/src/v2.0/containers/Regions2d.python.cpp new file mode 100644 index 000000000..2e815efa1 --- /dev/null +++ b/python/src/v2.0/containers/Regions2d.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Regions2d.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Regions2d wrapper +void wrapRegions2d(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Regions2d; + + // create the component + python::class_ component( + module, + "Regions2d", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const containers::Function2ds & + >(), + python::arg("label") = std::nullopt, + python::arg("outer_domain_value") = std::nullopt, + python::arg("axes") = std::nullopt, + python::arg("function2ds"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "outer_domain_value", + &Component::outerDomainValue, + Component::documentation("outer_domain_value").data() + ) + .def_property_readonly( + "axes", + python::overload_cast<>(&Component::axes), + Component::documentation("axes").data() + ) + .def_property_readonly( + "function2ds", + python::overload_cast<>(&Component::function2ds), + Component::documentation("function2ds").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Regions3d.python.cpp b/python/src/v2.0/containers/Regions3d.python.cpp new file mode 100644 index 000000000..2b8aff7a6 --- /dev/null +++ b/python/src/v2.0/containers/Regions3d.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Regions3d.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Regions3d wrapper +void wrapRegions3d(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Regions3d; + + // create the component + python::class_ component( + module, + "Regions3d", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const containers::Function3ds & + >(), + python::arg("label") = std::nullopt, + python::arg("outer_domain_value") = std::nullopt, + python::arg("axes") = std::nullopt, + python::arg("function3ds"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "outer_domain_value", + &Component::outerDomainValue, + Component::documentation("outer_domain_value").data() + ) + .def_property_readonly( + "axes", + python::overload_cast<>(&Component::axes), + Component::documentation("axes").data() + ) + .def_property_readonly( + "function3ds", + python::overload_cast<>(&Component::function3ds), + Component::documentation("function3ds").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/String.python.cpp b/python/src/v2.0/containers/String.python.cpp new file mode 100644 index 000000000..c33b29969 --- /dev/null +++ b/python/src/v2.0/containers/String.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/String.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// String wrapper +void wrapString(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::String; + + // create the component + python::class_ component( + module, + "String", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const XMLName & + >(), + python::arg("label") = std::nullopt, + python::arg("unit") = std::nullopt, + python::arg("value"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Table.python.cpp b/python/src/v2.0/containers/Table.python.cpp new file mode 100644 index 000000000..94239c1ba --- /dev/null +++ b/python/src/v2.0/containers/Table.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Table.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Table wrapper +void wrapTable(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Table; + + // create the component + python::class_ component( + module, + "Table", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const Integer32 &, + const Integer32 &, + const std::optional &, + const containers::ColumnHeaders &, + const containers::Data & + >(), + python::arg("columns"), + python::arg("rows"), + python::arg("storage_order") = std::nullopt, + python::arg("column_headers"), + python::arg("data"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "columns", + &Component::columns, + Component::documentation("columns").data() + ) + .def_property_readonly( + "rows", + &Component::rows, + Component::documentation("rows").data() + ) + .def_property_readonly( + "storage_order", + [](const Component &self) { return self.storageOrder().value(); }, + Component::documentation("storage_order").data() + ) + .def_property_readonly( + "column_headers", + python::overload_cast<>(&Component::columnHeaders), + Component::documentation("column_headers").data() + ) + .def_property_readonly( + "data", + python::overload_cast<>(&Component::data), + Component::documentation("data").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Values.python.cpp b/python/src/v2.0/containers/Values.python.cpp new file mode 100644 index 000000000..b2358a8f6 --- /dev/null +++ b/python/src/v2.0/containers/Values.python.cpp @@ -0,0 +1,127 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Values.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Values wrapper +void wrapValues(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Values; + + // create the component + python::class_ component( + module, + "Values", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("count") = std::nullopt, + python::arg("href") = std::nullopt, + python::arg("length") = std::nullopt, + python::arg("start") = std::nullopt, + python::arg("start_index") = std::nullopt, + python::arg("value_type") = std::nullopt, + Component::documentation("constructor").data() + ) + .def( + python::init< + const std::vector & + >(), + python::arg("ints"), + Component::documentation("constructor").data() + ) + .def( + python::init< + const std::vector & + >(), + python::arg("doubles"), + Component::documentation("constructor").data() + ) + .def( + python::init< + const std::vector & + >(), + python::arg("strings"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "count", + &Component::count, + Component::documentation("count").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + .def_property_readonly( + "length", + &Component::length, + Component::documentation("length").data() + ) + .def_property_readonly( + "start", + [](const Component &self) { return self.start().value(); }, + Component::documentation("start").data() + ) + .def_property_readonly( + "start_index", + &Component::startIndex, + Component::documentation("start_index").data() + ) + .def_property_readonly( + "value_type", + [](const Component &self) { return self.valueType().value(); }, + Component::documentation("value_type").data() + ) + .def_property_readonly( + "ints", + [] (const Component &self) { return self.ints(); }, + Component::documentation("ints").data() + ) + .def_property_readonly( + "doubles", + [] (const Component &self) { return self.doubles(); }, + Component::documentation("doubles").data() + ) + .def_property_readonly( + "strings", + [] (const Component &self) { return self.strings(); }, + Component::documentation("strings").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/XYs1d.python.cpp b/python/src/v2.0/containers/XYs1d.python.cpp new file mode 100644 index 000000000..44a5ea6cc --- /dev/null +++ b/python/src/v2.0/containers/XYs1d.python.cpp @@ -0,0 +1,91 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/XYs1d.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// XYs1d wrapper +void wrapXYs1d(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::XYs1d; + + // create the component + python::class_ component( + module, + "XYs1d", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const containers::Values & + >(), + python::arg("index") = std::nullopt, + python::arg("interpolation") = std::nullopt, + python::arg("label") = std::nullopt, + python::arg("outer_domain_value") = std::nullopt, + python::arg("axes") = std::nullopt, + python::arg("values"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "index", + &Component::index, + Component::documentation("index").data() + ) + .def_property_readonly( + "interpolation", + [](const Component &self) { return self.interpolation().value(); }, + Component::documentation("interpolation").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "outer_domain_value", + &Component::outerDomainValue, + Component::documentation("outer_domain_value").data() + ) + .def_property_readonly( + "axes", + python::overload_cast<>(&Component::axes), + Component::documentation("axes").data() + ) + .def_property_readonly( + "values", + python::overload_cast<>(&Component::values), + Component::documentation("values").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/XYs2d.python.cpp b/python/src/v2.0/containers/XYs2d.python.cpp new file mode 100644 index 000000000..869f3b455 --- /dev/null +++ b/python/src/v2.0/containers/XYs2d.python.cpp @@ -0,0 +1,91 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/XYs2d.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// XYs2d wrapper +void wrapXYs2d(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::XYs2d; + + // create the component + python::class_ component( + module, + "XYs2d", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const containers::Function1ds & + >(), + python::arg("index") = std::nullopt, + python::arg("interpolation") = std::nullopt, + python::arg("interpolation_qualifier") = std::nullopt, + python::arg("outer_domain_value") = std::nullopt, + python::arg("axes") = std::nullopt, + python::arg("function1ds"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "index", + &Component::index, + Component::documentation("index").data() + ) + .def_property_readonly( + "interpolation", + [](const Component &self) { return self.interpolation().value(); }, + Component::documentation("interpolation").data() + ) + .def_property_readonly( + "interpolation_qualifier", + &Component::interpolationQualifier, + Component::documentation("interpolation_qualifier").data() + ) + .def_property_readonly( + "outer_domain_value", + &Component::outerDomainValue, + Component::documentation("outer_domain_value").data() + ) + .def_property_readonly( + "axes", + python::overload_cast<>(&Component::axes), + Component::documentation("axes").data() + ) + .def_property_readonly( + "function1ds", + python::overload_cast<>(&Component::function1ds), + Component::documentation("function1ds").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/XYs3d.python.cpp b/python/src/v2.0/containers/XYs3d.python.cpp new file mode 100644 index 000000000..00e7e247a --- /dev/null +++ b/python/src/v2.0/containers/XYs3d.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/XYs3d.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// XYs3d wrapper +void wrapXYs3d(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::XYs3d; + + // create the component + python::class_ component( + module, + "XYs3d", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const containers::Function2ds & + >(), + python::arg("interpolation") = std::nullopt, + python::arg("interpolation_qualifier") = std::nullopt, + python::arg("axes") = std::nullopt, + python::arg("function2ds"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "interpolation", + [](const Component &self) { return self.interpolation().value(); }, + Component::documentation("interpolation").data() + ) + .def_property_readonly( + "interpolation_qualifier", + &Component::interpolationQualifier, + Component::documentation("interpolation_qualifier").data() + ) + .def_property_readonly( + "axes", + python::overload_cast<>(&Component::axes), + Component::documentation("axes").data() + ) + .def_property_readonly( + "function2ds", + python::overload_cast<>(&Component::function2ds), + Component::documentation("function2ds").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/containers/Ys1d.python.cpp b/python/src/v2.0/containers/Ys1d.python.cpp new file mode 100644 index 000000000..4c6ca9ecb --- /dev/null +++ b/python/src/v2.0/containers/Ys1d.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/containers/Ys1d.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_containers { + +// Ys1d wrapper +void wrapYs1d(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = containers::Ys1d; + + // create the component + python::class_ component( + module, + "Ys1d", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const containers::Axes &, + const containers::Values & + >(), + python::arg("interpolation") = std::nullopt, + python::arg("label") = std::nullopt, + python::arg("axes"), + python::arg("values"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "interpolation", + [](const Component &self) { return self.interpolation().value(); }, + Component::documentation("interpolation").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "axes", + python::overload_cast<>(&Component::axes), + Component::documentation("axes").data() + ) + .def_property_readonly( + "values", + python::overload_cast<>(&Component::values), + Component::documentation("values").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_containers +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance.python.cpp b/python/src/v2.0/covariance.python.cpp new file mode 100644 index 000000000..88456fdfe --- /dev/null +++ b/python/src/v2.0/covariance.python.cpp @@ -0,0 +1,73 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include +#include + +namespace python = pybind11; + +// v2.0 interface +namespace python_v2_0 { + +// covariance declarations +namespace python_covariance { + void wrapSlice(python::module &); + void wrapSlices(python::module &); + void wrapColumnData(python::module &); + void wrapRowData(python::module &); + void wrapColumnSensitivity(python::module &); + void wrapCovariance(python::module &); + void wrapRowSensitivity(python::module &); + void wrapSandwichProduct(python::module &); + void wrapCovarianceMatrix(python::module &); + void wrapAverageParameterCovariance(python::module &); + void wrapShortRangeSelfScalingVariance(python::module &); + void wrapSummand(python::module &); + void wrapSum(python::module &); + void wrapMixed(python::module &); + void wrapCovarianceSection(python::module &); + void wrapCovarianceSections(python::module &); + void wrapParameterCovariance(python::module &); + void wrapParameterCovariances(python::module &); + void wrapCovarianceSuite(python::module &); + void wrapParameterLink(python::module &); + void wrapParameters(python::module &); + void wrapParameterCovariancMatrix(python::module &); +} // namespace python_covariance + +// covariance wrapper +void wrapCovariance(python::module &module) +{ + // create the covariance submodule + python::module submodule = module.def_submodule( + "covariance", + "GNDS v2.0 covariance" + ); + + // wrap covariance components + python_covariance::wrapSlice(submodule); + python_covariance::wrapSlices(submodule); + python_covariance::wrapColumnData(submodule); + python_covariance::wrapRowData(submodule); + python_covariance::wrapColumnSensitivity(submodule); + python_covariance::wrapCovariance(submodule); + python_covariance::wrapRowSensitivity(submodule); + python_covariance::wrapSandwichProduct(submodule); + python_covariance::wrapCovarianceMatrix(submodule); + python_covariance::wrapAverageParameterCovariance(submodule); + python_covariance::wrapShortRangeSelfScalingVariance(submodule); + python_covariance::wrapSummand(submodule); + python_covariance::wrapSum(submodule); + python_covariance::wrapMixed(submodule); + python_covariance::wrapCovarianceSection(submodule); + python_covariance::wrapCovarianceSections(submodule); + python_covariance::wrapParameterCovariance(submodule); + python_covariance::wrapParameterCovariances(submodule); + python_covariance::wrapCovarianceSuite(submodule); + python_covariance::wrapParameterLink(submodule); + python_covariance::wrapParameters(submodule); + python_covariance::wrapParameterCovariancMatrix(submodule); +}; + +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/AverageParameterCovariance.python.cpp b/python/src/v2.0/covariance/AverageParameterCovariance.python.cpp new file mode 100644 index 000000000..84cbc2b01 --- /dev/null +++ b/python/src/v2.0/covariance/AverageParameterCovariance.python.cpp @@ -0,0 +1,92 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/AverageParameterCovariance.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// AverageParameterCovariance wrapper +void wrapAverageParameterCovariance(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::AverageParameterCovariance; + using _t = std::variant< + covariance::CovarianceMatrix + >; + + // create the component + python::class_ component( + module, + "AverageParameterCovariance", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const _t & + >(), + python::arg("cross_term") = std::nullopt, + python::arg("label") = std::nullopt, + python::arg("column_data") = std::nullopt, + python::arg("row_data") = std::nullopt, + python::arg("_covariance_matrix"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "cross_term", + &Component::crossTerm, + Component::documentation("cross_term").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "column_data", + python::overload_cast<>(&Component::columnData), + Component::documentation("column_data").data() + ) + .def_property_readonly( + "row_data", + python::overload_cast<>(&Component::rowData), + Component::documentation("row_data").data() + ) + .def_property_readonly( + "covariance_matrix", + python::overload_cast<>(&Component::covarianceMatrix), + Component::documentation("covariance_matrix").data() + ) + .def_property_readonly( + "_covariance_matrix", + python::overload_cast<>(&Component::_covarianceMatrix), + Component::documentation("_covariance_matrix").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/ColumnData.python.cpp b/python/src/v2.0/covariance/ColumnData.python.cpp new file mode 100644 index 000000000..fcc5b7044 --- /dev/null +++ b/python/src/v2.0/covariance/ColumnData.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/ColumnData.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// ColumnData wrapper +void wrapColumnData(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::ColumnData; + + // create the component + python::class_ component( + module, + "ColumnData", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("endf_mfmt") = std::nullopt, + python::arg("dimension") = std::nullopt, + python::arg("href") = std::nullopt, + python::arg("slices") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "endf_mfmt", + &Component::ENDF_MFMT, + Component::documentation("endf_mfmt").data() + ) + .def_property_readonly( + "dimension", + &Component::dimension, + Component::documentation("dimension").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + .def_property_readonly( + "slices", + python::overload_cast<>(&Component::slices), + Component::documentation("slices").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/ColumnSensitivity.python.cpp b/python/src/v2.0/covariance/ColumnSensitivity.python.cpp new file mode 100644 index 000000000..6abc20ce7 --- /dev/null +++ b/python/src/v2.0/covariance/ColumnSensitivity.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/ColumnSensitivity.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// ColumnSensitivity wrapper +void wrapColumnSensitivity(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::ColumnSensitivity; + + // create the component + python::class_ component( + module, + "ColumnSensitivity", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const containers::Array & + >(), + python::arg("array"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "array", + python::overload_cast<>(&Component::array), + Component::documentation("array").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/Covariance.python.cpp b/python/src/v2.0/covariance/Covariance.python.cpp new file mode 100644 index 000000000..e7dc38304 --- /dev/null +++ b/python/src/v2.0/covariance/Covariance.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/Covariance.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// Covariance wrapper +void wrapCovariance(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::Covariance; + + // create the component + python::class_ component( + module, + "Covariance", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const containers::Array & + >(), + python::arg("array"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "array", + python::overload_cast<>(&Component::array), + Component::documentation("array").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/CovarianceMatrix.python.cpp b/python/src/v2.0/covariance/CovarianceMatrix.python.cpp new file mode 100644 index 000000000..703aff5e3 --- /dev/null +++ b/python/src/v2.0/covariance/CovarianceMatrix.python.cpp @@ -0,0 +1,91 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/CovarianceMatrix.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// CovarianceMatrix wrapper +void wrapCovarianceMatrix(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::CovarianceMatrix; + using _t = std::variant< + containers::Gridded2d, + covariance::SandwichProduct + >; + + // create the component + python::class_ component( + module, + "CovarianceMatrix", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const XMLName &, + const _t & + >(), + python::arg("label") = std::nullopt, + python::arg("product_frame") = std::nullopt, + python::arg("type"), + python::arg("_gridded2dsandwich_product"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "product_frame", + &Component::productFrame, + Component::documentation("product_frame").data() + ) + .def_property_readonly( + "type", + &Component::type, + Component::documentation("type").data() + ) + .def_property_readonly( + "gridded2d", + python::overload_cast<>(&Component::gridded2d), + Component::documentation("gridded2d").data() + ) + .def_property_readonly( + "sandwich_product", + python::overload_cast<>(&Component::sandwichProduct), + Component::documentation("sandwich_product").data() + ) + .def_property_readonly( + "_gridded2dsandwich_product", + python::overload_cast<>(&Component::_gridded2dsandwichProduct), + Component::documentation("_gridded2dsandwich_product").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/CovarianceSection.python.cpp b/python/src/v2.0/covariance/CovarianceSection.python.cpp new file mode 100644 index 000000000..683e94fc7 --- /dev/null +++ b/python/src/v2.0/covariance/CovarianceSection.python.cpp @@ -0,0 +1,104 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/CovarianceSection.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// CovarianceSection wrapper +void wrapCovarianceSection(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::CovarianceSection; + using _t = std::variant< + covariance::CovarianceMatrix, + covariance::Mixed, + covariance::Sum + >; + + // create the component + python::class_ component( + module, + "CovarianceSection", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const covariance::RowData &, + const _t & + >(), + python::arg("cross_term") = std::nullopt, + python::arg("label") = std::nullopt, + python::arg("column_data") = std::nullopt, + python::arg("row_data"), + python::arg("_covariance_matrixmixedsum"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "cross_term", + [](const Component &self) { return self.crossTerm().value(); }, + Component::documentation("cross_term").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "column_data", + python::overload_cast<>(&Component::columnData), + Component::documentation("column_data").data() + ) + .def_property_readonly( + "row_data", + python::overload_cast<>(&Component::rowData), + Component::documentation("row_data").data() + ) + .def_property_readonly( + "covariance_matrix", + python::overload_cast<>(&Component::covarianceMatrix), + Component::documentation("covariance_matrix").data() + ) + .def_property_readonly( + "mixed", + python::overload_cast<>(&Component::mixed), + Component::documentation("mixed").data() + ) + .def_property_readonly( + "sum", + python::overload_cast<>(&Component::sum), + Component::documentation("sum").data() + ) + .def_property_readonly( + "_covariance_matrixmixedsum", + python::overload_cast<>(&Component::_covarianceMatrixmixedsum), + Component::documentation("_covariance_matrixmixedsum").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/CovarianceSections.python.cpp b/python/src/v2.0/covariance/CovarianceSections.python.cpp new file mode 100644 index 000000000..3adc2f904 --- /dev/null +++ b/python/src/v2.0/covariance/CovarianceSections.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/CovarianceSections.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// CovarianceSections wrapper +void wrapCovarianceSections(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::CovarianceSections; + + // create the component + python::class_ component( + module, + "CovarianceSections", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional> & + >(), + python::arg("covariance_section") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "covariance_section", + python::overload_cast<>(&Component::covarianceSection), + Component::documentation("covariance_section").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/CovarianceSuite.python.cpp b/python/src/v2.0/covariance/CovarianceSuite.python.cpp new file mode 100644 index 000000000..165492548 --- /dev/null +++ b/python/src/v2.0/covariance/CovarianceSuite.python.cpp @@ -0,0 +1,112 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/CovarianceSuite.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// CovarianceSuite wrapper +void wrapCovarianceSuite(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::CovarianceSuite; + + // create the component + python::class_ component( + module, + "CovarianceSuite", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const enums::Interaction &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("evaluation") = std::nullopt, + python::arg("version") = std::nullopt, + python::arg("interaction"), + python::arg("projectile") = std::nullopt, + python::arg("target") = std::nullopt, + python::arg("covariance_sections") = std::nullopt, + python::arg("external_files") = std::nullopt, + python::arg("parameter_covariances") = std::nullopt, + python::arg("styles") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "evaluation", + &Component::evaluation, + Component::documentation("evaluation").data() + ) + .def_property_readonly( + "version", + &Component::version, + Component::documentation("version").data() + ) + .def_property_readonly( + "interaction", + &Component::interaction, + Component::documentation("interaction").data() + ) + .def_property_readonly( + "projectile", + &Component::projectile, + Component::documentation("projectile").data() + ) + .def_property_readonly( + "target", + &Component::target, + Component::documentation("target").data() + ) + .def_property_readonly( + "covariance_sections", + python::overload_cast<>(&Component::covarianceSections), + Component::documentation("covariance_sections").data() + ) + .def_property_readonly( + "external_files", + python::overload_cast<>(&Component::externalFiles), + Component::documentation("external_files").data() + ) + .def_property_readonly( + "parameter_covariances", + python::overload_cast<>(&Component::parameterCovariances), + Component::documentation("parameter_covariances").data() + ) + .def_property_readonly( + "styles", + python::overload_cast<>(&Component::styles), + Component::documentation("styles").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/Mixed.python.cpp b/python/src/v2.0/covariance/Mixed.python.cpp new file mode 100644 index 000000000..1d82d3864 --- /dev/null +++ b/python/src/v2.0/covariance/Mixed.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/Mixed.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// Mixed wrapper +void wrapMixed(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::Mixed; + + // create the component + python::class_ component( + module, + "Mixed", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const std::optional> &, + const std::optional> &, + const std::optional> & + >(), + python::arg("label"), + python::arg("covariance_matrix") = std::nullopt, + python::arg("short_range_self_scaling_variance") = std::nullopt, + python::arg("sum") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "covariance_matrix", + python::overload_cast<>(&Component::covarianceMatrix), + Component::documentation("covariance_matrix").data() + ) + .def_property_readonly( + "short_range_self_scaling_variance", + python::overload_cast<>(&Component::shortRangeSelfScalingVariance), + Component::documentation("short_range_self_scaling_variance").data() + ) + .def_property_readonly( + "sum", + python::overload_cast<>(&Component::sum), + Component::documentation("sum").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/ParameterCovariancMatrix.python.cpp b/python/src/v2.0/covariance/ParameterCovariancMatrix.python.cpp new file mode 100644 index 000000000..63259079e --- /dev/null +++ b/python/src/v2.0/covariance/ParameterCovariancMatrix.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/ParameterCovariancMatrix.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// ParameterCovariancMatrix wrapper +void wrapParameterCovariancMatrix(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::ParameterCovariancMatrix; + + // create the component + python::class_ component( + module, + "ParameterCovariancMatrix", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const std::optional &, + const containers::Array &, + const covariance::Parameters & + >(), + python::arg("label"), + python::arg("type") = std::nullopt, + python::arg("array"), + python::arg("parameters"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "type", + &Component::type, + Component::documentation("type").data() + ) + .def_property_readonly( + "array", + python::overload_cast<>(&Component::array), + Component::documentation("array").data() + ) + .def_property_readonly( + "parameters", + python::overload_cast<>(&Component::parameters), + Component::documentation("parameters").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/ParameterCovariance.python.cpp b/python/src/v2.0/covariance/ParameterCovariance.python.cpp new file mode 100644 index 000000000..10a2fedb5 --- /dev/null +++ b/python/src/v2.0/covariance/ParameterCovariance.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/ParameterCovariance.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// ParameterCovariance wrapper +void wrapParameterCovariance(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::ParameterCovariance; + + // create the component + python::class_ component( + module, + "ParameterCovariance", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::vector &, + const covariance::RowData & + >(), + python::arg("label") = std::nullopt, + python::arg("parameter_covariance_matrix"), + python::arg("row_data"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "parameter_covariance_matrix", + python::overload_cast<>(&Component::parameterCovarianceMatrix), + Component::documentation("parameter_covariance_matrix").data() + ) + .def_property_readonly( + "row_data", + python::overload_cast<>(&Component::rowData), + Component::documentation("row_data").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/ParameterCovariances.python.cpp b/python/src/v2.0/covariance/ParameterCovariances.python.cpp new file mode 100644 index 000000000..cf937a7d0 --- /dev/null +++ b/python/src/v2.0/covariance/ParameterCovariances.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/ParameterCovariances.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// ParameterCovariances wrapper +void wrapParameterCovariances(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::ParameterCovariances; + + // create the component + python::class_ component( + module, + "ParameterCovariances", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional> &, + const std::optional> & + >(), + python::arg("average_parameter_covariance") = std::nullopt, + python::arg("parameter_covariance") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "average_parameter_covariance", + python::overload_cast<>(&Component::averageParameterCovariance), + Component::documentation("average_parameter_covariance").data() + ) + .def_property_readonly( + "parameter_covariance", + python::overload_cast<>(&Component::parameterCovariance), + Component::documentation("parameter_covariance").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/ParameterLink.python.cpp b/python/src/v2.0/covariance/ParameterLink.python.cpp new file mode 100644 index 000000000..679c108f5 --- /dev/null +++ b/python/src/v2.0/covariance/ParameterLink.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/ParameterLink.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// ParameterLink wrapper +void wrapParameterLink(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::ParameterLink; + + // create the component + python::class_ component( + module, + "ParameterLink", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("href") = std::nullopt, + python::arg("label") = std::nullopt, + python::arg("matrix_start_index") = std::nullopt, + python::arg("n_parameters") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "matrix_start_index", + [](const Component &self) { return self.matrixStartIndex().value(); }, + Component::documentation("matrix_start_index").data() + ) + .def_property_readonly( + "n_parameters", + [](const Component &self) { return self.nParameters().value(); }, + Component::documentation("n_parameters").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/Parameters.python.cpp b/python/src/v2.0/covariance/Parameters.python.cpp new file mode 100644 index 000000000..578b63bca --- /dev/null +++ b/python/src/v2.0/covariance/Parameters.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/Parameters.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// Parameters wrapper +void wrapParameters(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::Parameters; + + // create the component + python::class_ component( + module, + "Parameters", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional> & + >(), + python::arg("parameter_link") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "parameter_link", + python::overload_cast<>(&Component::parameterLink), + Component::documentation("parameter_link").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/RowData.python.cpp b/python/src/v2.0/covariance/RowData.python.cpp new file mode 100644 index 000000000..13b0d699c --- /dev/null +++ b/python/src/v2.0/covariance/RowData.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/RowData.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// RowData wrapper +void wrapRowData(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::RowData; + + // create the component + python::class_ component( + module, + "RowData", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("endf_mfmt") = std::nullopt, + python::arg("dimension") = std::nullopt, + python::arg("href") = std::nullopt, + python::arg("slices") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "endf_mfmt", + &Component::ENDF_MFMT, + Component::documentation("endf_mfmt").data() + ) + .def_property_readonly( + "dimension", + &Component::dimension, + Component::documentation("dimension").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + .def_property_readonly( + "slices", + python::overload_cast<>(&Component::slices), + Component::documentation("slices").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/RowSensitivity.python.cpp b/python/src/v2.0/covariance/RowSensitivity.python.cpp new file mode 100644 index 000000000..06ed2dd2f --- /dev/null +++ b/python/src/v2.0/covariance/RowSensitivity.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/RowSensitivity.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// RowSensitivity wrapper +void wrapRowSensitivity(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::RowSensitivity; + + // create the component + python::class_ component( + module, + "RowSensitivity", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const containers::Array & + >(), + python::arg("array"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "array", + python::overload_cast<>(&Component::array), + Component::documentation("array").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/SandwichProduct.python.cpp b/python/src/v2.0/covariance/SandwichProduct.python.cpp new file mode 100644 index 000000000..9e0a11c62 --- /dev/null +++ b/python/src/v2.0/covariance/SandwichProduct.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/SandwichProduct.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// SandwichProduct wrapper +void wrapSandwichProduct(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::SandwichProduct; + + // create the component + python::class_ component( + module, + "SandwichProduct", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const containers::Axes &, + const std::optional &, + const covariance::Covariance &, + const covariance::RowSensitivity & + >(), + python::arg("axes"), + python::arg("column_sensitivity") = std::nullopt, + python::arg("covariance"), + python::arg("row_sensitivity"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "axes", + python::overload_cast<>(&Component::axes), + Component::documentation("axes").data() + ) + .def_property_readonly( + "column_sensitivity", + python::overload_cast<>(&Component::columnSensitivity), + Component::documentation("column_sensitivity").data() + ) + .def_property_readonly( + "covariance", + python::overload_cast<>(&Component::covariance), + Component::documentation("covariance").data() + ) + .def_property_readonly( + "row_sensitivity", + python::overload_cast<>(&Component::rowSensitivity), + Component::documentation("row_sensitivity").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/ShortRangeSelfScalingVariance.python.cpp b/python/src/v2.0/covariance/ShortRangeSelfScalingVariance.python.cpp new file mode 100644 index 000000000..e3cb40ee0 --- /dev/null +++ b/python/src/v2.0/covariance/ShortRangeSelfScalingVariance.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/ShortRangeSelfScalingVariance.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// ShortRangeSelfScalingVariance wrapper +void wrapShortRangeSelfScalingVariance(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::ShortRangeSelfScalingVariance; + + // create the component + python::class_ component( + module, + "ShortRangeSelfScalingVariance", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("dependence_on_processed_group_width") = std::nullopt, + python::arg("label") = std::nullopt, + python::arg("type") = std::nullopt, + python::arg("gridded2d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "dependence_on_processed_group_width", + &Component::dependenceOnProcessedGroupWidth, + Component::documentation("dependence_on_processed_group_width").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "type", + &Component::type, + Component::documentation("type").data() + ) + .def_property_readonly( + "gridded2d", + python::overload_cast<>(&Component::gridded2d), + Component::documentation("gridded2d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/Slice.python.cpp b/python/src/v2.0/covariance/Slice.python.cpp new file mode 100644 index 000000000..77eb6e2e2 --- /dev/null +++ b/python/src/v2.0/covariance/Slice.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/Slice.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// Slice wrapper +void wrapSlice(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::Slice; + + // create the component + python::class_ component( + module, + "Slice", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const Integer32 &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("dimension"), + python::arg("domain_max") = std::nullopt, + python::arg("domain_min") = std::nullopt, + python::arg("domain_unit") = std::nullopt, + python::arg("domain_value") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "dimension", + &Component::dimension, + Component::documentation("dimension").data() + ) + .def_property_readonly( + "domain_max", + &Component::domainMax, + Component::documentation("domain_max").data() + ) + .def_property_readonly( + "domain_min", + &Component::domainMin, + Component::documentation("domain_min").data() + ) + .def_property_readonly( + "domain_unit", + &Component::domainUnit, + Component::documentation("domain_unit").data() + ) + .def_property_readonly( + "domain_value", + &Component::domainValue, + Component::documentation("domain_value").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/Slices.python.cpp b/python/src/v2.0/covariance/Slices.python.cpp new file mode 100644 index 000000000..6b749b173 --- /dev/null +++ b/python/src/v2.0/covariance/Slices.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/Slices.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// Slices wrapper +void wrapSlices(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::Slices; + + // create the component + python::class_ component( + module, + "Slices", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("slice"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "slice", + python::overload_cast<>(&Component::slice), + Component::documentation("slice").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/Sum.python.cpp b/python/src/v2.0/covariance/Sum.python.cpp new file mode 100644 index 000000000..bba0976c7 --- /dev/null +++ b/python/src/v2.0/covariance/Sum.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/Sum.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// Sum wrapper +void wrapSum(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::Sum; + + // create the component + python::class_ component( + module, + "Sum", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const Float64 &, + const Float64 &, + const XMLName &, + const std::optional &, + const std::optional> & + >(), + python::arg("domain_max"), + python::arg("domain_min"), + python::arg("domain_unit"), + python::arg("label") = std::nullopt, + python::arg("summand") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "domain_max", + &Component::domainMax, + Component::documentation("domain_max").data() + ) + .def_property_readonly( + "domain_min", + &Component::domainMin, + Component::documentation("domain_min").data() + ) + .def_property_readonly( + "domain_unit", + &Component::domainUnit, + Component::documentation("domain_unit").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "summand", + python::overload_cast<>(&Component::summand), + Component::documentation("summand").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/covariance/Summand.python.cpp b/python/src/v2.0/covariance/Summand.python.cpp new file mode 100644 index 000000000..268787c82 --- /dev/null +++ b/python/src/v2.0/covariance/Summand.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/covariance/Summand.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_covariance { + +// Summand wrapper +void wrapSummand(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = covariance::Summand; + + // create the component + python::class_ component( + module, + "Summand", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("endf_mfmt") = std::nullopt, + python::arg("coefficient") = std::nullopt, + python::arg("href") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "endf_mfmt", + &Component::ENDF_MFMT, + Component::documentation("endf_mfmt").data() + ) + .def_property_readonly( + "coefficient", + &Component::coefficient, + Component::documentation("coefficient").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_covariance +} // namespace python_v2_0 diff --git a/python/src/v2.0/cpTransport.python.cpp b/python/src/v2.0/cpTransport.python.cpp new file mode 100644 index 000000000..c5513b630 --- /dev/null +++ b/python/src/v2.0/cpTransport.python.cpp @@ -0,0 +1,43 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include +#include + +namespace python = pybind11; + +// v2.0 interface +namespace python_v2_0 { + +// cpTransport declarations +namespace python_cpTransport { + void wrapRutherfordScattering(python::module &); + void wrapImaginaryInterferenceTerm(python::module &); + void wrapNuclearTerm(python::module &); + void wrapRealInterferenceTerm(python::module &); + void wrapNuclearAmplitudeExpansion(python::module &); + void wrapNuclearPlusInterference(python::module &); + void wrapCoulombPlusNuclearElastic(python::module &); +} // namespace python_cpTransport + +// cpTransport wrapper +void wrapCpTransport(python::module &module) +{ + // create the cpTransport submodule + python::module submodule = module.def_submodule( + "cpTransport", + "GNDS v2.0 cpTransport" + ); + + // wrap cpTransport components + python_cpTransport::wrapRutherfordScattering(submodule); + python_cpTransport::wrapImaginaryInterferenceTerm(submodule); + python_cpTransport::wrapNuclearTerm(submodule); + python_cpTransport::wrapRealInterferenceTerm(submodule); + python_cpTransport::wrapNuclearAmplitudeExpansion(submodule); + python_cpTransport::wrapNuclearPlusInterference(submodule); + python_cpTransport::wrapCoulombPlusNuclearElastic(submodule); +}; + +} // namespace python_v2_0 diff --git a/python/src/v2.0/cpTransport/CoulombPlusNuclearElastic.python.cpp b/python/src/v2.0/cpTransport/CoulombPlusNuclearElastic.python.cpp new file mode 100644 index 000000000..6cc40e4d2 --- /dev/null +++ b/python/src/v2.0/cpTransport/CoulombPlusNuclearElastic.python.cpp @@ -0,0 +1,105 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/cpTransport/CoulombPlusNuclearElastic.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_cpTransport { + +// CoulombPlusNuclearElastic wrapper +void wrapCoulombPlusNuclearElastic(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = cpTransport::CoulombPlusNuclearElastic; + + // create the component + python::class_ component( + module, + "CoulombPlusNuclearElastic", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const XMLName &, + const XMLName &, + const enums::Frame &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("href") = std::nullopt, + python::arg("identical_particles") = std::nullopt, + python::arg("label"), + python::arg("pid"), + python::arg("product_frame"), + python::arg("rutherford_scattering") = std::nullopt, + python::arg("nuclear_amplitude_expansion") = std::nullopt, + python::arg("nuclear_plus_interference") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + .def_property_readonly( + "identical_particles", + [](const Component &self) { return self.identicalParticles().value(); }, + Component::documentation("identical_particles").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "pid", + &Component::pid, + Component::documentation("pid").data() + ) + .def_property_readonly( + "product_frame", + &Component::productFrame, + Component::documentation("product_frame").data() + ) + .def_property_readonly( + "rutherford_scattering", + python::overload_cast<>(&Component::RutherfordScattering), + Component::documentation("rutherford_scattering").data() + ) + .def_property_readonly( + "nuclear_amplitude_expansion", + python::overload_cast<>(&Component::nuclearAmplitudeExpansion), + Component::documentation("nuclear_amplitude_expansion").data() + ) + .def_property_readonly( + "nuclear_plus_interference", + python::overload_cast<>(&Component::nuclearPlusInterference), + Component::documentation("nuclear_plus_interference").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_cpTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/cpTransport/ImaginaryInterferenceTerm.python.cpp b/python/src/v2.0/cpTransport/ImaginaryInterferenceTerm.python.cpp new file mode 100644 index 000000000..f50a617ae --- /dev/null +++ b/python/src/v2.0/cpTransport/ImaginaryInterferenceTerm.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/cpTransport/ImaginaryInterferenceTerm.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_cpTransport { + +// ImaginaryInterferenceTerm wrapper +void wrapImaginaryInterferenceTerm(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = cpTransport::ImaginaryInterferenceTerm; + + // create the component + python::class_ component( + module, + "ImaginaryInterferenceTerm", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("xys2d") = std::nullopt, + python::arg("regions2d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys2d", + python::overload_cast<>(&Component::XYs2d), + Component::documentation("xys2d").data() + ) + .def_property_readonly( + "regions2d", + python::overload_cast<>(&Component::regions2d), + Component::documentation("regions2d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_cpTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/cpTransport/NuclearAmplitudeExpansion.python.cpp b/python/src/v2.0/cpTransport/NuclearAmplitudeExpansion.python.cpp new file mode 100644 index 000000000..bb2f70589 --- /dev/null +++ b/python/src/v2.0/cpTransport/NuclearAmplitudeExpansion.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/cpTransport/NuclearAmplitudeExpansion.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_cpTransport { + +// NuclearAmplitudeExpansion wrapper +void wrapNuclearAmplitudeExpansion(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = cpTransport::NuclearAmplitudeExpansion; + + // create the component + python::class_ component( + module, + "NuclearAmplitudeExpansion", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const cpTransport::ImaginaryInterferenceTerm &, + const cpTransport::NuclearTerm &, + const cpTransport::RealInterferenceTerm & + >(), + python::arg("imaginary_interference_term"), + python::arg("nuclear_term"), + python::arg("real_interference_term"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "imaginary_interference_term", + python::overload_cast<>(&Component::imaginaryInterferenceTerm), + Component::documentation("imaginary_interference_term").data() + ) + .def_property_readonly( + "nuclear_term", + python::overload_cast<>(&Component::nuclearTerm), + Component::documentation("nuclear_term").data() + ) + .def_property_readonly( + "real_interference_term", + python::overload_cast<>(&Component::realInterferenceTerm), + Component::documentation("real_interference_term").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_cpTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/cpTransport/NuclearPlusInterference.python.cpp b/python/src/v2.0/cpTransport/NuclearPlusInterference.python.cpp new file mode 100644 index 000000000..fd1c96a29 --- /dev/null +++ b/python/src/v2.0/cpTransport/NuclearPlusInterference.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/cpTransport/NuclearPlusInterference.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_cpTransport { + +// NuclearPlusInterference wrapper +void wrapNuclearPlusInterference(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = cpTransport::NuclearPlusInterference; + + // create the component + python::class_ component( + module, + "NuclearPlusInterference", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const Float64 &, + const transport::CrossSection &, + const transport::Distribution & + >(), + python::arg("mu_cutoff"), + python::arg("cross_section"), + python::arg("distribution"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "mu_cutoff", + &Component::muCutoff, + Component::documentation("mu_cutoff").data() + ) + .def_property_readonly( + "cross_section", + python::overload_cast<>(&Component::crossSection), + Component::documentation("cross_section").data() + ) + .def_property_readonly( + "distribution", + python::overload_cast<>(&Component::distribution), + Component::documentation("distribution").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_cpTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/cpTransport/NuclearTerm.python.cpp b/python/src/v2.0/cpTransport/NuclearTerm.python.cpp new file mode 100644 index 000000000..25f0d280b --- /dev/null +++ b/python/src/v2.0/cpTransport/NuclearTerm.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/cpTransport/NuclearTerm.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_cpTransport { + +// NuclearTerm wrapper +void wrapNuclearTerm(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = cpTransport::NuclearTerm; + + // create the component + python::class_ component( + module, + "NuclearTerm", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("xys2d") = std::nullopt, + python::arg("regions2d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys2d", + python::overload_cast<>(&Component::XYs2d), + Component::documentation("xys2d").data() + ) + .def_property_readonly( + "regions2d", + python::overload_cast<>(&Component::regions2d), + Component::documentation("regions2d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_cpTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/cpTransport/RealInterferenceTerm.python.cpp b/python/src/v2.0/cpTransport/RealInterferenceTerm.python.cpp new file mode 100644 index 000000000..9e8e2aebd --- /dev/null +++ b/python/src/v2.0/cpTransport/RealInterferenceTerm.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/cpTransport/RealInterferenceTerm.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_cpTransport { + +// RealInterferenceTerm wrapper +void wrapRealInterferenceTerm(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = cpTransport::RealInterferenceTerm; + + // create the component + python::class_ component( + module, + "RealInterferenceTerm", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("xys2d") = std::nullopt, + python::arg("regions2d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys2d", + python::overload_cast<>(&Component::XYs2d), + Component::documentation("xys2d").data() + ) + .def_property_readonly( + "regions2d", + python::overload_cast<>(&Component::regions2d), + Component::documentation("regions2d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_cpTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/cpTransport/RutherfordScattering.python.cpp b/python/src/v2.0/cpTransport/RutherfordScattering.python.cpp new file mode 100644 index 000000000..e0c66a750 --- /dev/null +++ b/python/src/v2.0/cpTransport/RutherfordScattering.python.cpp @@ -0,0 +1,49 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/cpTransport/RutherfordScattering.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_cpTransport { + +// RutherfordScattering wrapper +void wrapRutherfordScattering(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = cpTransport::RutherfordScattering; + + // create the component + python::class_ component( + module, + "RutherfordScattering", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + >(), + Component::documentation("constructor").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_cpTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation.python.cpp b/python/src/v2.0/documentation.python.cpp new file mode 100644 index 000000000..412446621 --- /dev/null +++ b/python/src/v2.0/documentation.python.cpp @@ -0,0 +1,89 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include +#include + +namespace python = pybind11; + +// v2.0 interface +namespace python_v2_0 { + +// documentation declarations +namespace python_documentation { + void wrapAcknowledgement(python::module &); + void wrapAcknowledgements(python::module &); + void wrapAffiliation(python::module &); + void wrapAffiliations(python::module &); + void wrapAuthor(python::module &); + void wrapAuthors(python::module &); + void wrapBibitem(python::module &); + void wrapBibliography(python::module &); + void wrapCollaboration(python::module &); + void wrapCollaborations(python::module &); + void wrapCodeRepo(python::module &); + void wrapInputDeck(python::module &); + void wrapInputDecks(python::module &); + void wrapOutputDeck(python::module &); + void wrapOutputDecks(python::module &); + void wrapComputerCode(python::module &); + void wrapComputerCodes(python::module &); + void wrapContributor(python::module &); + void wrapContributors(python::module &); + void wrapCopyright(python::module &); + void wrapDate(python::module &); + void wrapDates(python::module &); + void wrapExforDataSet(python::module &); + void wrapExforDataSets(python::module &); + void wrapExperimentalDataSets(python::module &); + void wrapKeyword(python::module &); + void wrapKeywords(python::module &); + void wrapRelatedItem(python::module &); + void wrapRelatedItems(python::module &); + void wrapDocumentation(python::module &); +} // namespace python_documentation + +// documentation wrapper +void wrapDocumentation(python::module &module) +{ + // create the documentation submodule + python::module submodule = module.def_submodule( + "documentation", + "GNDS v2.0 documentation" + ); + + // wrap documentation components + python_documentation::wrapAcknowledgement(submodule); + python_documentation::wrapAcknowledgements(submodule); + python_documentation::wrapAffiliation(submodule); + python_documentation::wrapAffiliations(submodule); + python_documentation::wrapAuthor(submodule); + python_documentation::wrapAuthors(submodule); + python_documentation::wrapBibitem(submodule); + python_documentation::wrapBibliography(submodule); + python_documentation::wrapCollaboration(submodule); + python_documentation::wrapCollaborations(submodule); + python_documentation::wrapCodeRepo(submodule); + python_documentation::wrapInputDeck(submodule); + python_documentation::wrapInputDecks(submodule); + python_documentation::wrapOutputDeck(submodule); + python_documentation::wrapOutputDecks(submodule); + python_documentation::wrapComputerCode(submodule); + python_documentation::wrapComputerCodes(submodule); + python_documentation::wrapContributor(submodule); + python_documentation::wrapContributors(submodule); + python_documentation::wrapCopyright(submodule); + python_documentation::wrapDate(submodule); + python_documentation::wrapDates(submodule); + python_documentation::wrapExforDataSet(submodule); + python_documentation::wrapExforDataSets(submodule); + python_documentation::wrapExperimentalDataSets(submodule); + python_documentation::wrapKeyword(submodule); + python_documentation::wrapKeywords(submodule); + python_documentation::wrapRelatedItem(submodule); + python_documentation::wrapRelatedItems(submodule); + python_documentation::wrapDocumentation(submodule); +}; + +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Acknowledgement.python.cpp b/python/src/v2.0/documentation/Acknowledgement.python.cpp new file mode 100644 index 000000000..ad9aa4096 --- /dev/null +++ b/python/src/v2.0/documentation/Acknowledgement.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Acknowledgement.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Acknowledgement wrapper +void wrapAcknowledgement(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Acknowledgement; + + // create the component + python::class_ component( + module, + "Acknowledgement", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName & + >(), + python::arg("label"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Acknowledgements.python.cpp b/python/src/v2.0/documentation/Acknowledgements.python.cpp new file mode 100644 index 000000000..b4f45ea70 --- /dev/null +++ b/python/src/v2.0/documentation/Acknowledgements.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Acknowledgements.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Acknowledgements wrapper +void wrapAcknowledgements(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Acknowledgements; + + // create the component + python::class_ component( + module, + "Acknowledgements", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("acknowledgement"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "acknowledgement", + python::overload_cast<>(&Component::acknowledgement), + Component::documentation("acknowledgement").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Affiliation.python.cpp b/python/src/v2.0/documentation/Affiliation.python.cpp new file mode 100644 index 000000000..7855ab744 --- /dev/null +++ b/python/src/v2.0/documentation/Affiliation.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Affiliation.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Affiliation wrapper +void wrapAffiliation(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Affiliation; + + // create the component + python::class_ component( + module, + "Affiliation", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const UTF8Text & + >(), + python::arg("href") = std::nullopt, + python::arg("name"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + .def_property_readonly( + "name", + &Component::name, + Component::documentation("name").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Affiliations.python.cpp b/python/src/v2.0/documentation/Affiliations.python.cpp new file mode 100644 index 000000000..c39742815 --- /dev/null +++ b/python/src/v2.0/documentation/Affiliations.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Affiliations.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Affiliations wrapper +void wrapAffiliations(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Affiliations; + + // create the component + python::class_ component( + module, + "Affiliations", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("affiliation"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "affiliation", + python::overload_cast<>(&Component::affiliation), + Component::documentation("affiliation").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Author.python.cpp b/python/src/v2.0/documentation/Author.python.cpp new file mode 100644 index 000000000..1b7e72afd --- /dev/null +++ b/python/src/v2.0/documentation/Author.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Author.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Author wrapper +void wrapAuthor(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Author; + + // create the component + python::class_ component( + module, + "Author", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const UTF8Text &, + const std::optional &, + const std::optional & + >(), + python::arg("email") = std::nullopt, + python::arg("name"), + python::arg("orcid_id") = std::nullopt, + python::arg("affiliations") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "email", + &Component::email, + Component::documentation("email").data() + ) + .def_property_readonly( + "name", + &Component::name, + Component::documentation("name").data() + ) + .def_property_readonly( + "orcid_id", + &Component::orcid_id, + Component::documentation("orcid_id").data() + ) + .def_property_readonly( + "affiliations", + python::overload_cast<>(&Component::affiliations), + Component::documentation("affiliations").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Authors.python.cpp b/python/src/v2.0/documentation/Authors.python.cpp new file mode 100644 index 000000000..2464c7a6c --- /dev/null +++ b/python/src/v2.0/documentation/Authors.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Authors.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Authors wrapper +void wrapAuthors(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Authors; + + // create the component + python::class_ component( + module, + "Authors", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("author"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "author", + python::overload_cast<>(&Component::author), + Component::documentation("author").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Bibitem.python.cpp b/python/src/v2.0/documentation/Bibitem.python.cpp new file mode 100644 index 000000000..597e83915 --- /dev/null +++ b/python/src/v2.0/documentation/Bibitem.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Bibitem.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Bibitem wrapper +void wrapBibitem(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Bibitem; + + // create the component + python::class_ component( + module, + "Bibitem", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName & + >(), + python::arg("xref"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xref", + &Component::xref, + Component::documentation("xref").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Bibliography.python.cpp b/python/src/v2.0/documentation/Bibliography.python.cpp new file mode 100644 index 000000000..92aea4702 --- /dev/null +++ b/python/src/v2.0/documentation/Bibliography.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Bibliography.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Bibliography wrapper +void wrapBibliography(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Bibliography; + + // create the component + python::class_ component( + module, + "Bibliography", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("bibitem"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "bibitem", + python::overload_cast<>(&Component::bibitem), + Component::documentation("bibitem").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Body.python.cpp b/python/src/v2.0/documentation/Body.python.cpp new file mode 100644 index 000000000..f3d692294 --- /dev/null +++ b/python/src/v2.0/documentation/Body.python.cpp @@ -0,0 +1,49 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Body.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Body wrapper +void wrapBody(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Body; + + // create the component + python::class_ component( + module, + "Body", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + >(), + Component::documentation("constructor").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/CodeRepo.python.cpp b/python/src/v2.0/documentation/CodeRepo.python.cpp new file mode 100644 index 000000000..9bf199e41 --- /dev/null +++ b/python/src/v2.0/documentation/CodeRepo.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/CodeRepo.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// CodeRepo wrapper +void wrapCodeRepo(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::CodeRepo; + + // create the component + python::class_ component( + module, + "CodeRepo", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const XMLName &, + const XMLName & + >(), + python::arg("href"), + python::arg("revision_id"), + python::arg("revision_system"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + .def_property_readonly( + "revision_id", + &Component::revisionID, + Component::documentation("revision_id").data() + ) + .def_property_readonly( + "revision_system", + &Component::revisionSystem, + Component::documentation("revision_system").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Collaboration.python.cpp b/python/src/v2.0/documentation/Collaboration.python.cpp new file mode 100644 index 000000000..f18576523 --- /dev/null +++ b/python/src/v2.0/documentation/Collaboration.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Collaboration.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Collaboration wrapper +void wrapCollaboration(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Collaboration; + + // create the component + python::class_ component( + module, + "Collaboration", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const UTF8Text & + >(), + python::arg("href") = std::nullopt, + python::arg("name"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + .def_property_readonly( + "name", + &Component::name, + Component::documentation("name").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Collaborations.python.cpp b/python/src/v2.0/documentation/Collaborations.python.cpp new file mode 100644 index 000000000..f53919497 --- /dev/null +++ b/python/src/v2.0/documentation/Collaborations.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Collaborations.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Collaborations wrapper +void wrapCollaborations(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Collaborations; + + // create the component + python::class_ component( + module, + "Collaborations", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("collaboration"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "collaboration", + python::overload_cast<>(&Component::collaboration), + Component::documentation("collaboration").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/ComputerCode.python.cpp b/python/src/v2.0/documentation/ComputerCode.python.cpp new file mode 100644 index 000000000..983892e5b --- /dev/null +++ b/python/src/v2.0/documentation/ComputerCode.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/ComputerCode.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// ComputerCode wrapper +void wrapComputerCode(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::ComputerCode; + + // create the component + python::class_ component( + module, + "ComputerCode", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const UTF8Text &, + const XMLName &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("name"), + python::arg("version"), + python::arg("code_repo") = std::nullopt, + python::arg("input_decks") = std::nullopt, + python::arg("output_decks") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "name", + &Component::name, + Component::documentation("name").data() + ) + .def_property_readonly( + "version", + &Component::version, + Component::documentation("version").data() + ) + .def_property_readonly( + "code_repo", + python::overload_cast<>(&Component::codeRepo), + Component::documentation("code_repo").data() + ) + .def_property_readonly( + "input_decks", + python::overload_cast<>(&Component::inputDecks), + Component::documentation("input_decks").data() + ) + .def_property_readonly( + "output_decks", + python::overload_cast<>(&Component::outputDecks), + Component::documentation("output_decks").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/ComputerCodes.python.cpp b/python/src/v2.0/documentation/ComputerCodes.python.cpp new file mode 100644 index 000000000..7d879cd0c --- /dev/null +++ b/python/src/v2.0/documentation/ComputerCodes.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/ComputerCodes.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// ComputerCodes wrapper +void wrapComputerCodes(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::ComputerCodes; + + // create the component + python::class_ component( + module, + "ComputerCodes", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("computer_code"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "computer_code", + python::overload_cast<>(&Component::computerCode), + Component::documentation("computer_code").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Contributor.python.cpp b/python/src/v2.0/documentation/Contributor.python.cpp new file mode 100644 index 000000000..64c3a3c15 --- /dev/null +++ b/python/src/v2.0/documentation/Contributor.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Contributor.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Contributor wrapper +void wrapContributor(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Contributor; + + // create the component + python::class_ component( + module, + "Contributor", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const enums::ContributorType &, + const std::optional &, + const UTF8Text &, + const std::optional &, + const std::optional & + >(), + python::arg("contributor_type"), + python::arg("email") = std::nullopt, + python::arg("name"), + python::arg("orcid_id") = std::nullopt, + python::arg("affiliations") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "contributor_type", + &Component::contributorType, + Component::documentation("contributor_type").data() + ) + .def_property_readonly( + "email", + &Component::email, + Component::documentation("email").data() + ) + .def_property_readonly( + "name", + &Component::name, + Component::documentation("name").data() + ) + .def_property_readonly( + "orcid_id", + &Component::orcid_id, + Component::documentation("orcid_id").data() + ) + .def_property_readonly( + "affiliations", + python::overload_cast<>(&Component::affiliations), + Component::documentation("affiliations").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Contributors.python.cpp b/python/src/v2.0/documentation/Contributors.python.cpp new file mode 100644 index 000000000..c419eb923 --- /dev/null +++ b/python/src/v2.0/documentation/Contributors.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Contributors.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Contributors wrapper +void wrapContributors(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Contributors; + + // create the component + python::class_ component( + module, + "Contributors", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("contributor"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "contributor", + python::overload_cast<>(&Component::contributor), + Component::documentation("contributor").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Copyright.python.cpp b/python/src/v2.0/documentation/Copyright.python.cpp new file mode 100644 index 000000000..9f0696bb2 --- /dev/null +++ b/python/src/v2.0/documentation/Copyright.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Copyright.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Copyright wrapper +void wrapCopyright(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Copyright; + + // create the component + python::class_ component( + module, + "Copyright", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("href") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/CorrectionScript.python.cpp b/python/src/v2.0/documentation/CorrectionScript.python.cpp new file mode 100644 index 000000000..5aba50f1f --- /dev/null +++ b/python/src/v2.0/documentation/CorrectionScript.python.cpp @@ -0,0 +1,49 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/CorrectionScript.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// CorrectionScript wrapper +void wrapCorrectionScript(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::CorrectionScript; + + // create the component + python::class_ component( + module, + "CorrectionScript", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + >(), + Component::documentation("constructor").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/CovarianceScript.python.cpp b/python/src/v2.0/documentation/CovarianceScript.python.cpp new file mode 100644 index 000000000..609ec09d1 --- /dev/null +++ b/python/src/v2.0/documentation/CovarianceScript.python.cpp @@ -0,0 +1,49 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/CovarianceScript.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// CovarianceScript wrapper +void wrapCovarianceScript(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::CovarianceScript; + + // create the component + python::class_ component( + module, + "CovarianceScript", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + >(), + Component::documentation("constructor").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Date.python.cpp b/python/src/v2.0/documentation/Date.python.cpp new file mode 100644 index 000000000..e36e73d16 --- /dev/null +++ b/python/src/v2.0/documentation/Date.python.cpp @@ -0,0 +1,92 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Date.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Date wrapper +void wrapDate(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Date; + + // create the component + python::class_ component( + module, + "Date", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const enums::DateType & + >(), + python::arg("date_type"), + Component::documentation("constructor").data() + ) + .def( + python::init< + const std::vector & + >(), + python::arg("ints"), + Component::documentation("constructor").data() + ) + .def( + python::init< + const std::vector & + >(), + python::arg("doubles"), + Component::documentation("constructor").data() + ) + .def( + python::init< + const std::vector & + >(), + python::arg("strings"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "date_type", + &Component::dateType, + Component::documentation("date_type").data() + ) + .def_property_readonly( + "ints", + [] (const Component &self) { return self.ints(); }, + Component::documentation("ints").data() + ) + .def_property_readonly( + "doubles", + [] (const Component &self) { return self.doubles(); }, + Component::documentation("doubles").data() + ) + .def_property_readonly( + "strings", + [] (const Component &self) { return self.strings(); }, + Component::documentation("strings").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Dates.python.cpp b/python/src/v2.0/documentation/Dates.python.cpp new file mode 100644 index 000000000..aca6860bc --- /dev/null +++ b/python/src/v2.0/documentation/Dates.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Dates.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Dates wrapper +void wrapDates(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Dates; + + // create the component + python::class_ component( + module, + "Dates", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("date"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "date", + python::overload_cast<>(&Component::date), + Component::documentation("date").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Documentation.python.cpp b/python/src/v2.0/documentation/Documentation.python.cpp new file mode 100644 index 000000000..cdedfe9b9 --- /dev/null +++ b/python/src/v2.0/documentation/Documentation.python.cpp @@ -0,0 +1,147 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Documentation.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Documentation wrapper +void wrapDocumentation(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Documentation; + + // create the component + python::class_ component( + module, + "Documentation", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const documentation::Authors &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const documentation::Dates &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("doi") = std::nullopt, + python::arg("publication_date") = std::nullopt, + python::arg("version") = std::nullopt, + python::arg("acknowledgements") = std::nullopt, + python::arg("authors"), + python::arg("bibliography") = std::nullopt, + python::arg("collaborations") = std::nullopt, + python::arg("computer_codes") = std::nullopt, + python::arg("contributors") = std::nullopt, + python::arg("copyright") = std::nullopt, + python::arg("dates"), + python::arg("experimental_data_sets") = std::nullopt, + python::arg("keywords") = std::nullopt, + python::arg("related_items") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "doi", + &Component::doi, + Component::documentation("doi").data() + ) + .def_property_readonly( + "publication_date", + &Component::publicationDate, + Component::documentation("publication_date").data() + ) + .def_property_readonly( + "version", + &Component::version, + Component::documentation("version").data() + ) + .def_property_readonly( + "acknowledgements", + python::overload_cast<>(&Component::acknowledgements), + Component::documentation("acknowledgements").data() + ) + .def_property_readonly( + "authors", + python::overload_cast<>(&Component::authors), + Component::documentation("authors").data() + ) + .def_property_readonly( + "bibliography", + python::overload_cast<>(&Component::bibliography), + Component::documentation("bibliography").data() + ) + .def_property_readonly( + "collaborations", + python::overload_cast<>(&Component::collaborations), + Component::documentation("collaborations").data() + ) + .def_property_readonly( + "computer_codes", + python::overload_cast<>(&Component::computerCodes), + Component::documentation("computer_codes").data() + ) + .def_property_readonly( + "contributors", + python::overload_cast<>(&Component::contributors), + Component::documentation("contributors").data() + ) + .def_property_readonly( + "copyright", + python::overload_cast<>(&Component::copyright), + Component::documentation("copyright").data() + ) + .def_property_readonly( + "dates", + python::overload_cast<>(&Component::dates), + Component::documentation("dates").data() + ) + .def_property_readonly( + "experimental_data_sets", + python::overload_cast<>(&Component::experimentalDataSets), + Component::documentation("experimental_data_sets").data() + ) + .def_property_readonly( + "keywords", + python::overload_cast<>(&Component::keywords), + Component::documentation("keywords").data() + ) + .def_property_readonly( + "related_items", + python::overload_cast<>(&Component::relatedItems), + Component::documentation("related_items").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/EndfCompatible.python.cpp b/python/src/v2.0/documentation/EndfCompatible.python.cpp new file mode 100644 index 000000000..511ee9d89 --- /dev/null +++ b/python/src/v2.0/documentation/EndfCompatible.python.cpp @@ -0,0 +1,49 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/EndfCompatible.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// EndfCompatible wrapper +void wrapEndfCompatible(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::EndfCompatible; + + // create the component + python::class_ component( + module, + "EndfCompatible", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + >(), + Component::documentation("constructor").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/ExecutionArguments.python.cpp b/python/src/v2.0/documentation/ExecutionArguments.python.cpp new file mode 100644 index 000000000..7c95287c7 --- /dev/null +++ b/python/src/v2.0/documentation/ExecutionArguments.python.cpp @@ -0,0 +1,49 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/ExecutionArguments.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// ExecutionArguments wrapper +void wrapExecutionArguments(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::ExecutionArguments; + + // create the component + python::class_ component( + module, + "ExecutionArguments", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + >(), + Component::documentation("constructor").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/ExforDataSet.python.cpp b/python/src/v2.0/documentation/ExforDataSet.python.cpp new file mode 100644 index 000000000..d2b649c26 --- /dev/null +++ b/python/src/v2.0/documentation/ExforDataSet.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/ExforDataSet.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// ExforDataSet wrapper +void wrapExforDataSet(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::ExforDataSet; + + // create the component + python::class_ component( + module, + "ExforDataSet", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const XMLName & + >(), + python::arg("retrieval_date"), + python::arg("subentry"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "retrieval_date", + &Component::retrievalDate, + Component::documentation("retrieval_date").data() + ) + .def_property_readonly( + "subentry", + &Component::subentry, + Component::documentation("subentry").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/ExforDataSets.python.cpp b/python/src/v2.0/documentation/ExforDataSets.python.cpp new file mode 100644 index 000000000..4d6a7a9ca --- /dev/null +++ b/python/src/v2.0/documentation/ExforDataSets.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/ExforDataSets.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// ExforDataSets wrapper +void wrapExforDataSets(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::ExforDataSets; + + // create the component + python::class_ component( + module, + "ExforDataSets", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("exfor_data_set"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "exfor_data_set", + python::overload_cast<>(&Component::exforDataSet), + Component::documentation("exfor_data_set").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/ExperimentalDataSets.python.cpp b/python/src/v2.0/documentation/ExperimentalDataSets.python.cpp new file mode 100644 index 000000000..7d45df8dd --- /dev/null +++ b/python/src/v2.0/documentation/ExperimentalDataSets.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/ExperimentalDataSets.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// ExperimentalDataSets wrapper +void wrapExperimentalDataSets(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::ExperimentalDataSets; + + // create the component + python::class_ component( + module, + "ExperimentalDataSets", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const documentation::ExforDataSets & + >(), + python::arg("exfor_data_sets"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "exfor_data_sets", + python::overload_cast<>(&Component::exforDataSets), + Component::documentation("exfor_data_sets").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/InputDeck.python.cpp b/python/src/v2.0/documentation/InputDeck.python.cpp new file mode 100644 index 000000000..cce675f10 --- /dev/null +++ b/python/src/v2.0/documentation/InputDeck.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/InputDeck.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// InputDeck wrapper +void wrapInputDeck(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::InputDeck; + + // create the component + python::class_ component( + module, + "InputDeck", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("filename") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "filename", + &Component::filename, + Component::documentation("filename").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/InputDecks.python.cpp b/python/src/v2.0/documentation/InputDecks.python.cpp new file mode 100644 index 000000000..87e030f00 --- /dev/null +++ b/python/src/v2.0/documentation/InputDecks.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/InputDecks.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// InputDecks wrapper +void wrapInputDecks(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::InputDecks; + + // create the component + python::class_ component( + module, + "InputDecks", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("input_deck"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "input_deck", + python::overload_cast<>(&Component::inputDeck), + Component::documentation("input_deck").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Keyword.python.cpp b/python/src/v2.0/documentation/Keyword.python.cpp new file mode 100644 index 000000000..85a7965e3 --- /dev/null +++ b/python/src/v2.0/documentation/Keyword.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Keyword.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Keyword wrapper +void wrapKeyword(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Keyword; + + // create the component + python::class_ component( + module, + "Keyword", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName & + >(), + python::arg("type"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "type", + &Component::type, + Component::documentation("type").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Keywords.python.cpp b/python/src/v2.0/documentation/Keywords.python.cpp new file mode 100644 index 000000000..bf3bf30b5 --- /dev/null +++ b/python/src/v2.0/documentation/Keywords.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Keywords.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Keywords wrapper +void wrapKeywords(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Keywords; + + // create the component + python::class_ component( + module, + "Keywords", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("keyword"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "keyword", + python::overload_cast<>(&Component::keyword), + Component::documentation("keyword").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Note.python.cpp b/python/src/v2.0/documentation/Note.python.cpp new file mode 100644 index 000000000..9dcd6af22 --- /dev/null +++ b/python/src/v2.0/documentation/Note.python.cpp @@ -0,0 +1,49 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Note.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Note wrapper +void wrapNote(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Note; + + // create the component + python::class_ component( + module, + "Note", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + >(), + Component::documentation("constructor").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/OutputDeck.python.cpp b/python/src/v2.0/documentation/OutputDeck.python.cpp new file mode 100644 index 000000000..ebbf13caf --- /dev/null +++ b/python/src/v2.0/documentation/OutputDeck.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/OutputDeck.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// OutputDeck wrapper +void wrapOutputDeck(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::OutputDeck; + + // create the component + python::class_ component( + module, + "OutputDeck", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("filename") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "filename", + &Component::filename, + Component::documentation("filename").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/OutputDecks.python.cpp b/python/src/v2.0/documentation/OutputDecks.python.cpp new file mode 100644 index 000000000..fd9aeda27 --- /dev/null +++ b/python/src/v2.0/documentation/OutputDecks.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/OutputDecks.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// OutputDecks wrapper +void wrapOutputDecks(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::OutputDecks; + + // create the component + python::class_ component( + module, + "OutputDecks", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("output_deck"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "output_deck", + python::overload_cast<>(&Component::outputDeck), + Component::documentation("output_deck").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/RelatedItem.python.cpp b/python/src/v2.0/documentation/RelatedItem.python.cpp new file mode 100644 index 000000000..946db207b --- /dev/null +++ b/python/src/v2.0/documentation/RelatedItem.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/RelatedItem.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// RelatedItem wrapper +void wrapRelatedItem(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::RelatedItem; + + // create the component + python::class_ component( + module, + "RelatedItem", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const UTF8Text &, + const std::optional & + >(), + python::arg("href") = std::nullopt, + python::arg("name"), + python::arg("relation_type") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + .def_property_readonly( + "name", + &Component::name, + Component::documentation("name").data() + ) + .def_property_readonly( + "relation_type", + &Component::relationType, + Component::documentation("relation_type").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/RelatedItems.python.cpp b/python/src/v2.0/documentation/RelatedItems.python.cpp new file mode 100644 index 000000000..83755cd6d --- /dev/null +++ b/python/src/v2.0/documentation/RelatedItems.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/RelatedItems.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// RelatedItems wrapper +void wrapRelatedItems(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::RelatedItems; + + // create the component + python::class_ component( + module, + "RelatedItems", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("related_item"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "related_item", + python::overload_cast<>(&Component::relatedItem), + Component::documentation("related_item").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/documentation/Version.python.cpp b/python/src/v2.0/documentation/Version.python.cpp new file mode 100644 index 000000000..653c851db --- /dev/null +++ b/python/src/v2.0/documentation/Version.python.cpp @@ -0,0 +1,49 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/documentation/Version.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_documentation { + +// Version wrapper +void wrapVersion(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = documentation::Version; + + // create the component + python::class_ component( + module, + "Version", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + >(), + Component::documentation("constructor").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_documentation +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionFragmentData.python.cpp b/python/src/v2.0/fissionFragmentData.python.cpp new file mode 100644 index 000000000..f07e98b83 --- /dev/null +++ b/python/src/v2.0/fissionFragmentData.python.cpp @@ -0,0 +1,37 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include +#include + +namespace python = pybind11; + +// v2.0 interface +namespace python_v2_0 { + +// fissionFragmentData declarations +namespace python_fissionFragmentData { + void wrapRate(python::module &); + void wrapDelayedNeutron(python::module &); + void wrapDelayedNeutrons(python::module &); + void wrapFissionFragmentData(python::module &); +} // namespace python_fissionFragmentData + +// fissionFragmentData wrapper +void wrapFissionFragmentData(python::module &module) +{ + // create the fissionFragmentData submodule + python::module submodule = module.def_submodule( + "fissionFragmentData", + "GNDS v2.0 fissionFragmentData" + ); + + // wrap fissionFragmentData components + python_fissionFragmentData::wrapRate(submodule); + python_fissionFragmentData::wrapDelayedNeutron(submodule); + python_fissionFragmentData::wrapDelayedNeutrons(submodule); + python_fissionFragmentData::wrapFissionFragmentData(submodule); +}; + +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionFragmentData/DelayedNeutron.python.cpp b/python/src/v2.0/fissionFragmentData/DelayedNeutron.python.cpp new file mode 100644 index 000000000..382706b79 --- /dev/null +++ b/python/src/v2.0/fissionFragmentData/DelayedNeutron.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionFragmentData/DelayedNeutron.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionFragmentData { + +// DelayedNeutron wrapper +void wrapDelayedNeutron(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionFragmentData::DelayedNeutron; + + // create the component + python::class_ component( + module, + "DelayedNeutron", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const pops::Product &, + const fissionFragmentData::Rate & + >(), + python::arg("label"), + python::arg("product"), + python::arg("rate"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "product", + python::overload_cast<>(&Component::product), + Component::documentation("product").data() + ) + .def_property_readonly( + "rate", + python::overload_cast<>(&Component::rate), + Component::documentation("rate").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionFragmentData +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionFragmentData/DelayedNeutrons.python.cpp b/python/src/v2.0/fissionFragmentData/DelayedNeutrons.python.cpp new file mode 100644 index 000000000..bf0f6b0cc --- /dev/null +++ b/python/src/v2.0/fissionFragmentData/DelayedNeutrons.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionFragmentData/DelayedNeutrons.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionFragmentData { + +// DelayedNeutrons wrapper +void wrapDelayedNeutrons(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionFragmentData::DelayedNeutrons; + + // create the component + python::class_ component( + module, + "DelayedNeutrons", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("delayed_neutron"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "delayed_neutron", + python::overload_cast<>(&Component::delayedNeutron), + Component::documentation("delayed_neutron").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionFragmentData +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionFragmentData/FissionFragmentData.python.cpp b/python/src/v2.0/fissionFragmentData/FissionFragmentData.python.cpp new file mode 100644 index 000000000..ff341ce62 --- /dev/null +++ b/python/src/v2.0/fissionFragmentData/FissionFragmentData.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionFragmentData/FissionFragmentData.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionFragmentData { + +// FissionFragmentData wrapper +void wrapFissionFragmentData(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionFragmentData::FissionFragmentData; + + // create the component + python::class_ component( + module, + "FissionFragmentData", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("delayed_neutrons") = std::nullopt, + python::arg("fission_energy_released") = std::nullopt, + python::arg("product_yields") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "delayed_neutrons", + python::overload_cast<>(&Component::delayedNeutrons), + Component::documentation("delayed_neutrons").data() + ) + .def_property_readonly( + "fission_energy_released", + python::overload_cast<>(&Component::fissionEnergyReleased), + Component::documentation("fission_energy_released").data() + ) + .def_property_readonly( + "product_yields", + python::overload_cast<>(&Component::productYields), + Component::documentation("product_yields").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionFragmentData +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionFragmentData/Rate.python.cpp b/python/src/v2.0/fissionFragmentData/Rate.python.cpp new file mode 100644 index 000000000..4f451f1d2 --- /dev/null +++ b/python/src/v2.0/fissionFragmentData/Rate.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionFragmentData/Rate.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionFragmentData { + +// Rate wrapper +void wrapRate(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionFragmentData::Rate; + + // create the component + python::class_ component( + module, + "Rate", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const containers::Double & + >(), + python::arg("double"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "double", + python::overload_cast<>(&Component::Double), + Component::documentation("double").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionFragmentData +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionTransport.python.cpp b/python/src/v2.0/fissionTransport.python.cpp new file mode 100644 index 000000000..b1846e8ff --- /dev/null +++ b/python/src/v2.0/fissionTransport.python.cpp @@ -0,0 +1,67 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include +#include + +namespace python = pybind11; + +// v2.0 interface +namespace python_v2_0 { + +// fissionTransport declarations +namespace python_fissionTransport { + void wrapEFH(python::module &); + void wrapEFL(python::module &); + void wrapT_M(python::module &); + void wrapMadlandNix(python::module &); + void wrapB(python::module &); + void wrapWatt(python::module &); + void wrapSimpleMaxwellianFission(python::module &); + void wrapDelayedBetaEnergy(python::module &); + void wrapDelayedGammaEnergy(python::module &); + void wrapDelayedNeutronKE(python::module &); + void wrapNeutrinoEnergy(python::module &); + void wrapNonNeutrinoEnergy(python::module &); + void wrapPromptGammaEnergy(python::module &); + void wrapPromptNeutronKE(python::module &); + void wrapPromptProductKE(python::module &); + void wrapTotalEnergy(python::module &); + void wrapFissionEnergyReleased(python::module &); + void wrapFissionComponent(python::module &); + void wrapFissionComponents(python::module &); +} // namespace python_fissionTransport + +// fissionTransport wrapper +void wrapFissionTransport(python::module &module) +{ + // create the fissionTransport submodule + python::module submodule = module.def_submodule( + "fissionTransport", + "GNDS v2.0 fissionTransport" + ); + + // wrap fissionTransport components + python_fissionTransport::wrapEFH(submodule); + python_fissionTransport::wrapEFL(submodule); + python_fissionTransport::wrapT_M(submodule); + python_fissionTransport::wrapMadlandNix(submodule); + python_fissionTransport::wrapB(submodule); + python_fissionTransport::wrapWatt(submodule); + python_fissionTransport::wrapSimpleMaxwellianFission(submodule); + python_fissionTransport::wrapDelayedBetaEnergy(submodule); + python_fissionTransport::wrapDelayedGammaEnergy(submodule); + python_fissionTransport::wrapDelayedNeutronKE(submodule); + python_fissionTransport::wrapNeutrinoEnergy(submodule); + python_fissionTransport::wrapNonNeutrinoEnergy(submodule); + python_fissionTransport::wrapPromptGammaEnergy(submodule); + python_fissionTransport::wrapPromptNeutronKE(submodule); + python_fissionTransport::wrapPromptProductKE(submodule); + python_fissionTransport::wrapTotalEnergy(submodule); + python_fissionTransport::wrapFissionEnergyReleased(submodule); + python_fissionTransport::wrapFissionComponent(submodule); + python_fissionTransport::wrapFissionComponents(submodule); +}; + +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionTransport/B.python.cpp b/python/src/v2.0/fissionTransport/B.python.cpp new file mode 100644 index 000000000..a6dc9e0dc --- /dev/null +++ b/python/src/v2.0/fissionTransport/B.python.cpp @@ -0,0 +1,49 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionTransport/B.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionTransport { + +// B wrapper +void wrapB(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionTransport::B; + + // create the component + python::class_ component( + module, + "B", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + >(), + Component::documentation("constructor").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionTransport/DelayedBetaEnergy.python.cpp b/python/src/v2.0/fissionTransport/DelayedBetaEnergy.python.cpp new file mode 100644 index 000000000..2adfc5aec --- /dev/null +++ b/python/src/v2.0/fissionTransport/DelayedBetaEnergy.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionTransport/DelayedBetaEnergy.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionTransport { + +// DelayedBetaEnergy wrapper +void wrapDelayedBetaEnergy(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionTransport::DelayedBetaEnergy; + + // create the component + python::class_ component( + module, + "DelayedBetaEnergy", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("polynomial1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "polynomial1d", + python::overload_cast<>(&Component::polynomial1d), + Component::documentation("polynomial1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionTransport/DelayedGammaEnergy.python.cpp b/python/src/v2.0/fissionTransport/DelayedGammaEnergy.python.cpp new file mode 100644 index 000000000..e815ed923 --- /dev/null +++ b/python/src/v2.0/fissionTransport/DelayedGammaEnergy.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionTransport/DelayedGammaEnergy.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionTransport { + +// DelayedGammaEnergy wrapper +void wrapDelayedGammaEnergy(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionTransport::DelayedGammaEnergy; + + // create the component + python::class_ component( + module, + "DelayedGammaEnergy", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("polynomial1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "polynomial1d", + python::overload_cast<>(&Component::polynomial1d), + Component::documentation("polynomial1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionTransport/DelayedNeutronKE.python.cpp b/python/src/v2.0/fissionTransport/DelayedNeutronKE.python.cpp new file mode 100644 index 000000000..e88c485cb --- /dev/null +++ b/python/src/v2.0/fissionTransport/DelayedNeutronKE.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionTransport/DelayedNeutronKE.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionTransport { + +// DelayedNeutronKE wrapper +void wrapDelayedNeutronKE(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionTransport::DelayedNeutronKE; + + // create the component + python::class_ component( + module, + "DelayedNeutronKE", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("xys1d") = std::nullopt, + python::arg("polynomial1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "polynomial1d", + python::overload_cast<>(&Component::polynomial1d), + Component::documentation("polynomial1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionTransport/EFH.python.cpp b/python/src/v2.0/fissionTransport/EFH.python.cpp new file mode 100644 index 000000000..c3e619f97 --- /dev/null +++ b/python/src/v2.0/fissionTransport/EFH.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionTransport/EFH.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionTransport { + +// EFH wrapper +void wrapEFH(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionTransport::EFH; + + // create the component + python::class_ component( + module, + "EFH", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const Float64 & + >(), + python::arg("unit"), + python::arg("value"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionTransport/EFL.python.cpp b/python/src/v2.0/fissionTransport/EFL.python.cpp new file mode 100644 index 000000000..f2aa103d7 --- /dev/null +++ b/python/src/v2.0/fissionTransport/EFL.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionTransport/EFL.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionTransport { + +// EFL wrapper +void wrapEFL(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionTransport::EFL; + + // create the component + python::class_ component( + module, + "EFL", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const Float64 & + >(), + python::arg("unit"), + python::arg("value"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionTransport/FissionComponent.python.cpp b/python/src/v2.0/fissionTransport/FissionComponent.python.cpp new file mode 100644 index 000000000..27b3d23a8 --- /dev/null +++ b/python/src/v2.0/fissionTransport/FissionComponent.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionTransport/FissionComponent.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionTransport { + +// FissionComponent wrapper +void wrapFissionComponent(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionTransport::FissionComponent; + + // create the component + python::class_ component( + module, + "FissionComponent", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const XMLName &, + const XMLName &, + const std::optional &, + const std::optional & + >(), + python::arg("endf_mt") = std::nullopt, + python::arg("fission_genre"), + python::arg("label"), + python::arg("cross_section") = std::nullopt, + python::arg("output_channel") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "endf_mt", + &Component::ENDF_MT, + Component::documentation("endf_mt").data() + ) + .def_property_readonly( + "fission_genre", + &Component::fissionGenre, + Component::documentation("fission_genre").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "cross_section", + python::overload_cast<>(&Component::crossSection), + Component::documentation("cross_section").data() + ) + .def_property_readonly( + "output_channel", + python::overload_cast<>(&Component::outputChannel), + Component::documentation("output_channel").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionTransport/FissionComponents.python.cpp b/python/src/v2.0/fissionTransport/FissionComponents.python.cpp new file mode 100644 index 000000000..edb038afb --- /dev/null +++ b/python/src/v2.0/fissionTransport/FissionComponents.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionTransport/FissionComponents.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionTransport { + +// FissionComponents wrapper +void wrapFissionComponents(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionTransport::FissionComponents; + + // create the component + python::class_ component( + module, + "FissionComponents", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional> & + >(), + python::arg("fission_component") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "fission_component", + python::overload_cast<>(&Component::fissionComponent), + Component::documentation("fission_component").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionTransport/FissionEnergyReleased.python.cpp b/python/src/v2.0/fissionTransport/FissionEnergyReleased.python.cpp new file mode 100644 index 000000000..e5b217739 --- /dev/null +++ b/python/src/v2.0/fissionTransport/FissionEnergyReleased.python.cpp @@ -0,0 +1,119 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionTransport/FissionEnergyReleased.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionTransport { + +// FissionEnergyReleased wrapper +void wrapFissionEnergyReleased(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionTransport::FissionEnergyReleased; + + // create the component + python::class_ component( + module, + "FissionEnergyReleased", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("label") = std::nullopt, + python::arg("delayed_beta_energy") = std::nullopt, + python::arg("delayed_gamma_energy") = std::nullopt, + python::arg("delayed_neutron_ke") = std::nullopt, + python::arg("neutrino_energy") = std::nullopt, + python::arg("non_neutrino_energy") = std::nullopt, + python::arg("prompt_gamma_energy") = std::nullopt, + python::arg("prompt_neutron_ke") = std::nullopt, + python::arg("prompt_product_ke") = std::nullopt, + python::arg("total_energy") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "delayed_beta_energy", + python::overload_cast<>(&Component::delayedBetaEnergy), + Component::documentation("delayed_beta_energy").data() + ) + .def_property_readonly( + "delayed_gamma_energy", + python::overload_cast<>(&Component::delayedGammaEnergy), + Component::documentation("delayed_gamma_energy").data() + ) + .def_property_readonly( + "delayed_neutron_ke", + python::overload_cast<>(&Component::delayedNeutronKE), + Component::documentation("delayed_neutron_ke").data() + ) + .def_property_readonly( + "neutrino_energy", + python::overload_cast<>(&Component::neutrinoEnergy), + Component::documentation("neutrino_energy").data() + ) + .def_property_readonly( + "non_neutrino_energy", + python::overload_cast<>(&Component::nonNeutrinoEnergy), + Component::documentation("non_neutrino_energy").data() + ) + .def_property_readonly( + "prompt_gamma_energy", + python::overload_cast<>(&Component::promptGammaEnergy), + Component::documentation("prompt_gamma_energy").data() + ) + .def_property_readonly( + "prompt_neutron_ke", + python::overload_cast<>(&Component::promptNeutronKE), + Component::documentation("prompt_neutron_ke").data() + ) + .def_property_readonly( + "prompt_product_ke", + python::overload_cast<>(&Component::promptProductKE), + Component::documentation("prompt_product_ke").data() + ) + .def_property_readonly( + "total_energy", + python::overload_cast<>(&Component::totalEnergy), + Component::documentation("total_energy").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionTransport/MadlandNix.python.cpp b/python/src/v2.0/fissionTransport/MadlandNix.python.cpp new file mode 100644 index 000000000..120c19301 --- /dev/null +++ b/python/src/v2.0/fissionTransport/MadlandNix.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionTransport/MadlandNix.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionTransport { + +// MadlandNix wrapper +void wrapMadlandNix(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionTransport::MadlandNix; + + // create the component + python::class_ component( + module, + "MadlandNix", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const fissionTransport::EFH &, + const fissionTransport::EFL &, + const fissionTransport::T_M & + >(), + python::arg("efh"), + python::arg("efl"), + python::arg("t_m"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "efh", + python::overload_cast<>(&Component::EFH), + Component::documentation("efh").data() + ) + .def_property_readonly( + "efl", + python::overload_cast<>(&Component::EFL), + Component::documentation("efl").data() + ) + .def_property_readonly( + "t_m", + python::overload_cast<>(&Component::T_M), + Component::documentation("t_m").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionTransport/NeutrinoEnergy.python.cpp b/python/src/v2.0/fissionTransport/NeutrinoEnergy.python.cpp new file mode 100644 index 000000000..05196fe8d --- /dev/null +++ b/python/src/v2.0/fissionTransport/NeutrinoEnergy.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionTransport/NeutrinoEnergy.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionTransport { + +// NeutrinoEnergy wrapper +void wrapNeutrinoEnergy(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionTransport::NeutrinoEnergy; + + // create the component + python::class_ component( + module, + "NeutrinoEnergy", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("polynomial1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "polynomial1d", + python::overload_cast<>(&Component::polynomial1d), + Component::documentation("polynomial1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionTransport/NonNeutrinoEnergy.python.cpp b/python/src/v2.0/fissionTransport/NonNeutrinoEnergy.python.cpp new file mode 100644 index 000000000..9528782dd --- /dev/null +++ b/python/src/v2.0/fissionTransport/NonNeutrinoEnergy.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionTransport/NonNeutrinoEnergy.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionTransport { + +// NonNeutrinoEnergy wrapper +void wrapNonNeutrinoEnergy(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionTransport::NonNeutrinoEnergy; + + // create the component + python::class_ component( + module, + "NonNeutrinoEnergy", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("polynomial1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "polynomial1d", + python::overload_cast<>(&Component::polynomial1d), + Component::documentation("polynomial1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionTransport/PromptGammaEnergy.python.cpp b/python/src/v2.0/fissionTransport/PromptGammaEnergy.python.cpp new file mode 100644 index 000000000..d9068e41d --- /dev/null +++ b/python/src/v2.0/fissionTransport/PromptGammaEnergy.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionTransport/PromptGammaEnergy.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionTransport { + +// PromptGammaEnergy wrapper +void wrapPromptGammaEnergy(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionTransport::PromptGammaEnergy; + + // create the component + python::class_ component( + module, + "PromptGammaEnergy", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("xys1d") = std::nullopt, + python::arg("polynomial1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "polynomial1d", + python::overload_cast<>(&Component::polynomial1d), + Component::documentation("polynomial1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionTransport/PromptNeutronKE.python.cpp b/python/src/v2.0/fissionTransport/PromptNeutronKE.python.cpp new file mode 100644 index 000000000..2dc5eccde --- /dev/null +++ b/python/src/v2.0/fissionTransport/PromptNeutronKE.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionTransport/PromptNeutronKE.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionTransport { + +// PromptNeutronKE wrapper +void wrapPromptNeutronKE(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionTransport::PromptNeutronKE; + + // create the component + python::class_ component( + module, + "PromptNeutronKE", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("xys1d") = std::nullopt, + python::arg("polynomial1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "polynomial1d", + python::overload_cast<>(&Component::polynomial1d), + Component::documentation("polynomial1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionTransport/PromptProductKE.python.cpp b/python/src/v2.0/fissionTransport/PromptProductKE.python.cpp new file mode 100644 index 000000000..cf9386a99 --- /dev/null +++ b/python/src/v2.0/fissionTransport/PromptProductKE.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionTransport/PromptProductKE.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionTransport { + +// PromptProductKE wrapper +void wrapPromptProductKE(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionTransport::PromptProductKE; + + // create the component + python::class_ component( + module, + "PromptProductKE", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("xys1d") = std::nullopt, + python::arg("polynomial1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "polynomial1d", + python::overload_cast<>(&Component::polynomial1d), + Component::documentation("polynomial1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionTransport/SimpleMaxwellianFission.python.cpp b/python/src/v2.0/fissionTransport/SimpleMaxwellianFission.python.cpp new file mode 100644 index 000000000..8a0a954c7 --- /dev/null +++ b/python/src/v2.0/fissionTransport/SimpleMaxwellianFission.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionTransport/SimpleMaxwellianFission.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionTransport { + +// SimpleMaxwellianFission wrapper +void wrapSimpleMaxwellianFission(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionTransport::SimpleMaxwellianFission; + + // create the component + python::class_ component( + module, + "SimpleMaxwellianFission", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("u") = std::nullopt, + python::arg("theta") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "u", + python::overload_cast<>(&Component::U), + Component::documentation("u").data() + ) + .def_property_readonly( + "theta", + python::overload_cast<>(&Component::theta), + Component::documentation("theta").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionTransport/T_M.python.cpp b/python/src/v2.0/fissionTransport/T_M.python.cpp new file mode 100644 index 000000000..7cca5fd4b --- /dev/null +++ b/python/src/v2.0/fissionTransport/T_M.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionTransport/T_M.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionTransport { + +// T_M wrapper +void wrapT_M(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionTransport::T_M; + + // create the component + python::class_ component( + module, + "T_M", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const containers::XYs1d & + >(), + python::arg("xys1d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionTransport/TotalEnergy.python.cpp b/python/src/v2.0/fissionTransport/TotalEnergy.python.cpp new file mode 100644 index 000000000..842417212 --- /dev/null +++ b/python/src/v2.0/fissionTransport/TotalEnergy.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionTransport/TotalEnergy.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionTransport { + +// TotalEnergy wrapper +void wrapTotalEnergy(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionTransport::TotalEnergy; + + // create the component + python::class_ component( + module, + "TotalEnergy", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("polynomial1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "polynomial1d", + python::overload_cast<>(&Component::polynomial1d), + Component::documentation("polynomial1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/fissionTransport/Watt.python.cpp b/python/src/v2.0/fissionTransport/Watt.python.cpp new file mode 100644 index 000000000..75cded907 --- /dev/null +++ b/python/src/v2.0/fissionTransport/Watt.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fissionTransport/Watt.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fissionTransport { + +// Watt wrapper +void wrapWatt(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fissionTransport::Watt; + + // create the component + python::class_ component( + module, + "Watt", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const transport::U &, + const transport::A &, + const fissionTransport::B & + >(), + python::arg("u"), + python::arg("a"), + python::arg("b"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "u", + python::overload_cast<>(&Component::U), + Component::documentation("u").data() + ) + .def_property_readonly( + "a", + python::overload_cast<>(&Component::a), + Component::documentation("a").data() + ) + .def_property_readonly( + "b", + python::overload_cast<>(&Component::b), + Component::documentation("b").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fissionTransport +} // namespace python_v2_0 diff --git a/python/src/v2.0/fpy.python.cpp b/python/src/v2.0/fpy.python.cpp new file mode 100644 index 000000000..df15af1ee --- /dev/null +++ b/python/src/v2.0/fpy.python.cpp @@ -0,0 +1,49 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include +#include + +namespace python = pybind11; + +// v2.0 interface +namespace python_v2_0 { + +// fpy declarations +namespace python_fpy { + void wrapTime(python::module &); + void wrapEnergy(python::module &); + void wrapNuclides(python::module &); + void wrapYields(python::module &); + void wrapIncidentEnergy(python::module &); + void wrapIncidentEnergies(python::module &); + void wrapElapsedTime(python::module &); + void wrapElapsedTimes(python::module &); + void wrapProductYield(python::module &); + void wrapProductYields(python::module &); +} // namespace python_fpy + +// fpy wrapper +void wrapFpy(python::module &module) +{ + // create the fpy submodule + python::module submodule = module.def_submodule( + "fpy", + "GNDS v2.0 fpy" + ); + + // wrap fpy components + python_fpy::wrapTime(submodule); + python_fpy::wrapEnergy(submodule); + python_fpy::wrapNuclides(submodule); + python_fpy::wrapYields(submodule); + python_fpy::wrapIncidentEnergy(submodule); + python_fpy::wrapIncidentEnergies(submodule); + python_fpy::wrapElapsedTime(submodule); + python_fpy::wrapElapsedTimes(submodule); + python_fpy::wrapProductYield(submodule); + python_fpy::wrapProductYields(submodule); +}; + +} // namespace python_v2_0 diff --git a/python/src/v2.0/fpy/ElapsedTime.python.cpp b/python/src/v2.0/fpy/ElapsedTime.python.cpp new file mode 100644 index 000000000..94dcdc678 --- /dev/null +++ b/python/src/v2.0/fpy/ElapsedTime.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fpy/ElapsedTime.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fpy { + +// ElapsedTime wrapper +void wrapElapsedTime(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fpy::ElapsedTime; + using _t = std::variant< + fpy::IncidentEnergies, + fpy::Yields + >; + + // create the component + python::class_ component( + module, + "ElapsedTime", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const fpy::Time &, + const _t & + >(), + python::arg("label") = std::nullopt, + python::arg("time"), + python::arg("_incident_energiesyields"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "time", + python::overload_cast<>(&Component::time), + Component::documentation("time").data() + ) + .def_property_readonly( + "incident_energies", + python::overload_cast<>(&Component::incidentEnergies), + Component::documentation("incident_energies").data() + ) + .def_property_readonly( + "yields", + python::overload_cast<>(&Component::yields), + Component::documentation("yields").data() + ) + .def_property_readonly( + "_incident_energiesyields", + python::overload_cast<>(&Component::_incidentEnergiesyields), + Component::documentation("_incident_energiesyields").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fpy +} // namespace python_v2_0 diff --git a/python/src/v2.0/fpy/ElapsedTimes.python.cpp b/python/src/v2.0/fpy/ElapsedTimes.python.cpp new file mode 100644 index 000000000..f22e9378f --- /dev/null +++ b/python/src/v2.0/fpy/ElapsedTimes.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fpy/ElapsedTimes.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fpy { + +// ElapsedTimes wrapper +void wrapElapsedTimes(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fpy::ElapsedTimes; + + // create the component + python::class_ component( + module, + "ElapsedTimes", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("elapsed_time"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "elapsed_time", + python::overload_cast<>(&Component::elapsedTime), + Component::documentation("elapsed_time").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fpy +} // namespace python_v2_0 diff --git a/python/src/v2.0/fpy/Energy.python.cpp b/python/src/v2.0/fpy/Energy.python.cpp new file mode 100644 index 000000000..142ba67d4 --- /dev/null +++ b/python/src/v2.0/fpy/Energy.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fpy/Energy.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fpy { + +// Energy wrapper +void wrapEnergy(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fpy::Energy; + + // create the component + python::class_ component( + module, + "Energy", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const containers::Double & + >(), + python::arg("double"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "double", + python::overload_cast<>(&Component::Double), + Component::documentation("double").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fpy +} // namespace python_v2_0 diff --git a/python/src/v2.0/fpy/IncidentEnergies.python.cpp b/python/src/v2.0/fpy/IncidentEnergies.python.cpp new file mode 100644 index 000000000..3b4138ae8 --- /dev/null +++ b/python/src/v2.0/fpy/IncidentEnergies.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fpy/IncidentEnergies.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fpy { + +// IncidentEnergies wrapper +void wrapIncidentEnergies(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fpy::IncidentEnergies; + + // create the component + python::class_ component( + module, + "IncidentEnergies", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("incident_energy"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "incident_energy", + python::overload_cast<>(&Component::incidentEnergy), + Component::documentation("incident_energy").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fpy +} // namespace python_v2_0 diff --git a/python/src/v2.0/fpy/IncidentEnergy.python.cpp b/python/src/v2.0/fpy/IncidentEnergy.python.cpp new file mode 100644 index 000000000..61fb000ac --- /dev/null +++ b/python/src/v2.0/fpy/IncidentEnergy.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fpy/IncidentEnergy.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fpy { + +// IncidentEnergy wrapper +void wrapIncidentEnergy(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fpy::IncidentEnergy; + + // create the component + python::class_ component( + module, + "IncidentEnergy", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const fpy::Energy &, + const fpy::Yields & + >(), + python::arg("label"), + python::arg("energy"), + python::arg("yields"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "energy", + python::overload_cast<>(&Component::energy), + Component::documentation("energy").data() + ) + .def_property_readonly( + "yields", + python::overload_cast<>(&Component::yields), + Component::documentation("yields").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fpy +} // namespace python_v2_0 diff --git a/python/src/v2.0/fpy/Nuclides.python.cpp b/python/src/v2.0/fpy/Nuclides.python.cpp new file mode 100644 index 000000000..c3829ef26 --- /dev/null +++ b/python/src/v2.0/fpy/Nuclides.python.cpp @@ -0,0 +1,92 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fpy/Nuclides.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fpy { + +// Nuclides wrapper +void wrapNuclides(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fpy::Nuclides; + + // create the component + python::class_ component( + module, + "Nuclides", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("href") = std::nullopt, + Component::documentation("constructor").data() + ) + .def( + python::init< + const std::vector & + >(), + python::arg("ints"), + Component::documentation("constructor").data() + ) + .def( + python::init< + const std::vector & + >(), + python::arg("doubles"), + Component::documentation("constructor").data() + ) + .def( + python::init< + const std::vector & + >(), + python::arg("strings"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + .def_property_readonly( + "ints", + [] (const Component &self) { return self.ints(); }, + Component::documentation("ints").data() + ) + .def_property_readonly( + "doubles", + [] (const Component &self) { return self.doubles(); }, + Component::documentation("doubles").data() + ) + .def_property_readonly( + "strings", + [] (const Component &self) { return self.strings(); }, + Component::documentation("strings").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fpy +} // namespace python_v2_0 diff --git a/python/src/v2.0/fpy/ProductYield.python.cpp b/python/src/v2.0/fpy/ProductYield.python.cpp new file mode 100644 index 000000000..1ea7dad70 --- /dev/null +++ b/python/src/v2.0/fpy/ProductYield.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fpy/ProductYield.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fpy { + +// ProductYield wrapper +void wrapProductYield(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fpy::ProductYield; + + // create the component + python::class_ component( + module, + "ProductYield", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const fpy::ElapsedTimes &, + const std::optional & + >(), + python::arg("label"), + python::arg("elapsed_times"), + python::arg("nuclides") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "elapsed_times", + python::overload_cast<>(&Component::elapsedTimes), + Component::documentation("elapsed_times").data() + ) + .def_property_readonly( + "nuclides", + python::overload_cast<>(&Component::nuclides), + Component::documentation("nuclides").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fpy +} // namespace python_v2_0 diff --git a/python/src/v2.0/fpy/ProductYields.python.cpp b/python/src/v2.0/fpy/ProductYields.python.cpp new file mode 100644 index 000000000..5b1d2e7ea --- /dev/null +++ b/python/src/v2.0/fpy/ProductYields.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fpy/ProductYields.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fpy { + +// ProductYields wrapper +void wrapProductYields(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fpy::ProductYields; + + // create the component + python::class_ component( + module, + "ProductYields", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("product_yield"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "product_yield", + python::overload_cast<>(&Component::productYield), + Component::documentation("product_yield").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fpy +} // namespace python_v2_0 diff --git a/python/src/v2.0/fpy/Time.python.cpp b/python/src/v2.0/fpy/Time.python.cpp new file mode 100644 index 000000000..9776283a0 --- /dev/null +++ b/python/src/v2.0/fpy/Time.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fpy/Time.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fpy { + +// Time wrapper +void wrapTime(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fpy::Time; + using _t = std::variant< + containers::Double, + containers::String + >; + + // create the component + python::class_ component( + module, + "Time", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const _t & + >(), + python::arg("_doublestring"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "double", + python::overload_cast<>(&Component::Double), + Component::documentation("double").data() + ) + .def_property_readonly( + "string", + python::overload_cast<>(&Component::string), + Component::documentation("string").data() + ) + .def_property_readonly( + "_doublestring", + python::overload_cast<>(&Component::_Doublestring), + Component::documentation("_doublestring").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fpy +} // namespace python_v2_0 diff --git a/python/src/v2.0/fpy/Yields.python.cpp b/python/src/v2.0/fpy/Yields.python.cpp new file mode 100644 index 000000000..fbc74c730 --- /dev/null +++ b/python/src/v2.0/fpy/Yields.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/fpy/Yields.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_fpy { + +// Yields wrapper +void wrapYields(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = fpy::Yields; + + // create the component + python::class_ component( + module, + "Yields", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const fpy::Nuclides &, + const containers::Values & + >(), + python::arg("nuclides"), + python::arg("values"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "nuclides", + python::overload_cast<>(&Component::nuclides), + Component::documentation("nuclides").data() + ) + .def_property_readonly( + "values", + python::overload_cast<>(&Component::values), + Component::documentation("values").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_fpy +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops.python.cpp b/python/src/v2.0/pops.python.cpp new file mode 100644 index 000000000..0f178d45c --- /dev/null +++ b/python/src/v2.0/pops.python.cpp @@ -0,0 +1,129 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include +#include + +namespace python = pybind11; + +// v2.0 interface +namespace python_v2_0 { + +// pops declarations +namespace python_pops { + void wrapAlias(python::module &); + void wrapMetaStable(python::module &); + void wrapAliases(python::module &); + void wrapCharge(python::module &); + void wrapAverageEnergy(python::module &); + void wrapAverageEnergies(python::module &); + void wrapQ(python::module &); + void wrapProduct(python::module &); + void wrapProducts(python::module &); + void wrapDecay(python::module &); + void wrapDecayPath(python::module &); + void wrapShell(python::module &); + void wrapInternalConversionCoefficients(python::module &); + void wrapPhotonEmissionProbabilities(python::module &); + void wrapProbability(python::module &); + void wrapContinuum(python::module &); + void wrapEnergy(python::module &); + void wrapIntensity(python::module &); + void wrapInternalPairFormationCoefficient(python::module &); + void wrapDiscrete(python::module &); + void wrapSpectrum(python::module &); + void wrapSpectra(python::module &); + void wrapDecayMode(python::module &); + void wrapDecayModes(python::module &); + void wrapDecayData(python::module &); + void wrapHalflife(python::module &); + void wrapMass(python::module &); + void wrapParity(python::module &); + void wrapSpin(python::module &); + void wrapBaryon(python::module &); + void wrapBaryons(python::module &); + void wrapBindingEnergy(python::module &); + void wrapConfiguration(python::module &); + void wrapConfigurations(python::module &); + void wrapAtomic(python::module &); + void wrapEnergy(python::module &); + void wrapNucleus(python::module &); + void wrapNuclide(python::module &); + void wrapNuclides(python::module &); + void wrapIsotope(python::module &); + void wrapIsotopes(python::module &); + void wrapChemicalElement(python::module &); + void wrapChemicalElements(python::module &); + void wrapGaugeBoson(python::module &); + void wrapGaugeBosons(python::module &); + void wrapLepton(python::module &); + void wrapLeptons(python::module &); + void wrapUnorthodox(python::module &); + void wrapUnorthodoxes(python::module &); + void wrapPoPs(python::module &); +} // namespace python_pops + +// pops wrapper +void wrapPops(python::module &module) +{ + // create the pops submodule + python::module submodule = module.def_submodule( + "pops", + "GNDS v2.0 pops" + ); + + // wrap pops components + python_pops::wrapAlias(submodule); + python_pops::wrapMetaStable(submodule); + python_pops::wrapAliases(submodule); + python_pops::wrapCharge(submodule); + python_pops::wrapAverageEnergy(submodule); + python_pops::wrapAverageEnergies(submodule); + python_pops::wrapQ(submodule); + python_pops::wrapProduct(submodule); + python_pops::wrapProducts(submodule); + python_pops::wrapDecay(submodule); + python_pops::wrapDecayPath(submodule); + python_pops::wrapShell(submodule); + python_pops::wrapInternalConversionCoefficients(submodule); + python_pops::wrapPhotonEmissionProbabilities(submodule); + python_pops::wrapProbability(submodule); + python_pops::wrapContinuum(submodule); + python_pops::wrapEnergy(submodule); + python_pops::wrapIntensity(submodule); + python_pops::wrapInternalPairFormationCoefficient(submodule); + python_pops::wrapDiscrete(submodule); + python_pops::wrapSpectrum(submodule); + python_pops::wrapSpectra(submodule); + python_pops::wrapDecayMode(submodule); + python_pops::wrapDecayModes(submodule); + python_pops::wrapDecayData(submodule); + python_pops::wrapHalflife(submodule); + python_pops::wrapMass(submodule); + python_pops::wrapParity(submodule); + python_pops::wrapSpin(submodule); + python_pops::wrapBaryon(submodule); + python_pops::wrapBaryons(submodule); + python_pops::wrapBindingEnergy(submodule); + python_pops::wrapConfiguration(submodule); + python_pops::wrapConfigurations(submodule); + python_pops::wrapAtomic(submodule); + python_pops::wrapEnergy(submodule); + python_pops::wrapNucleus(submodule); + python_pops::wrapNuclide(submodule); + python_pops::wrapNuclides(submodule); + python_pops::wrapIsotope(submodule); + python_pops::wrapIsotopes(submodule); + python_pops::wrapChemicalElement(submodule); + python_pops::wrapChemicalElements(submodule); + python_pops::wrapGaugeBoson(submodule); + python_pops::wrapGaugeBosons(submodule); + python_pops::wrapLepton(submodule); + python_pops::wrapLeptons(submodule); + python_pops::wrapUnorthodox(submodule); + python_pops::wrapUnorthodoxes(submodule); + python_pops::wrapPoPs(submodule); +}; + +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Alias.python.cpp b/python/src/v2.0/pops/Alias.python.cpp new file mode 100644 index 000000000..44c9f4e32 --- /dev/null +++ b/python/src/v2.0/pops/Alias.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Alias.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Alias wrapper +void wrapAlias(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Alias; + + // create the component + python::class_ component( + module, + "Alias", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const XMLName & + >(), + python::arg("id"), + python::arg("pid"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "id", + &Component::id, + Component::documentation("id").data() + ) + .def_property_readonly( + "pid", + &Component::pid, + Component::documentation("pid").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Aliases.python.cpp b/python/src/v2.0/pops/Aliases.python.cpp new file mode 100644 index 000000000..7aa384847 --- /dev/null +++ b/python/src/v2.0/pops/Aliases.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Aliases.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Aliases wrapper +void wrapAliases(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Aliases; + + // create the component + python::class_ component( + module, + "Aliases", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional> &, + const std::optional> & + >(), + python::arg("alias") = std::nullopt, + python::arg("meta_stable") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "alias", + python::overload_cast<>(&Component::alias), + Component::documentation("alias").data() + ) + .def_property_readonly( + "meta_stable", + python::overload_cast<>(&Component::metaStable), + Component::documentation("meta_stable").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Atomic.python.cpp b/python/src/v2.0/pops/Atomic.python.cpp new file mode 100644 index 000000000..3a2b35c71 --- /dev/null +++ b/python/src/v2.0/pops/Atomic.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Atomic.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Atomic wrapper +void wrapAtomic(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Atomic; + + // create the component + python::class_ component( + module, + "Atomic", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("configurations") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "configurations", + python::overload_cast<>(&Component::configurations), + Component::documentation("configurations").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/AverageEnergies.python.cpp b/python/src/v2.0/pops/AverageEnergies.python.cpp new file mode 100644 index 000000000..fddc39ac7 --- /dev/null +++ b/python/src/v2.0/pops/AverageEnergies.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/AverageEnergies.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// AverageEnergies wrapper +void wrapAverageEnergies(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::AverageEnergies; + + // create the component + python::class_ component( + module, + "AverageEnergies", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("average_energy"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "average_energy", + python::overload_cast<>(&Component::averageEnergy), + Component::documentation("average_energy").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/AverageEnergy.python.cpp b/python/src/v2.0/pops/AverageEnergy.python.cpp new file mode 100644 index 000000000..109763339 --- /dev/null +++ b/python/src/v2.0/pops/AverageEnergy.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/AverageEnergy.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// AverageEnergy wrapper +void wrapAverageEnergy(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::AverageEnergy; + + // create the component + python::class_ component( + module, + "AverageEnergy", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const XMLName &, + const Float64 & + >(), + python::arg("label"), + python::arg("unit"), + python::arg("value"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Baryon.python.cpp b/python/src/v2.0/pops/Baryon.python.cpp new file mode 100644 index 000000000..6475c9ead --- /dev/null +++ b/python/src/v2.0/pops/Baryon.python.cpp @@ -0,0 +1,98 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Baryon.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Baryon wrapper +void wrapBaryon(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Baryon; + + // create the component + python::class_ component( + module, + "Baryon", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("id"), + python::arg("charge") = std::nullopt, + python::arg("decay_data") = std::nullopt, + python::arg("halflife") = std::nullopt, + python::arg("mass") = std::nullopt, + python::arg("parity") = std::nullopt, + python::arg("spin") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "id", + &Component::id, + Component::documentation("id").data() + ) + .def_property_readonly( + "charge", + python::overload_cast<>(&Component::charge), + Component::documentation("charge").data() + ) + .def_property_readonly( + "decay_data", + python::overload_cast<>(&Component::decayData), + Component::documentation("decay_data").data() + ) + .def_property_readonly( + "halflife", + python::overload_cast<>(&Component::halflife), + Component::documentation("halflife").data() + ) + .def_property_readonly( + "mass", + python::overload_cast<>(&Component::mass), + Component::documentation("mass").data() + ) + .def_property_readonly( + "parity", + python::overload_cast<>(&Component::parity), + Component::documentation("parity").data() + ) + .def_property_readonly( + "spin", + python::overload_cast<>(&Component::spin), + Component::documentation("spin").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Baryons.python.cpp b/python/src/v2.0/pops/Baryons.python.cpp new file mode 100644 index 000000000..29dd9732d --- /dev/null +++ b/python/src/v2.0/pops/Baryons.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Baryons.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Baryons wrapper +void wrapBaryons(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Baryons; + + // create the component + python::class_ component( + module, + "Baryons", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional> & + >(), + python::arg("baryon") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "baryon", + python::overload_cast<>(&Component::baryon), + Component::documentation("baryon").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/BindingEnergy.python.cpp b/python/src/v2.0/pops/BindingEnergy.python.cpp new file mode 100644 index 000000000..17f2df4d8 --- /dev/null +++ b/python/src/v2.0/pops/BindingEnergy.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/BindingEnergy.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// BindingEnergy wrapper +void wrapBindingEnergy(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::BindingEnergy; + + // create the component + python::class_ component( + module, + "BindingEnergy", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional> & + >(), + python::arg("double") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "double", + python::overload_cast<>(&Component::Double), + Component::documentation("double").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Charge.python.cpp b/python/src/v2.0/pops/Charge.python.cpp new file mode 100644 index 000000000..ebb7e5889 --- /dev/null +++ b/python/src/v2.0/pops/Charge.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Charge.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Charge wrapper +void wrapCharge(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Charge; + using _t = std::variant< + containers::Fraction, + containers::Integer + >; + + // create the component + python::class_ component( + module, + "Charge", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const _t & + >(), + python::arg("_fractioninteger"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "fraction", + python::overload_cast<>(&Component::fraction), + Component::documentation("fraction").data() + ) + .def_property_readonly( + "integer", + python::overload_cast<>(&Component::integer), + Component::documentation("integer").data() + ) + .def_property_readonly( + "_fractioninteger", + python::overload_cast<>(&Component::_fractioninteger), + Component::documentation("_fractioninteger").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/ChemicalElement.python.cpp b/python/src/v2.0/pops/ChemicalElement.python.cpp new file mode 100644 index 000000000..4ab5f32a6 --- /dev/null +++ b/python/src/v2.0/pops/ChemicalElement.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/ChemicalElement.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// ChemicalElement wrapper +void wrapChemicalElement(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::ChemicalElement; + + // create the component + python::class_ component( + module, + "ChemicalElement", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const Integer32 &, + const std::optional &, + const XMLName &, + const std::optional &, + const std::optional & + >(), + python::arg("z"), + python::arg("name") = std::nullopt, + python::arg("symbol"), + python::arg("atomic") = std::nullopt, + python::arg("isotopes") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "z", + &Component::Z, + Component::documentation("z").data() + ) + .def_property_readonly( + "name", + &Component::name, + Component::documentation("name").data() + ) + .def_property_readonly( + "symbol", + &Component::symbol, + Component::documentation("symbol").data() + ) + .def_property_readonly( + "atomic", + python::overload_cast<>(&Component::atomic), + Component::documentation("atomic").data() + ) + .def_property_readonly( + "isotopes", + python::overload_cast<>(&Component::isotopes), + Component::documentation("isotopes").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/ChemicalElements.python.cpp b/python/src/v2.0/pops/ChemicalElements.python.cpp new file mode 100644 index 000000000..0f6112db2 --- /dev/null +++ b/python/src/v2.0/pops/ChemicalElements.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/ChemicalElements.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// ChemicalElements wrapper +void wrapChemicalElements(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::ChemicalElements; + + // create the component + python::class_ component( + module, + "ChemicalElements", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional> & + >(), + python::arg("chemical_element") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "chemical_element", + python::overload_cast<>(&Component::chemicalElement), + Component::documentation("chemical_element").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Configuration.python.cpp b/python/src/v2.0/pops/Configuration.python.cpp new file mode 100644 index 000000000..48c95dd4f --- /dev/null +++ b/python/src/v2.0/pops/Configuration.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Configuration.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Configuration wrapper +void wrapConfiguration(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Configuration; + + // create the component + python::class_ component( + module, + "Configuration", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const Float64 &, + const std::string &, + const pops::BindingEnergy &, + const std::optional & + >(), + python::arg("electron_number"), + python::arg("subshell"), + python::arg("binding_energy"), + python::arg("decay_data") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "electron_number", + &Component::electronNumber, + Component::documentation("electron_number").data() + ) + .def_property_readonly( + "subshell", + &Component::subshell, + Component::documentation("subshell").data() + ) + .def_property_readonly( + "binding_energy", + python::overload_cast<>(&Component::bindingEnergy), + Component::documentation("binding_energy").data() + ) + .def_property_readonly( + "decay_data", + python::overload_cast<>(&Component::decayData), + Component::documentation("decay_data").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Configurations.python.cpp b/python/src/v2.0/pops/Configurations.python.cpp new file mode 100644 index 000000000..9f7525447 --- /dev/null +++ b/python/src/v2.0/pops/Configurations.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Configurations.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Configurations wrapper +void wrapConfigurations(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Configurations; + + // create the component + python::class_ component( + module, + "Configurations", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("configuration"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "configuration", + python::overload_cast<>(&Component::configuration), + Component::documentation("configuration").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Continuum.python.cpp b/python/src/v2.0/pops/Continuum.python.cpp new file mode 100644 index 000000000..5730a879d --- /dev/null +++ b/python/src/v2.0/pops/Continuum.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Continuum.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Continuum wrapper +void wrapContinuum(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Continuum; + + // create the component + python::class_ component( + module, + "Continuum", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("xys1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Decay.python.cpp b/python/src/v2.0/pops/Decay.python.cpp new file mode 100644 index 000000000..f4174df78 --- /dev/null +++ b/python/src/v2.0/pops/Decay.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Decay.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Decay wrapper +void wrapDecay(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Decay; + + // create the component + python::class_ component( + module, + "Decay", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const Integer32 &, + const std::optional &, + const std::optional & + >(), + python::arg("complete") = std::nullopt, + python::arg("index"), + python::arg("mode") = std::nullopt, + python::arg("products") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "complete", + [](const Component &self) { return self.complete().value(); }, + Component::documentation("complete").data() + ) + .def_property_readonly( + "index", + &Component::index, + Component::documentation("index").data() + ) + .def_property_readonly( + "mode", + &Component::mode, + Component::documentation("mode").data() + ) + .def_property_readonly( + "products", + python::overload_cast<>(&Component::products), + Component::documentation("products").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/DecayData.python.cpp b/python/src/v2.0/pops/DecayData.python.cpp new file mode 100644 index 000000000..d55ceace9 --- /dev/null +++ b/python/src/v2.0/pops/DecayData.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/DecayData.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// DecayData wrapper +void wrapDecayData(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::DecayData; + + // create the component + python::class_ component( + module, + "DecayData", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("average_energies") = std::nullopt, + python::arg("decay_modes") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "average_energies", + python::overload_cast<>(&Component::averageEnergies), + Component::documentation("average_energies").data() + ) + .def_property_readonly( + "decay_modes", + python::overload_cast<>(&Component::decayModes), + Component::documentation("decay_modes").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/DecayMode.python.cpp b/python/src/v2.0/pops/DecayMode.python.cpp new file mode 100644 index 000000000..630db23af --- /dev/null +++ b/python/src/v2.0/pops/DecayMode.python.cpp @@ -0,0 +1,105 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/DecayMode.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// DecayMode wrapper +void wrapDecayMode(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::DecayMode; + + // create the component + python::class_ component( + module, + "DecayMode", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const enums::DecayType &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const pops::Probability &, + const std::optional & + >(), + python::arg("label"), + python::arg("mode"), + python::arg("q") = std::nullopt, + python::arg("decay_path") = std::nullopt, + python::arg("internal_conversion_coefficients") = std::nullopt, + python::arg("photon_emission_probabilities") = std::nullopt, + python::arg("probability"), + python::arg("spectra") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "mode", + &Component::mode, + Component::documentation("mode").data() + ) + .def_property_readonly( + "q", + python::overload_cast<>(&Component::Q), + Component::documentation("q").data() + ) + .def_property_readonly( + "decay_path", + python::overload_cast<>(&Component::decayPath), + Component::documentation("decay_path").data() + ) + .def_property_readonly( + "internal_conversion_coefficients", + python::overload_cast<>(&Component::internalConversionCoefficients), + Component::documentation("internal_conversion_coefficients").data() + ) + .def_property_readonly( + "photon_emission_probabilities", + python::overload_cast<>(&Component::photonEmissionProbabilities), + Component::documentation("photon_emission_probabilities").data() + ) + .def_property_readonly( + "probability", + python::overload_cast<>(&Component::probability), + Component::documentation("probability").data() + ) + .def_property_readonly( + "spectra", + python::overload_cast<>(&Component::spectra), + Component::documentation("spectra").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/DecayModes.python.cpp b/python/src/v2.0/pops/DecayModes.python.cpp new file mode 100644 index 000000000..c13e0a8fa --- /dev/null +++ b/python/src/v2.0/pops/DecayModes.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/DecayModes.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// DecayModes wrapper +void wrapDecayModes(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::DecayModes; + + // create the component + python::class_ component( + module, + "DecayModes", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("decay_mode"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "decay_mode", + python::overload_cast<>(&Component::decayMode), + Component::documentation("decay_mode").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/DecayPath.python.cpp b/python/src/v2.0/pops/DecayPath.python.cpp new file mode 100644 index 000000000..f6e2b0811 --- /dev/null +++ b/python/src/v2.0/pops/DecayPath.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/DecayPath.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// DecayPath wrapper +void wrapDecayPath(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::DecayPath; + + // create the component + python::class_ component( + module, + "DecayPath", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("decay"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "decay", + python::overload_cast<>(&Component::decay), + Component::documentation("decay").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Discrete.python.cpp b/python/src/v2.0/pops/Discrete.python.cpp new file mode 100644 index 000000000..b1cbe0a1e --- /dev/null +++ b/python/src/v2.0/pops/Discrete.python.cpp @@ -0,0 +1,91 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Discrete.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Discrete wrapper +void wrapDiscrete(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Discrete; + + // create the component + python::class_ component( + module, + "Discrete", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const pops::Energy &, + const pops::Intensity &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("type") = std::nullopt, + python::arg("energy"), + python::arg("intensity"), + python::arg("internal_conversion_coefficients") = std::nullopt, + python::arg("internal_pair_formation_coefficient") = std::nullopt, + python::arg("photon_emission_probabilities") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "type", + &Component::type, + Component::documentation("type").data() + ) + .def_property_readonly( + "energy", + python::overload_cast<>(&Component::energy), + Component::documentation("energy").data() + ) + .def_property_readonly( + "intensity", + python::overload_cast<>(&Component::intensity), + Component::documentation("intensity").data() + ) + .def_property_readonly( + "internal_conversion_coefficients", + python::overload_cast<>(&Component::internalConversionCoefficients), + Component::documentation("internal_conversion_coefficients").data() + ) + .def_property_readonly( + "internal_pair_formation_coefficient", + python::overload_cast<>(&Component::internalPairFormationCoefficient), + Component::documentation("internal_pair_formation_coefficient").data() + ) + .def_property_readonly( + "photon_emission_probabilities", + python::overload_cast<>(&Component::photonEmissionProbabilities), + Component::documentation("photon_emission_probabilities").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Energy.python.cpp b/python/src/v2.0/pops/Energy.python.cpp new file mode 100644 index 000000000..ec2f9a194 --- /dev/null +++ b/python/src/v2.0/pops/Energy.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Energy.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Energy wrapper +void wrapEnergy(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Energy; + + // create the component + python::class_ component( + module, + "Energy", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const Float64 &, + const std::optional> & + >(), + python::arg("unit"), + python::arg("value"), + python::arg("double") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + .def_property_readonly( + "double", + python::overload_cast<>(&Component::Double), + Component::documentation("double").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/GaugeBoson.python.cpp b/python/src/v2.0/pops/GaugeBoson.python.cpp new file mode 100644 index 000000000..83ea4000a --- /dev/null +++ b/python/src/v2.0/pops/GaugeBoson.python.cpp @@ -0,0 +1,98 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/GaugeBoson.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// GaugeBoson wrapper +void wrapGaugeBoson(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::GaugeBoson; + + // create the component + python::class_ component( + module, + "GaugeBoson", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("id"), + python::arg("charge") = std::nullopt, + python::arg("decay_data") = std::nullopt, + python::arg("halflife") = std::nullopt, + python::arg("mass") = std::nullopt, + python::arg("parity") = std::nullopt, + python::arg("spin") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "id", + &Component::id, + Component::documentation("id").data() + ) + .def_property_readonly( + "charge", + python::overload_cast<>(&Component::charge), + Component::documentation("charge").data() + ) + .def_property_readonly( + "decay_data", + python::overload_cast<>(&Component::decayData), + Component::documentation("decay_data").data() + ) + .def_property_readonly( + "halflife", + python::overload_cast<>(&Component::halflife), + Component::documentation("halflife").data() + ) + .def_property_readonly( + "mass", + python::overload_cast<>(&Component::mass), + Component::documentation("mass").data() + ) + .def_property_readonly( + "parity", + python::overload_cast<>(&Component::parity), + Component::documentation("parity").data() + ) + .def_property_readonly( + "spin", + python::overload_cast<>(&Component::spin), + Component::documentation("spin").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/GaugeBosons.python.cpp b/python/src/v2.0/pops/GaugeBosons.python.cpp new file mode 100644 index 000000000..f9a364045 --- /dev/null +++ b/python/src/v2.0/pops/GaugeBosons.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/GaugeBosons.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// GaugeBosons wrapper +void wrapGaugeBosons(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::GaugeBosons; + + // create the component + python::class_ component( + module, + "GaugeBosons", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional> & + >(), + python::arg("gauge_boson") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "gauge_boson", + python::overload_cast<>(&Component::gaugeBoson), + Component::documentation("gauge_boson").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Halflife.python.cpp b/python/src/v2.0/pops/Halflife.python.cpp new file mode 100644 index 000000000..a81ed4133 --- /dev/null +++ b/python/src/v2.0/pops/Halflife.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Halflife.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Halflife wrapper +void wrapHalflife(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Halflife; + using _t = std::variant< + containers::Double, + containers::String + >; + + // create the component + python::class_ component( + module, + "Halflife", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const _t & + >(), + python::arg("_doublestring"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "double", + python::overload_cast<>(&Component::Double), + Component::documentation("double").data() + ) + .def_property_readonly( + "string", + python::overload_cast<>(&Component::string), + Component::documentation("string").data() + ) + .def_property_readonly( + "_doublestring", + python::overload_cast<>(&Component::_Doublestring), + Component::documentation("_doublestring").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Intensity.python.cpp b/python/src/v2.0/pops/Intensity.python.cpp new file mode 100644 index 000000000..2032db005 --- /dev/null +++ b/python/src/v2.0/pops/Intensity.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Intensity.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Intensity wrapper +void wrapIntensity(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Intensity; + + // create the component + python::class_ component( + module, + "Intensity", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("value") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/InternalConversionCoefficients.python.cpp b/python/src/v2.0/pops/InternalConversionCoefficients.python.cpp new file mode 100644 index 000000000..25dec44f6 --- /dev/null +++ b/python/src/v2.0/pops/InternalConversionCoefficients.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/InternalConversionCoefficients.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// InternalConversionCoefficients wrapper +void wrapInternalConversionCoefficients(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::InternalConversionCoefficients; + + // create the component + python::class_ component( + module, + "InternalConversionCoefficients", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("shell"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "shell", + python::overload_cast<>(&Component::shell), + Component::documentation("shell").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/InternalPairFormationCoefficient.python.cpp b/python/src/v2.0/pops/InternalPairFormationCoefficient.python.cpp new file mode 100644 index 000000000..358d9794d --- /dev/null +++ b/python/src/v2.0/pops/InternalPairFormationCoefficient.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/InternalPairFormationCoefficient.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// InternalPairFormationCoefficient wrapper +void wrapInternalPairFormationCoefficient(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::InternalPairFormationCoefficient; + + // create the component + python::class_ component( + module, + "InternalPairFormationCoefficient", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const Float64 & + >(), + python::arg("unit"), + python::arg("value"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Isotope.python.cpp b/python/src/v2.0/pops/Isotope.python.cpp new file mode 100644 index 000000000..51832486b --- /dev/null +++ b/python/src/v2.0/pops/Isotope.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Isotope.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Isotope wrapper +void wrapIsotope(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Isotope; + + // create the component + python::class_ component( + module, + "Isotope", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const Integer32 &, + const XMLName &, + const std::optional & + >(), + python::arg("a"), + python::arg("symbol"), + python::arg("nuclides") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "a", + &Component::A, + Component::documentation("a").data() + ) + .def_property_readonly( + "symbol", + &Component::symbol, + Component::documentation("symbol").data() + ) + .def_property_readonly( + "nuclides", + python::overload_cast<>(&Component::nuclides), + Component::documentation("nuclides").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Isotopes.python.cpp b/python/src/v2.0/pops/Isotopes.python.cpp new file mode 100644 index 000000000..2d4224237 --- /dev/null +++ b/python/src/v2.0/pops/Isotopes.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Isotopes.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Isotopes wrapper +void wrapIsotopes(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Isotopes; + + // create the component + python::class_ component( + module, + "Isotopes", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("isotope"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "isotope", + python::overload_cast<>(&Component::isotope), + Component::documentation("isotope").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Lepton.python.cpp b/python/src/v2.0/pops/Lepton.python.cpp new file mode 100644 index 000000000..71543dc5a --- /dev/null +++ b/python/src/v2.0/pops/Lepton.python.cpp @@ -0,0 +1,105 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Lepton.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Lepton wrapper +void wrapLepton(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Lepton; + + // create the component + python::class_ component( + module, + "Lepton", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const XMLName &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("generation") = std::nullopt, + python::arg("id"), + python::arg("charge") = std::nullopt, + python::arg("decay_data") = std::nullopt, + python::arg("halflife") = std::nullopt, + python::arg("mass") = std::nullopt, + python::arg("parity") = std::nullopt, + python::arg("spin") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "generation", + &Component::generation, + Component::documentation("generation").data() + ) + .def_property_readonly( + "id", + &Component::id, + Component::documentation("id").data() + ) + .def_property_readonly( + "charge", + python::overload_cast<>(&Component::charge), + Component::documentation("charge").data() + ) + .def_property_readonly( + "decay_data", + python::overload_cast<>(&Component::decayData), + Component::documentation("decay_data").data() + ) + .def_property_readonly( + "halflife", + python::overload_cast<>(&Component::halflife), + Component::documentation("halflife").data() + ) + .def_property_readonly( + "mass", + python::overload_cast<>(&Component::mass), + Component::documentation("mass").data() + ) + .def_property_readonly( + "parity", + python::overload_cast<>(&Component::parity), + Component::documentation("parity").data() + ) + .def_property_readonly( + "spin", + python::overload_cast<>(&Component::spin), + Component::documentation("spin").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Leptons.python.cpp b/python/src/v2.0/pops/Leptons.python.cpp new file mode 100644 index 000000000..644ac0c94 --- /dev/null +++ b/python/src/v2.0/pops/Leptons.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Leptons.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Leptons wrapper +void wrapLeptons(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Leptons; + + // create the component + python::class_ component( + module, + "Leptons", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("lepton"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "lepton", + python::overload_cast<>(&Component::lepton), + Component::documentation("lepton").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Mass.python.cpp b/python/src/v2.0/pops/Mass.python.cpp new file mode 100644 index 000000000..9a3337ddf --- /dev/null +++ b/python/src/v2.0/pops/Mass.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Mass.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Mass wrapper +void wrapMass(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Mass; + + // create the component + python::class_ component( + module, + "Mass", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("double") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "double", + python::overload_cast<>(&Component::Double), + Component::documentation("double").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/MetaStable.python.cpp b/python/src/v2.0/pops/MetaStable.python.cpp new file mode 100644 index 000000000..13ad8fcd3 --- /dev/null +++ b/python/src/v2.0/pops/MetaStable.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/MetaStable.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// MetaStable wrapper +void wrapMetaStable(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::MetaStable; + + // create the component + python::class_ component( + module, + "MetaStable", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const Integer32 &, + const XMLName & + >(), + python::arg("id"), + python::arg("meta_stable_index"), + python::arg("pid"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "id", + &Component::id, + Component::documentation("id").data() + ) + .def_property_readonly( + "meta_stable_index", + &Component::metaStableIndex, + Component::documentation("meta_stable_index").data() + ) + .def_property_readonly( + "pid", + &Component::pid, + Component::documentation("pid").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Nucleus.python.cpp b/python/src/v2.0/pops/Nucleus.python.cpp new file mode 100644 index 000000000..d7cb79869 --- /dev/null +++ b/python/src/v2.0/pops/Nucleus.python.cpp @@ -0,0 +1,112 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Nucleus.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Nucleus wrapper +void wrapNucleus(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Nucleus; + + // create the component + python::class_ component( + module, + "Nucleus", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const Integer32 &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("id"), + python::arg("index"), + python::arg("charge") = std::nullopt, + python::arg("decay_data") = std::nullopt, + python::arg("energy") = std::nullopt, + python::arg("fission_fragment_data") = std::nullopt, + python::arg("halflife") = std::nullopt, + python::arg("parity") = std::nullopt, + python::arg("spin") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "id", + &Component::id, + Component::documentation("id").data() + ) + .def_property_readonly( + "index", + &Component::index, + Component::documentation("index").data() + ) + .def_property_readonly( + "charge", + python::overload_cast<>(&Component::charge), + Component::documentation("charge").data() + ) + .def_property_readonly( + "decay_data", + python::overload_cast<>(&Component::decayData), + Component::documentation("decay_data").data() + ) + .def_property_readonly( + "energy", + python::overload_cast<>(&Component::energy), + Component::documentation("energy").data() + ) + .def_property_readonly( + "fission_fragment_data", + python::overload_cast<>(&Component::fissionFragmentData), + Component::documentation("fission_fragment_data").data() + ) + .def_property_readonly( + "halflife", + python::overload_cast<>(&Component::halflife), + Component::documentation("halflife").data() + ) + .def_property_readonly( + "parity", + python::overload_cast<>(&Component::parity), + Component::documentation("parity").data() + ) + .def_property_readonly( + "spin", + python::overload_cast<>(&Component::spin), + Component::documentation("spin").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Nuclide.python.cpp b/python/src/v2.0/pops/Nuclide.python.cpp new file mode 100644 index 000000000..fe604313f --- /dev/null +++ b/python/src/v2.0/pops/Nuclide.python.cpp @@ -0,0 +1,105 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Nuclide.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Nuclide wrapper +void wrapNuclide(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Nuclide; + + // create the component + python::class_ component( + module, + "Nuclide", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("id"), + python::arg("charge") = std::nullopt, + python::arg("decay_data") = std::nullopt, + python::arg("fission_fragment_data") = std::nullopt, + python::arg("mass") = std::nullopt, + python::arg("nucleus") = std::nullopt, + python::arg("parity") = std::nullopt, + python::arg("spin") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "id", + &Component::id, + Component::documentation("id").data() + ) + .def_property_readonly( + "charge", + python::overload_cast<>(&Component::charge), + Component::documentation("charge").data() + ) + .def_property_readonly( + "decay_data", + python::overload_cast<>(&Component::decayData), + Component::documentation("decay_data").data() + ) + .def_property_readonly( + "fission_fragment_data", + python::overload_cast<>(&Component::fissionFragmentData), + Component::documentation("fission_fragment_data").data() + ) + .def_property_readonly( + "mass", + python::overload_cast<>(&Component::mass), + Component::documentation("mass").data() + ) + .def_property_readonly( + "nucleus", + python::overload_cast<>(&Component::nucleus), + Component::documentation("nucleus").data() + ) + .def_property_readonly( + "parity", + python::overload_cast<>(&Component::parity), + Component::documentation("parity").data() + ) + .def_property_readonly( + "spin", + python::overload_cast<>(&Component::spin), + Component::documentation("spin").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Nuclides.python.cpp b/python/src/v2.0/pops/Nuclides.python.cpp new file mode 100644 index 000000000..d0efa5f8e --- /dev/null +++ b/python/src/v2.0/pops/Nuclides.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Nuclides.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Nuclides wrapper +void wrapNuclides(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Nuclides; + + // create the component + python::class_ component( + module, + "Nuclides", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("nuclide"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "nuclide", + python::overload_cast<>(&Component::nuclide), + Component::documentation("nuclide").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Parity.python.cpp b/python/src/v2.0/pops/Parity.python.cpp new file mode 100644 index 000000000..82adc4a0f --- /dev/null +++ b/python/src/v2.0/pops/Parity.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Parity.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Parity wrapper +void wrapParity(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Parity; + + // create the component + python::class_ component( + module, + "Parity", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional> & + >(), + python::arg("integer") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "integer", + python::overload_cast<>(&Component::integer), + Component::documentation("integer").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/PhotonEmissionProbabilities.python.cpp b/python/src/v2.0/pops/PhotonEmissionProbabilities.python.cpp new file mode 100644 index 000000000..05fe46b31 --- /dev/null +++ b/python/src/v2.0/pops/PhotonEmissionProbabilities.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/PhotonEmissionProbabilities.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// PhotonEmissionProbabilities wrapper +void wrapPhotonEmissionProbabilities(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::PhotonEmissionProbabilities; + + // create the component + python::class_ component( + module, + "PhotonEmissionProbabilities", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("shell"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "shell", + python::overload_cast<>(&Component::shell), + Component::documentation("shell").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/PoPs.python.cpp b/python/src/v2.0/pops/PoPs.python.cpp new file mode 100644 index 000000000..398704e0f --- /dev/null +++ b/python/src/v2.0/pops/PoPs.python.cpp @@ -0,0 +1,126 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/PoPs.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// PoPs wrapper +void wrapPoPs(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::PoPs; + + // create the component + python::class_ component( + module, + "PoPs", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const XMLName &, + const XMLName &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("format"), + python::arg("name"), + python::arg("version"), + python::arg("aliases") = std::nullopt, + python::arg("baryons") = std::nullopt, + python::arg("chemical_elements") = std::nullopt, + python::arg("documentation") = std::nullopt, + python::arg("gauge_bosons") = std::nullopt, + python::arg("leptons") = std::nullopt, + python::arg("styles") = std::nullopt, + python::arg("unorthodoxes") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "format", + &Component::format, + Component::documentation("format").data() + ) + .def_property_readonly( + "name", + &Component::name, + Component::documentation("name").data() + ) + .def_property_readonly( + "version", + &Component::version, + Component::documentation("version").data() + ) + .def_property_readonly( + "aliases", + python::overload_cast<>(&Component::aliases), + Component::documentation("aliases").data() + ) + .def_property_readonly( + "baryons", + python::overload_cast<>(&Component::baryons), + Component::documentation("baryons").data() + ) + .def_property_readonly( + "chemical_elements", + python::overload_cast<>(&Component::chemicalElements), + Component::documentation("chemical_elements").data() + ) + .def_property_readonly( + "documentation", + python::overload_cast<>(&Component::doc), + Component::documentation("documentation").data() + ) + .def_property_readonly( + "gauge_bosons", + python::overload_cast<>(&Component::gaugeBosons), + Component::documentation("gauge_bosons").data() + ) + .def_property_readonly( + "leptons", + python::overload_cast<>(&Component::leptons), + Component::documentation("leptons").data() + ) + .def_property_readonly( + "styles", + python::overload_cast<>(&Component::styles), + Component::documentation("styles").data() + ) + .def_property_readonly( + "unorthodoxes", + python::overload_cast<>(&Component::unorthodoxes), + Component::documentation("unorthodoxes").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Probability.python.cpp b/python/src/v2.0/pops/Probability.python.cpp new file mode 100644 index 000000000..fce7fb4b1 --- /dev/null +++ b/python/src/v2.0/pops/Probability.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Probability.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Probability wrapper +void wrapProbability(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Probability; + + // create the component + python::class_ component( + module, + "Probability", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("double"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "double", + python::overload_cast<>(&Component::Double), + Component::documentation("double").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Product.python.cpp b/python/src/v2.0/pops/Product.python.cpp new file mode 100644 index 000000000..ed673aad8 --- /dev/null +++ b/python/src/v2.0/pops/Product.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Product.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Product wrapper +void wrapProduct(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Product; + + // create the component + python::class_ component( + module, + "Product", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const XMLName & + >(), + python::arg("label"), + python::arg("pid"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "pid", + &Component::pid, + Component::documentation("pid").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Products.python.cpp b/python/src/v2.0/pops/Products.python.cpp new file mode 100644 index 000000000..d7467e5c6 --- /dev/null +++ b/python/src/v2.0/pops/Products.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Products.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Products wrapper +void wrapProducts(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Products; + + // create the component + python::class_ component( + module, + "Products", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("product"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "product", + python::overload_cast<>(&Component::product), + Component::documentation("product").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Q.python.cpp b/python/src/v2.0/pops/Q.python.cpp new file mode 100644 index 000000000..7246cf770 --- /dev/null +++ b/python/src/v2.0/pops/Q.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Q.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Q wrapper +void wrapQ(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Q; + + // create the component + python::class_ component( + module, + "Q", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("double"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "double", + python::overload_cast<>(&Component::Double), + Component::documentation("double").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Shell.python.cpp b/python/src/v2.0/pops/Shell.python.cpp new file mode 100644 index 000000000..a1b97297a --- /dev/null +++ b/python/src/v2.0/pops/Shell.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Shell.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Shell wrapper +void wrapShell(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Shell; + + // create the component + python::class_ component( + module, + "Shell", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const std::optional &, + const Float64 & + >(), + python::arg("label"), + python::arg("unit") = std::nullopt, + python::arg("value"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "unit", + [](const Component &self) { return self.unit().value(); }, + Component::documentation("unit").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Spectra.python.cpp b/python/src/v2.0/pops/Spectra.python.cpp new file mode 100644 index 000000000..da31db827 --- /dev/null +++ b/python/src/v2.0/pops/Spectra.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Spectra.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Spectra wrapper +void wrapSpectra(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Spectra; + + // create the component + python::class_ component( + module, + "Spectra", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("spectrum"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "spectrum", + python::overload_cast<>(&Component::spectrum), + Component::documentation("spectrum").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Spectrum.python.cpp b/python/src/v2.0/pops/Spectrum.python.cpp new file mode 100644 index 000000000..6773d1bc3 --- /dev/null +++ b/python/src/v2.0/pops/Spectrum.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Spectrum.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Spectrum wrapper +void wrapSpectrum(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Spectrum; + + // create the component + python::class_ component( + module, + "Spectrum", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const XMLName &, + const std::optional &, + const std::optional> & + >(), + python::arg("label"), + python::arg("pid"), + python::arg("continuum") = std::nullopt, + python::arg("discrete") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "pid", + &Component::pid, + Component::documentation("pid").data() + ) + .def_property_readonly( + "continuum", + python::overload_cast<>(&Component::continuum), + Component::documentation("continuum").data() + ) + .def_property_readonly( + "discrete", + python::overload_cast<>(&Component::discrete), + Component::documentation("discrete").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Spin.python.cpp b/python/src/v2.0/pops/Spin.python.cpp new file mode 100644 index 000000000..624d7005c --- /dev/null +++ b/python/src/v2.0/pops/Spin.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Spin.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Spin wrapper +void wrapSpin(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Spin; + + // create the component + python::class_ component( + module, + "Spin", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional> & + >(), + python::arg("fraction") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "fraction", + python::overload_cast<>(&Component::fraction), + Component::documentation("fraction").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Unorthodox.python.cpp b/python/src/v2.0/pops/Unorthodox.python.cpp new file mode 100644 index 000000000..eaa3214aa --- /dev/null +++ b/python/src/v2.0/pops/Unorthodox.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Unorthodox.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Unorthodox wrapper +void wrapUnorthodox(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Unorthodox; + + // create the component + python::class_ component( + module, + "Unorthodox", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const std::optional &, + const std::optional & + >(), + python::arg("id"), + python::arg("charge") = std::nullopt, + python::arg("mass") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "id", + &Component::id, + Component::documentation("id").data() + ) + .def_property_readonly( + "charge", + python::overload_cast<>(&Component::charge), + Component::documentation("charge").data() + ) + .def_property_readonly( + "mass", + python::overload_cast<>(&Component::mass), + Component::documentation("mass").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/pops/Unorthodoxes.python.cpp b/python/src/v2.0/pops/Unorthodoxes.python.cpp new file mode 100644 index 000000000..ca46f1c53 --- /dev/null +++ b/python/src/v2.0/pops/Unorthodoxes.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/pops/Unorthodoxes.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_pops { + +// Unorthodoxes wrapper +void wrapUnorthodoxes(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = pops::Unorthodoxes; + + // create the component + python::class_ component( + module, + "Unorthodoxes", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("unorthodox"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "unorthodox", + python::overload_cast<>(&Component::unorthodox), + Component::documentation("unorthodox").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_pops +} // namespace python_v2_0 diff --git a/python/src/v2.0/processed.python.cpp b/python/src/v2.0/processed.python.cpp new file mode 100644 index 000000000..f556b0ec4 --- /dev/null +++ b/python/src/v2.0/processed.python.cpp @@ -0,0 +1,43 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include +#include + +namespace python = pybind11; + +// v2.0 interface +namespace python_v2_0 { + +// processed declarations +namespace python_processed { + void wrapAngularEnergyMC(python::module &); + void wrapEnergyAngularMC(python::module &); + void wrapMultiGroup3d(python::module &); + void wrapAvailableEnergy(python::module &); + void wrapAvailableMomentum(python::module &); + void wrapAverageProductEnergy(python::module &); + void wrapAverageProductMomentum(python::module &); +} // namespace python_processed + +// processed wrapper +void wrapProcessed(python::module &module) +{ + // create the processed submodule + python::module submodule = module.def_submodule( + "processed", + "GNDS v2.0 processed" + ); + + // wrap processed components + python_processed::wrapAngularEnergyMC(submodule); + python_processed::wrapEnergyAngularMC(submodule); + python_processed::wrapMultiGroup3d(submodule); + python_processed::wrapAvailableEnergy(submodule); + python_processed::wrapAvailableMomentum(submodule); + python_processed::wrapAverageProductEnergy(submodule); + python_processed::wrapAverageProductMomentum(submodule); +}; + +} // namespace python_v2_0 diff --git a/python/src/v2.0/processed/AngularEnergyMC.python.cpp b/python/src/v2.0/processed/AngularEnergyMC.python.cpp new file mode 100644 index 000000000..f352cc53a --- /dev/null +++ b/python/src/v2.0/processed/AngularEnergyMC.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/processed/AngularEnergyMC.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_processed { + +// AngularEnergyMC wrapper +void wrapAngularEnergyMC(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = processed::AngularEnergyMC; + + // create the component + python::class_ component( + module, + "AngularEnergyMC", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const XMLName &, + const transport::Angular &, + const transport::AngularEnergy & + >(), + python::arg("label"), + python::arg("product_frame"), + python::arg("angular"), + python::arg("angular_energy"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "product_frame", + &Component::productFrame, + Component::documentation("product_frame").data() + ) + .def_property_readonly( + "angular", + python::overload_cast<>(&Component::angular), + Component::documentation("angular").data() + ) + .def_property_readonly( + "angular_energy", + python::overload_cast<>(&Component::angularEnergy), + Component::documentation("angular_energy").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_processed +} // namespace python_v2_0 diff --git a/python/src/v2.0/processed/AvailableEnergy.python.cpp b/python/src/v2.0/processed/AvailableEnergy.python.cpp new file mode 100644 index 000000000..be1210306 --- /dev/null +++ b/python/src/v2.0/processed/AvailableEnergy.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/processed/AvailableEnergy.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_processed { + +// AvailableEnergy wrapper +void wrapAvailableEnergy(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = processed::AvailableEnergy; + + // create the component + python::class_ component( + module, + "AvailableEnergy", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("xys1d") = std::nullopt, + python::arg("gridded1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "gridded1d", + python::overload_cast<>(&Component::gridded1d), + Component::documentation("gridded1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_processed +} // namespace python_v2_0 diff --git a/python/src/v2.0/processed/AvailableMomentum.python.cpp b/python/src/v2.0/processed/AvailableMomentum.python.cpp new file mode 100644 index 000000000..43cb3ee40 --- /dev/null +++ b/python/src/v2.0/processed/AvailableMomentum.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/processed/AvailableMomentum.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_processed { + +// AvailableMomentum wrapper +void wrapAvailableMomentum(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = processed::AvailableMomentum; + + // create the component + python::class_ component( + module, + "AvailableMomentum", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("xys1d") = std::nullopt, + python::arg("gridded1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "gridded1d", + python::overload_cast<>(&Component::gridded1d), + Component::documentation("gridded1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_processed +} // namespace python_v2_0 diff --git a/python/src/v2.0/processed/AverageProductEnergy.python.cpp b/python/src/v2.0/processed/AverageProductEnergy.python.cpp new file mode 100644 index 000000000..1b0578f8b --- /dev/null +++ b/python/src/v2.0/processed/AverageProductEnergy.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/processed/AverageProductEnergy.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_processed { + +// AverageProductEnergy wrapper +void wrapAverageProductEnergy(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = processed::AverageProductEnergy; + + // create the component + python::class_ component( + module, + "AverageProductEnergy", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const containers::XYs1d &, + const std::optional & + >(), + python::arg("xys1d"), + python::arg("gridded1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "gridded1d", + python::overload_cast<>(&Component::gridded1d), + Component::documentation("gridded1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_processed +} // namespace python_v2_0 diff --git a/python/src/v2.0/processed/AverageProductMomentum.python.cpp b/python/src/v2.0/processed/AverageProductMomentum.python.cpp new file mode 100644 index 000000000..391855bac --- /dev/null +++ b/python/src/v2.0/processed/AverageProductMomentum.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/processed/AverageProductMomentum.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_processed { + +// AverageProductMomentum wrapper +void wrapAverageProductMomentum(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = processed::AverageProductMomentum; + + // create the component + python::class_ component( + module, + "AverageProductMomentum", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("xys1d") = std::nullopt, + python::arg("gridded1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "gridded1d", + python::overload_cast<>(&Component::gridded1d), + Component::documentation("gridded1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_processed +} // namespace python_v2_0 diff --git a/python/src/v2.0/processed/EnergyAngularMC.python.cpp b/python/src/v2.0/processed/EnergyAngularMC.python.cpp new file mode 100644 index 000000000..c86df1ab3 --- /dev/null +++ b/python/src/v2.0/processed/EnergyAngularMC.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/processed/EnergyAngularMC.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_processed { + +// EnergyAngularMC wrapper +void wrapEnergyAngularMC(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = processed::EnergyAngularMC; + + // create the component + python::class_ component( + module, + "EnergyAngularMC", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const XMLName &, + const ambiguousNamespace::Energy &, + const transport::EnergyAngular & + >(), + python::arg("label"), + python::arg("product_frame"), + python::arg("energy"), + python::arg("energy_angular"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "product_frame", + &Component::productFrame, + Component::documentation("product_frame").data() + ) + .def_property_readonly( + "energy", + python::overload_cast<>(&Component::energy), + Component::documentation("energy").data() + ) + .def_property_readonly( + "energy_angular", + python::overload_cast<>(&Component::energyAngular), + Component::documentation("energy_angular").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_processed +} // namespace python_v2_0 diff --git a/python/src/v2.0/processed/MultiGroup3d.python.cpp b/python/src/v2.0/processed/MultiGroup3d.python.cpp new file mode 100644 index 000000000..e0750d29b --- /dev/null +++ b/python/src/v2.0/processed/MultiGroup3d.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/processed/MultiGroup3d.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_processed { + +// MultiGroup3d wrapper +void wrapMultiGroup3d(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = processed::MultiGroup3d; + + // create the component + python::class_ component( + module, + "MultiGroup3d", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const XMLName &, + const containers::Gridded3d & + >(), + python::arg("label"), + python::arg("product_frame"), + python::arg("gridded3d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "product_frame", + &Component::productFrame, + Component::documentation("product_frame").data() + ) + .def_property_readonly( + "gridded3d", + python::overload_cast<>(&Component::gridded3d), + Component::documentation("gridded3d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_processed +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances.python.cpp b/python/src/v2.0/resonances.python.cpp new file mode 100644 index 000000000..f8520240d --- /dev/null +++ b/python/src/v2.0/resonances.python.cpp @@ -0,0 +1,79 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include +#include + +namespace python = pybind11; + +// v2.0 interface +namespace python_v2_0 { + +// resonances declarations +namespace python_resonances { + void wrapHardSphereRadius(python::module &); + void wrapResonanceParameters(python::module &); + void wrapScatteringRadius(python::module &); + void wrapBreitWigner(python::module &); + void wrapLevelSpacing(python::module &); + void wrapWidth(python::module &); + void wrapWidths(python::module &); + void wrapJ(python::module &); + void wrapJs(python::module &); + void wrapL(python::module &); + void wrapLs(python::module &); + void wrapResonanceReaction(python::module &); + void wrapResonanceReactions(python::module &); + void wrapExternalRMatrix(python::module &); + void wrapChannel(python::module &); + void wrapChannels(python::module &); + void wrapSpinGroup(python::module &); + void wrapSpinGroups(python::module &); + void wrapRMatrix(python::module &); + void wrapEnergyInterval(python::module &); + void wrapEnergyIntervals(python::module &); + void wrapResolved(python::module &); + void wrapTabulatedWidths(python::module &); + void wrapUnresolved(python::module &); + void wrapResonances(python::module &); +} // namespace python_resonances + +// resonances wrapper +void wrapResonances(python::module &module) +{ + // create the resonances submodule + python::module submodule = module.def_submodule( + "resonances", + "GNDS v2.0 resonances" + ); + + // wrap resonances components + python_resonances::wrapHardSphereRadius(submodule); + python_resonances::wrapResonanceParameters(submodule); + python_resonances::wrapScatteringRadius(submodule); + python_resonances::wrapBreitWigner(submodule); + python_resonances::wrapLevelSpacing(submodule); + python_resonances::wrapWidth(submodule); + python_resonances::wrapWidths(submodule); + python_resonances::wrapJ(submodule); + python_resonances::wrapJs(submodule); + python_resonances::wrapL(submodule); + python_resonances::wrapLs(submodule); + python_resonances::wrapResonanceReaction(submodule); + python_resonances::wrapResonanceReactions(submodule); + python_resonances::wrapExternalRMatrix(submodule); + python_resonances::wrapChannel(submodule); + python_resonances::wrapChannels(submodule); + python_resonances::wrapSpinGroup(submodule); + python_resonances::wrapSpinGroups(submodule); + python_resonances::wrapRMatrix(submodule); + python_resonances::wrapEnergyInterval(submodule); + python_resonances::wrapEnergyIntervals(submodule); + python_resonances::wrapResolved(submodule); + python_resonances::wrapTabulatedWidths(submodule); + python_resonances::wrapUnresolved(submodule); + python_resonances::wrapResonances(submodule); +}; + +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/BreitWigner.python.cpp b/python/src/v2.0/resonances/BreitWigner.python.cpp new file mode 100644 index 000000000..bac9108b2 --- /dev/null +++ b/python/src/v2.0/resonances/BreitWigner.python.cpp @@ -0,0 +1,105 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/BreitWigner.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// BreitWigner wrapper +void wrapBreitWigner(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::BreitWigner; + + // create the component + python::class_ component( + module, + "BreitWigner", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const std::optional &, + const XMLName &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("approximation"), + python::arg("calculate_channel_radius") = std::nullopt, + python::arg("label"), + python::arg("use_for_self_shielding_only") = std::nullopt, + python::arg("po_ps") = std::nullopt, + python::arg("hard_sphere_radius") = std::nullopt, + python::arg("resonance_parameters") = std::nullopt, + python::arg("scattering_radius") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "approximation", + &Component::approximation, + Component::documentation("approximation").data() + ) + .def_property_readonly( + "calculate_channel_radius", + [](const Component &self) { return self.calculateChannelRadius().value(); }, + Component::documentation("calculate_channel_radius").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "use_for_self_shielding_only", + [](const Component &self) { return self.useForSelfShieldingOnly().value(); }, + Component::documentation("use_for_self_shielding_only").data() + ) + .def_property_readonly( + "po_ps", + python::overload_cast<>(&Component::PoPs), + Component::documentation("po_ps").data() + ) + .def_property_readonly( + "hard_sphere_radius", + python::overload_cast<>(&Component::hardSphereRadius), + Component::documentation("hard_sphere_radius").data() + ) + .def_property_readonly( + "resonance_parameters", + python::overload_cast<>(&Component::resonanceParameters), + Component::documentation("resonance_parameters").data() + ) + .def_property_readonly( + "scattering_radius", + python::overload_cast<>(&Component::scatteringRadius), + Component::documentation("scattering_radius").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/Channel.python.cpp b/python/src/v2.0/resonances/Channel.python.cpp new file mode 100644 index 000000000..4cedf1b43 --- /dev/null +++ b/python/src/v2.0/resonances/Channel.python.cpp @@ -0,0 +1,112 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/Channel.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// Channel wrapper +void wrapChannel(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::Channel; + + // create the component + python::class_ component( + module, + "Channel", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const Integer32 &, + const std::optional &, + const Fraction32 &, + const Integer32 &, + const XMLName &, + const std::string &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("l"), + python::arg("boundary_condition_value") = std::nullopt, + python::arg("channel_spin"), + python::arg("column_index"), + python::arg("label"), + python::arg("resonance_reaction"), + python::arg("external_rmatrix") = std::nullopt, + python::arg("hard_sphere_radius") = std::nullopt, + python::arg("scattering_radius") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "l", + &Component::L, + Component::documentation("l").data() + ) + .def_property_readonly( + "boundary_condition_value", + &Component::boundaryConditionValue, + Component::documentation("boundary_condition_value").data() + ) + .def_property_readonly( + "channel_spin", + &Component::channelSpin, + Component::documentation("channel_spin").data() + ) + .def_property_readonly( + "column_index", + &Component::columnIndex, + Component::documentation("column_index").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "resonance_reaction", + &Component::resonanceReaction, + Component::documentation("resonance_reaction").data() + ) + .def_property_readonly( + "external_rmatrix", + python::overload_cast<>(&Component::externalRMatrix), + Component::documentation("external_rmatrix").data() + ) + .def_property_readonly( + "hard_sphere_radius", + python::overload_cast<>(&Component::hardSphereRadius), + Component::documentation("hard_sphere_radius").data() + ) + .def_property_readonly( + "scattering_radius", + python::overload_cast<>(&Component::scatteringRadius), + Component::documentation("scattering_radius").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/Channels.python.cpp b/python/src/v2.0/resonances/Channels.python.cpp new file mode 100644 index 000000000..4f0bbacec --- /dev/null +++ b/python/src/v2.0/resonances/Channels.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/Channels.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// Channels wrapper +void wrapChannels(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::Channels; + + // create the component + python::class_ component( + module, + "Channels", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("channel"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "channel", + python::overload_cast<>(&Component::channel), + Component::documentation("channel").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/EnergyInterval.python.cpp b/python/src/v2.0/resonances/EnergyInterval.python.cpp new file mode 100644 index 000000000..66165ece1 --- /dev/null +++ b/python/src/v2.0/resonances/EnergyInterval.python.cpp @@ -0,0 +1,98 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/EnergyInterval.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// EnergyInterval wrapper +void wrapEnergyInterval(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::EnergyInterval; + using _t = std::variant< + resonances::BreitWigner, + resonances::RMatrix + >; + + // create the component + python::class_ component( + module, + "EnergyInterval", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const Float64 &, + const Float64 &, + const XMLName &, + const Integer32 &, + const _t & + >(), + python::arg("domain_max"), + python::arg("domain_min"), + python::arg("domain_unit"), + python::arg("index"), + python::arg("_breit_wigner_rmatrix"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "domain_max", + &Component::domainMax, + Component::documentation("domain_max").data() + ) + .def_property_readonly( + "domain_min", + &Component::domainMin, + Component::documentation("domain_min").data() + ) + .def_property_readonly( + "domain_unit", + &Component::domainUnit, + Component::documentation("domain_unit").data() + ) + .def_property_readonly( + "index", + &Component::index, + Component::documentation("index").data() + ) + .def_property_readonly( + "breit_wigner", + python::overload_cast<>(&Component::BreitWigner), + Component::documentation("breit_wigner").data() + ) + .def_property_readonly( + "rmatrix", + python::overload_cast<>(&Component::RMatrix), + Component::documentation("rmatrix").data() + ) + .def_property_readonly( + "_breit_wigner_rmatrix", + python::overload_cast<>(&Component::_BreitWignerRMatrix), + Component::documentation("_breit_wigner_rmatrix").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/EnergyIntervals.python.cpp b/python/src/v2.0/resonances/EnergyIntervals.python.cpp new file mode 100644 index 000000000..d47f3e5cc --- /dev/null +++ b/python/src/v2.0/resonances/EnergyIntervals.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/EnergyIntervals.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// EnergyIntervals wrapper +void wrapEnergyIntervals(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::EnergyIntervals; + + // create the component + python::class_ component( + module, + "EnergyIntervals", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const std::vector & + >(), + python::arg("label"), + python::arg("energy_interval"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "energy_interval", + python::overload_cast<>(&Component::energyInterval), + Component::documentation("energy_interval").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/ExternalRMatrix.python.cpp b/python/src/v2.0/resonances/ExternalRMatrix.python.cpp new file mode 100644 index 000000000..4b155ab6a --- /dev/null +++ b/python/src/v2.0/resonances/ExternalRMatrix.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/ExternalRMatrix.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// ExternalRMatrix wrapper +void wrapExternalRMatrix(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::ExternalRMatrix; + + // create the component + python::class_ component( + module, + "ExternalRMatrix", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const std::vector & + >(), + python::arg("type"), + python::arg("double"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "type", + &Component::type, + Component::documentation("type").data() + ) + .def_property_readonly( + "double", + python::overload_cast<>(&Component::Double), + Component::documentation("double").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/HardSphereRadius.python.cpp b/python/src/v2.0/resonances/HardSphereRadius.python.cpp new file mode 100644 index 000000000..143ca77b9 --- /dev/null +++ b/python/src/v2.0/resonances/HardSphereRadius.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/HardSphereRadius.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// HardSphereRadius wrapper +void wrapHardSphereRadius(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::HardSphereRadius; + + // create the component + python::class_ component( + module, + "HardSphereRadius", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const containers::Constant1d & + >(), + python::arg("constant1d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "constant1d", + python::overload_cast<>(&Component::constant1d), + Component::documentation("constant1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/J.python.cpp b/python/src/v2.0/resonances/J.python.cpp new file mode 100644 index 000000000..b5b43169b --- /dev/null +++ b/python/src/v2.0/resonances/J.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/J.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// J wrapper +void wrapJ(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::J; + + // create the component + python::class_ component( + module, + "J", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const Fraction32 &, + const resonances::LevelSpacing &, + const resonances::Widths & + >(), + python::arg("label"), + python::arg("value"), + python::arg("level_spacing"), + python::arg("widths"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + .def_property_readonly( + "level_spacing", + python::overload_cast<>(&Component::levelSpacing), + Component::documentation("level_spacing").data() + ) + .def_property_readonly( + "widths", + python::overload_cast<>(&Component::widths), + Component::documentation("widths").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/Js.python.cpp b/python/src/v2.0/resonances/Js.python.cpp new file mode 100644 index 000000000..e8878e5d3 --- /dev/null +++ b/python/src/v2.0/resonances/Js.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/Js.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// Js wrapper +void wrapJs(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::Js; + + // create the component + python::class_ component( + module, + "Js", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("j"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "j", + python::overload_cast<>(&Component::J), + Component::documentation("j").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/L.python.cpp b/python/src/v2.0/resonances/L.python.cpp new file mode 100644 index 000000000..e7ffceeea --- /dev/null +++ b/python/src/v2.0/resonances/L.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/L.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// L wrapper +void wrapL(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::L; + + // create the component + python::class_ component( + module, + "L", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const Integer32 &, + const resonances::Js & + >(), + python::arg("label"), + python::arg("value"), + python::arg("js"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + .def_property_readonly( + "js", + python::overload_cast<>(&Component::Js), + Component::documentation("js").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/LevelSpacing.python.cpp b/python/src/v2.0/resonances/LevelSpacing.python.cpp new file mode 100644 index 000000000..0856fb696 --- /dev/null +++ b/python/src/v2.0/resonances/LevelSpacing.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/LevelSpacing.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// LevelSpacing wrapper +void wrapLevelSpacing(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::LevelSpacing; + + // create the component + python::class_ component( + module, + "LevelSpacing", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("xys1d") = std::nullopt, + python::arg("constant1d") = std::nullopt, + python::arg("regions1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "constant1d", + python::overload_cast<>(&Component::constant1d), + Component::documentation("constant1d").data() + ) + .def_property_readonly( + "regions1d", + python::overload_cast<>(&Component::regions1d), + Component::documentation("regions1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/Ls.python.cpp b/python/src/v2.0/resonances/Ls.python.cpp new file mode 100644 index 000000000..8922da2dc --- /dev/null +++ b/python/src/v2.0/resonances/Ls.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/Ls.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// Ls wrapper +void wrapLs(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::Ls; + + // create the component + python::class_ component( + module, + "Ls", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("l"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "l", + python::overload_cast<>(&Component::L), + Component::documentation("l").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/RMatrix.python.cpp b/python/src/v2.0/resonances/RMatrix.python.cpp new file mode 100644 index 000000000..784487410 --- /dev/null +++ b/python/src/v2.0/resonances/RMatrix.python.cpp @@ -0,0 +1,126 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/RMatrix.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// RMatrix wrapper +void wrapRMatrix(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::RMatrix; + + // create the component + python::class_ component( + module, + "RMatrix", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const XMLName &, + const std::optional &, + const std::optional &, + const std::optional &, + const resonances::ResonanceReactions &, + const resonances::SpinGroups & + >(), + python::arg("approximation"), + python::arg("boundary_condition") = std::nullopt, + python::arg("boundary_condition_value") = std::nullopt, + python::arg("calculate_channel_radius") = std::nullopt, + python::arg("calculate_penetrability") = std::nullopt, + python::arg("label"), + python::arg("supports_angular_reconstruction") = std::nullopt, + python::arg("use_for_self_shielding_only") = std::nullopt, + python::arg("po_ps") = std::nullopt, + python::arg("resonance_reactions"), + python::arg("spin_groups"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "approximation", + &Component::approximation, + Component::documentation("approximation").data() + ) + .def_property_readonly( + "boundary_condition", + [](const Component &self) { return self.boundaryCondition().value(); }, + Component::documentation("boundary_condition").data() + ) + .def_property_readonly( + "boundary_condition_value", + &Component::boundaryConditionValue, + Component::documentation("boundary_condition_value").data() + ) + .def_property_readonly( + "calculate_channel_radius", + [](const Component &self) { return self.calculateChannelRadius().value(); }, + Component::documentation("calculate_channel_radius").data() + ) + .def_property_readonly( + "calculate_penetrability", + [](const Component &self) { return self.calculatePenetrability().value(); }, + Component::documentation("calculate_penetrability").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "supports_angular_reconstruction", + [](const Component &self) { return self.supportsAngularReconstruction().value(); }, + Component::documentation("supports_angular_reconstruction").data() + ) + .def_property_readonly( + "use_for_self_shielding_only", + [](const Component &self) { return self.useForSelfShieldingOnly().value(); }, + Component::documentation("use_for_self_shielding_only").data() + ) + .def_property_readonly( + "po_ps", + python::overload_cast<>(&Component::PoPs), + Component::documentation("po_ps").data() + ) + .def_property_readonly( + "resonance_reactions", + python::overload_cast<>(&Component::resonanceReactions), + Component::documentation("resonance_reactions").data() + ) + .def_property_readonly( + "spin_groups", + python::overload_cast<>(&Component::spinGroups), + Component::documentation("spin_groups").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/Resolved.python.cpp b/python/src/v2.0/resonances/Resolved.python.cpp new file mode 100644 index 000000000..f35d22c87 --- /dev/null +++ b/python/src/v2.0/resonances/Resolved.python.cpp @@ -0,0 +1,97 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/Resolved.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// Resolved wrapper +void wrapResolved(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::Resolved; + using _t = std::variant< + resonances::BreitWigner, + resonances::RMatrix, + resonances::EnergyIntervals + >; + + // create the component + python::class_ component( + module, + "Resolved", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const Float64 &, + const Float64 &, + const XMLName &, + const _t & + >(), + python::arg("domain_max"), + python::arg("domain_min"), + python::arg("domain_unit"), + python::arg("_breit_wigner_rmatrixenergy_intervals"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "domain_max", + &Component::domainMax, + Component::documentation("domain_max").data() + ) + .def_property_readonly( + "domain_min", + &Component::domainMin, + Component::documentation("domain_min").data() + ) + .def_property_readonly( + "domain_unit", + &Component::domainUnit, + Component::documentation("domain_unit").data() + ) + .def_property_readonly( + "breit_wigner", + python::overload_cast<>(&Component::BreitWigner), + Component::documentation("breit_wigner").data() + ) + .def_property_readonly( + "rmatrix", + python::overload_cast<>(&Component::RMatrix), + Component::documentation("rmatrix").data() + ) + .def_property_readonly( + "energy_intervals", + python::overload_cast<>(&Component::energyIntervals), + Component::documentation("energy_intervals").data() + ) + .def_property_readonly( + "_breit_wigner_rmatrixenergy_intervals", + python::overload_cast<>(&Component::_BreitWignerRMatrixenergyIntervals), + Component::documentation("_breit_wigner_rmatrixenergy_intervals").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/ResonanceParameters.python.cpp b/python/src/v2.0/resonances/ResonanceParameters.python.cpp new file mode 100644 index 000000000..024aac8b0 --- /dev/null +++ b/python/src/v2.0/resonances/ResonanceParameters.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/ResonanceParameters.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// ResonanceParameters wrapper +void wrapResonanceParameters(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::ResonanceParameters; + + // create the component + python::class_ component( + module, + "ResonanceParameters", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const containers::Table & + >(), + python::arg("table"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "table", + python::overload_cast<>(&Component::table), + Component::documentation("table").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/ResonanceReaction.python.cpp b/python/src/v2.0/resonances/ResonanceReaction.python.cpp new file mode 100644 index 000000000..9cc2caf23 --- /dev/null +++ b/python/src/v2.0/resonances/ResonanceReaction.python.cpp @@ -0,0 +1,105 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/ResonanceReaction.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// ResonanceReaction wrapper +void wrapResonanceReaction(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::ResonanceReaction; + + // create the component + python::class_ component( + module, + "ResonanceReaction", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const XMLName &, + const std::optional &, + const XMLName &, + const std::optional &, + const std::optional &, + const containers::Link &, + const std::optional & + >(), + python::arg("boundary_condition_value") = std::nullopt, + python::arg("ejectile"), + python::arg("eliminated") = std::nullopt, + python::arg("label"), + python::arg("q") = std::nullopt, + python::arg("hard_sphere_radius") = std::nullopt, + python::arg("link"), + python::arg("scattering_radius") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "boundary_condition_value", + &Component::boundaryConditionValue, + Component::documentation("boundary_condition_value").data() + ) + .def_property_readonly( + "ejectile", + &Component::ejectile, + Component::documentation("ejectile").data() + ) + .def_property_readonly( + "eliminated", + [](const Component &self) { return self.eliminated().value(); }, + Component::documentation("eliminated").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "q", + python::overload_cast<>(&Component::Q), + Component::documentation("q").data() + ) + .def_property_readonly( + "hard_sphere_radius", + python::overload_cast<>(&Component::hardSphereRadius), + Component::documentation("hard_sphere_radius").data() + ) + .def_property_readonly( + "link", + python::overload_cast<>(&Component::link), + Component::documentation("link").data() + ) + .def_property_readonly( + "scattering_radius", + python::overload_cast<>(&Component::scatteringRadius), + Component::documentation("scattering_radius").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/ResonanceReactions.python.cpp b/python/src/v2.0/resonances/ResonanceReactions.python.cpp new file mode 100644 index 000000000..4ecd83df7 --- /dev/null +++ b/python/src/v2.0/resonances/ResonanceReactions.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/ResonanceReactions.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// ResonanceReactions wrapper +void wrapResonanceReactions(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::ResonanceReactions; + + // create the component + python::class_ component( + module, + "ResonanceReactions", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("resonance_reaction"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "resonance_reaction", + python::overload_cast<>(&Component::resonanceReaction), + Component::documentation("resonance_reaction").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/Resonances.python.cpp b/python/src/v2.0/resonances/Resonances.python.cpp new file mode 100644 index 000000000..687301304 --- /dev/null +++ b/python/src/v2.0/resonances/Resonances.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/Resonances.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// Resonances wrapper +void wrapResonances(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::Resonances; + + // create the component + python::class_ component( + module, + "Resonances", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional> &, + const resonances::ScatteringRadius &, + const std::optional> & + >(), + python::arg("href") = std::nullopt, + python::arg("hard_sphere_radius") = std::nullopt, + python::arg("resolved") = std::nullopt, + python::arg("scattering_radius"), + python::arg("unresolved") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + .def_property_readonly( + "hard_sphere_radius", + python::overload_cast<>(&Component::hardSphereRadius), + Component::documentation("hard_sphere_radius").data() + ) + .def_property_readonly( + "resolved", + python::overload_cast<>(&Component::resolved), + Component::documentation("resolved").data() + ) + .def_property_readonly( + "scattering_radius", + python::overload_cast<>(&Component::scatteringRadius), + Component::documentation("scattering_radius").data() + ) + .def_property_readonly( + "unresolved", + python::overload_cast<>(&Component::unresolved), + Component::documentation("unresolved").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/ScatteringRadius.python.cpp b/python/src/v2.0/resonances/ScatteringRadius.python.cpp new file mode 100644 index 000000000..711114000 --- /dev/null +++ b/python/src/v2.0/resonances/ScatteringRadius.python.cpp @@ -0,0 +1,76 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/ScatteringRadius.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// ScatteringRadius wrapper +void wrapScatteringRadius(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::ScatteringRadius; + using _t = std::variant< + containers::XYs1d, + containers::Constant1d, + containers::Regions1d + >; + + // create the component + python::class_ component( + module, + "ScatteringRadius", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const _t & + >(), + python::arg("_xys1dconstant1dregions1d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "constant1d", + python::overload_cast<>(&Component::constant1d), + Component::documentation("constant1d").data() + ) + .def_property_readonly( + "regions1d", + python::overload_cast<>(&Component::regions1d), + Component::documentation("regions1d").data() + ) + .def_property_readonly( + "_xys1dconstant1dregions1d", + python::overload_cast<>(&Component::_XYs1dconstant1dregions1d), + Component::documentation("_xys1dconstant1dregions1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/SpinGroup.python.cpp b/python/src/v2.0/resonances/SpinGroup.python.cpp new file mode 100644 index 000000000..87f6145f9 --- /dev/null +++ b/python/src/v2.0/resonances/SpinGroup.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/SpinGroup.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// SpinGroup wrapper +void wrapSpinGroup(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::SpinGroup; + + // create the component + python::class_ component( + module, + "SpinGroup", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const Integer32 &, + const Fraction32 &, + const resonances::Channels &, + const resonances::ResonanceParameters & + >(), + python::arg("label"), + python::arg("parity"), + python::arg("spin"), + python::arg("channels"), + python::arg("resonance_parameters"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "parity", + &Component::parity, + Component::documentation("parity").data() + ) + .def_property_readonly( + "spin", + &Component::spin, + Component::documentation("spin").data() + ) + .def_property_readonly( + "channels", + python::overload_cast<>(&Component::channels), + Component::documentation("channels").data() + ) + .def_property_readonly( + "resonance_parameters", + python::overload_cast<>(&Component::resonanceParameters), + Component::documentation("resonance_parameters").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/SpinGroups.python.cpp b/python/src/v2.0/resonances/SpinGroups.python.cpp new file mode 100644 index 000000000..20ff833e6 --- /dev/null +++ b/python/src/v2.0/resonances/SpinGroups.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/SpinGroups.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// SpinGroups wrapper +void wrapSpinGroups(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::SpinGroups; + + // create the component + python::class_ component( + module, + "SpinGroups", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("spin_group"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "spin_group", + python::overload_cast<>(&Component::spinGroup), + Component::documentation("spin_group").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/TabulatedWidths.python.cpp b/python/src/v2.0/resonances/TabulatedWidths.python.cpp new file mode 100644 index 000000000..5b4c51036 --- /dev/null +++ b/python/src/v2.0/resonances/TabulatedWidths.python.cpp @@ -0,0 +1,105 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/TabulatedWidths.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// TabulatedWidths wrapper +void wrapTabulatedWidths(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::TabulatedWidths; + + // create the component + python::class_ component( + module, + "TabulatedWidths", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const XMLName &, + const std::optional &, + const resonances::Ls &, + const std::optional &, + const std::optional &, + const resonances::ResonanceReactions &, + const std::optional & + >(), + python::arg("approximation"), + python::arg("label"), + python::arg("use_for_self_shielding_only") = std::nullopt, + python::arg("ls"), + python::arg("po_ps") = std::nullopt, + python::arg("hard_sphere_radius") = std::nullopt, + python::arg("resonance_reactions"), + python::arg("scattering_radius") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "approximation", + &Component::approximation, + Component::documentation("approximation").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "use_for_self_shielding_only", + [](const Component &self) { return self.useForSelfShieldingOnly().value(); }, + Component::documentation("use_for_self_shielding_only").data() + ) + .def_property_readonly( + "ls", + python::overload_cast<>(&Component::Ls), + Component::documentation("ls").data() + ) + .def_property_readonly( + "po_ps", + python::overload_cast<>(&Component::PoPs), + Component::documentation("po_ps").data() + ) + .def_property_readonly( + "hard_sphere_radius", + python::overload_cast<>(&Component::hardSphereRadius), + Component::documentation("hard_sphere_radius").data() + ) + .def_property_readonly( + "resonance_reactions", + python::overload_cast<>(&Component::resonanceReactions), + Component::documentation("resonance_reactions").data() + ) + .def_property_readonly( + "scattering_radius", + python::overload_cast<>(&Component::scatteringRadius), + Component::documentation("scattering_radius").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/Unresolved.python.cpp b/python/src/v2.0/resonances/Unresolved.python.cpp new file mode 100644 index 000000000..04c0afd0a --- /dev/null +++ b/python/src/v2.0/resonances/Unresolved.python.cpp @@ -0,0 +1,85 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/Unresolved.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// Unresolved wrapper +void wrapUnresolved(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::Unresolved; + using _t = std::variant< + resonances::TabulatedWidths + >; + + // create the component + python::class_ component( + module, + "Unresolved", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const Float64 &, + const Float64 &, + const XMLName &, + const _t & + >(), + python::arg("domain_max"), + python::arg("domain_min"), + python::arg("domain_unit"), + python::arg("_tabulated_widths"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "domain_max", + &Component::domainMax, + Component::documentation("domain_max").data() + ) + .def_property_readonly( + "domain_min", + &Component::domainMin, + Component::documentation("domain_min").data() + ) + .def_property_readonly( + "domain_unit", + &Component::domainUnit, + Component::documentation("domain_unit").data() + ) + .def_property_readonly( + "tabulated_widths", + python::overload_cast<>(&Component::tabulatedWidths), + Component::documentation("tabulated_widths").data() + ) + .def_property_readonly( + "_tabulated_widths", + python::overload_cast<>(&Component::_tabulatedWidths), + Component::documentation("_tabulated_widths").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/Width.python.cpp b/python/src/v2.0/resonances/Width.python.cpp new file mode 100644 index 000000000..e13ecc14b --- /dev/null +++ b/python/src/v2.0/resonances/Width.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/Width.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// Width wrapper +void wrapWidth(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::Width; + + // create the component + python::class_ component( + module, + "Width", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const Float64 &, + const std::string &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("degrees_of_freedom"), + python::arg("resonance_reaction"), + python::arg("xys1d") = std::nullopt, + python::arg("constant1d") = std::nullopt, + python::arg("regions1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "degrees_of_freedom", + &Component::degreesOfFreedom, + Component::documentation("degrees_of_freedom").data() + ) + .def_property_readonly( + "resonance_reaction", + &Component::resonanceReaction, + Component::documentation("resonance_reaction").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "constant1d", + python::overload_cast<>(&Component::constant1d), + Component::documentation("constant1d").data() + ) + .def_property_readonly( + "regions1d", + python::overload_cast<>(&Component::regions1d), + Component::documentation("regions1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/resonances/Widths.python.cpp b/python/src/v2.0/resonances/Widths.python.cpp new file mode 100644 index 000000000..600eeb8c6 --- /dev/null +++ b/python/src/v2.0/resonances/Widths.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/resonances/Widths.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_resonances { + +// Widths wrapper +void wrapWidths(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = resonances::Widths; + + // create the component + python::class_ component( + module, + "Widths", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("width"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "width", + python::overload_cast<>(&Component::width), + Component::documentation("width").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_resonances +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles.python.cpp b/python/src/v2.0/styles.python.cpp new file mode 100644 index 000000000..f5c4c5579 --- /dev/null +++ b/python/src/v2.0/styles.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include +#include + +namespace python = pybind11; + +// v2.0 interface +namespace python_v2_0 { + +// styles declarations +namespace python_styles { + void wrapMonteCarlo_cdf(python::module &); + void wrapSnElasticUpScatter(python::module &); + void wrapURR_probabilityTables(python::module &); + void wrapTemperature(python::module &); + void wrapAngularDistributionReconstructed(python::module &); + void wrapAverageProductData(python::module &); + void wrapCrossSectionReconstructed(python::module &); + void wrapProjectileEnergyDomain(python::module &); + void wrapEvaluated(python::module &); + void wrapGriddedCrossSection(python::module &); + void wrapHeated(python::module &); + void wrapFlux(python::module &); + void wrapInverseSpeed(python::module &); + void wrapMultiGroup(python::module &); + void wrapTransportable(python::module &); + void wrapTransportables(python::module &); + void wrapHeatedMultiGroup(python::module &); + void wrapStyles(python::module &); + void wrapSigmaZeros(python::module &); + void wrapBondarenko(python::module &); + void wrapCoulombPlusNuclearElasticMuCutoff(python::module &); + void wrapEqualProbableBins(python::module &); + void wrapMultiBand(python::module &); + void wrapRealization(python::module &); +} // namespace python_styles + +// styles wrapper +void wrapStyles(python::module &module) +{ + // create the styles submodule + python::module submodule = module.def_submodule( + "styles", + "GNDS v2.0 styles" + ); + + // wrap styles components + python_styles::wrapMonteCarlo_cdf(submodule); + python_styles::wrapSnElasticUpScatter(submodule); + python_styles::wrapURR_probabilityTables(submodule); + python_styles::wrapTemperature(submodule); + python_styles::wrapAngularDistributionReconstructed(submodule); + python_styles::wrapAverageProductData(submodule); + python_styles::wrapCrossSectionReconstructed(submodule); + python_styles::wrapProjectileEnergyDomain(submodule); + python_styles::wrapEvaluated(submodule); + python_styles::wrapGriddedCrossSection(submodule); + python_styles::wrapHeated(submodule); + python_styles::wrapFlux(submodule); + python_styles::wrapInverseSpeed(submodule); + python_styles::wrapMultiGroup(submodule); + python_styles::wrapTransportable(submodule); + python_styles::wrapTransportables(submodule); + python_styles::wrapHeatedMultiGroup(submodule); + python_styles::wrapStyles(submodule); + python_styles::wrapSigmaZeros(submodule); + python_styles::wrapBondarenko(submodule); + python_styles::wrapCoulombPlusNuclearElasticMuCutoff(submodule); + python_styles::wrapEqualProbableBins(submodule); + python_styles::wrapMultiBand(submodule); + python_styles::wrapRealization(submodule); +}; + +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/AngularDistributionReconstructed.python.cpp b/python/src/v2.0/styles/AngularDistributionReconstructed.python.cpp new file mode 100644 index 000000000..c9a3a2e8a --- /dev/null +++ b/python/src/v2.0/styles/AngularDistributionReconstructed.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/AngularDistributionReconstructed.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// AngularDistributionReconstructed wrapper +void wrapAngularDistributionReconstructed(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::AngularDistributionReconstructed; + + // create the component + python::class_ component( + module, + "AngularDistributionReconstructed", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string &, + const std::optional &, + const XMLName &, + const std::optional &, + const std::optional & + >(), + python::arg("date"), + python::arg("derived_from") = std::nullopt, + python::arg("label"), + python::arg("documentation") = std::nullopt, + python::arg("temperature") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "date", + &Component::date, + Component::documentation("date").data() + ) + .def_property_readonly( + "derived_from", + &Component::derivedFrom, + Component::documentation("derived_from").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "documentation", + python::overload_cast<>(&Component::documentation), + Component::documentation("documentation").data() + ) + .def_property_readonly( + "temperature", + python::overload_cast<>(&Component::temperature), + Component::documentation("temperature").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/AverageProductData.python.cpp b/python/src/v2.0/styles/AverageProductData.python.cpp new file mode 100644 index 000000000..03d4b62a2 --- /dev/null +++ b/python/src/v2.0/styles/AverageProductData.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/AverageProductData.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// AverageProductData wrapper +void wrapAverageProductData(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::AverageProductData; + + // create the component + python::class_ component( + module, + "AverageProductData", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string &, + const std::optional &, + const XMLName &, + const std::optional &, + const styles::Temperature & + >(), + python::arg("date"), + python::arg("derived_from") = std::nullopt, + python::arg("label"), + python::arg("documentation") = std::nullopt, + python::arg("temperature"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "date", + &Component::date, + Component::documentation("date").data() + ) + .def_property_readonly( + "derived_from", + &Component::derivedFrom, + Component::documentation("derived_from").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "documentation", + python::overload_cast<>(&Component::documentation), + Component::documentation("documentation").data() + ) + .def_property_readonly( + "temperature", + python::overload_cast<>(&Component::temperature), + Component::documentation("temperature").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/Bondarenko.python.cpp b/python/src/v2.0/styles/Bondarenko.python.cpp new file mode 100644 index 000000000..30a6fa1a8 --- /dev/null +++ b/python/src/v2.0/styles/Bondarenko.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/Bondarenko.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// Bondarenko wrapper +void wrapBondarenko(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::Bondarenko; + + // create the component + python::class_ component( + module, + "Bondarenko", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string &, + const XMLName &, + const XMLName &, + const styles::SigmaZeros & + >(), + python::arg("date"), + python::arg("derived_from"), + python::arg("label"), + python::arg("sigma_zeros"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "date", + &Component::date, + Component::documentation("date").data() + ) + .def_property_readonly( + "derived_from", + &Component::derivedFrom, + Component::documentation("derived_from").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "sigma_zeros", + python::overload_cast<>(&Component::sigmaZeros), + Component::documentation("sigma_zeros").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/CoulombPlusNuclearElasticMuCutoff.python.cpp b/python/src/v2.0/styles/CoulombPlusNuclearElasticMuCutoff.python.cpp new file mode 100644 index 000000000..e4622931d --- /dev/null +++ b/python/src/v2.0/styles/CoulombPlusNuclearElasticMuCutoff.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/CoulombPlusNuclearElasticMuCutoff.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// CoulombPlusNuclearElasticMuCutoff wrapper +void wrapCoulombPlusNuclearElasticMuCutoff(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::CoulombPlusNuclearElasticMuCutoff; + + // create the component + python::class_ component( + module, + "CoulombPlusNuclearElasticMuCutoff", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string &, + const XMLName &, + const XMLName &, + const Float64 & + >(), + python::arg("date"), + python::arg("derived_from"), + python::arg("label"), + python::arg("mu_cutoff"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "date", + &Component::date, + Component::documentation("date").data() + ) + .def_property_readonly( + "derived_from", + &Component::derivedFrom, + Component::documentation("derived_from").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "mu_cutoff", + &Component::muCutoff, + Component::documentation("mu_cutoff").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/CrossSectionReconstructed.python.cpp b/python/src/v2.0/styles/CrossSectionReconstructed.python.cpp new file mode 100644 index 000000000..1db6c7ac6 --- /dev/null +++ b/python/src/v2.0/styles/CrossSectionReconstructed.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/CrossSectionReconstructed.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// CrossSectionReconstructed wrapper +void wrapCrossSectionReconstructed(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::CrossSectionReconstructed; + + // create the component + python::class_ component( + module, + "CrossSectionReconstructed", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string &, + const std::optional &, + const XMLName &, + const std::optional &, + const std::optional & + >(), + python::arg("date"), + python::arg("derived_from") = std::nullopt, + python::arg("label"), + python::arg("documentation") = std::nullopt, + python::arg("temperature") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "date", + &Component::date, + Component::documentation("date").data() + ) + .def_property_readonly( + "derived_from", + &Component::derivedFrom, + Component::documentation("derived_from").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "documentation", + python::overload_cast<>(&Component::documentation), + Component::documentation("documentation").data() + ) + .def_property_readonly( + "temperature", + python::overload_cast<>(&Component::temperature), + Component::documentation("temperature").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/EqualProbableBins.python.cpp b/python/src/v2.0/styles/EqualProbableBins.python.cpp new file mode 100644 index 000000000..df16e13e1 --- /dev/null +++ b/python/src/v2.0/styles/EqualProbableBins.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/EqualProbableBins.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// EqualProbableBins wrapper +void wrapEqualProbableBins(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::EqualProbableBins; + + // create the component + python::class_ component( + module, + "EqualProbableBins", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string &, + const XMLName &, + const XMLName &, + const Integer32 & + >(), + python::arg("date"), + python::arg("derived_from"), + python::arg("label"), + python::arg("number_of_bins"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "date", + &Component::date, + Component::documentation("date").data() + ) + .def_property_readonly( + "derived_from", + &Component::derivedFrom, + Component::documentation("derived_from").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "number_of_bins", + &Component::numberOfBins, + Component::documentation("number_of_bins").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/Evaluated.python.cpp b/python/src/v2.0/styles/Evaluated.python.cpp new file mode 100644 index 000000000..5ab94ce77 --- /dev/null +++ b/python/src/v2.0/styles/Evaluated.python.cpp @@ -0,0 +1,105 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/Evaluated.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// Evaluated wrapper +void wrapEvaluated(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::Evaluated; + + // create the component + python::class_ component( + module, + "Evaluated", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string &, + const std::optional &, + const XMLName &, + const XMLName &, + const XMLName &, + const documentation::Documentation &, + const styles::ProjectileEnergyDomain &, + const styles::Temperature & + >(), + python::arg("date"), + python::arg("derived_from") = std::nullopt, + python::arg("label"), + python::arg("library"), + python::arg("version"), + python::arg("documentation"), + python::arg("projectile_energy_domain"), + python::arg("temperature"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "date", + &Component::date, + Component::documentation("date").data() + ) + .def_property_readonly( + "derived_from", + &Component::derivedFrom, + Component::documentation("derived_from").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "library", + &Component::library, + Component::documentation("library").data() + ) + .def_property_readonly( + "version", + &Component::version, + Component::documentation("version").data() + ) + .def_property_readonly( + "documentation", + python::overload_cast<>(&Component::documentation), + Component::documentation("documentation").data() + ) + .def_property_readonly( + "projectile_energy_domain", + python::overload_cast<>(&Component::projectileEnergyDomain), + Component::documentation("projectile_energy_domain").data() + ) + .def_property_readonly( + "temperature", + python::overload_cast<>(&Component::temperature), + Component::documentation("temperature").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/Flux.python.cpp b/python/src/v2.0/styles/Flux.python.cpp new file mode 100644 index 000000000..b3ae3c56b --- /dev/null +++ b/python/src/v2.0/styles/Flux.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/Flux.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// Flux wrapper +void wrapFlux(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::Flux; + + // create the component + python::class_ component( + module, + "Flux", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const containers::XYs2d & + >(), + python::arg("label"), + python::arg("xys2d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "xys2d", + python::overload_cast<>(&Component::XYs2d), + Component::documentation("xys2d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/GriddedCrossSection.python.cpp b/python/src/v2.0/styles/GriddedCrossSection.python.cpp new file mode 100644 index 000000000..ef820b753 --- /dev/null +++ b/python/src/v2.0/styles/GriddedCrossSection.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/GriddedCrossSection.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// GriddedCrossSection wrapper +void wrapGriddedCrossSection(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::GriddedCrossSection; + + // create the component + python::class_ component( + module, + "GriddedCrossSection", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string &, + const XMLName &, + const XMLName &, + const std::optional &, + const containers::Grid & + >(), + python::arg("date"), + python::arg("derived_from"), + python::arg("label"), + python::arg("documentation") = std::nullopt, + python::arg("grid"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "date", + &Component::date, + Component::documentation("date").data() + ) + .def_property_readonly( + "derived_from", + &Component::derivedFrom, + Component::documentation("derived_from").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "documentation", + python::overload_cast<>(&Component::documentation), + Component::documentation("documentation").data() + ) + .def_property_readonly( + "grid", + python::overload_cast<>(&Component::grid), + Component::documentation("grid").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/Heated.python.cpp b/python/src/v2.0/styles/Heated.python.cpp new file mode 100644 index 000000000..441634058 --- /dev/null +++ b/python/src/v2.0/styles/Heated.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/Heated.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// Heated wrapper +void wrapHeated(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::Heated; + + // create the component + python::class_ component( + module, + "Heated", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string &, + const XMLName &, + const XMLName &, + const std::optional &, + const styles::Temperature & + >(), + python::arg("date"), + python::arg("derived_from"), + python::arg("label"), + python::arg("documentation") = std::nullopt, + python::arg("temperature"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "date", + &Component::date, + Component::documentation("date").data() + ) + .def_property_readonly( + "derived_from", + &Component::derivedFrom, + Component::documentation("derived_from").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "documentation", + python::overload_cast<>(&Component::documentation), + Component::documentation("documentation").data() + ) + .def_property_readonly( + "temperature", + python::overload_cast<>(&Component::temperature), + Component::documentation("temperature").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/HeatedMultiGroup.python.cpp b/python/src/v2.0/styles/HeatedMultiGroup.python.cpp new file mode 100644 index 000000000..697ac825d --- /dev/null +++ b/python/src/v2.0/styles/HeatedMultiGroup.python.cpp @@ -0,0 +1,91 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/HeatedMultiGroup.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// HeatedMultiGroup wrapper +void wrapHeatedMultiGroup(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::HeatedMultiGroup; + + // create the component + python::class_ component( + module, + "HeatedMultiGroup", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string &, + const XMLName &, + const XMLName &, + const styles::Flux &, + const styles::InverseSpeed &, + const styles::Transportables & + >(), + python::arg("date"), + python::arg("derived_from"), + python::arg("label"), + python::arg("flux"), + python::arg("inverse_speed"), + python::arg("transportables"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "date", + &Component::date, + Component::documentation("date").data() + ) + .def_property_readonly( + "derived_from", + &Component::derivedFrom, + Component::documentation("derived_from").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "flux", + python::overload_cast<>(&Component::flux), + Component::documentation("flux").data() + ) + .def_property_readonly( + "inverse_speed", + python::overload_cast<>(&Component::inverseSpeed), + Component::documentation("inverse_speed").data() + ) + .def_property_readonly( + "transportables", + python::overload_cast<>(&Component::transportables), + Component::documentation("transportables").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/InverseSpeed.python.cpp b/python/src/v2.0/styles/InverseSpeed.python.cpp new file mode 100644 index 000000000..7db133cf2 --- /dev/null +++ b/python/src/v2.0/styles/InverseSpeed.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/InverseSpeed.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// InverseSpeed wrapper +void wrapInverseSpeed(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::InverseSpeed; + + // create the component + python::class_ component( + module, + "InverseSpeed", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const containers::Gridded1d & + >(), + python::arg("gridded1d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "gridded1d", + python::overload_cast<>(&Component::gridded1d), + Component::documentation("gridded1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/MonteCarlo_cdf.python.cpp b/python/src/v2.0/styles/MonteCarlo_cdf.python.cpp new file mode 100644 index 000000000..f0703b286 --- /dev/null +++ b/python/src/v2.0/styles/MonteCarlo_cdf.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/MonteCarlo_cdf.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// MonteCarlo_cdf wrapper +void wrapMonteCarlo_cdf(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::MonteCarlo_cdf; + + // create the component + python::class_ component( + module, + "MonteCarlo_cdf", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string &, + const XMLName &, + const XMLName &, + const std::optional & + >(), + python::arg("date"), + python::arg("derived_from"), + python::arg("label"), + python::arg("documentation") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "date", + &Component::date, + Component::documentation("date").data() + ) + .def_property_readonly( + "derived_from", + &Component::derivedFrom, + Component::documentation("derived_from").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "documentation", + python::overload_cast<>(&Component::documentation), + Component::documentation("documentation").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/MultiBand.python.cpp b/python/src/v2.0/styles/MultiBand.python.cpp new file mode 100644 index 000000000..43d105fdc --- /dev/null +++ b/python/src/v2.0/styles/MultiBand.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/MultiBand.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// MultiBand wrapper +void wrapMultiBand(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::MultiBand; + + // create the component + python::class_ component( + module, + "MultiBand", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string &, + const XMLName &, + const XMLName &, + const Integer32 & + >(), + python::arg("date"), + python::arg("derived_from"), + python::arg("label"), + python::arg("number_of_bands"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "date", + &Component::date, + Component::documentation("date").data() + ) + .def_property_readonly( + "derived_from", + &Component::derivedFrom, + Component::documentation("derived_from").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "number_of_bands", + &Component::numberOfBands, + Component::documentation("number_of_bands").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/MultiGroup.python.cpp b/python/src/v2.0/styles/MultiGroup.python.cpp new file mode 100644 index 000000000..e3a092d98 --- /dev/null +++ b/python/src/v2.0/styles/MultiGroup.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/MultiGroup.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// MultiGroup wrapper +void wrapMultiGroup(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::MultiGroup; + + // create the component + python::class_ component( + module, + "MultiGroup", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const containers::Grid & + >(), + python::arg("label"), + python::arg("grid"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "grid", + python::overload_cast<>(&Component::grid), + Component::documentation("grid").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/ProjectileEnergyDomain.python.cpp b/python/src/v2.0/styles/ProjectileEnergyDomain.python.cpp new file mode 100644 index 000000000..c8adcba22 --- /dev/null +++ b/python/src/v2.0/styles/ProjectileEnergyDomain.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/ProjectileEnergyDomain.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// ProjectileEnergyDomain wrapper +void wrapProjectileEnergyDomain(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::ProjectileEnergyDomain; + + // create the component + python::class_ component( + module, + "ProjectileEnergyDomain", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const Float64 &, + const Float64 &, + const XMLName & + >(), + python::arg("max"), + python::arg("min"), + python::arg("unit"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "max", + &Component::max, + Component::documentation("max").data() + ) + .def_property_readonly( + "min", + &Component::min, + Component::documentation("min").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/Realization.python.cpp b/python/src/v2.0/styles/Realization.python.cpp new file mode 100644 index 000000000..10891198d --- /dev/null +++ b/python/src/v2.0/styles/Realization.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/Realization.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// Realization wrapper +void wrapRealization(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::Realization; + + // create the component + python::class_ component( + module, + "Realization", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string &, + const XMLName &, + const XMLName & + >(), + python::arg("date"), + python::arg("derived_from"), + python::arg("label"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "date", + &Component::date, + Component::documentation("date").data() + ) + .def_property_readonly( + "derived_from", + &Component::derivedFrom, + Component::documentation("derived_from").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/SigmaZeros.python.cpp b/python/src/v2.0/styles/SigmaZeros.python.cpp new file mode 100644 index 000000000..6deba6699 --- /dev/null +++ b/python/src/v2.0/styles/SigmaZeros.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/SigmaZeros.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// SigmaZeros wrapper +void wrapSigmaZeros(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::SigmaZeros; + + // create the component + python::class_ component( + module, + "SigmaZeros", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const containers::Values & + >(), + python::arg("values"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "values", + python::overload_cast<>(&Component::values), + Component::documentation("values").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/SnElasticUpScatter.python.cpp b/python/src/v2.0/styles/SnElasticUpScatter.python.cpp new file mode 100644 index 000000000..a83a391d1 --- /dev/null +++ b/python/src/v2.0/styles/SnElasticUpScatter.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/SnElasticUpScatter.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// SnElasticUpScatter wrapper +void wrapSnElasticUpScatter(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::SnElasticUpScatter; + + // create the component + python::class_ component( + module, + "SnElasticUpScatter", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string &, + const XMLName &, + const XMLName &, + const std::optional & + >(), + python::arg("date"), + python::arg("derived_from"), + python::arg("label"), + python::arg("upper_calculated_group") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "date", + &Component::date, + Component::documentation("date").data() + ) + .def_property_readonly( + "derived_from", + &Component::derivedFrom, + Component::documentation("derived_from").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "upper_calculated_group", + &Component::upperCalculatedGroup, + Component::documentation("upper_calculated_group").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/Styles.python.cpp b/python/src/v2.0/styles/Styles.python.cpp new file mode 100644 index 000000000..5ff95939e --- /dev/null +++ b/python/src/v2.0/styles/Styles.python.cpp @@ -0,0 +1,119 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/Styles.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// Styles wrapper +void wrapStyles(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::Styles; + + // create the component + python::class_ component( + module, + "Styles", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional> &, + const std::optional> &, + const std::optional> &, + const std::optional> &, + const std::optional> &, + const std::optional> &, + const std::optional> &, + const std::optional> &, + const std::optional> &, + const std::optional> & + >(), + python::arg("monte_carlo_cdf") = std::nullopt, + python::arg("sn_elastic_up_scatter") = std::nullopt, + python::arg("urr_probability_tables") = std::nullopt, + python::arg("angular_distribution_reconstructed") = std::nullopt, + python::arg("average_product_data") = std::nullopt, + python::arg("cross_section_reconstructed") = std::nullopt, + python::arg("evaluated") = std::nullopt, + python::arg("gridded_cross_section") = std::nullopt, + python::arg("heated") = std::nullopt, + python::arg("heated_multi_group") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "monte_carlo_cdf", + python::overload_cast<>(&Component::MonteCarlo_cdf), + Component::documentation("monte_carlo_cdf").data() + ) + .def_property_readonly( + "sn_elastic_up_scatter", + python::overload_cast<>(&Component::SnElasticUpScatter), + Component::documentation("sn_elastic_up_scatter").data() + ) + .def_property_readonly( + "urr_probability_tables", + python::overload_cast<>(&Component::URR_probabilityTables), + Component::documentation("urr_probability_tables").data() + ) + .def_property_readonly( + "angular_distribution_reconstructed", + python::overload_cast<>(&Component::angularDistributionReconstructed), + Component::documentation("angular_distribution_reconstructed").data() + ) + .def_property_readonly( + "average_product_data", + python::overload_cast<>(&Component::averageProductData), + Component::documentation("average_product_data").data() + ) + .def_property_readonly( + "cross_section_reconstructed", + python::overload_cast<>(&Component::crossSectionReconstructed), + Component::documentation("cross_section_reconstructed").data() + ) + .def_property_readonly( + "evaluated", + python::overload_cast<>(&Component::evaluated), + Component::documentation("evaluated").data() + ) + .def_property_readonly( + "gridded_cross_section", + python::overload_cast<>(&Component::griddedCrossSection), + Component::documentation("gridded_cross_section").data() + ) + .def_property_readonly( + "heated", + python::overload_cast<>(&Component::heated), + Component::documentation("heated").data() + ) + .def_property_readonly( + "heated_multi_group", + python::overload_cast<>(&Component::heatedMultiGroup), + Component::documentation("heated_multi_group").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/Temperature.python.cpp b/python/src/v2.0/styles/Temperature.python.cpp new file mode 100644 index 000000000..06a717973 --- /dev/null +++ b/python/src/v2.0/styles/Temperature.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/Temperature.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// Temperature wrapper +void wrapTemperature(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::Temperature; + + // create the component + python::class_ component( + module, + "Temperature", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const Float64 & + >(), + python::arg("unit"), + python::arg("value"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/Transportable.python.cpp b/python/src/v2.0/styles/Transportable.python.cpp new file mode 100644 index 000000000..24207c559 --- /dev/null +++ b/python/src/v2.0/styles/Transportable.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/Transportable.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// Transportable wrapper +void wrapTransportable(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::Transportable; + + // create the component + python::class_ component( + module, + "Transportable", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const XMLName &, + const styles::MultiGroup & + >(), + python::arg("conserve") = std::nullopt, + python::arg("label"), + python::arg("multi_group"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "conserve", + [](const Component &self) { return self.conserve().value(); }, + Component::documentation("conserve").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "multi_group", + python::overload_cast<>(&Component::multiGroup), + Component::documentation("multi_group").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/Transportables.python.cpp b/python/src/v2.0/styles/Transportables.python.cpp new file mode 100644 index 000000000..931542f2d --- /dev/null +++ b/python/src/v2.0/styles/Transportables.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/Transportables.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// Transportables wrapper +void wrapTransportables(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::Transportables; + + // create the component + python::class_ component( + module, + "Transportables", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("transportable"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "transportable", + python::overload_cast<>(&Component::transportable), + Component::documentation("transportable").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/styles/URR_probabilityTables.python.cpp b/python/src/v2.0/styles/URR_probabilityTables.python.cpp new file mode 100644 index 000000000..8a5dd6701 --- /dev/null +++ b/python/src/v2.0/styles/URR_probabilityTables.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/styles/URR_probabilityTables.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_styles { + +// URR_probabilityTables wrapper +void wrapURR_probabilityTables(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = styles::URR_probabilityTables; + + // create the component + python::class_ component( + module, + "URR_probabilityTables", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string &, + const XMLName &, + const XMLName & + >(), + python::arg("date"), + python::arg("derived_from"), + python::arg("label"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "date", + &Component::date, + Component::documentation("date").data() + ) + .def_property_readonly( + "derived_from", + &Component::derivedFrom, + Component::documentation("derived_from").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_styles +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport.python.cpp b/python/src/v2.0/transport.python.cpp new file mode 100644 index 000000000..53bade5a8 --- /dev/null +++ b/python/src/v2.0/transport.python.cpp @@ -0,0 +1,145 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include +#include + +namespace python = pybind11; + +// v2.0 interface +namespace python_v2_0 { + +// transport declarations +namespace python_transport { + void wrapURR_probabilityTables1d(python::module &); + void wrapReference(python::module &); + void wrapFastRegion(python::module &); + void wrapResolvedRegion(python::module &); + void wrapUnresolvedRegion(python::module &); + void wrapBackground(python::module &); + void wrapResonances(python::module &); + void wrapResonancesWithBackground(python::module &); + void wrapCrossSection(python::module &); + void wrapA(python::module &); + void wrapF(python::module &); + void wrapR(python::module &); + void wrapKalbachMann(python::module &); + void wrapAngularEnergy(python::module &); + void wrapForward(python::module &); + void wrapIsotropic2d(python::module &); + void wrapAngular(python::module &); + void wrapRecoil(python::module &); + void wrapAngularTwoBody(python::module &); + void wrapBranching3d(python::module &); + void wrapEnergyAngular(python::module &); + void wrapNBodyPhaseSpace(python::module &); + void wrapU(python::module &); + void wrapDiscreteGamma(python::module &); + void wrapTheta(python::module &); + void wrapEvaporation(python::module &); + void wrapG(python::module &); + void wrapGeneralEvaporation(python::module &); + void wrapPrimaryGamma(python::module &); + void wrapWeighted(python::module &); + void wrapWeightedFunctionals(python::module &); + void wrapEnergy(python::module &); + void wrapUncorrelated(python::module &); + void wrapUnspecified(python::module &); + void wrapDistribution(python::module &); + void wrapBranching1d(python::module &); + void wrapMultiplicity(python::module &); + void wrapOutputChannel(python::module &); + void wrapAdd(python::module &); + void wrapCoherentPhoton(python::module &); + void wrapSummands(python::module &); + void wrapCrossSectionSum(python::module &); + void wrapCrossSectionSums(python::module &); + void wrapDoubleDifferentialCrossSection(python::module &); + void wrapIncoherentPhoton(python::module &); + void wrapReaction(python::module &); + void wrapIncompleteReactions(python::module &); + void wrapScatteringMatrix(python::module &); + void wrapMultiplicitySum(python::module &); + void wrapMultiplicitySums(python::module &); + void wrapOrphanProduct(python::module &); + void wrapOrphanProducts(python::module &); + void wrapPhotonEmissionProbabilities(python::module &); + void wrapProduction(python::module &); + void wrapProductions(python::module &); + void wrapReactions(python::module &); + void wrapSums(python::module &); + void wrapReactionSuite(python::module &); +} // namespace python_transport + +// transport wrapper +void wrapTransport(python::module &module) +{ + // create the transport submodule + python::module submodule = module.def_submodule( + "transport", + "GNDS v2.0 transport" + ); + + // wrap transport components + python_transport::wrapURR_probabilityTables1d(submodule); + python_transport::wrapReference(submodule); + python_transport::wrapFastRegion(submodule); + python_transport::wrapResolvedRegion(submodule); + python_transport::wrapUnresolvedRegion(submodule); + python_transport::wrapBackground(submodule); + python_transport::wrapResonances(submodule); + python_transport::wrapResonancesWithBackground(submodule); + python_transport::wrapCrossSection(submodule); + python_transport::wrapA(submodule); + python_transport::wrapF(submodule); + python_transport::wrapR(submodule); + python_transport::wrapKalbachMann(submodule); + python_transport::wrapAngularEnergy(submodule); + python_transport::wrapForward(submodule); + python_transport::wrapIsotropic2d(submodule); + python_transport::wrapAngular(submodule); + python_transport::wrapRecoil(submodule); + python_transport::wrapAngularTwoBody(submodule); + python_transport::wrapBranching3d(submodule); + python_transport::wrapEnergyAngular(submodule); + python_transport::wrapNBodyPhaseSpace(submodule); + python_transport::wrapU(submodule); + python_transport::wrapDiscreteGamma(submodule); + python_transport::wrapTheta(submodule); + python_transport::wrapEvaporation(submodule); + python_transport::wrapG(submodule); + python_transport::wrapGeneralEvaporation(submodule); + python_transport::wrapPrimaryGamma(submodule); + python_transport::wrapWeighted(submodule); + python_transport::wrapWeightedFunctionals(submodule); + python_transport::wrapEnergy(submodule); + python_transport::wrapUncorrelated(submodule); + python_transport::wrapUnspecified(submodule); + python_transport::wrapDistribution(submodule); + python_transport::wrapBranching1d(submodule); + python_transport::wrapMultiplicity(submodule); + python_transport::wrapOutputChannel(submodule); + python_transport::wrapAdd(submodule); + python_transport::wrapCoherentPhoton(submodule); + python_transport::wrapSummands(submodule); + python_transport::wrapCrossSectionSum(submodule); + python_transport::wrapCrossSectionSums(submodule); + python_transport::wrapDoubleDifferentialCrossSection(submodule); + python_transport::wrapIncoherentPhoton(submodule); + python_transport::wrapReaction(submodule); + python_transport::wrapIncompleteReactions(submodule); + python_transport::wrapScatteringMatrix(submodule); + python_transport::wrapMultiplicitySum(submodule); + python_transport::wrapMultiplicitySums(submodule); + python_transport::wrapOrphanProduct(submodule); + python_transport::wrapOrphanProducts(submodule); + python_transport::wrapPhotonEmissionProbabilities(submodule); + python_transport::wrapProduction(submodule); + python_transport::wrapProductions(submodule); + python_transport::wrapReactions(submodule); + python_transport::wrapSums(submodule); + python_transport::wrapReactionSuite(submodule); +}; + +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/A.python.cpp b/python/src/v2.0/transport/A.python.cpp new file mode 100644 index 000000000..60c61bd74 --- /dev/null +++ b/python/src/v2.0/transport/A.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/A.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// A wrapper +void wrapA(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::A; + using _t = std::variant< + containers::XYs2d, + containers::Regions2d + >; + + // create the component + python::class_ component( + module, + "A", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const _t & + >(), + python::arg("_xys2dregions2d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys2d", + python::overload_cast<>(&Component::XYs2d), + Component::documentation("xys2d").data() + ) + .def_property_readonly( + "regions2d", + python::overload_cast<>(&Component::regions2d), + Component::documentation("regions2d").data() + ) + .def_property_readonly( + "_xys2dregions2d", + python::overload_cast<>(&Component::_XYs2dregions2d), + Component::documentation("_xys2dregions2d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Add.python.cpp b/python/src/v2.0/transport/Add.python.cpp new file mode 100644 index 000000000..1623dff81 --- /dev/null +++ b/python/src/v2.0/transport/Add.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Add.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Add wrapper +void wrapAdd(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Add; + + // create the component + python::class_ component( + module, + "Add", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("href") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Angular.python.cpp b/python/src/v2.0/transport/Angular.python.cpp new file mode 100644 index 000000000..07e7e8343 --- /dev/null +++ b/python/src/v2.0/transport/Angular.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Angular.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Angular wrapper +void wrapAngular(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Angular; + + // create the component + python::class_ component( + module, + "Angular", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("xys2d") = std::nullopt, + python::arg("forward") = std::nullopt, + python::arg("isotropic2d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys2d", + python::overload_cast<>(&Component::XYs2d), + Component::documentation("xys2d").data() + ) + .def_property_readonly( + "forward", + python::overload_cast<>(&Component::forward), + Component::documentation("forward").data() + ) + .def_property_readonly( + "isotropic2d", + python::overload_cast<>(&Component::isotropic2d), + Component::documentation("isotropic2d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/AngularEnergy.python.cpp b/python/src/v2.0/transport/AngularEnergy.python.cpp new file mode 100644 index 000000000..f1da46bc8 --- /dev/null +++ b/python/src/v2.0/transport/AngularEnergy.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/AngularEnergy.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// AngularEnergy wrapper +void wrapAngularEnergy(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::AngularEnergy; + + // create the component + python::class_ component( + module, + "AngularEnergy", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const XMLName &, + const containers::XYs3d & + >(), + python::arg("label"), + python::arg("product_frame"), + python::arg("xys3d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "product_frame", + &Component::productFrame, + Component::documentation("product_frame").data() + ) + .def_property_readonly( + "xys3d", + python::overload_cast<>(&Component::XYs3d), + Component::documentation("xys3d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/AngularTwoBody.python.cpp b/python/src/v2.0/transport/AngularTwoBody.python.cpp new file mode 100644 index 000000000..e09c8cb35 --- /dev/null +++ b/python/src/v2.0/transport/AngularTwoBody.python.cpp @@ -0,0 +1,91 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/AngularTwoBody.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// AngularTwoBody wrapper +void wrapAngularTwoBody(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::AngularTwoBody; + + // create the component + python::class_ component( + module, + "AngularTwoBody", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const XMLName &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("label") = std::nullopt, + python::arg("product_frame"), + python::arg("xys2d") = std::nullopt, + python::arg("isotropic2d") = std::nullopt, + python::arg("recoil") = std::nullopt, + python::arg("regions2d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "product_frame", + &Component::productFrame, + Component::documentation("product_frame").data() + ) + .def_property_readonly( + "xys2d", + python::overload_cast<>(&Component::XYs2d), + Component::documentation("xys2d").data() + ) + .def_property_readonly( + "isotropic2d", + python::overload_cast<>(&Component::isotropic2d), + Component::documentation("isotropic2d").data() + ) + .def_property_readonly( + "recoil", + python::overload_cast<>(&Component::recoil), + Component::documentation("recoil").data() + ) + .def_property_readonly( + "regions2d", + python::overload_cast<>(&Component::regions2d), + Component::documentation("regions2d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Background.python.cpp b/python/src/v2.0/transport/Background.python.cpp new file mode 100644 index 000000000..2ab924517 --- /dev/null +++ b/python/src/v2.0/transport/Background.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Background.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Background wrapper +void wrapBackground(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Background; + + // create the component + python::class_ component( + module, + "Background", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("fast_region") = std::nullopt, + python::arg("resolved_region") = std::nullopt, + python::arg("unresolved_region") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "fast_region", + python::overload_cast<>(&Component::fastRegion), + Component::documentation("fast_region").data() + ) + .def_property_readonly( + "resolved_region", + python::overload_cast<>(&Component::resolvedRegion), + Component::documentation("resolved_region").data() + ) + .def_property_readonly( + "unresolved_region", + python::overload_cast<>(&Component::unresolvedRegion), + Component::documentation("unresolved_region").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Branching1d.python.cpp b/python/src/v2.0/transport/Branching1d.python.cpp new file mode 100644 index 000000000..f3c25b174 --- /dev/null +++ b/python/src/v2.0/transport/Branching1d.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Branching1d.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Branching1d wrapper +void wrapBranching1d(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Branching1d; + + // create the component + python::class_ component( + module, + "Branching1d", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName & + >(), + python::arg("label"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Branching3d.python.cpp b/python/src/v2.0/transport/Branching3d.python.cpp new file mode 100644 index 000000000..eefec1d26 --- /dev/null +++ b/python/src/v2.0/transport/Branching3d.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Branching3d.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Branching3d wrapper +void wrapBranching3d(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Branching3d; + + // create the component + python::class_ component( + module, + "Branching3d", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const XMLName & + >(), + python::arg("label"), + python::arg("product_frame"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "product_frame", + &Component::productFrame, + Component::documentation("product_frame").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/CoherentPhoton.python.cpp b/python/src/v2.0/transport/CoherentPhoton.python.cpp new file mode 100644 index 000000000..85f4f8cd0 --- /dev/null +++ b/python/src/v2.0/transport/CoherentPhoton.python.cpp @@ -0,0 +1,49 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/CoherentPhoton.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// CoherentPhoton wrapper +void wrapCoherentPhoton(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::CoherentPhoton; + + // create the component + python::class_ component( + module, + "CoherentPhoton", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + >(), + Component::documentation("constructor").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/CrossSection.python.cpp b/python/src/v2.0/transport/CrossSection.python.cpp new file mode 100644 index 000000000..5e615e550 --- /dev/null +++ b/python/src/v2.0/transport/CrossSection.python.cpp @@ -0,0 +1,112 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/CrossSection.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// CrossSection wrapper +void wrapCrossSection(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::CrossSection; + using _t = std::variant< + cpTransport::CoulombPlusNuclearElastic, + transport::URR_probabilityTables1d, + containers::XYs1d, + containers::Ys1d, + containers::Gridded1d, + transport::Reference, + containers::Regions1d, + transport::ResonancesWithBackground, + tsl::ThermalNeutronScatteringLaw1d + >; + + // create the component + python::class_ component( + module, + "CrossSection", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const _t & + >(), + python::arg("_coulomb_plus_nuclear_elastic_urr_probability_tables1d_xys1d_ys1dgridded1dreferenceregions1dresonances_with_backgroundthermal_neutron_scattering_law1d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "coulomb_plus_nuclear_elastic", + python::overload_cast<>(&Component::CoulombPlusNuclearElastic), + Component::documentation("coulomb_plus_nuclear_elastic").data() + ) + .def_property_readonly( + "urr_probability_tables1d", + python::overload_cast<>(&Component::URR_probabilityTables1d), + Component::documentation("urr_probability_tables1d").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "ys1d", + python::overload_cast<>(&Component::Ys1d), + Component::documentation("ys1d").data() + ) + .def_property_readonly( + "gridded1d", + python::overload_cast<>(&Component::gridded1d), + Component::documentation("gridded1d").data() + ) + .def_property_readonly( + "reference", + python::overload_cast<>(&Component::reference), + Component::documentation("reference").data() + ) + .def_property_readonly( + "regions1d", + python::overload_cast<>(&Component::regions1d), + Component::documentation("regions1d").data() + ) + .def_property_readonly( + "resonances_with_background", + python::overload_cast<>(&Component::resonancesWithBackground), + Component::documentation("resonances_with_background").data() + ) + .def_property_readonly( + "thermal_neutron_scattering_law1d", + python::overload_cast<>(&Component::thermalNeutronScatteringLaw1d), + Component::documentation("thermal_neutron_scattering_law1d").data() + ) + .def_property_readonly( + "_coulomb_plus_nuclear_elastic_urr_probability_tables1d_xys1d_ys1dgridded1dreferenceregions1dresonances_with_backgroundthermal_neutron_scattering_law1d", + python::overload_cast<>(&Component::_CoulombPlusNuclearElasticURR_probabilityTables1dXYs1dYs1dgridded1dreferenceregions1dresonancesWithBackgroundthermalNeutronScatteringLaw1d), + Component::documentation("_coulomb_plus_nuclear_elastic_urr_probability_tables1d_xys1d_ys1dgridded1dreferenceregions1dresonances_with_backgroundthermal_neutron_scattering_law1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/CrossSectionSum.python.cpp b/python/src/v2.0/transport/CrossSectionSum.python.cpp new file mode 100644 index 000000000..9c854ce01 --- /dev/null +++ b/python/src/v2.0/transport/CrossSectionSum.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/CrossSectionSum.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// CrossSectionSum wrapper +void wrapCrossSectionSum(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::CrossSectionSum; + + // create the component + python::class_ component( + module, + "CrossSectionSum", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const XMLName &, + const ambiguousNamespace::Q &, + const transport::CrossSection &, + const transport::Summands & + >(), + python::arg("endf_mt") = std::nullopt, + python::arg("label"), + python::arg("q"), + python::arg("cross_section"), + python::arg("summands"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "endf_mt", + &Component::ENDF_MT, + Component::documentation("endf_mt").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "q", + python::overload_cast<>(&Component::Q), + Component::documentation("q").data() + ) + .def_property_readonly( + "cross_section", + python::overload_cast<>(&Component::crossSection), + Component::documentation("cross_section").data() + ) + .def_property_readonly( + "summands", + python::overload_cast<>(&Component::summands), + Component::documentation("summands").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/CrossSectionSums.python.cpp b/python/src/v2.0/transport/CrossSectionSums.python.cpp new file mode 100644 index 000000000..e531b6ed3 --- /dev/null +++ b/python/src/v2.0/transport/CrossSectionSums.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/CrossSectionSums.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// CrossSectionSums wrapper +void wrapCrossSectionSums(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::CrossSectionSums; + + // create the component + python::class_ component( + module, + "CrossSectionSums", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional> & + >(), + python::arg("cross_section_sum") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "cross_section_sum", + python::overload_cast<>(&Component::crossSectionSum), + Component::documentation("cross_section_sum").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/DiscreteGamma.python.cpp b/python/src/v2.0/transport/DiscreteGamma.python.cpp new file mode 100644 index 000000000..145f3b5f1 --- /dev/null +++ b/python/src/v2.0/transport/DiscreteGamma.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/DiscreteGamma.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// DiscreteGamma wrapper +void wrapDiscreteGamma(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::DiscreteGamma; + + // create the component + python::class_ component( + module, + "DiscreteGamma", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("domain_max") = std::nullopt, + python::arg("domain_min") = std::nullopt, + python::arg("value") = std::nullopt, + python::arg("axes") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "domain_max", + &Component::domainMax, + Component::documentation("domain_max").data() + ) + .def_property_readonly( + "domain_min", + &Component::domainMin, + Component::documentation("domain_min").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + .def_property_readonly( + "axes", + python::overload_cast<>(&Component::axes), + Component::documentation("axes").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Distribution.python.cpp b/python/src/v2.0/transport/Distribution.python.cpp new file mode 100644 index 000000000..83219eb78 --- /dev/null +++ b/python/src/v2.0/transport/Distribution.python.cpp @@ -0,0 +1,148 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Distribution.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Distribution wrapper +void wrapDistribution(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Distribution; + using _t = std::variant< + cpTransport::CoulombPlusNuclearElastic, + transport::KalbachMann, + transport::AngularEnergy, + processed::AngularEnergyMC, + transport::AngularTwoBody, + transport::Branching3d, + atomic::CoherentPhotonScattering, + transport::EnergyAngular, + processed::EnergyAngularMC, + atomic::IncoherentPhotonScattering, + processed::MultiGroup3d, + transport::Reference, + tsl::ThermalNeutronScatteringLaw, + transport::Uncorrelated, + transport::Unspecified + >; + + // create the component + python::class_ component( + module, + "Distribution", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const _t & + >(), + python::arg("_coulomb_plus_nuclear_elastic_kalbach_mannangular_energyangular_energy_mcangular_two_bodybranching3dcoherent_photon_scatteringenergy_angularenergy_angular_mcincoherent_photon_scatteringmulti_group3dreferencethermal_neutron_scattering_lawuncorrelatedunspecified"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "coulomb_plus_nuclear_elastic", + python::overload_cast<>(&Component::CoulombPlusNuclearElastic), + Component::documentation("coulomb_plus_nuclear_elastic").data() + ) + .def_property_readonly( + "kalbach_mann", + python::overload_cast<>(&Component::KalbachMann), + Component::documentation("kalbach_mann").data() + ) + .def_property_readonly( + "angular_energy", + python::overload_cast<>(&Component::angularEnergy), + Component::documentation("angular_energy").data() + ) + .def_property_readonly( + "angular_energy_mc", + python::overload_cast<>(&Component::angularEnergyMC), + Component::documentation("angular_energy_mc").data() + ) + .def_property_readonly( + "angular_two_body", + python::overload_cast<>(&Component::angularTwoBody), + Component::documentation("angular_two_body").data() + ) + .def_property_readonly( + "branching3d", + python::overload_cast<>(&Component::branching3d), + Component::documentation("branching3d").data() + ) + .def_property_readonly( + "coherent_photon_scattering", + python::overload_cast<>(&Component::coherentPhotonScattering), + Component::documentation("coherent_photon_scattering").data() + ) + .def_property_readonly( + "energy_angular", + python::overload_cast<>(&Component::energyAngular), + Component::documentation("energy_angular").data() + ) + .def_property_readonly( + "energy_angular_mc", + python::overload_cast<>(&Component::energyAngularMC), + Component::documentation("energy_angular_mc").data() + ) + .def_property_readonly( + "incoherent_photon_scattering", + python::overload_cast<>(&Component::incoherentPhotonScattering), + Component::documentation("incoherent_photon_scattering").data() + ) + .def_property_readonly( + "multi_group3d", + python::overload_cast<>(&Component::multiGroup3d), + Component::documentation("multi_group3d").data() + ) + .def_property_readonly( + "reference", + python::overload_cast<>(&Component::reference), + Component::documentation("reference").data() + ) + .def_property_readonly( + "thermal_neutron_scattering_law", + python::overload_cast<>(&Component::thermalNeutronScatteringLaw), + Component::documentation("thermal_neutron_scattering_law").data() + ) + .def_property_readonly( + "uncorrelated", + python::overload_cast<>(&Component::uncorrelated), + Component::documentation("uncorrelated").data() + ) + .def_property_readonly( + "unspecified", + python::overload_cast<>(&Component::unspecified), + Component::documentation("unspecified").data() + ) + .def_property_readonly( + "_coulomb_plus_nuclear_elastic_kalbach_mannangular_energyangular_energy_mcangular_two_bodybranching3dcoherent_photon_scatteringenergy_angularenergy_angular_mcincoherent_photon_scatteringmulti_group3dreferencethermal_neutron_scattering_lawuncorrelatedunspecified", + python::overload_cast<>(&Component::_CoulombPlusNuclearElasticKalbachMannangularEnergyangularEnergyMCangularTwoBodybranching3dcoherentPhotonScatteringenergyAngularenergyAngularMCincoherentPhotonScatteringmultiGroup3dreferencethermalNeutronScatteringLawuncorrelatedunspecified), + Component::documentation("_coulomb_plus_nuclear_elastic_kalbach_mannangular_energyangular_energy_mcangular_two_bodybranching3dcoherent_photon_scatteringenergy_angularenergy_angular_mcincoherent_photon_scatteringmulti_group3dreferencethermal_neutron_scattering_lawuncorrelatedunspecified").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/DoubleDifferentialCrossSection.python.cpp b/python/src/v2.0/transport/DoubleDifferentialCrossSection.python.cpp new file mode 100644 index 000000000..8681a6a4b --- /dev/null +++ b/python/src/v2.0/transport/DoubleDifferentialCrossSection.python.cpp @@ -0,0 +1,112 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/DoubleDifferentialCrossSection.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// DoubleDifferentialCrossSection wrapper +void wrapDoubleDifferentialCrossSection(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::DoubleDifferentialCrossSection; + + // create the component + python::class_ component( + module, + "DoubleDifferentialCrossSection", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("coulomb_plus_nuclear_elastic") = std::nullopt, + python::arg("xys3d") = std::nullopt, + python::arg("coherent_photon_scattering") = std::nullopt, + python::arg("incoherent_photon_scattering") = std::nullopt, + python::arg("reference") = std::nullopt, + python::arg("regions3d") = std::nullopt, + python::arg("thermal_neutron_scattering_law_coherent_elastic") = std::nullopt, + python::arg("thermal_neutron_scattering_law_incoherent_elastic") = std::nullopt, + python::arg("thermal_neutron_scattering_law_incoherent_inelastic") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "coulomb_plus_nuclear_elastic", + python::overload_cast<>(&Component::CoulombPlusNuclearElastic), + Component::documentation("coulomb_plus_nuclear_elastic").data() + ) + .def_property_readonly( + "xys3d", + python::overload_cast<>(&Component::XYs3d), + Component::documentation("xys3d").data() + ) + .def_property_readonly( + "coherent_photon_scattering", + python::overload_cast<>(&Component::coherentPhotonScattering), + Component::documentation("coherent_photon_scattering").data() + ) + .def_property_readonly( + "incoherent_photon_scattering", + python::overload_cast<>(&Component::incoherentPhotonScattering), + Component::documentation("incoherent_photon_scattering").data() + ) + .def_property_readonly( + "reference", + python::overload_cast<>(&Component::reference), + Component::documentation("reference").data() + ) + .def_property_readonly( + "regions3d", + python::overload_cast<>(&Component::regions3d), + Component::documentation("regions3d").data() + ) + .def_property_readonly( + "thermal_neutron_scattering_law_coherent_elastic", + python::overload_cast<>(&Component::thermalNeutronScatteringLaw_coherentElastic), + Component::documentation("thermal_neutron_scattering_law_coherent_elastic").data() + ) + .def_property_readonly( + "thermal_neutron_scattering_law_incoherent_elastic", + python::overload_cast<>(&Component::thermalNeutronScatteringLaw_incoherentElastic), + Component::documentation("thermal_neutron_scattering_law_incoherent_elastic").data() + ) + .def_property_readonly( + "thermal_neutron_scattering_law_incoherent_inelastic", + python::overload_cast<>(&Component::thermalNeutronScatteringLaw_incoherentInelastic), + Component::documentation("thermal_neutron_scattering_law_incoherent_inelastic").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Energy.python.cpp b/python/src/v2.0/transport/Energy.python.cpp new file mode 100644 index 000000000..09b70c1fb --- /dev/null +++ b/python/src/v2.0/transport/Energy.python.cpp @@ -0,0 +1,126 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Energy.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Energy wrapper +void wrapEnergy(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Energy; + + // create the component + python::class_ component( + module, + "Energy", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("madland_nix") = std::nullopt, + python::arg("nbody_phase_space") = std::nullopt, + python::arg("watt") = std::nullopt, + python::arg("xys2d") = std::nullopt, + python::arg("discrete_gamma") = std::nullopt, + python::arg("evaporation") = std::nullopt, + python::arg("general_evaporation") = std::nullopt, + python::arg("primary_gamma") = std::nullopt, + python::arg("regions2d") = std::nullopt, + python::arg("simple_maxwellian_fission") = std::nullopt, + python::arg("weighted_functionals") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "madland_nix", + python::overload_cast<>(&Component::MadlandNix), + Component::documentation("madland_nix").data() + ) + .def_property_readonly( + "nbody_phase_space", + python::overload_cast<>(&Component::NBodyPhaseSpace), + Component::documentation("nbody_phase_space").data() + ) + .def_property_readonly( + "watt", + python::overload_cast<>(&Component::Watt), + Component::documentation("watt").data() + ) + .def_property_readonly( + "xys2d", + python::overload_cast<>(&Component::XYs2d), + Component::documentation("xys2d").data() + ) + .def_property_readonly( + "discrete_gamma", + python::overload_cast<>(&Component::discreteGamma), + Component::documentation("discrete_gamma").data() + ) + .def_property_readonly( + "evaporation", + python::overload_cast<>(&Component::evaporation), + Component::documentation("evaporation").data() + ) + .def_property_readonly( + "general_evaporation", + python::overload_cast<>(&Component::generalEvaporation), + Component::documentation("general_evaporation").data() + ) + .def_property_readonly( + "primary_gamma", + python::overload_cast<>(&Component::primaryGamma), + Component::documentation("primary_gamma").data() + ) + .def_property_readonly( + "regions2d", + python::overload_cast<>(&Component::regions2d), + Component::documentation("regions2d").data() + ) + .def_property_readonly( + "simple_maxwellian_fission", + python::overload_cast<>(&Component::simpleMaxwellianFission), + Component::documentation("simple_maxwellian_fission").data() + ) + .def_property_readonly( + "weighted_functionals", + python::overload_cast<>(&Component::weightedFunctionals), + Component::documentation("weighted_functionals").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/EnergyAngular.python.cpp b/python/src/v2.0/transport/EnergyAngular.python.cpp new file mode 100644 index 000000000..d2aa88a20 --- /dev/null +++ b/python/src/v2.0/transport/EnergyAngular.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/EnergyAngular.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// EnergyAngular wrapper +void wrapEnergyAngular(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::EnergyAngular; + + // create the component + python::class_ component( + module, + "EnergyAngular", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const XMLName &, + const containers::XYs3d & + >(), + python::arg("label") = std::nullopt, + python::arg("product_frame"), + python::arg("xys3d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "product_frame", + &Component::productFrame, + Component::documentation("product_frame").data() + ) + .def_property_readonly( + "xys3d", + python::overload_cast<>(&Component::XYs3d), + Component::documentation("xys3d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Evaporation.python.cpp b/python/src/v2.0/transport/Evaporation.python.cpp new file mode 100644 index 000000000..605387707 --- /dev/null +++ b/python/src/v2.0/transport/Evaporation.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Evaporation.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Evaporation wrapper +void wrapEvaporation(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Evaporation; + + // create the component + python::class_ component( + module, + "Evaporation", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("u") = std::nullopt, + python::arg("theta") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "u", + python::overload_cast<>(&Component::U), + Component::documentation("u").data() + ) + .def_property_readonly( + "theta", + python::overload_cast<>(&Component::theta), + Component::documentation("theta").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/F.python.cpp b/python/src/v2.0/transport/F.python.cpp new file mode 100644 index 000000000..6307bdef5 --- /dev/null +++ b/python/src/v2.0/transport/F.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/F.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// F wrapper +void wrapF(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::F; + using _t = std::variant< + containers::XYs2d, + containers::Regions2d + >; + + // create the component + python::class_ component( + module, + "F", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const _t & + >(), + python::arg("_xys2dregions2d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys2d", + python::overload_cast<>(&Component::XYs2d), + Component::documentation("xys2d").data() + ) + .def_property_readonly( + "regions2d", + python::overload_cast<>(&Component::regions2d), + Component::documentation("regions2d").data() + ) + .def_property_readonly( + "_xys2dregions2d", + python::overload_cast<>(&Component::_XYs2dregions2d), + Component::documentation("_xys2dregions2d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/FastRegion.python.cpp b/python/src/v2.0/transport/FastRegion.python.cpp new file mode 100644 index 000000000..52f50bfe5 --- /dev/null +++ b/python/src/v2.0/transport/FastRegion.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/FastRegion.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// FastRegion wrapper +void wrapFastRegion(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::FastRegion; + using _t = std::variant< + containers::XYs1d, + containers::Regions1d + >; + + // create the component + python::class_ component( + module, + "FastRegion", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const _t & + >(), + python::arg("_xys1dregions1d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "regions1d", + python::overload_cast<>(&Component::regions1d), + Component::documentation("regions1d").data() + ) + .def_property_readonly( + "_xys1dregions1d", + python::overload_cast<>(&Component::_XYs1dregions1d), + Component::documentation("_xys1dregions1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Forward.python.cpp b/python/src/v2.0/transport/Forward.python.cpp new file mode 100644 index 000000000..cba675358 --- /dev/null +++ b/python/src/v2.0/transport/Forward.python.cpp @@ -0,0 +1,49 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Forward.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Forward wrapper +void wrapForward(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Forward; + + // create the component + python::class_ component( + module, + "Forward", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + >(), + Component::documentation("constructor").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/G.python.cpp b/python/src/v2.0/transport/G.python.cpp new file mode 100644 index 000000000..f01d26ee9 --- /dev/null +++ b/python/src/v2.0/transport/G.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/G.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// G wrapper +void wrapG(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::G; + + // create the component + python::class_ component( + module, + "G", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("xys1d") = std::nullopt, + python::arg("regions1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "regions1d", + python::overload_cast<>(&Component::regions1d), + Component::documentation("regions1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/GeneralEvaporation.python.cpp b/python/src/v2.0/transport/GeneralEvaporation.python.cpp new file mode 100644 index 000000000..001e45abe --- /dev/null +++ b/python/src/v2.0/transport/GeneralEvaporation.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/GeneralEvaporation.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// GeneralEvaporation wrapper +void wrapGeneralEvaporation(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::GeneralEvaporation; + + // create the component + python::class_ component( + module, + "GeneralEvaporation", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("u") = std::nullopt, + python::arg("g") = std::nullopt, + python::arg("theta") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "u", + python::overload_cast<>(&Component::U), + Component::documentation("u").data() + ) + .def_property_readonly( + "g", + python::overload_cast<>(&Component::g), + Component::documentation("g").data() + ) + .def_property_readonly( + "theta", + python::overload_cast<>(&Component::theta), + Component::documentation("theta").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/IncoherentPhoton.python.cpp b/python/src/v2.0/transport/IncoherentPhoton.python.cpp new file mode 100644 index 000000000..3c34ab939 --- /dev/null +++ b/python/src/v2.0/transport/IncoherentPhoton.python.cpp @@ -0,0 +1,49 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/IncoherentPhoton.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// IncoherentPhoton wrapper +void wrapIncoherentPhoton(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::IncoherentPhoton; + + // create the component + python::class_ component( + module, + "IncoherentPhoton", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + >(), + Component::documentation("constructor").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/IncompleteReactions.python.cpp b/python/src/v2.0/transport/IncompleteReactions.python.cpp new file mode 100644 index 000000000..e397cd3b5 --- /dev/null +++ b/python/src/v2.0/transport/IncompleteReactions.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/IncompleteReactions.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// IncompleteReactions wrapper +void wrapIncompleteReactions(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::IncompleteReactions; + + // create the component + python::class_ component( + module, + "IncompleteReactions", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("reaction") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "reaction", + python::overload_cast<>(&Component::reaction), + Component::documentation("reaction").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Isotropic2d.python.cpp b/python/src/v2.0/transport/Isotropic2d.python.cpp new file mode 100644 index 000000000..63326d8f1 --- /dev/null +++ b/python/src/v2.0/transport/Isotropic2d.python.cpp @@ -0,0 +1,49 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Isotropic2d.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Isotropic2d wrapper +void wrapIsotropic2d(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Isotropic2d; + + // create the component + python::class_ component( + module, + "Isotropic2d", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + >(), + Component::documentation("constructor").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/KalbachMann.python.cpp b/python/src/v2.0/transport/KalbachMann.python.cpp new file mode 100644 index 000000000..d141645b8 --- /dev/null +++ b/python/src/v2.0/transport/KalbachMann.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/KalbachMann.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// KalbachMann wrapper +void wrapKalbachMann(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::KalbachMann; + + // create the component + python::class_ component( + module, + "KalbachMann", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const XMLName &, + const std::optional &, + const transport::F &, + const transport::R & + >(), + python::arg("label") = std::nullopt, + python::arg("product_frame"), + python::arg("a") = std::nullopt, + python::arg("f"), + python::arg("r"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "product_frame", + &Component::productFrame, + Component::documentation("product_frame").data() + ) + .def_property_readonly( + "a", + python::overload_cast<>(&Component::a), + Component::documentation("a").data() + ) + .def_property_readonly( + "f", + python::overload_cast<>(&Component::f), + Component::documentation("f").data() + ) + .def_property_readonly( + "r", + python::overload_cast<>(&Component::r), + Component::documentation("r").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Multiplicity.python.cpp b/python/src/v2.0/transport/Multiplicity.python.cpp new file mode 100644 index 000000000..53eb0807f --- /dev/null +++ b/python/src/v2.0/transport/Multiplicity.python.cpp @@ -0,0 +1,100 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Multiplicity.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Multiplicity wrapper +void wrapMultiplicity(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Multiplicity; + using _t = std::variant< + containers::XYs1d, + transport::Branching1d, + containers::Constant1d, + containers::Gridded1d, + containers::Polynomial1d, + transport::Reference, + containers::Regions1d + >; + + // create the component + python::class_ component( + module, + "Multiplicity", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const _t & + >(), + python::arg("_xys1dbranching1dconstant1dgridded1dpolynomial1dreferenceregions1d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "branching1d", + python::overload_cast<>(&Component::branching1d), + Component::documentation("branching1d").data() + ) + .def_property_readonly( + "constant1d", + python::overload_cast<>(&Component::constant1d), + Component::documentation("constant1d").data() + ) + .def_property_readonly( + "gridded1d", + python::overload_cast<>(&Component::gridded1d), + Component::documentation("gridded1d").data() + ) + .def_property_readonly( + "polynomial1d", + python::overload_cast<>(&Component::polynomial1d), + Component::documentation("polynomial1d").data() + ) + .def_property_readonly( + "reference", + python::overload_cast<>(&Component::reference), + Component::documentation("reference").data() + ) + .def_property_readonly( + "regions1d", + python::overload_cast<>(&Component::regions1d), + Component::documentation("regions1d").data() + ) + .def_property_readonly( + "_xys1dbranching1dconstant1dgridded1dpolynomial1dreferenceregions1d", + python::overload_cast<>(&Component::_XYs1dbranching1dconstant1dgridded1dpolynomial1dreferenceregions1d), + Component::documentation("_xys1dbranching1dconstant1dgridded1dpolynomial1dreferenceregions1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/MultiplicitySum.python.cpp b/python/src/v2.0/transport/MultiplicitySum.python.cpp new file mode 100644 index 000000000..9e0b388b9 --- /dev/null +++ b/python/src/v2.0/transport/MultiplicitySum.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/MultiplicitySum.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// MultiplicitySum wrapper +void wrapMultiplicitySum(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::MultiplicitySum; + + // create the component + python::class_ component( + module, + "MultiplicitySum", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const XMLName &, + const transport::Multiplicity &, + const transport::Summands & + >(), + python::arg("endf_mt") = std::nullopt, + python::arg("label"), + python::arg("multiplicity"), + python::arg("summands"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "endf_mt", + &Component::ENDF_MT, + Component::documentation("endf_mt").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "multiplicity", + python::overload_cast<>(&Component::multiplicity), + Component::documentation("multiplicity").data() + ) + .def_property_readonly( + "summands", + python::overload_cast<>(&Component::summands), + Component::documentation("summands").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/MultiplicitySums.python.cpp b/python/src/v2.0/transport/MultiplicitySums.python.cpp new file mode 100644 index 000000000..8b069fddf --- /dev/null +++ b/python/src/v2.0/transport/MultiplicitySums.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/MultiplicitySums.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// MultiplicitySums wrapper +void wrapMultiplicitySums(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::MultiplicitySums; + + // create the component + python::class_ component( + module, + "MultiplicitySums", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional> & + >(), + python::arg("multiplicity_sum") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "multiplicity_sum", + python::overload_cast<>(&Component::multiplicitySum), + Component::documentation("multiplicity_sum").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/NBodyPhaseSpace.python.cpp b/python/src/v2.0/transport/NBodyPhaseSpace.python.cpp new file mode 100644 index 000000000..e0e5c4c8b --- /dev/null +++ b/python/src/v2.0/transport/NBodyPhaseSpace.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/NBodyPhaseSpace.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// NBodyPhaseSpace wrapper +void wrapNBodyPhaseSpace(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::NBodyPhaseSpace; + + // create the component + python::class_ component( + module, + "NBodyPhaseSpace", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("number_of_products") = std::nullopt, + python::arg("mass") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "number_of_products", + &Component::numberOfProducts, + Component::documentation("number_of_products").data() + ) + .def_property_readonly( + "mass", + python::overload_cast<>(&Component::mass), + Component::documentation("mass").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/OrphanProduct.python.cpp b/python/src/v2.0/transport/OrphanProduct.python.cpp new file mode 100644 index 000000000..3339c044a --- /dev/null +++ b/python/src/v2.0/transport/OrphanProduct.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/OrphanProduct.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// OrphanProduct wrapper +void wrapOrphanProduct(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::OrphanProduct; + + // create the component + python::class_ component( + module, + "OrphanProduct", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const Integer32 &, + const XMLName &, + const transport::CrossSection &, + const transport::OutputChannel & + >(), + python::arg("endf_mt"), + python::arg("label"), + python::arg("cross_section"), + python::arg("output_channel"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "endf_mt", + &Component::ENDF_MT, + Component::documentation("endf_mt").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "cross_section", + python::overload_cast<>(&Component::crossSection), + Component::documentation("cross_section").data() + ) + .def_property_readonly( + "output_channel", + python::overload_cast<>(&Component::outputChannel), + Component::documentation("output_channel").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/OrphanProducts.python.cpp b/python/src/v2.0/transport/OrphanProducts.python.cpp new file mode 100644 index 000000000..04b5391cf --- /dev/null +++ b/python/src/v2.0/transport/OrphanProducts.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/OrphanProducts.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// OrphanProducts wrapper +void wrapOrphanProducts(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::OrphanProducts; + + // create the component + python::class_ component( + module, + "OrphanProducts", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("orphan_product"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "orphan_product", + python::overload_cast<>(&Component::orphanProduct), + Component::documentation("orphan_product").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/OutputChannel.python.cpp b/python/src/v2.0/transport/OutputChannel.python.cpp new file mode 100644 index 000000000..c3d8aa5e7 --- /dev/null +++ b/python/src/v2.0/transport/OutputChannel.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/OutputChannel.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// OutputChannel wrapper +void wrapOutputChannel(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::OutputChannel; + + // create the component + python::class_ component( + module, + "OutputChannel", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("genre") = std::nullopt, + python::arg("process") = std::nullopt, + python::arg("q") = std::nullopt, + python::arg("fission_fragment_data") = std::nullopt, + python::arg("products") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "genre", + &Component::genre, + Component::documentation("genre").data() + ) + .def_property_readonly( + "process", + &Component::process, + Component::documentation("process").data() + ) + .def_property_readonly( + "q", + python::overload_cast<>(&Component::Q), + Component::documentation("q").data() + ) + .def_property_readonly( + "fission_fragment_data", + python::overload_cast<>(&Component::fissionFragmentData), + Component::documentation("fission_fragment_data").data() + ) + .def_property_readonly( + "products", + python::overload_cast<>(&Component::products), + Component::documentation("products").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/PhotonEmissionProbabilities.python.cpp b/python/src/v2.0/transport/PhotonEmissionProbabilities.python.cpp new file mode 100644 index 000000000..cd51af174 --- /dev/null +++ b/python/src/v2.0/transport/PhotonEmissionProbabilities.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/PhotonEmissionProbabilities.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// PhotonEmissionProbabilities wrapper +void wrapPhotonEmissionProbabilities(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::PhotonEmissionProbabilities; + + // create the component + python::class_ component( + module, + "PhotonEmissionProbabilities", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("shell") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "shell", + python::overload_cast<>(&Component::shell), + Component::documentation("shell").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/PrimaryGamma.python.cpp b/python/src/v2.0/transport/PrimaryGamma.python.cpp new file mode 100644 index 000000000..de933e85e --- /dev/null +++ b/python/src/v2.0/transport/PrimaryGamma.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/PrimaryGamma.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// PrimaryGamma wrapper +void wrapPrimaryGamma(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::PrimaryGamma; + + // create the component + python::class_ component( + module, + "PrimaryGamma", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("domain_max") = std::nullopt, + python::arg("domain_min") = std::nullopt, + python::arg("final_state") = std::nullopt, + python::arg("value") = std::nullopt, + python::arg("axes") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "domain_max", + &Component::domainMax, + Component::documentation("domain_max").data() + ) + .def_property_readonly( + "domain_min", + &Component::domainMin, + Component::documentation("domain_min").data() + ) + .def_property_readonly( + "final_state", + &Component::finalState, + Component::documentation("final_state").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + .def_property_readonly( + "axes", + python::overload_cast<>(&Component::axes), + Component::documentation("axes").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Production.python.cpp b/python/src/v2.0/transport/Production.python.cpp new file mode 100644 index 000000000..e25a0c975 --- /dev/null +++ b/python/src/v2.0/transport/Production.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Production.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Production wrapper +void wrapProduction(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Production; + + // create the component + python::class_ component( + module, + "Production", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("endf_mt") = std::nullopt, + python::arg("label") = std::nullopt, + python::arg("cross_section") = std::nullopt, + python::arg("output_channel") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "endf_mt", + &Component::ENDF_MT, + Component::documentation("endf_mt").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "cross_section", + python::overload_cast<>(&Component::crossSection), + Component::documentation("cross_section").data() + ) + .def_property_readonly( + "output_channel", + python::overload_cast<>(&Component::outputChannel), + Component::documentation("output_channel").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Productions.python.cpp b/python/src/v2.0/transport/Productions.python.cpp new file mode 100644 index 000000000..d1a2fc935 --- /dev/null +++ b/python/src/v2.0/transport/Productions.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Productions.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Productions wrapper +void wrapProductions(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Productions; + + // create the component + python::class_ component( + module, + "Productions", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("production") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "production", + python::overload_cast<>(&Component::production), + Component::documentation("production").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/R.python.cpp b/python/src/v2.0/transport/R.python.cpp new file mode 100644 index 000000000..2e7dce263 --- /dev/null +++ b/python/src/v2.0/transport/R.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/R.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// R wrapper +void wrapR(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::R; + using _t = std::variant< + containers::XYs2d, + containers::Regions2d + >; + + // create the component + python::class_ component( + module, + "R", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const _t & + >(), + python::arg("_xys2dregions2d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys2d", + python::overload_cast<>(&Component::XYs2d), + Component::documentation("xys2d").data() + ) + .def_property_readonly( + "regions2d", + python::overload_cast<>(&Component::regions2d), + Component::documentation("regions2d").data() + ) + .def_property_readonly( + "_xys2dregions2d", + python::overload_cast<>(&Component::_XYs2dregions2d), + Component::documentation("_xys2dregions2d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Reaction.python.cpp b/python/src/v2.0/transport/Reaction.python.cpp new file mode 100644 index 000000000..6414cc506 --- /dev/null +++ b/python/src/v2.0/transport/Reaction.python.cpp @@ -0,0 +1,91 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Reaction.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Reaction wrapper +void wrapReaction(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Reaction; + + // create the component + python::class_ component( + module, + "Reaction", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const Integer32 &, + const std::optional &, + const XMLName &, + const transport::CrossSection &, + const std::optional &, + const transport::OutputChannel & + >(), + python::arg("endf_mt"), + python::arg("fission_genre") = std::nullopt, + python::arg("label"), + python::arg("cross_section"), + python::arg("double_differential_cross_section") = std::nullopt, + python::arg("output_channel"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "endf_mt", + &Component::ENDF_MT, + Component::documentation("endf_mt").data() + ) + .def_property_readonly( + "fission_genre", + &Component::fissionGenre, + Component::documentation("fission_genre").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "cross_section", + python::overload_cast<>(&Component::crossSection), + Component::documentation("cross_section").data() + ) + .def_property_readonly( + "double_differential_cross_section", + python::overload_cast<>(&Component::doubleDifferentialCrossSection), + Component::documentation("double_differential_cross_section").data() + ) + .def_property_readonly( + "output_channel", + python::overload_cast<>(&Component::outputChannel), + Component::documentation("output_channel").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/ReactionSuite.python.cpp b/python/src/v2.0/transport/ReactionSuite.python.cpp new file mode 100644 index 000000000..12ea44914 --- /dev/null +++ b/python/src/v2.0/transport/ReactionSuite.python.cpp @@ -0,0 +1,168 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/ReactionSuite.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// ReactionSuite wrapper +void wrapReactionSuite(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::ReactionSuite; + + // create the component + python::class_ component( + module, + "ReactionSuite", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const XMLName &, + const enums::Interaction &, + const XMLName &, + const enums::Frame &, + const XMLName &, + const pops::PoPs &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional &, + const styles::Styles &, + const std::optional & + >(), + python::arg("evaluation"), + python::arg("format"), + python::arg("interaction"), + python::arg("projectile"), + python::arg("projectile_frame"), + python::arg("target"), + python::arg("po_ps"), + python::arg("application_data") = std::nullopt, + python::arg("external_files") = std::nullopt, + python::arg("fission_components") = std::nullopt, + python::arg("incomplete_reactions") = std::nullopt, + python::arg("orphan_products") = std::nullopt, + python::arg("productions") = std::nullopt, + python::arg("reactions") = std::nullopt, + python::arg("resonances") = std::nullopt, + python::arg("styles"), + python::arg("sums") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "evaluation", + &Component::evaluation, + Component::documentation("evaluation").data() + ) + .def_property_readonly( + "format", + &Component::format, + Component::documentation("format").data() + ) + .def_property_readonly( + "interaction", + &Component::interaction, + Component::documentation("interaction").data() + ) + .def_property_readonly( + "projectile", + &Component::projectile, + Component::documentation("projectile").data() + ) + .def_property_readonly( + "projectile_frame", + &Component::projectileFrame, + Component::documentation("projectile_frame").data() + ) + .def_property_readonly( + "target", + &Component::target, + Component::documentation("target").data() + ) + .def_property_readonly( + "po_ps", + python::overload_cast<>(&Component::PoPs), + Component::documentation("po_ps").data() + ) + .def_property_readonly( + "application_data", + python::overload_cast<>(&Component::applicationData), + Component::documentation("application_data").data() + ) + .def_property_readonly( + "external_files", + python::overload_cast<>(&Component::externalFiles), + Component::documentation("external_files").data() + ) + .def_property_readonly( + "fission_components", + python::overload_cast<>(&Component::fissionComponents), + Component::documentation("fission_components").data() + ) + .def_property_readonly( + "incomplete_reactions", + python::overload_cast<>(&Component::incompleteReactions), + Component::documentation("incomplete_reactions").data() + ) + .def_property_readonly( + "orphan_products", + python::overload_cast<>(&Component::orphanProducts), + Component::documentation("orphan_products").data() + ) + .def_property_readonly( + "productions", + python::overload_cast<>(&Component::productions), + Component::documentation("productions").data() + ) + .def_property_readonly( + "reactions", + python::overload_cast<>(&Component::reactions), + Component::documentation("reactions").data() + ) + .def_property_readonly( + "resonances", + python::overload_cast<>(&Component::resonances), + Component::documentation("resonances").data() + ) + .def_property_readonly( + "styles", + python::overload_cast<>(&Component::styles), + Component::documentation("styles").data() + ) + .def_property_readonly( + "sums", + python::overload_cast<>(&Component::sums), + Component::documentation("sums").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Reactions.python.cpp b/python/src/v2.0/transport/Reactions.python.cpp new file mode 100644 index 000000000..4dff38fd6 --- /dev/null +++ b/python/src/v2.0/transport/Reactions.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Reactions.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Reactions wrapper +void wrapReactions(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Reactions; + + // create the component + python::class_ component( + module, + "Reactions", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("reaction"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "reaction", + python::overload_cast<>(&Component::reaction), + Component::documentation("reaction").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Recoil.python.cpp b/python/src/v2.0/transport/Recoil.python.cpp new file mode 100644 index 000000000..fe73fd62e --- /dev/null +++ b/python/src/v2.0/transport/Recoil.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Recoil.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Recoil wrapper +void wrapRecoil(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Recoil; + + // create the component + python::class_ component( + module, + "Recoil", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string & + >(), + python::arg("href"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Reference.python.cpp b/python/src/v2.0/transport/Reference.python.cpp new file mode 100644 index 000000000..bd468c137 --- /dev/null +++ b/python/src/v2.0/transport/Reference.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Reference.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Reference wrapper +void wrapReference(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Reference; + + // create the component + python::class_ component( + module, + "Reference", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("href") = std::nullopt, + python::arg("label") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/ResolvedRegion.python.cpp b/python/src/v2.0/transport/ResolvedRegion.python.cpp new file mode 100644 index 000000000..f38517951 --- /dev/null +++ b/python/src/v2.0/transport/ResolvedRegion.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/ResolvedRegion.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// ResolvedRegion wrapper +void wrapResolvedRegion(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::ResolvedRegion; + using _t = std::variant< + containers::XYs1d, + containers::Regions1d + >; + + // create the component + python::class_ component( + module, + "ResolvedRegion", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const _t & + >(), + python::arg("_xys1dregions1d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "regions1d", + python::overload_cast<>(&Component::regions1d), + Component::documentation("regions1d").data() + ) + .def_property_readonly( + "_xys1dregions1d", + python::overload_cast<>(&Component::_XYs1dregions1d), + Component::documentation("_xys1dregions1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Resonances.python.cpp b/python/src/v2.0/transport/Resonances.python.cpp new file mode 100644 index 000000000..c1f2bca36 --- /dev/null +++ b/python/src/v2.0/transport/Resonances.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Resonances.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Resonances wrapper +void wrapResonances(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Resonances; + + // create the component + python::class_ component( + module, + "Resonances", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::string &, + const std::optional & + >(), + python::arg("href"), + python::arg("label") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/ResonancesWithBackground.python.cpp b/python/src/v2.0/transport/ResonancesWithBackground.python.cpp new file mode 100644 index 000000000..6c2e52104 --- /dev/null +++ b/python/src/v2.0/transport/ResonancesWithBackground.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/ResonancesWithBackground.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// ResonancesWithBackground wrapper +void wrapResonancesWithBackground(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::ResonancesWithBackground; + + // create the component + python::class_ component( + module, + "ResonancesWithBackground", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const transport::Background &, + const transport::Resonances &, + const std::optional & + >(), + python::arg("label"), + python::arg("background"), + python::arg("resonances"), + python::arg("uncertainty") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "background", + python::overload_cast<>(&Component::background), + Component::documentation("background").data() + ) + .def_property_readonly( + "resonances", + python::overload_cast<>(&Component::resonances), + Component::documentation("resonances").data() + ) + .def_property_readonly( + "uncertainty", + python::overload_cast<>(&Component::uncertainty), + Component::documentation("uncertainty").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/ScatteringMatrix.python.cpp b/python/src/v2.0/transport/ScatteringMatrix.python.cpp new file mode 100644 index 000000000..4c7139331 --- /dev/null +++ b/python/src/v2.0/transport/ScatteringMatrix.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/ScatteringMatrix.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// ScatteringMatrix wrapper +void wrapScatteringMatrix(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::ScatteringMatrix; + + // create the component + python::class_ component( + module, + "ScatteringMatrix", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const XMLName &, + const containers::Gridded3d & + >(), + python::arg("label"), + python::arg("product_frame"), + python::arg("gridded3d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "product_frame", + &Component::productFrame, + Component::documentation("product_frame").data() + ) + .def_property_readonly( + "gridded3d", + python::overload_cast<>(&Component::gridded3d), + Component::documentation("gridded3d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Summands.python.cpp b/python/src/v2.0/transport/Summands.python.cpp new file mode 100644 index 000000000..4367f562a --- /dev/null +++ b/python/src/v2.0/transport/Summands.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Summands.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Summands wrapper +void wrapSummands(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Summands; + + // create the component + python::class_ component( + module, + "Summands", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional> & + >(), + python::arg("add") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "add", + python::overload_cast<>(&Component::add), + Component::documentation("add").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Sums.python.cpp b/python/src/v2.0/transport/Sums.python.cpp new file mode 100644 index 000000000..257d47462 --- /dev/null +++ b/python/src/v2.0/transport/Sums.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Sums.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Sums wrapper +void wrapSums(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Sums; + + // create the component + python::class_ component( + module, + "Sums", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const transport::CrossSectionSums &, + const std::optional & + >(), + python::arg("cross_section_sums"), + python::arg("multiplicity_sums") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "cross_section_sums", + python::overload_cast<>(&Component::crossSectionSums), + Component::documentation("cross_section_sums").data() + ) + .def_property_readonly( + "multiplicity_sums", + python::overload_cast<>(&Component::multiplicitySums), + Component::documentation("multiplicity_sums").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Theta.python.cpp b/python/src/v2.0/transport/Theta.python.cpp new file mode 100644 index 000000000..274522a39 --- /dev/null +++ b/python/src/v2.0/transport/Theta.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Theta.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Theta wrapper +void wrapTheta(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Theta; + + // create the component + python::class_ component( + module, + "Theta", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("xys1d") = std::nullopt, + python::arg("regions1d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "regions1d", + python::overload_cast<>(&Component::regions1d), + Component::documentation("regions1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/U.python.cpp b/python/src/v2.0/transport/U.python.cpp new file mode 100644 index 000000000..57b21127c --- /dev/null +++ b/python/src/v2.0/transport/U.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/U.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// U wrapper +void wrapU(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::U; + + // create the component + python::class_ component( + module, + "U", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("unit") = std::nullopt, + python::arg("value") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/URR_probabilityTables1d.python.cpp b/python/src/v2.0/transport/URR_probabilityTables1d.python.cpp new file mode 100644 index 000000000..bd4bc6305 --- /dev/null +++ b/python/src/v2.0/transport/URR_probabilityTables1d.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/URR_probabilityTables1d.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// URR_probabilityTables1d wrapper +void wrapURR_probabilityTables1d(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::URR_probabilityTables1d; + using _t = std::variant< + containers::XYs2d, + containers::Regions2d + >; + + // create the component + python::class_ component( + module, + "URR_probabilityTables1d", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const _t & + >(), + python::arg("label"), + python::arg("_xys2dregions2d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "xys2d", + python::overload_cast<>(&Component::XYs2d), + Component::documentation("xys2d").data() + ) + .def_property_readonly( + "regions2d", + python::overload_cast<>(&Component::regions2d), + Component::documentation("regions2d").data() + ) + .def_property_readonly( + "_xys2dregions2d", + python::overload_cast<>(&Component::_XYs2dregions2d), + Component::documentation("_xys2dregions2d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Uncorrelated.python.cpp b/python/src/v2.0/transport/Uncorrelated.python.cpp new file mode 100644 index 000000000..776665628 --- /dev/null +++ b/python/src/v2.0/transport/Uncorrelated.python.cpp @@ -0,0 +1,77 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Uncorrelated.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Uncorrelated wrapper +void wrapUncorrelated(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Uncorrelated; + + // create the component + python::class_ component( + module, + "Uncorrelated", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const XMLName &, + const transport::Angular &, + const transport::Energy & + >(), + python::arg("label") = std::nullopt, + python::arg("product_frame"), + python::arg("angular"), + python::arg("energy"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "product_frame", + &Component::productFrame, + Component::documentation("product_frame").data() + ) + .def_property_readonly( + "angular", + python::overload_cast<>(&Component::angular), + Component::documentation("angular").data() + ) + .def_property_readonly( + "energy", + python::overload_cast<>(&Component::energy), + Component::documentation("energy").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/UnresolvedRegion.python.cpp b/python/src/v2.0/transport/UnresolvedRegion.python.cpp new file mode 100644 index 000000000..a8cf9ff51 --- /dev/null +++ b/python/src/v2.0/transport/UnresolvedRegion.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/UnresolvedRegion.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// UnresolvedRegion wrapper +void wrapUnresolvedRegion(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::UnresolvedRegion; + using _t = std::variant< + containers::XYs1d, + containers::Regions1d + >; + + // create the component + python::class_ component( + module, + "UnresolvedRegion", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const _t & + >(), + python::arg("_xys1dregions1d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "regions1d", + python::overload_cast<>(&Component::regions1d), + Component::documentation("regions1d").data() + ) + .def_property_readonly( + "_xys1dregions1d", + python::overload_cast<>(&Component::_XYs1dregions1d), + Component::documentation("_xys1dregions1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Unspecified.python.cpp b/python/src/v2.0/transport/Unspecified.python.cpp new file mode 100644 index 000000000..cbfad1442 --- /dev/null +++ b/python/src/v2.0/transport/Unspecified.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Unspecified.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Unspecified wrapper +void wrapUnspecified(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Unspecified; + + // create the component + python::class_ component( + module, + "Unspecified", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const XMLName & + >(), + python::arg("label") = std::nullopt, + python::arg("product_frame"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "product_frame", + &Component::productFrame, + Component::documentation("product_frame").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/Weighted.python.cpp b/python/src/v2.0/transport/Weighted.python.cpp new file mode 100644 index 000000000..342809cc7 --- /dev/null +++ b/python/src/v2.0/transport/Weighted.python.cpp @@ -0,0 +1,98 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/Weighted.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// Weighted wrapper +void wrapWeighted(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::Weighted; + + // create the component + python::class_ component( + module, + "Weighted", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const containers::XYs1d &, + const std::optional &, + const std::optional &, + const std::optional &, + const std::optional & + >(), + python::arg("madland_nix") = std::nullopt, + python::arg("watt") = std::nullopt, + python::arg("xys1d"), + python::arg("xys2d") = std::nullopt, + python::arg("evaporation") = std::nullopt, + python::arg("general_evaporation") = std::nullopt, + python::arg("simple_maxwellian_fission") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "madland_nix", + python::overload_cast<>(&Component::MadlandNix), + Component::documentation("madland_nix").data() + ) + .def_property_readonly( + "watt", + python::overload_cast<>(&Component::Watt), + Component::documentation("watt").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + .def_property_readonly( + "xys2d", + python::overload_cast<>(&Component::XYs2d), + Component::documentation("xys2d").data() + ) + .def_property_readonly( + "evaporation", + python::overload_cast<>(&Component::evaporation), + Component::documentation("evaporation").data() + ) + .def_property_readonly( + "general_evaporation", + python::overload_cast<>(&Component::generalEvaporation), + Component::documentation("general_evaporation").data() + ) + .def_property_readonly( + "simple_maxwellian_fission", + python::overload_cast<>(&Component::simpleMaxwellianFission), + Component::documentation("simple_maxwellian_fission").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/transport/WeightedFunctionals.python.cpp b/python/src/v2.0/transport/WeightedFunctionals.python.cpp new file mode 100644 index 000000000..37993ba20 --- /dev/null +++ b/python/src/v2.0/transport/WeightedFunctionals.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/transport/WeightedFunctionals.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_transport { + +// WeightedFunctionals wrapper +void wrapWeightedFunctionals(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = transport::WeightedFunctionals; + + // create the component + python::class_ component( + module, + "WeightedFunctionals", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const transport::Weighted & + >(), + python::arg("weighted"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "weighted", + python::overload_cast<>(&Component::weighted), + Component::documentation("weighted").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_transport +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl.python.cpp b/python/src/v2.0/tsl.python.cpp new file mode 100644 index 000000000..01ca73493 --- /dev/null +++ b/python/src/v2.0/tsl.python.cpp @@ -0,0 +1,75 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +#include +#include + +namespace python = pybind11; + +// v2.0 interface +namespace python_v2_0 { + +// tsl declarations +namespace python_tsl { + void wrapThermalNeutronScatteringLaw1d(python::module &); + void wrapThermalNeutronScatteringLaw(python::module &); + void wrapBraggEnergy(python::module &); + void wrapStructureFactor(python::module &); + void wrapBraggEdge(python::module &); + void wrapBraggEdges(python::module &); + void wrapS_table(python::module &); + void wrapThermalNeutronScatteringLaw_coherentElastic(python::module &); + void wrapDebyeWallerIntegral(python::module &); + void wrapBoundAtomCrossSection(python::module &); + void wrapThermalNeutronScatteringLaw_incoherentElastic(python::module &); + void wrapCoherentAtomCrossSection(python::module &); + void wrapDistinctScatteringKernel(python::module &); + void wrapE_critical(python::module &); + void wrapE_max(python::module &); + void wrapT_effective(python::module &); + void wrapSelfScatteringKernelSCTApproximation(python::module &); + void wrapPhononSpectrum(python::module &); + void wrapSelfScatteringKernelGaussianApproximation(python::module &); + void wrapSelfScatteringKernel(python::module &); + void wrapScatteringAtom(python::module &); + void wrapScatteringAtoms(python::module &); + void wrapThermalNeutronScatteringLaw_incoherentInelastic(python::module &); +} // namespace python_tsl + +// tsl wrapper +void wrapTsl(python::module &module) +{ + // create the tsl submodule + python::module submodule = module.def_submodule( + "tsl", + "GNDS v2.0 tsl" + ); + + // wrap tsl components + python_tsl::wrapThermalNeutronScatteringLaw1d(submodule); + python_tsl::wrapThermalNeutronScatteringLaw(submodule); + python_tsl::wrapBraggEnergy(submodule); + python_tsl::wrapStructureFactor(submodule); + python_tsl::wrapBraggEdge(submodule); + python_tsl::wrapBraggEdges(submodule); + python_tsl::wrapS_table(submodule); + python_tsl::wrapThermalNeutronScatteringLaw_coherentElastic(submodule); + python_tsl::wrapDebyeWallerIntegral(submodule); + python_tsl::wrapBoundAtomCrossSection(submodule); + python_tsl::wrapThermalNeutronScatteringLaw_incoherentElastic(submodule); + python_tsl::wrapCoherentAtomCrossSection(submodule); + python_tsl::wrapDistinctScatteringKernel(submodule); + python_tsl::wrapE_critical(submodule); + python_tsl::wrapE_max(submodule); + python_tsl::wrapT_effective(submodule); + python_tsl::wrapSelfScatteringKernelSCTApproximation(submodule); + python_tsl::wrapPhononSpectrum(submodule); + python_tsl::wrapSelfScatteringKernelGaussianApproximation(submodule); + python_tsl::wrapSelfScatteringKernel(submodule); + python_tsl::wrapScatteringAtom(submodule); + python_tsl::wrapScatteringAtoms(submodule); + python_tsl::wrapThermalNeutronScatteringLaw_incoherentInelastic(submodule); +}; + +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/BoundAtomCrossSection.python.cpp b/python/src/v2.0/tsl/BoundAtomCrossSection.python.cpp new file mode 100644 index 000000000..d97759f20 --- /dev/null +++ b/python/src/v2.0/tsl/BoundAtomCrossSection.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/BoundAtomCrossSection.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// BoundAtomCrossSection wrapper +void wrapBoundAtomCrossSection(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::BoundAtomCrossSection; + + // create the component + python::class_ component( + module, + "BoundAtomCrossSection", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const Float64 & + >(), + python::arg("unit"), + python::arg("value"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/BraggEdge.python.cpp b/python/src/v2.0/tsl/BraggEdge.python.cpp new file mode 100644 index 000000000..47d7fcf04 --- /dev/null +++ b/python/src/v2.0/tsl/BraggEdge.python.cpp @@ -0,0 +1,70 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/BraggEdge.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// BraggEdge wrapper +void wrapBraggEdge(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::BraggEdge; + + // create the component + python::class_ component( + module, + "BraggEdge", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const tsl::BraggEnergy &, + const tsl::StructureFactor & + >(), + python::arg("label"), + python::arg("bragg_energy"), + python::arg("structure_factor"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "bragg_energy", + python::overload_cast<>(&Component::BraggEnergy), + Component::documentation("bragg_energy").data() + ) + .def_property_readonly( + "structure_factor", + python::overload_cast<>(&Component::structureFactor), + Component::documentation("structure_factor").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/BraggEdges.python.cpp b/python/src/v2.0/tsl/BraggEdges.python.cpp new file mode 100644 index 000000000..4b77ce9b9 --- /dev/null +++ b/python/src/v2.0/tsl/BraggEdges.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/BraggEdges.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// BraggEdges wrapper +void wrapBraggEdges(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::BraggEdges; + + // create the component + python::class_ component( + module, + "BraggEdges", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("bragg_edge"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "bragg_edge", + python::overload_cast<>(&Component::BraggEdge), + Component::documentation("bragg_edge").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/BraggEnergy.python.cpp b/python/src/v2.0/tsl/BraggEnergy.python.cpp new file mode 100644 index 000000000..4c7ec4669 --- /dev/null +++ b/python/src/v2.0/tsl/BraggEnergy.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/BraggEnergy.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// BraggEnergy wrapper +void wrapBraggEnergy(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::BraggEnergy; + + // create the component + python::class_ component( + module, + "BraggEnergy", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const containers::XYs1d & + >(), + python::arg("xys1d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/CoherentAtomCrossSection.python.cpp b/python/src/v2.0/tsl/CoherentAtomCrossSection.python.cpp new file mode 100644 index 000000000..6b28d2e10 --- /dev/null +++ b/python/src/v2.0/tsl/CoherentAtomCrossSection.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/CoherentAtomCrossSection.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// CoherentAtomCrossSection wrapper +void wrapCoherentAtomCrossSection(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::CoherentAtomCrossSection; + + // create the component + python::class_ component( + module, + "CoherentAtomCrossSection", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const Float64 & + >(), + python::arg("unit"), + python::arg("value"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/DebyeWallerIntegral.python.cpp b/python/src/v2.0/tsl/DebyeWallerIntegral.python.cpp new file mode 100644 index 000000000..d3a243c7e --- /dev/null +++ b/python/src/v2.0/tsl/DebyeWallerIntegral.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/DebyeWallerIntegral.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// DebyeWallerIntegral wrapper +void wrapDebyeWallerIntegral(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::DebyeWallerIntegral; + + // create the component + python::class_ component( + module, + "DebyeWallerIntegral", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const containers::XYs1d & + >(), + python::arg("xys1d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/DistinctScatteringKernel.python.cpp b/python/src/v2.0/tsl/DistinctScatteringKernel.python.cpp new file mode 100644 index 000000000..9b6f5fb69 --- /dev/null +++ b/python/src/v2.0/tsl/DistinctScatteringKernel.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/DistinctScatteringKernel.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// DistinctScatteringKernel wrapper +void wrapDistinctScatteringKernel(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::DistinctScatteringKernel; + + // create the component + python::class_ component( + module, + "DistinctScatteringKernel", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("gridded3d") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "gridded3d", + python::overload_cast<>(&Component::gridded3d), + Component::documentation("gridded3d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/E_critical.python.cpp b/python/src/v2.0/tsl/E_critical.python.cpp new file mode 100644 index 000000000..7fbfee12e --- /dev/null +++ b/python/src/v2.0/tsl/E_critical.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/E_critical.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// E_critical wrapper +void wrapE_critical(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::E_critical; + + // create the component + python::class_ component( + module, + "E_critical", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("unit") = std::nullopt, + python::arg("value") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/E_max.python.cpp b/python/src/v2.0/tsl/E_max.python.cpp new file mode 100644 index 000000000..06d1cf6c8 --- /dev/null +++ b/python/src/v2.0/tsl/E_max.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/E_max.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// E_max wrapper +void wrapE_max(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::E_max; + + // create the component + python::class_ component( + module, + "E_max", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional & + >(), + python::arg("unit") = std::nullopt, + python::arg("value") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "unit", + &Component::unit, + Component::documentation("unit").data() + ) + .def_property_readonly( + "value", + &Component::value, + Component::documentation("value").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/PhononSpectrum.python.cpp b/python/src/v2.0/tsl/PhononSpectrum.python.cpp new file mode 100644 index 000000000..d9c14c30c --- /dev/null +++ b/python/src/v2.0/tsl/PhononSpectrum.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/PhononSpectrum.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// PhononSpectrum wrapper +void wrapPhononSpectrum(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::PhononSpectrum; + + // create the component + python::class_ component( + module, + "PhononSpectrum", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const containers::XYs1d & + >(), + python::arg("xys1d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/S_table.python.cpp b/python/src/v2.0/tsl/S_table.python.cpp new file mode 100644 index 000000000..45954234e --- /dev/null +++ b/python/src/v2.0/tsl/S_table.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/S_table.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// S_table wrapper +void wrapS_table(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::S_table; + + // create the component + python::class_ component( + module, + "S_table", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const containers::Gridded2d & + >(), + python::arg("gridded2d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "gridded2d", + python::overload_cast<>(&Component::gridded2d), + Component::documentation("gridded2d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/ScatteringAtom.python.cpp b/python/src/v2.0/tsl/ScatteringAtom.python.cpp new file mode 100644 index 000000000..f8781527e --- /dev/null +++ b/python/src/v2.0/tsl/ScatteringAtom.python.cpp @@ -0,0 +1,119 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/ScatteringAtom.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// ScatteringAtom wrapper +void wrapScatteringAtom(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::ScatteringAtom; + + // create the component + python::class_ component( + module, + "ScatteringAtom", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const Integer32 &, + const XMLName &, + const bool &, + const tsl::BoundAtomCrossSection &, + const std::optional &, + const std::optional &, + const std::optional &, + const tsl::E_max &, + const ambiguousNamespace::Mass &, + const tsl::SelfScatteringKernel & + >(), + python::arg("number_per_molecule"), + python::arg("pid"), + python::arg("primary_scatterer"), + python::arg("bound_atom_cross_section"), + python::arg("coherent_atom_cross_section") = std::nullopt, + python::arg("distinct_scattering_kernel") = std::nullopt, + python::arg("e_critical") = std::nullopt, + python::arg("e_max"), + python::arg("mass"), + python::arg("self_scattering_kernel"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "number_per_molecule", + &Component::numberPerMolecule, + Component::documentation("number_per_molecule").data() + ) + .def_property_readonly( + "pid", + &Component::pid, + Component::documentation("pid").data() + ) + .def_property_readonly( + "primary_scatterer", + &Component::primaryScatterer, + Component::documentation("primary_scatterer").data() + ) + .def_property_readonly( + "bound_atom_cross_section", + python::overload_cast<>(&Component::boundAtomCrossSection), + Component::documentation("bound_atom_cross_section").data() + ) + .def_property_readonly( + "coherent_atom_cross_section", + python::overload_cast<>(&Component::coherentAtomCrossSection), + Component::documentation("coherent_atom_cross_section").data() + ) + .def_property_readonly( + "distinct_scattering_kernel", + python::overload_cast<>(&Component::distinctScatteringKernel), + Component::documentation("distinct_scattering_kernel").data() + ) + .def_property_readonly( + "e_critical", + python::overload_cast<>(&Component::e_critical), + Component::documentation("e_critical").data() + ) + .def_property_readonly( + "e_max", + python::overload_cast<>(&Component::e_max), + Component::documentation("e_max").data() + ) + .def_property_readonly( + "mass", + python::overload_cast<>(&Component::mass), + Component::documentation("mass").data() + ) + .def_property_readonly( + "self_scattering_kernel", + python::overload_cast<>(&Component::selfScatteringKernel), + Component::documentation("self_scattering_kernel").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/ScatteringAtoms.python.cpp b/python/src/v2.0/tsl/ScatteringAtoms.python.cpp new file mode 100644 index 000000000..af3eeefd7 --- /dev/null +++ b/python/src/v2.0/tsl/ScatteringAtoms.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/ScatteringAtoms.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// ScatteringAtoms wrapper +void wrapScatteringAtoms(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::ScatteringAtoms; + + // create the component + python::class_ component( + module, + "ScatteringAtoms", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::vector & + >(), + python::arg("scattering_atom"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "scattering_atom", + python::overload_cast<>(&Component::scatteringAtom), + Component::documentation("scattering_atom").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/SelfScatteringKernel.python.cpp b/python/src/v2.0/tsl/SelfScatteringKernel.python.cpp new file mode 100644 index 000000000..10c15ff62 --- /dev/null +++ b/python/src/v2.0/tsl/SelfScatteringKernel.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/SelfScatteringKernel.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// SelfScatteringKernel wrapper +void wrapSelfScatteringKernel(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::SelfScatteringKernel; + using _t = std::variant< + containers::Gridded3d, + tsl::SelfScatteringKernelGaussianApproximation + >; + + // create the component + python::class_ component( + module, + "SelfScatteringKernel", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const std::optional &, + const _t & + >(), + python::arg("symmetric") = std::nullopt, + python::arg("self_scattering_kernel_sctapproximation") = std::nullopt, + python::arg("_gridded3dself_scattering_kernel_gaussian_approximation"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "symmetric", + &Component::symmetric, + Component::documentation("symmetric").data() + ) + .def_property_readonly( + "self_scattering_kernel_sctapproximation", + python::overload_cast<>(&Component::selfScatteringKernelSCTApproximation), + Component::documentation("self_scattering_kernel_sctapproximation").data() + ) + .def_property_readonly( + "gridded3d", + python::overload_cast<>(&Component::gridded3d), + Component::documentation("gridded3d").data() + ) + .def_property_readonly( + "self_scattering_kernel_gaussian_approximation", + python::overload_cast<>(&Component::selfScatteringKernelGaussianApproximation), + Component::documentation("self_scattering_kernel_gaussian_approximation").data() + ) + .def_property_readonly( + "_gridded3dself_scattering_kernel_gaussian_approximation", + python::overload_cast<>(&Component::_gridded3dselfScatteringKernelGaussianApproximation), + Component::documentation("_gridded3dself_scattering_kernel_gaussian_approximation").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/SelfScatteringKernelGaussianApproximation.python.cpp b/python/src/v2.0/tsl/SelfScatteringKernelGaussianApproximation.python.cpp new file mode 100644 index 000000000..f6aead58a --- /dev/null +++ b/python/src/v2.0/tsl/SelfScatteringKernelGaussianApproximation.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/SelfScatteringKernelGaussianApproximation.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// SelfScatteringKernelGaussianApproximation wrapper +void wrapSelfScatteringKernelGaussianApproximation(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::SelfScatteringKernelGaussianApproximation; + + // create the component + python::class_ component( + module, + "SelfScatteringKernelGaussianApproximation", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("phonon_spectrum") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "phonon_spectrum", + python::overload_cast<>(&Component::phononSpectrum), + Component::documentation("phonon_spectrum").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/SelfScatteringKernelSCTApproximation.python.cpp b/python/src/v2.0/tsl/SelfScatteringKernelSCTApproximation.python.cpp new file mode 100644 index 000000000..a12063e2d --- /dev/null +++ b/python/src/v2.0/tsl/SelfScatteringKernelSCTApproximation.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/SelfScatteringKernelSCTApproximation.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// SelfScatteringKernelSCTApproximation wrapper +void wrapSelfScatteringKernelSCTApproximation(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::SelfScatteringKernelSCTApproximation; + + // create the component + python::class_ component( + module, + "SelfScatteringKernelSCTApproximation", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional & + >(), + python::arg("t_effective") = std::nullopt, + Component::documentation("constructor").data() + ) + .def_property_readonly( + "t_effective", + python::overload_cast<>(&Component::T_effective), + Component::documentation("t_effective").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/StructureFactor.python.cpp b/python/src/v2.0/tsl/StructureFactor.python.cpp new file mode 100644 index 000000000..df7c26894 --- /dev/null +++ b/python/src/v2.0/tsl/StructureFactor.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/StructureFactor.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// StructureFactor wrapper +void wrapStructureFactor(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::StructureFactor; + + // create the component + python::class_ component( + module, + "StructureFactor", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const containers::XYs1d & + >(), + python::arg("xys1d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/T_effective.python.cpp b/python/src/v2.0/tsl/T_effective.python.cpp new file mode 100644 index 000000000..a39fdc9fd --- /dev/null +++ b/python/src/v2.0/tsl/T_effective.python.cpp @@ -0,0 +1,56 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/T_effective.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// T_effective wrapper +void wrapT_effective(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::T_effective; + + // create the component + python::class_ component( + module, + "T_effective", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const containers::XYs1d & + >(), + python::arg("xys1d"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "xys1d", + python::overload_cast<>(&Component::XYs1d), + Component::documentation("xys1d").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/ThermalNeutronScatteringLaw.python.cpp b/python/src/v2.0/tsl/ThermalNeutronScatteringLaw.python.cpp new file mode 100644 index 000000000..6ad6cf54b --- /dev/null +++ b/python/src/v2.0/tsl/ThermalNeutronScatteringLaw.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/ThermalNeutronScatteringLaw.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// ThermalNeutronScatteringLaw wrapper +void wrapThermalNeutronScatteringLaw(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::ThermalNeutronScatteringLaw; + + // create the component + python::class_ component( + module, + "ThermalNeutronScatteringLaw", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const XMLName & + >(), + python::arg("href"), + python::arg("label"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/ThermalNeutronScatteringLaw1d.python.cpp b/python/src/v2.0/tsl/ThermalNeutronScatteringLaw1d.python.cpp new file mode 100644 index 000000000..551de2d7d --- /dev/null +++ b/python/src/v2.0/tsl/ThermalNeutronScatteringLaw1d.python.cpp @@ -0,0 +1,63 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/ThermalNeutronScatteringLaw1d.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// ThermalNeutronScatteringLaw1d wrapper +void wrapThermalNeutronScatteringLaw1d(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::ThermalNeutronScatteringLaw1d; + + // create the component + python::class_ component( + module, + "ThermalNeutronScatteringLaw1d", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const XMLName & + >(), + python::arg("href"), + python::arg("label"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "href", + &Component::href, + Component::documentation("href").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/ThermalNeutronScatteringLaw_coherentElastic.python.cpp b/python/src/v2.0/tsl/ThermalNeutronScatteringLaw_coherentElastic.python.cpp new file mode 100644 index 000000000..7589dd4f1 --- /dev/null +++ b/python/src/v2.0/tsl/ThermalNeutronScatteringLaw_coherentElastic.python.cpp @@ -0,0 +1,91 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/ThermalNeutronScatteringLaw_coherentElastic.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// ThermalNeutronScatteringLaw_coherentElastic wrapper +void wrapThermalNeutronScatteringLaw_coherentElastic(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::ThermalNeutronScatteringLaw_coherentElastic; + using _t = std::variant< + tsl::BraggEdges, + tsl::S_table + >; + + // create the component + python::class_ component( + module, + "ThermalNeutronScatteringLaw_coherentElastic", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const XMLName &, + const enums::Frame &, + const _t & + >(), + python::arg("label"), + python::arg("pid"), + python::arg("product_frame"), + python::arg("_bragg_edges_s_table"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "pid", + &Component::pid, + Component::documentation("pid").data() + ) + .def_property_readonly( + "product_frame", + &Component::productFrame, + Component::documentation("product_frame").data() + ) + .def_property_readonly( + "bragg_edges", + python::overload_cast<>(&Component::BraggEdges), + Component::documentation("bragg_edges").data() + ) + .def_property_readonly( + "s_table", + python::overload_cast<>(&Component::S_table), + Component::documentation("s_table").data() + ) + .def_property_readonly( + "_bragg_edges_s_table", + python::overload_cast<>(&Component::_BraggEdgesS_table), + Component::documentation("_bragg_edges_s_table").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/ThermalNeutronScatteringLaw_incoherentElastic.python.cpp b/python/src/v2.0/tsl/ThermalNeutronScatteringLaw_incoherentElastic.python.cpp new file mode 100644 index 000000000..54b3b5af3 --- /dev/null +++ b/python/src/v2.0/tsl/ThermalNeutronScatteringLaw_incoherentElastic.python.cpp @@ -0,0 +1,84 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/ThermalNeutronScatteringLaw_incoherentElastic.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// ThermalNeutronScatteringLaw_incoherentElastic wrapper +void wrapThermalNeutronScatteringLaw_incoherentElastic(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::ThermalNeutronScatteringLaw_incoherentElastic; + + // create the component + python::class_ component( + module, + "ThermalNeutronScatteringLaw_incoherentElastic", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const XMLName &, + const XMLName &, + const enums::Frame &, + const tsl::DebyeWallerIntegral &, + const tsl::BoundAtomCrossSection & + >(), + python::arg("label"), + python::arg("pid"), + python::arg("product_frame"), + python::arg("debye_waller_integral"), + python::arg("bound_atom_cross_section"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "pid", + &Component::pid, + Component::documentation("pid").data() + ) + .def_property_readonly( + "product_frame", + &Component::productFrame, + Component::documentation("product_frame").data() + ) + .def_property_readonly( + "debye_waller_integral", + python::overload_cast<>(&Component::DebyeWallerIntegral), + Component::documentation("debye_waller_integral").data() + ) + .def_property_readonly( + "bound_atom_cross_section", + python::overload_cast<>(&Component::boundAtomCrossSection), + Component::documentation("bound_atom_cross_section").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/src/v2.0/tsl/ThermalNeutronScatteringLaw_incoherentInelastic.python.cpp b/python/src/v2.0/tsl/ThermalNeutronScatteringLaw_incoherentInelastic.python.cpp new file mode 100644 index 000000000..01fe70507 --- /dev/null +++ b/python/src/v2.0/tsl/ThermalNeutronScatteringLaw_incoherentInelastic.python.cpp @@ -0,0 +1,91 @@ + +// THIS FILE WAS AUTOGENERATED! +// DO NOT MODIFY! + +// system includes +#include +#include + +// local includes +#include "GNDStk/v2.0/tsl/ThermalNeutronScatteringLaw_incoherentInelastic.hpp" +#include "definitions.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace python_v2_0 { +namespace python_tsl { + +// ThermalNeutronScatteringLaw_incoherentInelastic wrapper +void wrapThermalNeutronScatteringLaw_incoherentInelastic(python::module &module) +{ + using namespace njoy::GNDStk; + using namespace njoy::GNDStk::v2_0; + + // type aliases + using Component = tsl::ThermalNeutronScatteringLaw_incoherentInelastic; + + // create the component + python::class_ component( + module, + "ThermalNeutronScatteringLaw_incoherentInelastic", + Component::documentation().data() + ); + + // wrap the component + component + .def( + python::init< + const std::optional &, + const XMLName &, + const XMLName &, + const XMLName &, + const enums::Frame &, + const tsl::ScatteringAtoms & + >(), + python::arg("incoherent_approximation") = std::nullopt, + python::arg("label"), + python::arg("pid"), + python::arg("primary_scatterer"), + python::arg("product_frame"), + python::arg("scattering_atoms"), + Component::documentation("constructor").data() + ) + .def_property_readonly( + "incoherent_approximation", + [](const Component &self) { return self.incoherentApproximation().value(); }, + Component::documentation("incoherent_approximation").data() + ) + .def_property_readonly( + "label", + &Component::label, + Component::documentation("label").data() + ) + .def_property_readonly( + "pid", + &Component::pid, + Component::documentation("pid").data() + ) + .def_property_readonly( + "primary_scatterer", + &Component::primaryScatterer, + Component::documentation("primary_scatterer").data() + ) + .def_property_readonly( + "product_frame", + &Component::productFrame, + Component::documentation("product_frame").data() + ) + .def_property_readonly( + "scattering_atoms", + python::overload_cast<>(&Component::scatteringAtoms), + Component::documentation("scattering_atoms").data() + ) + ; + + // add standard component definitions + addStandardComponentDefinitions< Component >( component ); +} + +} // namespace python_tsl +} // namespace python_v2_0 diff --git a/python/test/Test_GNDStk_BoundaryCondition.py b/python/test/Test_GNDStk_BoundaryCondition.py new file mode 100644 index 000000000..7e9467ba0 --- /dev/null +++ b/python/test/Test_GNDStk_BoundaryCondition.py @@ -0,0 +1,64 @@ +# standard imports +import unittest + +# third party imports + +# local imports +from GNDStk import BoundaryCondition + +class Test_GNDStk_BoundaryCondition( unittest.TestCase ) : + """Unit test for the BoundaryCondition enumerator.""" + + def test_component( self ) : + + value = BoundaryCondition.EliminateShiftFunction + + self.assertTrue( value == BoundaryCondition.EliminateShiftFunction ) + self.assertFalse( value == BoundaryCondition.NegativeOrbitalMomentum ) + self.assertFalse( value == BoundaryCondition.Brune ) + self.assertFalse( value == BoundaryCondition.Given ) + + self.assertFalse( value != BoundaryCondition.EliminateShiftFunction ) + self.assertTrue( value != BoundaryCondition.NegativeOrbitalMomentum ) + self.assertTrue( value != BoundaryCondition.Brune ) + self.assertTrue( value != BoundaryCondition.Given ) + + value = BoundaryCondition.NegativeOrbitalMomentum + + self.assertFalse( value == BoundaryCondition.EliminateShiftFunction ) + self.assertTrue( value == BoundaryCondition.NegativeOrbitalMomentum ) + self.assertFalse( value == BoundaryCondition.Brune ) + self.assertFalse( value == BoundaryCondition.Given ) + + self.assertTrue( value != BoundaryCondition.EliminateShiftFunction ) + self.assertFalse( value != BoundaryCondition.NegativeOrbitalMomentum ) + self.assertTrue( value != BoundaryCondition.Brune ) + self.assertTrue( value != BoundaryCondition.Given ) + + value = BoundaryCondition.Brune + + self.assertFalse( value == BoundaryCondition.EliminateShiftFunction ) + self.assertFalse( value == BoundaryCondition.NegativeOrbitalMomentum ) + self.assertTrue( value == BoundaryCondition.Brune ) + self.assertFalse( value == BoundaryCondition.Given ) + + self.assertTrue( value != BoundaryCondition.EliminateShiftFunction ) + self.assertTrue( value != BoundaryCondition.NegativeOrbitalMomentum ) + self.assertFalse( value != BoundaryCondition.Brune ) + self.assertTrue( value != BoundaryCondition.Given ) + + value = BoundaryCondition.Given + + self.assertFalse( value == BoundaryCondition.EliminateShiftFunction ) + self.assertFalse( value == BoundaryCondition.NegativeOrbitalMomentum ) + self.assertFalse( value == BoundaryCondition.Brune ) + self.assertTrue( value == BoundaryCondition.Given ) + + self.assertTrue( value != BoundaryCondition.EliminateShiftFunction ) + self.assertTrue( value != BoundaryCondition.NegativeOrbitalMomentum ) + self.assertTrue( value != BoundaryCondition.Brune ) + self.assertFalse( value != BoundaryCondition.Given ) + +if __name__ == '__main__' : + + unittest.main() diff --git a/python/test/Test_GNDStk_GridStyle.pyc b/python/test/Test_GNDStk_GridStyle.pyc new file mode 100644 index 000000000..e5734f548 Binary files /dev/null and b/python/test/Test_GNDStk_GridStyle.pyc differ diff --git a/python/test/Test_GNDStk_Interpolation.pyc b/python/test/Test_GNDStk_Interpolation.pyc new file mode 100644 index 000000000..feefb9231 Binary files /dev/null and b/python/test/Test_GNDStk_Interpolation.pyc differ diff --git a/python/test/__init__.pyc b/python/test/__init__.pyc new file mode 100644 index 000000000..b65ba59b5 Binary files /dev/null and b/python/test/__init__.pyc differ diff --git a/python/test/core/Test_GNDStk_core_Node.pyc b/python/test/core/Test_GNDStk_core_Node.pyc new file mode 100644 index 000000000..e48dd2c5e Binary files /dev/null and b/python/test/core/Test_GNDStk_core_Node.pyc differ diff --git a/python/test/core/__init__.pyc b/python/test/core/__init__.pyc new file mode 100644 index 000000000..f09dbaae2 Binary files /dev/null and b/python/test/core/__init__.pyc differ diff --git a/src/GNDStk.hpp b/src/GNDStk.hpp index c665be5ae..1214b7bb4 100644 --- a/src/GNDStk.hpp +++ b/src/GNDStk.hpp @@ -6,9 +6,20 @@ // External libraries // ------------------------ +// To circumvent errors in other libraries +#include +#undef CHAR_WIDTH + #include "pugixml.hpp" #include "nlohmann/json.hpp" #include "Log.hpp" +#include +#include + +// OpenMP +#ifdef _OPENMP +#include +#endif // ------------------------ @@ -26,6 +37,8 @@ #include #include #include +#include +#include #include #include #include @@ -55,90 +68,49 @@ namespace njoy { namespace GNDStk { -// basic +// Basic #include "GNDStk/utility.hpp" #include "GNDStk/precision.hpp" #include "GNDStk/enums.hpp" -// external-library wrappers +// External-library wrappers #include "GNDStk/XML.hpp" #include "GNDStk/JSON.hpp" +#include "GNDStk/HDF5.hpp" -// string/Node to/from type +// std::string/Node to/from type #include "GNDStk/string2type.hpp" #include "GNDStk/type2string.hpp" // Meta, Child, and related -#include "GNDStk/convert_t.hpp" #include "GNDStk/Meta.hpp" #include "GNDStk/Child.hpp" -#include "GNDStk/keyword.hpp" #include "GNDStk/or.hpp" -// optional, with default +// Like std::optional, but with a default #include "GNDStk/Defaulted.hpp" -// sets of Meta/Child -#include "GNDStk/basic.hpp" -#include "GNDStk/misc.hpp" - -// Tree: primary constructs +// Main classes #include "GNDStk/Node.hpp" #include "GNDStk/Tree.hpp" -// fixme This really belongs with basic.hpp and misc.hpp above, but I had to -// move it here due to some ordering issues that arose when I de-templated -// Node and Tree. We'll deal with this later; it's an internal issue, not -// something that will affect users in any manner. -#include "GNDStk/common.hpp" - // Node to/from type #include "GNDStk/node2type.hpp" #include "GNDStk/type2node.hpp" -// xml/json/tree conversions +// Node/XML/JSON/HDF5 conversions #include "GNDStk/convert.hpp" -// fixme See above fixme -namespace basic { using namespace common; } -namespace misc { using namespace common; } - // Miscellaneous support constructs for Standard Interface classes #include "GNDStk/Support.hpp" +#include "GNDStk/Lookup.hpp" // Base classes for primary Standard Interface data classes -#include "GNDStk/BodyText.hpp" +#include "GNDStk/BlockData.hpp" #include "GNDStk/Component.hpp" - -// ------------------------ -// GNDStk "core interface" -// ------------------------ - -/* -In a user code, writing this: - - using namespace njoy::GNDStk::core; - -gives the same effect as writing this: - - using namespace njoy::GNDStk; - using namespace njoy::GNDStk::basic; - -Meaning: We consider our "core interface" to consist of everything in GNDStk:: -proper, plus our basic:: set of Meta and Child objects. Those are the ones with - type, so that they return metadata and nodes in their original tree form. -Note that basic:: itself brings in Meta and Child objects from its own nested -meta:: and child:: namespaces. Those are separate because there's a small amount -of overlap between allowable GNDS metadatum names and node names. With this -scheme, if a name you wish to use isn't one of the overlapping names, just use -it. If it is, then prefix with meta:: or child:: as necessary. -*/ - -namespace core { - using namespace GNDStk; - using namespace basic; -} +// Helper constructs for C language interfaces +#include "GNDStk/CInterface.hpp" } // namespace GNDStk } // namespace njoy diff --git a/src/GNDStk/BlockData.hpp b/src/GNDStk/BlockData.hpp new file mode 100644 index 000000000..2e4bfe3e6 --- /dev/null +++ b/src/GNDStk/BlockData.hpp @@ -0,0 +1,159 @@ + +// Printing-related colors. +// todo Eventually, this probably belongs in a more context-agnostic +// location, such as GNDStk's utility.hpp file or something like it. +#include "GNDStk/BlockData/src/colors.hpp" + +// Miscellaneous helper constructs. +#include "GNDStk/BlockData/src/detail.hpp" + + +// ----------------------------------------------------------------------------- +// BlockData +// The case is specialized and has the fun stuff. This one needs +// just a bit of content, in order to facilitate uniform treatment of BlockData. +// ----------------------------------------------------------------------------- + +template +class BlockData { +public: + using VariantOfVectors = std::variant; + using VariantOfScalars = std::variant; + static inline constexpr bool runtime = false; + template + static inline constexpr bool supported = false; +}; + + +// ----------------------------------------------------------------------------- +// BlockData +// +// Designed to be flexible, smart, and safe. Does lots of checks, and, for the +// DATATYPE == void case, can essentially re-form itself depending on what type +// of data someone tries to extract. +// +// For efficiency in the DATATYPE == void case, an application may want to copy +// to its own vector (e.g. auto myvec = myblockdata.get>()) +// in order to do work on (or with) the vector there, before copying it back. +// ----------------------------------------------------------------------------- + +template +class BlockData { +public: + + #include "GNDStk/BlockData/src/types.hpp" + + // For convenience in various SFINAE and if-constexpr constructs + static inline constexpr bool runtime = detail::isVoid; + template + struct is_supported { + static inline constexpr bool value = + ( runtime && detail::isAlternative) || + (!runtime && ( + std::is_constructible_v || + std::is_convertible_v + )); + }; + template + static inline constexpr bool supported = is_supported::value; + + enum class Active { string, vector }; + +private: + + // For internal use + mutable Active act = Active::string; + + // Raw string, directly from "plain character data" in a GNDS file. + // We'll allow callers to set this by using a setter. + std::string rawstring; + + // Vector of . + // *** This will be used if, and only if, DATATYPE == void. + // Mutable, so that we can defer processing of the raw string into + // a vector until, and unless, a caller *asks* for the vector. + mutable VariantOfVectors variant; + + // Vector of + // *** This will be used if, and only if, DATATYPE != void. + // data_t is used in a few places where, without it, we'd create compilation + // errors by using "void" in invalid ways. The "int" below is arbitrary - + // basically a placeholder - because the following is used only if !runtime. + using data_t = std::conditional_t; + mutable std::vector vector; + +public: + + // Parameters that affect interpretation of the raw string: + // struct vars { length, start, valueType } + // Includes public getters and setters for those. + // We won't use valueType if DATATYPE != void. + #include "GNDStk/BlockData/src/params.hpp" + + // trim + // Flag: should the conversion of BlockData data back into textual data, + // in a Node, trim zeros from the start and end of the output? + mutable bool trim = true; + + // Getters and setters for the raw string: + #include "GNDStk/BlockData/src/string.hpp" + + // active() + Active active() const { return act; } + + // clear() + // Clears the vector, or the active vector alternative in the variant. + BlockData &clear() + { + if constexpr (runtime) + std::visit([](auto &&alt) { alt.clear(); }, variant); + else + vector.clear(); + + act = Active::vector; + return *this; + } + + // size() + // Returns the size of the vector, or of the active vector alternative in + // the variant. Depending on what someone may or may not have done with the + // current BlockData object, size() might or might not reflect the values of + // length and/or start, or reflect the current contents of the raw string. + std::size_t size() const + { + if constexpr (runtime) + return std::visit([](auto &&alt) { return alt.size(); }, variant); + else + return vector.size(); + } + + // Various vector get() functions, and the type-specific doubles() etc. + #include "GNDStk/BlockData/src/get.hpp" + + // Read/write data, from/to a Node + #include "GNDStk/BlockData/src/fromNode.hpp" + #include "GNDStk/BlockData/src/toNode.hpp" + + // Print to ostream + #include "GNDStk/BlockData/src/print.hpp" + + // Pull/push length/start/valueType from/to derived-class struct Content + #include "GNDStk/BlockData/src/sync.hpp" + + // Assignment + // From string or vector; the former == calling our raw string setter + #include "GNDStk/BlockData/src/assign.hpp" + + // Conversion to vector + // *** Available if, and only if, DATATYPE != void. + template< + class T = DATATYPE, + class = std::enable_if_t> + > + operator std::vector() const + { + // get(), not vector; get() handles properly if the string is active + return get(); + } + +}; // class BlockData diff --git a/src/GNDStk/BlockData/src/assign.hpp b/src/GNDStk/BlockData/src/assign.hpp new file mode 100644 index 000000000..c809b3a80 --- /dev/null +++ b/src/GNDStk/BlockData/src/assign.hpp @@ -0,0 +1,75 @@ + +// ----------------------------------------------------------------------------- +// Assignment from string +// Same effect as the string(new string) setter +// ----------------------------------------------------------------------------- + +BlockData &operator=(const std::string &str) +{ + return string(str); +} + + +// ----------------------------------------------------------------------------- +// Assignment from vector +// ----------------------------------------------------------------------------- + +/* +DISCUSSION + +Elsewhere, a BlockData object can be made from a GNDS node. From GNDS, we get +a text string (copied to the rawstring field), from which a vector of values +can be created on an as-needed basis. A GNDS node might also give us any of +length, start, and valueType, which, when pulling data from the Node, we'll +use if they're there, or otherwise assume to be our defaults. + +Here, we're allowing for an assignment BlockData = vector. For this assignment, +the caller should send the full, complete vector of values that's appropriate +for the GNDS Node whose data this BlockData object is intended to represent. + +Specifically: the vector should contain whatever leading and/or trailing 0s +the full data vector is supposed to have. The length and start values are +completely ignored by this function; they're neither used nor set. Future +vector accesses though our various get() functions simply access the vector +exactly as-is. Length and start won't come into play until - and unless - a +caller uses the string setter (or assignment to string) and subsequently +triggers a remake of the vector. (Which would then be a newly-created vector, +based on the value of the raw string - not the vector from which we're +assigning here.) + +As for valueType, this function attempts to guess it from the vector's element +type, and sets it to "", the empty string, if we don't recognize that type. + +If a vector that's assigned from, here, is still in play when this BlockData's +data are written to a Node (see the toNode() function), then toNode() will +recompute length and start automatically, based on the vector's beginning and +ending content, if the "trim" flag is set. See toNode() for more information. +*/ + +template +std::enable_if_t, BlockData &> +operator=(const std::vector &vec) +{ + // set the raw string to "", because it's no longer considered meaningful + rawstring = ""; + + // length, start, valueType + length(vec.size()); + start(0); + valueType(detail::Type2Names::value[0]); + + // assign vector + if constexpr (runtime) + variant = vec; + else if constexpr (std::is_same_v) + vector = vec; + else { + vector.clear(); + vector.reserve(vec.size()); + for (const T &element : vec) + vector.push_back(DATATYPE(element)); + } + + act = Active::vector; + return *this; +} diff --git a/src/GNDStk/BodyText/src/colors.hpp b/src/GNDStk/BlockData/src/colors.hpp similarity index 98% rename from src/GNDStk/BodyText/src/colors.hpp rename to src/GNDStk/BlockData/src/colors.hpp index f8850fde7..0f0c0affb 100644 --- a/src/GNDStk/BodyText/src/colors.hpp +++ b/src/GNDStk/BlockData/src/colors.hpp @@ -80,7 +80,7 @@ inline std::string bracket = plain::yellow; inline std::string optional = plain::cyan; inline std::string defaulted = plain::blue; -// Values in nodes with "body text" +// Values in nodes with block data inline std::string value = plain::white; // Comments diff --git a/src/GNDStk/BlockData/src/detail.hpp b/src/GNDStk/BlockData/src/detail.hpp new file mode 100644 index 000000000..feceb4ab9 --- /dev/null +++ b/src/GNDStk/BlockData/src/detail.hpp @@ -0,0 +1,167 @@ + +namespace detail { + +// ----------------------------------------------------------------------------- +// Miscellaneous +// ----------------------------------------------------------------------------- + +// scalarize +template +auto scalarize(const std::variant) +{ + return std::variant{}; +} + + +// ----------------------------------------------------------------------------- +// SFINAE constructs for detecting whether or not a class has certain members. +// Adapted from an answer here: https://stackoverflow.com/questions/1005476 +// ----------------------------------------------------------------------------- + +// ------------------------ +// has_index +// ------------------------ + +template +struct has_index + : std::false_type { }; + +template +struct has_index< + T, + decltype( + (void) + // Just using T{}.index() on the next line, like we do with other has_* + // classes above, can lead to an ambiguity between this specialization + // and the std::variant specialization below, arising from the fact that + // std::variant has an index() function. Hence the std::conditional_t. + std::conditional_t::value,void,T>{}.index(), + 0 + ) +> + : std::true_type { }; + +// for variant +template +struct has_index> { + // does any alternative have index? + static constexpr bool value = (has_index::value || ...); +}; + +// ------------------------ +// has_label +// ------------------------ + +template +struct has_label + : std::false_type { }; + +template +struct has_label< + T, + // std::variant doesn't have a label(), like it has an index(), but we'll + // do the same thing here, for has_label, as we do above for has_index. + // It's harmless, and if std::variant is ever given a label() function... + decltype((void)std::conditional_t::value,void,T>{}.label(),0) +> + : std::true_type { }; + +// for variant +template +struct has_label> { + // for variant: does any alternative have label? + static constexpr bool value = (has_label::value || ...); +}; + +// ------------------------ +// Prefer these. +// They apply std::decay, +// and don't need ::value +// ------------------------ + +template +inline constexpr bool hasIndex = has_index>::value; +template +inline constexpr bool hasLabel = has_label>::value; + + +// ----------------------------------------------------------------------------- +// element2element +// ----------------------------------------------------------------------------- + +// Remark: PrecisionContext::data, not PrecisionContext::metadata, is the right +// precision context (in terms of our functionality for handling floating-point +// precision) in the code for which element2element() is called. We could bypass +// element2element() entirely, using convert_t{}(...) instead, except that then +// PrecisionContext::metadata would ultimately get used for floating-point T. +// So, below, we recognize floating-point T directly, and handle it correctly. + +// string ==> arithmetic +template>> +void element2element(const std::string &str, T &value) +{ + if constexpr (std::is_floating_point_v) + value = Precision{}.read(str); + else + convert_t{}(str,value); +} + +// arithmetic ==> arithmetic +template +void element2element(const FROM &from, TO &to) +{ + convert_t{}(from,to); +} + +// arithmetic ==> string +template>> +void element2element(const T &value, std::string &str) +{ + if constexpr (std::is_floating_point_v) + str = Precision{}.write(value); + else + convert_t{}(value,str); +} + + +// ----------------------------------------------------------------------------- +// getBounds +// ----------------------------------------------------------------------------- + +template +auto getBounds(const std::vector &vec) +{ + T zero; + if constexpr (std::is_same_v) zero = ""; else zero = T(0); + std::pair bnd(0,vec.size()); + while (bnd.first < bnd.second && vec[bnd.first ] == zero) ++bnd.first; + while (bnd.first < bnd.second && vec[bnd.second-1] == zero) --bnd.second; + return bnd; +} + + +// ----------------------------------------------------------------------------- +// colorize_*(text) +// ----------------------------------------------------------------------------- + +#define gndstkPaste(one,two) one ## two +#define gndstkColorFun(part) \ + inline std::string gndstkPaste(colorize_,part)(const std::string &text) \ + { \ + return GNDStk::color && colors::part != "" \ + ? colors::part + text + colors::reset \ + : text; \ + } + + // colorize_label() etc. + gndstkColorFun(label) + gndstkColorFun(colon) + gndstkColorFun(component) + gndstkColorFun(brace) + gndstkColorFun(bracket) + gndstkColorFun(comment) + +#undef gndstkColorFun +#undef gndstkPaste + +} // namespace detail diff --git a/src/GNDStk/BlockData/src/fromNode.hpp b/src/GNDStk/BlockData/src/fromNode.hpp new file mode 100644 index 000000000..fda3eb93e --- /dev/null +++ b/src/GNDStk/BlockData/src/fromNode.hpp @@ -0,0 +1,40 @@ + +// ----------------------------------------------------------------------------- +// BlockData::fromNode(Node) +// ----------------------------------------------------------------------------- + +void fromNode(const Node &node) +{ + // length, start, and valueType might be present in the Node, but we won't + // fetch any of them here. Elsewhere, the current BlockData object should + // have had its length, start, and valueType pulled from those respective + // values in an object of a class derived from Component, which in turn + // derived from BlockData. That object's content will have been pulled from + // the same Node. Here, we just get the Node's values: plain character data, + // in XML terminology. + + bool found = false; + rawstring = node.pcdata(found); + + if (!found) { + rawstring = ""; + + // Warning, re: why are we in BlockData if there's no block + // data? Perhaps the Node has a non-default length and/or start, so that + // the values are all supposed to be...zero. Until and unless we discover + // otherwise, however, we doubt that that would be the case, and will + // consider a Node's lack of plain character data, in the present context, + // to be something that merits a warning. + log::warning( + "Component marked as having block data, a.k.a. XML \"pcdata\" " + "(plain\ncharacter data), " + "but no such content was found in the GNDS node." + ); + log::member("BlockData::fromNode(Node, with name \"{}\")", node.name); + } + + // Above, we set the raw string. The following reflects this, so that the + // vector, or a vector in the variant, will be rebuilt from the raw string + // if and when a caller asks for it. + act = Active::string; +} diff --git a/src/GNDStk/BodyText/src/get.hpp b/src/GNDStk/BlockData/src/get.hpp similarity index 77% rename from src/GNDStk/BodyText/src/get.hpp rename to src/GNDStk/BlockData/src/get.hpp index c2ff03d81..474b456e4 100644 --- a/src/GNDStk/BodyText/src/get.hpp +++ b/src/GNDStk/BlockData/src/get.hpp @@ -5,7 +5,7 @@ /* ------------------------ -When DATA == void +When DATATYPE == void ------------------------ Case 1 @@ -42,28 +42,28 @@ Type-specific getters with specific names: For example, name == doubles when T == double. ------------------------ -When DATA != void +When DATATYPE != void ------------------------ Case 1 Return reference to [const] vector: get> const get> -T must == DATA. +T must == DATATYPE. Case 2 Return reference to [const] T: get(n) const get(n) -T must == DATA. +T must == DATATYPE. Case 3 -Return reference to [const] vector +Return reference to [const] vector get() const get() Case 4 -Return reference to [const] DATA: +Return reference to [const] DATATYPE: get(n) const operator[](n) const get(n) @@ -71,13 +71,14 @@ Return reference to [const] DATA: Case 5 Type-specific getters with a specific name: - const std::vector &name() const - std::vector &name() - const DATA &name(n) const - DATA &name(n) -For example, name == doubles if DATA == double. Unlike in the DATA == void case, -we won't have this set of functions for each of name == doubles, name == ints, -name == strings, etc., but only for the name that's appropriate for type DATA. + const std::vector &name() const + std::vector &name() + const DATATYPE &name(n) const + DATATYPE &name(n) +For example, name == doubles if DATATYPE == double. Unlike in the DATATYPE == +void case, we won't have this set of functions for each of name == doubles, +name == ints, name == strings, etc., but only for the name that's appropriate +for type DATATYPE. */ @@ -107,7 +108,7 @@ If active == vector: If the variant already contains a vector: Return it; we're done. - *** Under the correct and normal use of BodyText, *** + *** Under the correct and normal use of BlockData, *** *** this simple action will probably be the most common. *** Else: @@ -117,7 +118,7 @@ If active == vector: In the active == vector case, length, start, and valueType aren't considered to be relevant, and play no role. We consider those values to be meaningful -ONLY in relation to BodyText's raw string, and we deal with them here only +ONLY in relation to BlockData's raw string, and we deal with them here only if and when we make the vector from the raw string. That way, callers can access, manipulate, and even completely change the @@ -144,7 +145,7 @@ vector in the variant. Note that because the variant was declared to be mutable, we were indeed able to rebuild the vector if doing so was necessary. But we'll still return a *const* reference in that case, because the present object is conceptually const, and a caller shouldn't therefore be allowed to -modify the vector outside of BodyText's machinery. +modify the vector outside of BlockData's machinery. Of course we also have a non-const version, for a non-const *this. */ @@ -154,7 +155,7 @@ Of course we also have a non-const version, for a non-const *this. template std::enable_if_t< ( runtime && detail::isAlternative) || - (!runtime && std::is_same_v>), + (!runtime && std::is_same_v>), const VECTOR & > get() const { @@ -168,7 +169,7 @@ std::enable_if_t< if (active() == Active::string) { static const std::string context_rebuilding = - "BodyText::get>(), remade from raw string"; + "BlockData::get>(), remade from raw string"; // Completely rebuild the vector from the raw string, making use of // length, start, and valueType. @@ -177,7 +178,7 @@ std::enable_if_t< // We'll print a warning if that vector type appears to conflict with // valueType. Regardless, we'll return what the caller requested. Note // that valueType == "" is acceptable with any element type. - if (valueType() != "" && !detail::MapTypeString::find(valueType())) { + if (valueType() != "" && !detail::Type2Names::find(valueType())) { log::warning( "Vector element type may be inconsistent with valueType \"{}\";\n" "we'll create the requested std::vector<> anyway", @@ -197,21 +198,23 @@ std::enable_if_t< } T zero; - if constexpr (std::is_same_v) zero = ""; else zero = T(0); + if constexpr (std::is_same_v) + zero = ""; + else + zero = T(0); // [*****----------]: leading 0s for (std::size_t i = 0; i < start(); ++i) to->push_back(zero); // [-----*****-----]: values from the raw string - std::istringstream iss(rawstring); if constexpr (std::is_floating_point_v) { - std::string str; - while (iss >> str) - to->push_back( - detail::Precision{}.read(str) - ); + // Below, the "false" means "don't clear the vector." We need that + // here, because leading 0s from the earlier loop might be present. + detail::Precision{}. + read(rawstring,*to,false); } else { + std::istringstream iss(rawstring); T element; while (iss >> element) to->push_back(element); @@ -261,8 +264,8 @@ std::enable_if_t< // and a call get>() was made, meaning that the caller // wants a vector. // - // BodyText is intended to store just one vector - one that represents - // values in a GNDS node that has "body text." We don't, and shouldn't, + // BlockData is intended to store just one vector - one that represents + // values in a GNDS node that has block data. We don't, and shouldn't, // try to juggle multiple vectors of different types. Therefore, we'll // attempt to convert the existing vector to one of the requested type, // then place the new vector into the variant (replacing the old one.) @@ -274,7 +277,7 @@ std::enable_if_t< log::info( "Re-forming vector of one type into vector of another type;\n" "was this intentional?"); - log::member("BodyText::get>()"); + log::member("BlockData::get>()"); // Initialize a new vector that will soon replace the old one VECTOR newVector; @@ -308,7 +311,7 @@ std::enable_if_t< template std::enable_if_t< ( runtime && detail::isAlternative) || - (!runtime && std::is_same_v>), + (!runtime && std::is_same_v>), VECTOR & > get() { @@ -321,18 +324,19 @@ std::enable_if_t< // 2. get(n) // ----------------------------------------------------------------------------- -// For DATA == void (so that we have a variants>): +// For DATATYPE == void (so that we have a variants>): // These trigger a complete rebuild of the vector, if it isn't already of type // vector for the given T. This is intentional, in order to provide maximum // flexibility. However, be aware of it, for the sake of efficiency! In general, -// when using a BodyText object, we recommend sticking with one underlying type. +// when using a BlockData object, we recommend sticking with one underlying +// type, not dynamically changing from one type to another. -// For DATA != void (so that we have a vector): -// T == DATA is required, so that returning an element of the vector will -// return a reference to T. (A constructibility/convertibility requirement that -// we have in other BodyText-related code thus needs to be more stringent here. -// We can't just be able to make a T from a DATA. Those must in fact be the same -// type, because we return a reference.) +// For DATATYPE != void (so that we have a vector): +// T == DATATYPE is required, so that returning an element of the +// vector will return a reference to T. (A constructibility/ +// convertibility requirement that we have in other BlockData-related code thus +// needs to be more stringent here. We can't just be able to make a T from a +// DATATYPE. They must in fact be the same type, because we return a reference.) // For both of the above cases: // If the string (not the variant or the vector) is active, then a rebuild from @@ -341,7 +345,7 @@ std::enable_if_t< // const template std::enable_if_t< - supported && (runtime || std::is_same_v), + supported && (runtime || std::is_same_v), const T & > get(const std::size_t n) const @@ -349,7 +353,7 @@ get(const std::size_t n) const try { return get>()[n]; } catch (...) { - log::member("BodyText::get({})", n); + log::member("BlockData::get({})", n); throw; } } @@ -357,7 +361,7 @@ get(const std::size_t n) const // non-const template std::enable_if_t< - supported && (runtime || std::is_same_v), + supported && (runtime || std::is_same_v), T & > get(const std::size_t n) @@ -369,29 +373,33 @@ get(const std::size_t n) // ----------------------------------------------------------------------------- // 3. get() -// If DATA == void, returns a variants>. -// If DATA != void, returns a vector<>. +// If DATATYPE == void, returns a variants>. +// If DATATYPE != void, returns a vector<>. // ----------------------------------------------------------------------------- // const std::conditional_t< runtime, const VariantOfVectors &, - const std::vector & + const std::vector & > get() const { if constexpr (runtime) { - detail::MapStringType( + detail::Names2Type( valueType(), - [this](auto &&t) { get>>(); } + [this](auto &&t) + { + // clang seems to need this-> explicitly to *not* emit a warning + this->get>>(); + } ); // We can't return the specific variant alternative that was just put - // in place; it depended on a run-time check. So, we return the whole + // in place; it depended on a run-time check. So, we return the entire // variant, for whatever use that might have to a caller. return variant; } else { // Simpler, but we do still need a get (in case the *string* is active). - get>(); + get>(); return vector; } } @@ -400,14 +408,14 @@ std::conditional_t< std::conditional_t< runtime, VariantOfVectors &, - std::vector & + std::vector & > get() { return const_cast< std::conditional_t< runtime, VariantOfVectors &, - std::vector & + std::vector & > >(std::as_const(*this).get()); } @@ -417,11 +425,11 @@ std::conditional_t< // ----------------------------------------------------------------------------- // 4. get(n) // -// If DATA == void, returns a variant (by value, because the returned -// object must be made on-the-fly from our variants>). +// If DATATYPE == void, returns a variant (by value, because the +// returned object must be made on-the-fly from our variants>). // -// If DATA != void, returns a scalar of type [const] DATA (by reference, because -// it's available directly in our vector). +// If DATATYPE != void, returns a scalar of type [const] DATATYPE (by reference, +// because it's available directly in our vector). // ----------------------------------------------------------------------------- // ------------------------ @@ -446,7 +454,7 @@ std::conditional_t< return vector[n]; } } catch (...) { - log::member("BodyText::get({})", n); + log::member("BlockData::get({})", n); throw; } } @@ -466,24 +474,24 @@ std::conditional_t< // non-const // ------------------------ -// If DATA == void: +// If DATATYPE == void: // Not needed, because the const versions return by value. // -// If DATA != void: -// Meaningful, because returns are by reference in this (DATA != void) case. +// If DATATYPE != void: +// Meaningful, because returns are by reference in this (DATATYPE != void) case. // So, we'll enable non-const versions for this case only. -// In case anyone wonders, D (not just DATA) is needed below because SFINAE -// applies when template argument *deduction* is taking place. DATA is already -// fixed, by context - we're in BodyText - and thus it isn't being -// deduced here. Templating these (otherwise non-template) functions with an -// argument that defaults to DATA, then using that argument in the SFINAE, is -// a simple trick that makes the SFINAE work as intended. As for VOID, it's -// necessary in order for the following to be unambiguous with the template -// versions of get(n) that are defined elsewhere in this file. +// In case anyone wonders, D (not just DATATYPE) is needed below because SFINAE +// applies when template argument *deduction* is taking place. DATATYPE is +// already fixed, by context - we're in BlockData - and thus it +// isn't being deduced here. Templating these (otherwise non-template) functions +// with an argument that defaults to DATATYPE, then using that argument in the +// SFINAE, is a simple trick that makes the SFINAE work as intended. As for +// VOID, it's necessary in order for the following to be unambiguous with the +// template versions of get(n) that are defined elsewhere in this file. // get(n) -template +template std::enable_if_t && !detail::isVoid, data_t &> get(const std::size_t n) { @@ -491,13 +499,13 @@ get(const std::size_t n) get(); return vector[n]; } catch (...) { - log::member("BodyText::get({})", n); + log::member("BlockData::get({})", n); throw; } } // operator[](n) -template +template std::enable_if_t, data_t &> operator[](const std::size_t n) { @@ -520,25 +528,25 @@ operator[](const std::size_t n) #define GNDSTK_MAKE_GETTER(name,TYPE) \ \ - template \ + template \ std::enable_if_t< \ detail::isVoid || \ std::is_same_v, const std::vector & \ > name() const { return get>(); } \ \ - template \ + template \ std::enable_if_t< \ detail::isVoid || \ std::is_same_v, std::vector & \ > name() { return get>(); } \ \ - template \ + template \ std::enable_if_t< \ detail::isVoid || \ std::is_same_v, const TYPE & \ > name(const std::size_t n) const { return get(n); } \ \ - template \ + template \ std::enable_if_t< \ detail::isVoid || \ std::is_same_v, TYPE & \ @@ -553,7 +561,7 @@ GNDSTK_MAKE_GETTER(longs, long) GNDSTK_MAKE_GETTER(longlongs, long long) GNDSTK_MAKE_GETTER(uchars, unsigned char) GNDSTK_MAKE_GETTER(ushorts, unsigned short) -GNDSTK_MAKE_GETTER(uints, unsigned int) +GNDSTK_MAKE_GETTER(uints, unsigned) GNDSTK_MAKE_GETTER(ulongs, unsigned long) GNDSTK_MAKE_GETTER(ulonglongs, unsigned long long) GNDSTK_MAKE_GETTER(floats, float) diff --git a/src/GNDStk/BodyText/src/params.hpp b/src/GNDStk/BlockData/src/params.hpp similarity index 76% rename from src/GNDStk/BodyText/src/params.hpp rename to src/GNDStk/BlockData/src/params.hpp index c545310f1..ad15c1534 100644 --- a/src/GNDStk/BodyText/src/params.hpp +++ b/src/GNDStk/BlockData/src/params.hpp @@ -12,7 +12,7 @@ Quoted [slightly edited] from the official JSON specification files for GNDS: values that are not stored. This attribute should only be used when the sum of start and the number of listed values do not add to the total number of data values. This should only happen when there are - trailing zeros not listed in the body text. + trailing zeros not listed in the block data. start Default: 0 @@ -31,37 +31,39 @@ our GNDS Standard Interface code autogeneration tool produces. private: -// toNode() works with a conceptually const object but may update these to be +// toNode() works with a conceptually const object, but may update these to be // consistent with vector data; so, mutable. -mutable struct { +struct { // Any of these might or might not have appeared in a particular node that - // had body text. For uniformity, we have them all here, and with defaults. - std::size_t length = 0; - std::size_t start = 0; - std::string valueType = ""; + // had block data. For uniformity, we have them all here, and with defaults. + mutable std::size_t length = 0; + mutable std::size_t start = 0; + mutable std::string valueType = ""; } vars; // ----------------------------------------------------------------------------- // Getters +// Note: we intentionally return by (non-const!) reference, because the values +// in question are mutable. // ----------------------------------------------------------------------------- public: // length -std::size_t length() const +std::size_t &length() const { return vars.length; } // start -std::size_t start() const +std::size_t &start() const { return vars.start; } // valueType -const std::string &valueType() const +std::string &valueType() const { return vars.valueType; } @@ -74,7 +76,7 @@ const std::string &valueType() const // ----------------------------------------------------------------------------- // length -BodyText &length(const std::optional &opt) +BlockData &length(const std::optional &opt) { if (opt.has_value()) vars.length = opt.value(); @@ -82,7 +84,7 @@ BodyText &length(const std::optional &opt) } // start -BodyText &start(const std::optional &opt) +BlockData &start(const std::optional &opt) { if (opt.has_value()) vars.start = opt.value(); @@ -90,7 +92,7 @@ BodyText &start(const std::optional &opt) } // valueType -BodyText &valueType(const std::optional &opt) +BlockData &valueType(const std::optional &opt) { if (opt.has_value()) vars.valueType = opt.value(); diff --git a/src/GNDStk/BlockData/src/print.hpp b/src/GNDStk/BlockData/src/print.hpp new file mode 100644 index 000000000..9a7eae7d6 --- /dev/null +++ b/src/GNDStk/BlockData/src/print.hpp @@ -0,0 +1,82 @@ + +// ----------------------------------------------------------------------------- +// print +// Used by Component's prettyprinting. +// ----------------------------------------------------------------------------- + +std::ostream &print(std::ostream &os, const int level) const +{ + // If empty, don't even print a newline + if ((active() == Active::string && rawstring == "") || + (active() == Active::vector && size() == 0)) + return os; + + // Coloring? + const bool coloring = GNDStk::color && GNDStk::colors::value != ""; + + // ------------------------ + // If string is active + // ------------------------ + + if (active() == Active::string) { + // Print the string exactly as-is, without our column formatting + // or any indentation; then also print a newline + return coloring + ? os << colors::value << rawstring << colors::reset << std::endl + : os << rawstring << std::endl; + } + + // ------------------------ + // If vector is active + // ------------------------ + + // Indentation (string, with some number of spaces) + const std::string indent(GNDStk::indent*level,' '); + + const auto printLambda = + [&os,&indent,coloring](auto &&alt) + { + using T = std::decay_t; + const std::size_t size = alt.size(); + const std::size_t end = (GNDStk::truncate < 0) + ? size + : std::min(size,std::size_t(GNDStk::truncate)); + + // Print, using our column formatting + for (std::size_t i = 0; i < end; ++i) { + const T &element = alt[i]; + + // value's whitespace prefix + i == 0 + ? os << indent // at the very beginning, or... + : GNDStk::columns <= 0 || + i % std::size_t(std::abs(GNDStk::columns)) != 0 + ? os << ' ' // still on the current line, or... + : os << '\n' << indent; // starting the next line + + // value + using namespace detail; + if (coloring) os << colors::value; + if constexpr (std::is_floating_point_v) + os << Precision{}.write(element); + else + os << element; + if (coloring) os << colors::reset; + }; + + // If applicable, print a message saying the data were truncated + if (end < size) { + if (end > 0) + os << '\n'; + os << indent << detail::colorize_comment( + "// truncated; total #values == " + std::to_string(size)); + } + }; + + if constexpr (runtime) + std::visit(printLambda,variant); + else + printLambda(vector); + + return os << std::endl; +} diff --git a/src/GNDStk/BlockData/src/string.hpp b/src/GNDStk/BlockData/src/string.hpp new file mode 100644 index 000000000..7b40d34e3 --- /dev/null +++ b/src/GNDStk/BlockData/src/string.hpp @@ -0,0 +1,25 @@ + +// ----------------------------------------------------------------------------- +// Getters and setters for the raw string +// ----------------------------------------------------------------------------- + +// getter +// string() +// Not to be confused with strings() (plural), which returns vector. +// Returns const &; the raw string can be *changed* only through the setter. +const std::string &string() const +{ + return rawstring; +} + +// setter +// string(new string) +// Builder pattern: return *this, so callers can use this function smoothly +// in conjunction with the setters for length, start, and valueType. +BlockData &string(const std::string &str) +{ + clear(); // <== the vector, because it's no longer considered meaningful + rawstring = str; + act = Active::string; + return *this; +} diff --git a/src/GNDStk/BlockData/src/sync.hpp b/src/GNDStk/BlockData/src/sync.hpp new file mode 100644 index 000000000..f73166935 --- /dev/null +++ b/src/GNDStk/BlockData/src/sync.hpp @@ -0,0 +1,22 @@ + +// pullFromDerived(derived) +// Make this BlockData's length, start, and valueType be consistent with any or +// all such parameters that exist in the given object. Remember that this class, +// BlockData, is a base of Component, which is a base of some other class. +template +void pullFromDerived(const DERIVED &derived) +{ + length (derived.length ()); + start (derived.start ()); + valueType(derived.valueType()); +} + +// pushToDerived(derived) +// The reverse of the above. +template +void pushToDerived(DERIVED &derived) const +{ + derived.length () = length (); + derived.start () = start (); + derived.valueType() = valueType(); +} diff --git a/src/GNDStk/BodyText/src/toNode.hpp b/src/GNDStk/BlockData/src/toNode.hpp similarity index 76% rename from src/GNDStk/BodyText/src/toNode.hpp rename to src/GNDStk/BlockData/src/toNode.hpp index 3f9dde5dc..7dd5d233a 100644 --- a/src/GNDStk/BodyText/src/toNode.hpp +++ b/src/GNDStk/BlockData/src/toNode.hpp @@ -1,17 +1,16 @@ // ----------------------------------------------------------------------------- -// BodyText::toNode +// BlockData::toNode // This is called by Component's conversion-to-Node (not toNode()) function. // It's "toNode()" here, not a conversion, because we're simply writing text // that Component's full conversion-to-Node will place into the Node itself. // ----------------------------------------------------------------------------- -// Use either (1) the original raw string, or (2) the variant of vectors or the -// vector (depending on DATA ==/!= void), based on whether or not the string -// is active. length, start, and valueType might be computed too, in which case -// they're also changed in the derived class in order to keep things consistent. -template -void toNode(std::string &text, DERIVED &derived) const +// Use either (1) the original raw string, or (2) either the variant of vectors +// or the vector (depending on DATATYPE ==/!= void), based on whether or not the +// raw string is active. If a vector (not the raw string) is active, then we'll +// also compute length, start, and valueType. +void toNode(std::string &text) const { // Use the raw string? if (active() == Active::string) { @@ -22,11 +21,11 @@ void toNode(std::string &text, DERIVED &derived) const // Use the vector... const bool isStringVector = ( runtime && std::holds_alternative>(variant)) || - (!runtime && std::is_same_v); + (!runtime && std::is_same_v); if constexpr ( runtime || - (!runtime && std::is_same_v) + (!runtime && std::is_same_v) ) { // the run-time if's get() calls below won't // necessarily make sense without the above if-constexpr @@ -36,7 +35,7 @@ void toNode(std::string &text, DERIVED &derived) const (get(0) == "" || get(size()-1) == "") ) { log::warning( - "BodyText.toNode() called with BodyText " + "BlockData.toNode() called with BlockData " "trim flag == false, but active\n" "data are in a vector. Printing " "leading/trailing empty strings\n" @@ -51,16 +50,15 @@ void toNode(std::string &text, DERIVED &derived) const ? runtime ? std::visit([](auto &&vec) { return detail::getBounds(vec); }, variant) : detail::getBounds(vector) - : std::make_pair(size_t(0),size()); + : std::make_pair(std::size_t(0),size()); // Compute length, start, and valueType vars.length = size(); // independent of trim vars.start = bounds.first; // dependent on trim, per the bounds computation if constexpr (runtime) - vars.valueType = detail::visitMapTypeString(variant); + vars.valueType = detail::visitType2Names(variant); else - vars.valueType = detail::MapTypeString::value[0]; - pushToDerived(derived); + vars.valueType = detail::Type2Names::value[0]; // Values std::ostringstream oss; diff --git a/src/GNDStk/BodyText/src/types.hpp b/src/GNDStk/BlockData/src/types.hpp similarity index 96% rename from src/GNDStk/BodyText/src/types.hpp rename to src/GNDStk/BlockData/src/types.hpp index 3eca8c0e1..46f7c3502 100644 --- a/src/GNDStk/BodyText/src/types.hpp +++ b/src/GNDStk/BlockData/src/types.hpp @@ -21,7 +21,7 @@ using VariantOfVectors = std::variant< // unsigned integrals std::vector, std::vector, - std::vector, + std::vector, std::vector, std::vector, diff --git a/src/GNDStk/BlockData/test/BlockData.test.cpp b/src/GNDStk/BlockData/test/BlockData.test.cpp new file mode 100644 index 000000000..ab5c35d60 --- /dev/null +++ b/src/GNDStk/BlockData/test/BlockData.test.cpp @@ -0,0 +1,192 @@ + +#define CATCH_CONFIG_MAIN + +#include "catch.hpp" +#include "GNDStk.hpp" + +using namespace njoy::GNDStk; + + +// ----------------------------------------------------------------------------- +// Scenario for DATATYPE == void +// ----------------------------------------------------------------------------- + +SCENARIO("Testing GNDStk BlockData with DATATYPE == void") { + // Most BlockData functionality is tested in the individual test files. + // There are just a few things we'll do here. + + // Ensure that we can make const and non-const and BlockData + // objects. Note that BlockData has only a default constructor. + + GIVEN("A const BlockData cbtextt") { + const BlockData cbtextt; + THEN("It constructed correctly, and its data are as expected") { + CHECK(cbtextt.length () == 0); + CHECK(cbtextt.size () == 0); + CHECK(cbtextt.valueType() == ""); + CHECK(cbtextt.string () == ""); + } + } + + GIVEN("A const BlockData cbtextf") { + const BlockData cbtextf; + THEN("It constructed correctly") { + // no data for + } + } + + GIVEN("A non-const BlockData nbtextt") { + BlockData nbtextt; + THEN("It constructed correctly, and its data are as expected") { + CHECK(nbtextt.length () == 0); + CHECK(nbtextt.size () == 0); + CHECK(nbtextt.valueType() == ""); + CHECK(nbtextt.string () == ""); + } + } + + GIVEN("A non-const BlockData nbtextf") { + BlockData nbtextf; + THEN("It constructed correctly") { + // no data for + } + } + + // clear() and size() are defined (at the time of this writing) in the + // BlockData.hpp file itself, so we'll test them here. size() actually + // was used in various tests, and thus was indirectly tested elsewhere. + + GIVEN("A BlockData") { + // clear + WHEN("We test clear()") { + BlockData b; + + // try int + THEN("size() works correctly for vector") { + b = std::vector{1,2,3,4,5}; + CHECK(b.size() == 5); + b.clear(); + CHECK(b.size() == 0); + } + + // try double + THEN("size() works correctly for vector") { + b = std::vector{1.1, 2.2, 3.3, 4.4, 5.5}; + CHECK(b.size() == 5); + b.clear(); + CHECK(b.size() == 0); + } + + // try string + THEN("size() works correctly for vector") { + b = std::vector{"one","two","three","four","five"}; + CHECK(b.size() == 5); + b.clear(); + CHECK(b.size() == 0); + } + } + + // size + WHEN("We test size()") { + BlockData b; + + // try int + THEN("size() works correctly for vector") { + b = std::vector{1,2,3,4,5}; + CHECK(b.size() == 5); + b = std::vector{1}; + CHECK(b.size() == 1); + b = std::vector{}; + CHECK(b.size() == 0); + } + + // try double + THEN("size() works correctly for vector") { + b = std::vector{1.1, 2.2, 3.3, 4.4, 5.5}; + CHECK(b.size() == 5); + b = std::vector{1.1}; + CHECK(b.size() == 1); + b = std::vector{}; + CHECK(b.size() == 0); + } + + // try string + THEN("size() works correctly for vector") { + b = std::vector{"one","two","three","four","five"}; + CHECK(b.size() == 5); + b = std::vector{"one"}; + CHECK(b.size() == 1); + b = std::vector{}; + CHECK(b.size() == 0); + } + } + } +} // SCENARIO + + +// ----------------------------------------------------------------------------- +// Scenario for DATATYPE != void +// ----------------------------------------------------------------------------- + +SCENARIO("Testing GNDStk BlockData with DATATYPE != void") { + + GIVEN("A const BlockData cbtextt") { + const BlockData cbtextt; + THEN("It constructed correctly, and its data are as expected") { + CHECK(cbtextt.length () == 0); + CHECK(cbtextt.size () == 0); + CHECK(cbtextt.valueType() == ""); + CHECK(cbtextt.string () == ""); + } + } + + GIVEN("A const BlockData cbtextf") { + const BlockData cbtextf; + THEN("It constructed correctly") { + // no data for + } + } + + GIVEN("A non-const BlockData nbtextt") { + BlockData nbtextt; + THEN("It constructed correctly, and its data are as expected") { + CHECK(nbtextt.length () == 0); + CHECK(nbtextt.size () == 0); + CHECK(nbtextt.valueType() == ""); + CHECK(nbtextt.string () == ""); + } + } + + GIVEN("A non-const BlockData nbtextf") { + BlockData nbtextf; + THEN("It constructed correctly") { + // no data for + } + } + + GIVEN("A BlockData") { + // clear + WHEN("We test clear()") { + BlockData b; + THEN("size() works correctly") { + b = std::vector{1,2,3,4,5}; + CHECK(b.size() == 5); + b.clear(); + CHECK(b.size() == 0); + } + } + + // size + WHEN("We test size()") { + BlockData b; + THEN("size() works correctly") { + b = std::vector{"one","two","three","four","five"}; + CHECK(b.size() == 5); + b = std::vector{"one"}; + CHECK(b.size() == 1); + b = std::vector{}; + CHECK(b.size() == 0); + } + } + } +} // SCENARIO diff --git a/src/GNDStk/BlockData/test/CMakeLists.txt b/src/GNDStk/BlockData/test/CMakeLists.txt new file mode 100644 index 000000000..a240f071b --- /dev/null +++ b/src/GNDStk/BlockData/test/CMakeLists.txt @@ -0,0 +1,26 @@ + +add_executable( GNDStk.BlockData.test + BlockData.test.cpp + assign.test.cpp + convert.test.cpp + detail.test.cpp + fromNode.test.cpp + get.test.cpp + params.test.cpp + string.test.cpp + sync.test.cpp + toNode.test.cpp + types.test.cpp + print.test.cpp ) +target_compile_options( GNDStk.BlockData.test PRIVATE ${${PREFIX}_common_flags} +$<$:${${PREFIX}_strict_flags}>$<$: +${${PREFIX}_DEBUG_flags} +$<$:${${PREFIX}_coverage_flags}>> +$<$: +${${PREFIX}_RELEASE_flags} +$<$:${${PREFIX}_link_time_optimization_flags}> +$<$:${${PREFIX}_nonportable_optimization_flags}>> + +${CXX_appended_flags} ${GNDStk_appended_flags} ) +target_link_libraries( GNDStk.BlockData.test PUBLIC GNDStk ) +add_test( NAME GNDStk.BlockData COMMAND GNDStk.BlockData.test ) diff --git a/src/GNDStk/BodyText/test/assign.test.cpp b/src/GNDStk/BlockData/test/assign.test.cpp similarity index 88% rename from src/GNDStk/BodyText/test/assign.test.cpp rename to src/GNDStk/BlockData/test/assign.test.cpp index 7326ae81d..8da3e023f 100644 --- a/src/GNDStk/BodyText/test/assign.test.cpp +++ b/src/GNDStk/BlockData/test/assign.test.cpp @@ -2,20 +2,20 @@ #include "catch.hpp" #include "GNDStk.hpp" -using namespace njoy::GNDStk::core; +using namespace njoy::GNDStk; // ----------------------------------------------------------------------------- -// Scenario for DATA == void +// Scenario for DATATYPE == void // ----------------------------------------------------------------------------- -SCENARIO("BodyText assignment operators") { - GIVEN("A default-constructed BodyText object") { +SCENARIO("BlockData assignment operators") { + GIVEN("A default-constructed BlockData object") { // Default value of raw string is as expected WHEN("We examine the raw string") { THEN("It is as expected") { - BodyText b; + BlockData b; CHECK(b.string() == ""); } } @@ -23,7 +23,7 @@ SCENARIO("BodyText assignment operators") { // Assignment from string works WHEN("We assign from a string") { THEN("The raw string has the correct value, and vector size() == 0") { - BodyText b; + BlockData b; // to ensure it clears the vector below... b = std::vector(10); @@ -40,7 +40,7 @@ SCENARIO("BodyText assignment operators") { // Assignment from vector works WHEN("We assign from a vector") { THEN("The variant has the correct value, and raw string == \"\"") { - BodyText b; + BlockData b; // to ensure it clears the raw string etc. below... b = "foo bar"; @@ -70,7 +70,7 @@ SCENARIO("BodyText assignment operators") { // Assign from vector; should set valueType WHEN("We assign from a vector") { THEN("valueType is set correctly") { - BodyText b; + BlockData b; b.string("foo").valueType("unknown"); CHECK(b.valueType() == "unknown"); @@ -83,7 +83,7 @@ SCENARIO("BodyText assignment operators") { // Assign from vector; should set valueType WHEN("We assign from a vector") { THEN("valueType is set correctly") { - BodyText b; + BlockData b; b.string("foo").valueType("unknown"); CHECK(b.valueType() == "unknown"); @@ -96,7 +96,7 @@ SCENARIO("BodyText assignment operators") { // For now, non-{int,double} sets valueType == "" WHEN("We assign from a vector") { THEN("valueType is set correctly") { - BodyText b; + BlockData b; b.string("foo").valueType("unknown"); CHECK(b.valueType() == "unknown"); @@ -111,16 +111,16 @@ SCENARIO("BodyText assignment operators") { // ----------------------------------------------------------------------------- -// Scenario for DATA != void +// Scenario for DATATYPE != void // ----------------------------------------------------------------------------- -SCENARIO("BodyText assignment operators") { - GIVEN("A default-constructed BodyText object") { +SCENARIO("BlockData assignment operators") { + GIVEN("A default-constructed BlockData object") { // Default value of raw string is as expected WHEN("We examine the raw string") { THEN("It is as expected") { - BodyText b; + BlockData b; CHECK(b.string() == ""); } } @@ -128,7 +128,7 @@ SCENARIO("BodyText assignment operators") { // Assignment from string works WHEN("We assign from a string") { THEN("The raw string has the correct value, and vector size() == 0") { - BodyText b; + BlockData b; // to ensure it clears the vector below... b = std::vector(10); @@ -145,7 +145,7 @@ SCENARIO("BodyText assignment operators") { // Assignment from vector works WHEN("We assign from a vector") { THEN("The vector has the correct value, and raw string == \"\"") { - BodyText b; + BlockData b; // to ensure it clears the raw string etc. below... b = "foo bar"; @@ -175,7 +175,7 @@ SCENARIO("BodyText assignment operators") { // Assign from vector; should set valueType WHEN("We assign from a vector") { THEN("valueType is set correctly") { - BodyText b; + BlockData b; b.string("foo").valueType("unknown"); CHECK(b.valueType() == "unknown"); @@ -188,7 +188,7 @@ SCENARIO("BodyText assignment operators") { // Assign from vector; should set valueType WHEN("We assign from a vector") { THEN("valueType is set correctly") { - BodyText b; + BlockData b; b.string("foo").valueType("unknown"); CHECK(b.valueType() == "unknown"); @@ -201,7 +201,7 @@ SCENARIO("BodyText assignment operators") { // For now, non-{int,double} sets valueType == "" WHEN("We assign from a vector") { THEN("valueType is set correctly") { - BodyText b; + BlockData b; b.string("foo").valueType("unknown"); CHECK(b.valueType() == "unknown"); diff --git a/src/GNDStk/BlockData/test/convert.test.cpp b/src/GNDStk/BlockData/test/convert.test.cpp new file mode 100644 index 000000000..b41c3848c --- /dev/null +++ b/src/GNDStk/BlockData/test/convert.test.cpp @@ -0,0 +1,53 @@ + +#include "catch.hpp" +#include "GNDStk.hpp" + +using namespace njoy::GNDStk; + +SCENARIO("BlockData conversion to vector") { + GIVEN("A BlockData object") { + + { + using T = int; + BlockData b; + b.start(2).length(6).string("-12 34 -56"); + std::vector myVector = b; + CHECK(myVector.size() == 6); + CHECK(myVector[0] == 0); + CHECK(myVector[1] == 0); + CHECK(myVector[2] == -12); + CHECK(myVector[3] == 34); + CHECK(myVector[4] == -56); + CHECK(myVector[5] == 0); + } + + { + using T = double; + BlockData b; + b.start(2).length(6).string("1.2 3.4 5.6"); + std::vector myVector = b; + CHECK(myVector.size() == 6); + CHECK(myVector[0] == 0); + CHECK(myVector[1] == 0); + CHECK(myVector[2] == 1.2); + CHECK(myVector[3] == 3.4); + CHECK(myVector[4] == 5.6); + CHECK(myVector[5] == 0); + } + + { + using T = std::string; + BlockData b; + b.start(2).length(6).string("ab cd ef"); + std::vector myVector = b; + CHECK(myVector.size() == 6); + CHECK(myVector[0] == ""); + CHECK(myVector[1] == ""); + CHECK(myVector[2] == "ab"); + CHECK(myVector[3] == "cd"); + CHECK(myVector[4] == "ef"); + CHECK(myVector[5] == ""); + } + + } // GIVEN +} // SCENARIO diff --git a/src/GNDStk/BlockData/test/detail.test.cpp b/src/GNDStk/BlockData/test/detail.test.cpp new file mode 100644 index 000000000..1500ff506 --- /dev/null +++ b/src/GNDStk/BlockData/test/detail.test.cpp @@ -0,0 +1,286 @@ + +#include "catch.hpp" +#include "GNDStk.hpp" + +using namespace njoy::GNDStk; +inline std::string bar = "bar"; + +// ----------------------------------------------------------------------------- +// Scenario +// ----------------------------------------------------------------------------- + +SCENARIO("Testing various BlockData-related detail:: constructs") { + + // ------------------------ + // scalarize + // ------------------------ + + GIVEN("Some variants of vectors") { + using vc = std::variant< + std::vector + >; + using vci = std::variant< + std::vector, + std::vector + >; + using vcid = std::variant< + std::vector, + std::vector, + std::vector + >; + + // Double parenthesis are needed for the CHECK macro, + // because of the commas... + THEN("detail::scalarize() works correctly") { + CHECK(( + std::is_same_v< + decltype(detail::scalarize(vc{})), + std::variant + > + )); + CHECK(( + std::is_same_v< + decltype(detail::scalarize(vci{})), + std::variant + > + )); + CHECK(( + std::is_same_v< + decltype(detail::scalarize(vcid{})), + std::variant + > + )); + } + } // GIVEN + + + // ------------------------ + // element2element + // ------------------------ + + GIVEN("Testing detail::element2element") { + WHEN("We use element2element(from int, to string)") { + const int from = 123; + std::string to; + detail::element2element(from,to); + CHECK(to == "123"); + } + + WHEN("We use element2element(from double, to string)") { + const double from = 4.56; + std::string to; + detail::element2element(from,to); + CHECK(to == "4.56"); + } + + WHEN("We use element2element(from string, to int)") { + const std::string from = "987"; + int to; + detail::element2element(from,to); + CHECK(to == 987); + } + + WHEN("We use element2element(from string, to double)") { + const std::string from = "6.54"; + double to; + detail::element2element(from,to); + CHECK(Approx(to) == 6.54); + } + + WHEN("We use element2element(from int, to double)") { + const int from = 345; + double to; + detail::element2element(from,to); + CHECK(to == double(345)); + } + + WHEN("We use element2element(from double, to int)") { + const double from = 6.78; + int to; + detail::element2element(from,to); + CHECK(to == 6); + } + } + + + // ------------------------ + // getBounds + // ------------------------ + + GIVEN("Testing detail::getBounds") { + + // ------------------------ + // Various vectors + // ------------------------ + + WHEN("We try vectors of varying sizes") { + + THEN("Bounds are correct when size == 0") { + std::vector v = {}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 0); + CHECK(bounds.second == 0); + } + + THEN("Bounds are correct when size == 1, with a 0") { + std::vector v = {0}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 1); + CHECK(bounds.second == 1); + } + + THEN("Bounds are correct when size == 2, all 0") { + std::vector v = {0, 0}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 2); + CHECK(bounds.second == 2); + } + + THEN("Bounds are correct when size == 3, all non-0") { + std::vector v = {2, 3, 5}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 0); + CHECK(bounds.second == 3); + } + + THEN("Bounds are correct when there are trailing 0s") { + std::vector v = {2, 3, 5, 0, 0, 0}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 0); + CHECK(bounds.second == 3); + } + + THEN("Bounds are correct when there are leading 0s") { + std::vector v = {0, 0, 2, 3, 5}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 2); + CHECK(bounds.second == 5); + } + + THEN("Bounds are correct when there are leading and trailing 0s") { + std::vector v = {0, 0, 2, 3, 5, 0, 0, 0}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 2); + CHECK(bounds.second == 5); + } + + } // WHEN + + + // ------------------------ + // Various vectors + // ------------------------ + + WHEN("We try vectors of varying sizes") { + + THEN("Bounds are correct when size == 0") { + std::vector v = {}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 0); + CHECK(bounds.second == 0); + } + + THEN("Bounds are correct when size == 1, with a 0") { + std::vector v = {0}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 1); + CHECK(bounds.second == 1); + } + + THEN("Bounds are correct when size == 3, all 0") { + std::vector v = {0, 0, 0}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 3); + CHECK(bounds.second == 3); + } + + THEN("Bounds are correct when size == 3, all non-0") { + std::vector v = {1.2, 3.4, 5.6}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 0); + CHECK(bounds.second == 3); + } + + THEN("Bounds are correct when there are trailing 0s") { + std::vector v = {1.2, 3.4, 5.6, 0, 0}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 0); + CHECK(bounds.second == 3); + } + + THEN("Bounds are correct when there are leading 0s") { + std::vector v = {0, 0, 0, 1.2, 3.4, 5.6}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 3); + CHECK(bounds.second == 6); + } + + THEN("Bounds are correct when there are leading and trailing 0s") { + std::vector v = {0, 0, 0, 1.2, 3.4, 5.6, 0, 0}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 3); + CHECK(bounds.second == 6); + } + + } + + + // ------------------------ + // Various vectors + // ------------------------ + + WHEN("We try vectors of varying sizes") { + + THEN("Bounds are correct when size == \"\"") { + std::vector v = {}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 0); + CHECK(bounds.second == 0); + } + + THEN("Bounds are correct when size == 1, with a \"\"") { + std::vector v = {""}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 1); + CHECK(bounds.second == 1); + } + + THEN("Bounds are correct when size == 2, all \"\"") { + std::vector v = {"", ""}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 2); + CHECK(bounds.second == 2); + } + + THEN("Bounds are correct when size == 2, all non-\"\"") { + std::vector v = {"abc", "def"}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 0); + CHECK(bounds.second == 2); + } + + THEN("Bounds are correct when there are trailing \"\"s") { + std::vector v = {"abc", "def", "", "", ""}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 0); + CHECK(bounds.second == 2); + } + + THEN("Bounds are correct when there are leading \"\"s") { + std::vector v = {"", "", "abc", "def"}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 2); + CHECK(bounds.second == 4); + } + + THEN("Bounds are correct when there are leading and trailing \"\"s") { + std::vector v = {"", "", "abc", "def", "", "", ""}; + const auto bounds = detail::getBounds(v); + CHECK(bounds.first == 2); + CHECK(bounds.second == 4); + } + + } // WHEN + } // GIVEN + +} // SCENARIO diff --git a/src/GNDStk/BlockData/test/fromNode.test.cpp b/src/GNDStk/BlockData/test/fromNode.test.cpp new file mode 100644 index 000000000..dda1bc292 --- /dev/null +++ b/src/GNDStk/BlockData/test/fromNode.test.cpp @@ -0,0 +1,115 @@ + +#include "catch.hpp" +#include "GNDStk.hpp" + +using namespace njoy::GNDStk; + + +// ----------------------------------------------------------------------------- +// Scenario for DATATYPE == void +// ----------------------------------------------------------------------------- + +SCENARIO("BlockData fromNode()") { + + GIVEN("A Node with no \"block data\"") { + WHEN("BlockData.fromNode(the node) is called") { + THEN("The BlockData's raw string is \"\", as expected") { + BlockData b; + b.string("This string should be replaced"); + CHECK(b.string() != ""); + + Node node; + node << ""; + b.fromNode(node); + CHECK(b.string() == ""); + } + } + } + + GIVEN("A Node with some \"block data\"") { + WHEN("BlockData.fromNode(the node) is called") { + THEN("The BlockData's raw string equals the text from the Node") { + BlockData b; + b.string("This string should be replaced"); + CHECK(b.string() != ""); + + Node node; + + node << "some plain character data"; + b.fromNode(node); + CHECK(b.string() == "some plain character data"); + + // it shouldn't matter, but leading spaces are preserved + node << " pcdata with leading spaces"; + b.fromNode(node); + CHECK(b.string() == " pcdata with leading spaces"); + + // ditto for trailing spaces + node << "pcdata with trailing spaces "; + b.fromNode(node); + CHECK(b.string() == "pcdata with trailing spaces "); + + // ditto for both together + node << " pcdata "; + b.fromNode(node); + CHECK(b.string() == " pcdata "); + } + } + } + +} // SCENARIO + + +// ----------------------------------------------------------------------------- +// Scenario for DATATYPE != void +// ----------------------------------------------------------------------------- + +SCENARIO("BlockData fromNode()") { + + GIVEN("A Node with no \"block data\"") { + WHEN("BlockData.fromNode(the node) is called") { + THEN("The BlockData's raw string is \"\", as expected") { + BlockData b; + b.string("This string should be replaced"); + CHECK(b.string() != ""); + + Node node; + node << ""; + b.fromNode(node); + CHECK(b.string() == ""); + } + } + } + + GIVEN("A Node with some \"block data\"") { + WHEN("BlockData.fromNode(the node) is called") { + THEN("The BlockData's raw string equals the text from the Node") { + BlockData b; + b.string("This string should be replaced"); + CHECK(b.string() != ""); + + Node node; + + node << "some plain character data"; + b.fromNode(node); + CHECK(b.string() == "some plain character data"); + + // it shouldn't matter, but leading spaces are preserved + node << " pcdata with leading spaces"; + b.fromNode(node); + CHECK(b.string() == " pcdata with leading spaces"); + + // ditto for trailing spaces + node << "pcdata with trailing spaces "; + b.fromNode(node); + CHECK(b.string() == "pcdata with trailing spaces "); + + // ditto for both together + node << " pcdata "; + b.fromNode(node); + CHECK(b.string() == " pcdata "); + } + } + } + +} // SCENARIO diff --git a/src/GNDStk/BlockData/test/get.test.cpp b/src/GNDStk/BlockData/test/get.test.cpp new file mode 100644 index 000000000..375a4d0f3 --- /dev/null +++ b/src/GNDStk/BlockData/test/get.test.cpp @@ -0,0 +1,695 @@ + +#include "catch.hpp" +#include "GNDStk.hpp" + +using namespace njoy::GNDStk; + + + +// ----------------------------------------------------------------------------- +// 1. Scenario: get() +// ----------------------------------------------------------------------------- + +// Helper +template +void scenario_get_vector() +{ + // We'll deal with these vector types for the test. They should cover + // sufficient cases (int, double, string, and none of the above) + // that we get good coverage, without this test being excessively long. + using ivec = std::vector; + using fvec = std::vector; + using svec = std::vector; + using uvec = std::vector; + + // We'll leave valueType at its default of "", which is compatible with + // every possible get type T. This simply means we won't get spammed + // with warnings about the asked-for T possibly being incompatible with + // valueType. Either way - with or without a "" for valueType - get + // gives us back a vector. + + // ------------------------ + // vector + // ------------------------ + + // 0 elements in string + { BlockData b; b.start(0).length(0).string(""); + CHECK((b.template get() == ivec{})); } + { BlockData b; b.start(0).length(4).string(""); + CHECK((b.template get() == ivec{{0,0,0,0}})); } + { BlockData b; b.start(1).length(5).string(""); + CHECK((b.template get() == ivec{{0,0,0,0,0}})); } + { BlockData b; b.start(2).length(6).string(""); + CHECK((b.template get() == ivec{{0,0,0,0,0,0}})); } + + // 1 element in string + { BlockData b; b.start(0).length(0).string("-12"); + CHECK((b.template get() == ivec(1,-12))); } + { BlockData b; b.start(0).length(4).string("-12"); + CHECK((b.template get() == ivec{{-12,0,0,0}})); } + { BlockData b; b.start(1).length(5).string("-12"); + CHECK((b.template get() == ivec{{0,-12,0,0,0}})); } + { BlockData b; b.start(2).length(6).string("-12"); + CHECK((b.template get() == ivec{{0,0,-12,0,0,0}})); } + + // 3 elements in string + { BlockData b; b.start(0).length(0).string("-12 34 -56"); + CHECK((b.template get() == ivec{{-12,34,-56}})); } + { BlockData b; b.start(0).length(4).string("-12 34 -56"); + CHECK((b.template get() == ivec{{-12,34,-56,0}})); } + { BlockData b; b.start(1).length(5).string("-12 34 -56"); + CHECK((b.template get() == ivec{{0,-12,34,-56,0}})); } + { BlockData b; b.start(2).length(6).string("-12 34 -56"); + CHECK((b.template get() == ivec{{0,0,-12,34,-56,0}})); } + + // ------------------------ + // vector + // ------------------------ + + // 0 elements in string + { BlockData b; b.start(0).length(0).string(""); + CHECK((b.template get() == fvec{})); } + { BlockData b; b.start(0).length(4).string(""); + CHECK((b.template get() == fvec{{0,0,0,0}})); } + { BlockData b; b.start(1).length(5).string(""); + CHECK((b.template get() == fvec{{0,0,0,0,0}})); } + { BlockData b; b.start(2).length(6).string(""); + CHECK((b.template get() == fvec{{0,0,0,0,0,0}})); } + + // 1 element in string + { BlockData b; b.start(0).length(0).string("1.2"); + CHECK((b.template get() == fvec(1,1.2))); } + { BlockData b; b.start(0).length(4).string("1.2"); + CHECK((b.template get() == fvec{{1.2,0,0,0}})); } + { BlockData b; b.start(1).length(5).string("1.2"); + CHECK((b.template get() == fvec{{0,1.2,0,0,0}})); } + { BlockData b; b.start(2).length(6).string("1.2"); + CHECK((b.template get() == fvec{{0,0,1.2,0,0,0}})); } + + // 3 elements in string + { BlockData b; b.start(0).length(0).string("1.2 3.4 5.6"); + CHECK((b.template get() == fvec{{1.2,3.4,5.6}})); } + { BlockData b; b.start(0).length(4).string("1.2 3.4 5.6"); + CHECK((b.template get() == fvec{{1.2,3.4,5.6,0}})); } + { BlockData b; b.start(1).length(5).string("1.2 3.4 5.6"); + CHECK((b.template get() == fvec{{0,1.2,3.4,5.6,0}})); } + { BlockData b; b.start(2).length(6).string("1.2 3.4 5.6"); + CHECK((b.template get() == fvec{{0,0,1.2,3.4,5.6,0}})); } + + // ------------------------ + // vector + // ------------------------ + + // 0 elements in string + { BlockData b; b.start(0).length(0).string(""); + CHECK((b.template get() == svec{})); } + { BlockData b; b.start(0).length(4).string(""); + CHECK((b.template get() == svec{{"","","",""}})); } + { BlockData b; b.start(1).length(5).string(""); + CHECK((b.template get() == svec{{"","","","",""}})); } + { BlockData b; b.start(2).length(6).string(""); + CHECK((b.template get() == svec{{"","","","","",""}})); } + + // 1 element in string + { BlockData b; b.start(0).length(0).string("ab"); + CHECK((b.template get() == svec(1,"ab"))); } + { BlockData b; b.start(0).length(4).string("ab"); + CHECK((b.template get() == svec{{"ab","","",""}})); } + { BlockData b; b.start(1).length(5).string("ab"); + CHECK((b.template get() == svec{{"","ab","","",""}})); } + { BlockData b; b.start(2).length(6).string("ab"); + CHECK((b.template get() == svec{{"","","ab","","",""}})); } + + // 3 elements in string + { BlockData b; b.start(0).length(0).string("ab cd ef"); + CHECK((b.template get() == svec{{"ab","cd","ef"}})); } + { BlockData b; b.start(0).length(4).string("ab cd ef"); + CHECK((b.template get() == svec{{"ab","cd","ef",""}})); } + { BlockData b; b.start(1).length(5).string("ab cd ef"); + CHECK((b.template get() == svec{{"","ab","cd","ef",""}})); } + { BlockData b; b.start(2).length(6).string("ab cd ef"); + CHECK((b.template get() == svec{{"","","ab","cd","ef",""}})); } + + // ------------------------ + // vector + // ------------------------ + + // 0 elements in string + { BlockData b; b.start(0).length(0).string(""); + CHECK((b.template get() == uvec{})); } + { BlockData b; b.start(0).length(4).string(""); + CHECK((b.template get() == uvec{{0,0,0,0}})); } + { BlockData b; b.start(1).length(5).string(""); + CHECK((b.template get() == uvec{{0,0,0,0,0}})); } + { BlockData b; b.start(2).length(6).string(""); + CHECK((b.template get() == uvec{{0,0,0,0,0,0}})); } + + // 1 element in string + { BlockData b; b.start(0).length(0).string("12"); + CHECK((b.template get() == uvec(1,12))); } + { BlockData b; b.start(0).length(4).string("12"); + CHECK((b.template get() == uvec{{12,0,0,0}})); } + { BlockData b; b.start(1).length(5).string("12"); + CHECK((b.template get() == uvec{{0,12,0,0,0}})); } + { BlockData b; b.start(2).length(6).string("12"); + CHECK((b.template get() == uvec{{0,0,12,0,0,0}})); } + + // 3 elements in string + { BlockData b; b.start(0).length(0).string("12 34 56"); + CHECK((b.template get() == uvec{{12,34,56}})); } + { BlockData b; b.start(0).length(4).string("12 34 56"); + CHECK((b.template get() == uvec{{12,34,56,0}})); } + { BlockData b; b.start(1).length(5).string("12 34 56"); + CHECK((b.template get() == uvec{{0,12,34,56,0}})); } + { BlockData b; b.start(2).length(6).string("12 34 56"); + CHECK((b.template get() == uvec{{0,0,12,34,56,0}})); } +} + +// For BlockData +SCENARIO("BlockData get()") { + GIVEN("A BlockData object") { + scenario_get_vector(); + } +} + +// For BlockData +SCENARIO("BlockData get()") { + GIVEN("A BlockData object") { + scenario_get_vector(); + } +} + + + +// ----------------------------------------------------------------------------- +// 2. Scenario: get(n) +// ----------------------------------------------------------------------------- + +// Helper +template +void scenario_get_template_n() +{ + // ------------------------ + // vector + // ------------------------ + + // 0 elements in string + { BlockData b; b.start(0).length(0).string(""); } + { BlockData b; b.start(0).length(4).string(""); + CHECK(b.template get(1) == 0); } + { BlockData b; b.start(1).length(5).string(""); + CHECK(b.template get(2) == 0); } + { BlockData b; b.start(2).length(6).string(""); + CHECK(b.template get(3) == 0); } + + // 1 element in string + { BlockData b; b.start(0).length(0).string("-12"); + CHECK(b.template get(0) == -12); } + { BlockData b; b.start(0).length(4).string("-12"); + CHECK(b.template get(1) == 0); } + { BlockData b; b.start(1).length(5).string("-12"); + CHECK(b.template get(2) == 0); } + { BlockData b; b.start(2).length(6).string("-12"); + CHECK(b.template get(3) == 0); } + + // 3 elements in string + { BlockData b; b.start(0).length(0).string("-12 34 -56"); + CHECK(b.template get(0) == -12); } + { BlockData b; b.start(0).length(4).string("-12 34 -56"); + CHECK(b.template get(1) == 34); } + { BlockData b; b.start(1).length(5).string("-12 34 -56"); + CHECK(b.template get(2) == 34); } + { BlockData b; b.start(2).length(6).string("-12 34 -56"); + CHECK(b.template get(3) == 34); } + + // ------------------------ + // vector + // ------------------------ + + // 0 elements in string + { BlockData b; b.start(0).length(0).string(""); } + { BlockData b; b.start(0).length(4).string(""); + CHECK(b.template get(1) == 0); } + { BlockData b; b.start(1).length(5).string(""); + CHECK(b.template get(2) == 0); } + { BlockData b; b.start(2).length(6).string(""); + CHECK(b.template get(3) == 0); } + + // 1 element in string + { BlockData b; b.start(0).length(0).string("1.2"); + CHECK(b.template get(0) == 1.2); } + { BlockData b; b.start(0).length(4).string("1.2"); + CHECK(b.template get(1) == 0); } + { BlockData b; b.start(1).length(5).string("1.2"); + CHECK(b.template get(2) == 0); } + { BlockData b; b.start(2).length(6).string("1.2"); + CHECK(b.template get(3) == 0); } + + // 3 elements in string + { BlockData b; b.start(0).length(0).string("1.2 3.4 5.6"); + CHECK(b.template get(0) == 1.2); } + { BlockData b; b.start(0).length(4).string("1.2 3.4 5.6"); + CHECK(b.template get(1) == 3.4); } + { BlockData b; b.start(1).length(5).string("1.2 3.4 5.6"); + CHECK(b.template get(2) == 3.4); } + { BlockData b; b.start(2).length(6).string("1.2 3.4 5.6"); + CHECK(b.template get(3) == 3.4); } + + // ------------------------ + // vector + // ------------------------ + + // 0 elements in string + { BlockData b; b.start(0).length(0).string(""); } + { BlockData b; b.start(0).length(4).string(""); + CHECK(b.template get(1) == ""); } + { BlockData b; b.start(1).length(5).string(""); + CHECK(b.template get(2) == ""); } + { BlockData b; b.start(2).length(6).string(""); + CHECK(b.template get(3) == ""); } + + // 1 element in string + { BlockData b; b.start(0).length(0).string("ab"); + CHECK(b.template get(0) == "ab"); } + { BlockData b; b.start(0).length(4).string("ab"); + CHECK(b.template get(1) == ""); } + { BlockData b; b.start(1).length(5).string("ab"); + CHECK(b.template get(2) == ""); } + { BlockData b; b.start(2).length(6).string("ab"); + CHECK(b.template get(3) == ""); } + + // 3 elements in string + { BlockData b; b.start(0).length(0).string("ab cd ef"); + CHECK(b.template get(0) == "ab"); } + { BlockData b; b.start(0).length(4).string("ab cd ef"); + CHECK(b.template get(1) == "cd"); } + { BlockData b; b.start(1).length(5).string("ab cd ef"); + CHECK(b.template get(2) == "cd"); } + { BlockData b; b.start(2).length(6).string("ab cd ef"); + CHECK(b.template get(3) == "cd"); } + + // ------------------------ + // vector + // ------------------------ + + // 0 elements in string + { BlockData b; b.start(0).length(0).string(""); } + { BlockData b; b.start(0).length(4).string(""); + CHECK(b.template get(1) == 0); } + { BlockData b; b.start(1).length(5).string(""); + CHECK(b.template get(2) == 0); } + { BlockData b; b.start(2).length(6).string(""); + CHECK(b.template get(3) == 0); } + + // 1 element in string + { BlockData b; b.start(0).length(0).string("12"); + CHECK(b.template get(0) == 12); } + { BlockData b; b.start(0).length(4).string("12"); + CHECK(b.template get(1) == 0); } + { BlockData b; b.start(1).length(5).string("12"); + CHECK(b.template get(2) == 0); } + { BlockData b; b.start(2).length(6).string("12"); + CHECK(b.template get(3) == 0); } + + // 3 elements in string + { BlockData b; b.start(0).length(0).string("12 34 56"); + CHECK(b.template get(0) == 12); } + { BlockData b; b.start(0).length(4).string("12 34 56"); + CHECK(b.template get(1) == 34); } + { BlockData b; b.start(1).length(5).string("12 34 56"); + CHECK(b.template get(2) == 34); } + { BlockData b; b.start(2).length(6).string("12 34 56"); + CHECK(b.template get(3) == 34); } +} + +// For BlockData +SCENARIO("BlockData get(n)") { + GIVEN("A BlockData object") { + scenario_get_template_n(); + } +} + +// For BlockData +SCENARIO("BlockData get(n)") { + GIVEN("A BlockData object") { + scenario_get_template_n(); + } +} + + + +// ----------------------------------------------------------------------------- +// 3. Scenario: get() +// ----------------------------------------------------------------------------- + +// For BlockData +SCENARIO("BlockData get()") { + GIVEN("A BlockData object") { + + using ivec = std::vector; + using fvec = std::vector; + using svec = std::vector; + + BlockData b; + + b.start(2).length(6).string("-12 34 -56"); + b.valueType("Integer32"); + CHECK(( std::holds_alternative(b.get()))); + CHECK((!std::holds_alternative(b.get()))); + CHECK((!std::holds_alternative(b.get()))); + CHECK((std::get(b.get()) == ivec{{0,0,-12,34,-56,0}})); + + b.start(2).length(6).string("1.2 3.4 5.6"); + b.valueType("Float64"); + CHECK((!std::holds_alternative(b.get()))); + CHECK(( std::holds_alternative(b.get()))); + CHECK((!std::holds_alternative(b.get()))); + CHECK((std::get(b.get()) == fvec{{0,0,1.2,3.4,5.6,0}})); + + b.start(2).length(6).string("ab cd ef"); + b.valueType(""); + CHECK((!std::holds_alternative(b.get()))); + CHECK((!std::holds_alternative(b.get()))); + CHECK(( std::holds_alternative(b.get()))); + CHECK((std::get(b.get()) == svec{{"","","ab","cd","ef",""}})); + + } // GIVEN +} // SCENARIO + + +// For BlockData +SCENARIO("BlockData get()") { + GIVEN("A BlockData object") { + + using ivec = std::vector; + using fvec = std::vector; + using svec = std::vector; + + { + BlockData b; + b.start(2).length(6).string("-12 34 -56"); + CHECK((b.get() == ivec{{0,0,-12,34,-56,0}})); + } + + { + BlockData b; + b.start(2).length(6).string("1.2 3.4 5.6"); + CHECK((b.get() == fvec{{0,0,1.2,3.4,5.6,0}})); + } + + { + BlockData b; + b.start(2).length(6).string("ab cd ef"); + CHECK((b.get() == svec{{"","","ab","cd","ef",""}})); + } + + } // GIVEN +} // SCENARIO + + + +// ----------------------------------------------------------------------------- +// 4. Scenario: get(n) +// ----------------------------------------------------------------------------- + +// For BlockData +SCENARIO("BlockData get(n)") { + GIVEN("A BlockData object") { + + BlockData b; + + // ------------------------ + // get(n) form + // ------------------------ + + b.start(2).length(6).string("-12 34 -56"); + b.valueType("Integer32"); + CHECK(( std::holds_alternative(b.get(0)))); + CHECK((!std::holds_alternative(b.get(0)))); + CHECK((!std::holds_alternative(b.get(0)))); + CHECK(( std::get( b.get(0) ) == 0 )); + CHECK(( std::get( b.get(1) ) == 0 )); + CHECK(( std::get( b.get(2) ) == -12 )); + CHECK(( std::get( b.get(3) ) == 34 )); + CHECK(( std::get( b.get(4) ) == -56 )); + CHECK(( std::get( b.get(5) ) == 0 )); + // test type changes (inefficient, but they work)... + CHECK(b.get(2) == -12); + CHECK(b.get(3) == double(34)); + CHECK(b.get(4) == "-56"); + + b.start(2).length(6).string("1.2 3.4 5.6"); + b.valueType("Float64"); + CHECK((!std::holds_alternative(b.get(0)))); + CHECK(( std::holds_alternative(b.get(0)))); + CHECK((!std::holds_alternative(b.get(0)))); + CHECK(( std::get( b.get(0) ) == 0 )); + CHECK(( std::get( b.get(1) ) == 0 )); + CHECK(( std::get( b.get(2) ) == 1.2 )); + CHECK(( std::get( b.get(3) ) == 3.4 )); + CHECK(( std::get( b.get(4) ) == 5.6 )); + CHECK(( std::get( b.get(5) ) == 0 )); + // test type changes... + CHECK(b.get(2) == 1); // truncated from 1.2 + // having converted to vector, the .#s aren't there any longer... + CHECK(b.get(2) == "1"); + CHECK(b.get(3) == 3); + CHECK(b.get(4) == "5"); + + b.start(2).length(8).string("ab cd ef 123 4.5"); + b.valueType(""); + CHECK((!std::holds_alternative(b.get(0)))); + CHECK((!std::holds_alternative(b.get(0)))); + CHECK(( std::holds_alternative(b.get(0)))); + CHECK(( std::get( b.get(0) ) == "" )); + CHECK(( std::get( b.get(1) ) == "" )); + CHECK(( std::get( b.get(2) ) == "ab" )); + CHECK(( std::get( b.get(3) ) == "cd" )); + CHECK(( std::get( b.get(4) ) == "ef" )); + CHECK(( std::get( b.get(5) ) == "123")); + CHECK(( std::get( b.get(6) ) == "4.5")); + CHECK(( std::get( b.get(7) ) == "" )); + + // ------------------------ + // operator[] form + // ------------------------ + + b.start(2).length(6).string("-12 34 -56"); + b.valueType("Integer32"); + CHECK(( std::holds_alternative(b[0]))); + CHECK((!std::holds_alternative(b[0]))); + CHECK((!std::holds_alternative(b[0]))); + CHECK(( std::get( b[0] ) == 0 )); + CHECK(( std::get( b[1] ) == 0 )); + CHECK(( std::get( b[2] ) == -12 )); + CHECK(( std::get( b[3] ) == 34 )); + CHECK(( std::get( b[4] ) == -56 )); + CHECK(( std::get( b[5] ) == 0 )); + + b.start(2).length(6).string("1.2 3.4 5.6"); + b.valueType("Float64"); + CHECK((!std::holds_alternative(b[0]))); + CHECK(( std::holds_alternative(b[0]))); + CHECK((!std::holds_alternative(b[0]))); + CHECK(( std::get( b[0] ) == 0 )); + CHECK(( std::get( b[1] ) == 0 )); + CHECK(( std::get( b[2] ) == 1.2 )); + CHECK(( std::get( b[3] ) == 3.4 )); + CHECK(( std::get( b[4] ) == 5.6 )); + CHECK(( std::get( b[5] ) == 0 )); + + b.start(2).length(6).string("ab cd ef"); + b.valueType(""); + CHECK((!std::holds_alternative(b[0]))); + CHECK((!std::holds_alternative(b[0]))); + CHECK(( std::holds_alternative(b[0]))); + CHECK(( std::get( b[0] ) == "" )); + CHECK(( std::get( b[1] ) == "" )); + CHECK(( std::get( b[2] ) == "ab" )); + CHECK(( std::get( b[3] ) == "cd" )); + CHECK(( std::get( b[4] ) == "ef" )); + CHECK(( std::get( b[5] ) == "" )); + + } // GIVEN +} // SCENARIO + + +// For BlockData +SCENARIO("BlockData get(n)") { + GIVEN("A BlockData object") { + + // ------------------------ + // get(n) form + // ------------------------ + + { + BlockData b; + b.start(2).length(6).string("-12 34 -56"); + CHECK(( b.get(0) == 0 )); + CHECK(( b.get(1) == 0 )); + CHECK(( b.get(2) == -12 )); + CHECK(( b.get(3) == 34 )); + CHECK(( b.get(4) == -56 )); + CHECK(( b.get(5) == 0 )); + } + + { + BlockData b; + b.start(2).length(6).string("1.2 3.4 5.6"); + CHECK(( b.get(0) == 0 )); + CHECK(( b.get(1) == 0 )); + CHECK(( b.get(2) == 1.2 )); + CHECK(( b.get(3) == 3.4 )); + CHECK(( b.get(4) == 5.6 )); + CHECK(( b.get(5) == 0 )); + } + + { + BlockData b; + b.start(2).length(8).string("ab cd ef 123 4.5"); + CHECK(( b.get(0) == "" )); + CHECK(( b.get(1) == "" )); + CHECK(( b.get(2) == "ab" )); + CHECK(( b.get(3) == "cd" )); + CHECK(( b.get(4) == "ef" )); + CHECK(( b.get(5) == "123")); + CHECK(( b.get(6) == "4.5")); + CHECK(( b.get(7) == "" )); + } + + // ------------------------ + // operator[] form + // ------------------------ + + { + BlockData b; + b.start(2).length(6).string("-12 34 -56"); + CHECK(( b[0] == 0 )); + CHECK(( b[1] == 0 )); + CHECK(( b[2] == -12 )); + CHECK(( b[3] == 34 )); + CHECK(( b[4] == -56 )); + CHECK(( b[5] == 0 )); + } + + { + BlockData b; + b.start(2).length(6).string("1.2 3.4 5.6"); + CHECK(( b[0] == 0 )); + CHECK(( b[1] == 0 )); + CHECK(( b[2] == 1.2 )); + CHECK(( b[3] == 3.4 )); + CHECK(( b[4] == 5.6 )); + CHECK(( b[5] == 0 )); + } + + { + BlockData b; + b.start(2).length(6).string("ab cd ef"); + CHECK(( b[0] == "" )); + CHECK(( b[1] == "" )); + CHECK(( b[2] == "ab" )); + CHECK(( b[3] == "cd" )); + CHECK(( b[4] == "ef" )); + CHECK(( b[5] == "" )); + } + + } // GIVEN +} // SCENARIO + + + +// ----------------------------------------------------------------------------- +// 5. Scenario: doubles() etc. +// ----------------------------------------------------------------------------- + +// Helper +template +void scenario_get_named() +{ + { + BlockData b; + + b.start(2).length(6).string("-12 34 -56"); + auto result = b.ints(); + CHECK((std::is_same_v>)); + + CHECK(result[0] == 0 ); + CHECK(result[1] == 0 ); + CHECK(result[2] == -12 ); + CHECK(result[3] == 34 ); + CHECK(result[4] == -56 ); + CHECK(result[5] == 0 ); + + CHECK(result[0] == b.ints(0) ); + CHECK(result[1] == b.ints(1) ); + CHECK(result[2] == b.ints(2) ); + CHECK(result[3] == b.ints(3) ); + CHECK(result[4] == b.ints(4) ); + CHECK(result[5] == b.ints(5) ); + } + + { + BlockData b; + + b.start(2).length(6).string("1.2 3.4 5.6"); + const BlockData &bconst = b; // ensure it works with const + const auto result = bconst.doubles(); + CHECK((std::is_same_v>)); + + CHECK(result[0] == 0 ); + CHECK(result[1] == 0 ); + CHECK(result[2] == 1.2 ); + CHECK(result[3] == 3.4 ); + CHECK(result[4] == 5.6 ); + CHECK(result[5] == 0 ); + + CHECK(result[0] == bconst.doubles(0) ); + CHECK(result[1] == bconst.doubles(1) ); + CHECK(result[2] == bconst.doubles(2) ); + CHECK(result[3] == bconst.doubles(3) ); + CHECK(result[4] == bconst.doubles(4) ); + CHECK(result[5] == bconst.doubles(5) ); + } + + { + BlockData b; + + b.start(2).length(6).string("ab cd ef"); + const auto &result = b.strings(); + CHECK((std::is_same_v &>)); + + CHECK(result[0] == "" ); + CHECK(result[1] == "" ); + CHECK(result[2] == "ab" ); + CHECK(result[3] == "cd" ); + CHECK(result[4] == "ef" ); + CHECK(result[5] == "" ); + + CHECK(result[0] == b.strings(0) ); + CHECK(result[1] == b.strings(1) ); + CHECK(result[2] == b.strings(2) ); + CHECK(result[3] == b.strings(3) ); + CHECK(result[4] == b.strings(4) ); + CHECK(result[5] == b.strings(5) ); + } +} + +// For BlockData +SCENARIO("BlockData type-specific get functions: " + "doubles() etc.") { + GIVEN("A BlockData object") { + scenario_get_named(); + } +} + +// For BlockData +SCENARIO("BlockData type-specific get functions: " + "doubles() etc.") { + GIVEN("A BlockData object") { + scenario_get_named(); + } +} diff --git a/src/GNDStk/BodyText/test/params.test.cpp b/src/GNDStk/BlockData/test/params.test.cpp similarity index 81% rename from src/GNDStk/BodyText/test/params.test.cpp rename to src/GNDStk/BlockData/test/params.test.cpp index 7e43e3e32..7f6df6682 100644 --- a/src/GNDStk/BodyText/test/params.test.cpp +++ b/src/GNDStk/BlockData/test/params.test.cpp @@ -2,20 +2,20 @@ #include "catch.hpp" #include "GNDStk.hpp" -using namespace njoy::GNDStk::core; +using namespace njoy::GNDStk; // ----------------------------------------------------------------------------- // Helper // ----------------------------------------------------------------------------- -template +template void scenario_params() { // Default values of parameters are as expected WHEN("We examine the default length, start, and valueType") { THEN("They are as expected") { - BodyText b; + BlockData b; CHECK(b.length() == 0); CHECK(b.start() == 0); CHECK(b.valueType() == ""); @@ -25,17 +25,17 @@ void scenario_params() // length setter/getter works WHEN("We set length, then get and verify") { THEN("It works for a plain value") { - BodyText b; + BlockData b; b.length(12); CHECK(b.length() == 12); } THEN("It works for optional-with-value") { - BodyText b; + BlockData b; b.length(std::optional(34)); CHECK(b.length() == 34); } THEN("It works for optional-without-value (remains unchanged)") { - BodyText b; + BlockData b; b.length(56); b.length(std::optional(std::nullopt)); CHECK(b.length() == 56); @@ -45,17 +45,17 @@ void scenario_params() // start setter/getter works WHEN("We set start, then get and verify") { THEN("It works for a plain value") { - BodyText b; + BlockData b; b.start(11); CHECK(b.start() == 11); } THEN("It works for optional-with-value") { - BodyText b; + BlockData b; b.start(std::optional(13)); CHECK(b.start() == 13); } THEN("It works for optional-without-value (remains unchanged)") { - BodyText b; + BlockData b; b.start(17); b.start(std::optional(std::nullopt)); CHECK(b.start() == 17); @@ -65,17 +65,17 @@ void scenario_params() // valueType setter/getter works WHEN("We set valueType, then get and verify") { THEN("It works for a plain value") { - BodyText b; + BlockData b; b.valueType("unknown"); CHECK(b.valueType() == "unknown"); } THEN("It works for optional-with-value") { - BodyText b; + BlockData b; b.valueType(std::optional("Integer32")); CHECK(b.valueType() == "Integer32"); } THEN("It works for optional-without-value (remains unchanged)") { - BodyText b; + BlockData b; b.valueType("Float64"); b.valueType(std::optional(std::nullopt)); CHECK(b.valueType() == "Float64"); @@ -85,7 +85,7 @@ void scenario_params() // Combo of the above, using builder-pattern nature of the setters WHEN("We set length/start/valueType together, then get and verify") { THEN("It works for a plain value") { - BodyText b; + BlockData b; b.length(1) .start(2) .valueType("a"); @@ -94,7 +94,7 @@ void scenario_params() CHECK(b.valueType() == "a"); } THEN("It works for optional-with-value") { - BodyText b; + BlockData b; b.length(std::optional(3)) .start(std::optional(4)) .valueType(std::optional("b")); @@ -103,7 +103,7 @@ void scenario_params() CHECK(b.valueType() == "b"); } THEN("It works for optional-without-value (remains unchanged)") { - BodyText b; + BlockData b; b.length(100).start(200).valueType("c"); b.length(std::optional(std::nullopt)) .start(std::optional(std::nullopt)) @@ -120,14 +120,14 @@ void scenario_params() // Scenarios // ----------------------------------------------------------------------------- -SCENARIO("BodyText length/start/valueType") { - GIVEN("A default-constructed BodyText object") { +SCENARIO("BlockData length/start/valueType") { + GIVEN("A default-constructed BlockData object") { scenario_params(); } } -SCENARIO("BodyText length/start/valueType") { - GIVEN("A default-constructed BodyText object") { +SCENARIO("BlockData length/start/valueType") { + GIVEN("A default-constructed BlockData object") { scenario_params(); } } diff --git a/src/GNDStk/BlockData/test/print.test.cpp b/src/GNDStk/BlockData/test/print.test.cpp new file mode 100644 index 000000000..5cc03e890 --- /dev/null +++ b/src/GNDStk/BlockData/test/print.test.cpp @@ -0,0 +1,437 @@ + +#include "catch.hpp" +#include "GNDStk.hpp" + +using namespace njoy::GNDStk; + + +// ----------------------------------------------------------------------------- +// Scenario: raw string is active +// ----------------------------------------------------------------------------- + +// Helper: scenario_print_string_active +template +void scenario_print_string_active() +{ + // string is active, but empty + GIVEN("A BlockData with an empty raw string") { + WHEN("BlockData.print() is called") { + THEN("Nothing is printed") { + BlockData b; + b.string(""); + + // with no indentation + std::ostringstream oss; + b.print(oss,0); + CHECK(oss.str() == ""); + + // the same (nothing is printed) even if indentation is nonzero + oss.str(""); + b.print(oss,2); + CHECK(oss.str() == ""); + } + } + } + + // string is active, and contains values + GIVEN("A BlockData with a non-empty raw string") { + WHEN("BlockData.print() is called") { + THEN("The raw string and a newline are printed") { + BlockData b; + b.string("foo bar baz"); + + // with no indentation + std::ostringstream oss; + b.print(oss,0); + CHECK(oss.str() == "foo bar baz\n"); + + // the same, even if indentation is nonzero; indentation isn't + // applied when the raw string (as opposed to the ) is active + oss.str(""); + b.print(oss,2); + CHECK(oss.str() == "foo bar baz\n"); + } + } + } +} + +// For DATATYPE == void +SCENARIO("BlockData print(), when the raw string is active") +{ + scenario_print_string_active(); +} + +// For DATATYPE == double +SCENARIO("BlockData print(), when the raw string is active") +{ + scenario_print_string_active(); +} + + +// ----------------------------------------------------------------------------- +// Scenario: vector is active +// ----------------------------------------------------------------------------- + +SCENARIO("BlockData print(), when a vector is active") +{ + // vector is active, but empty + GIVEN("A BlockData with an empty vector") { + WHEN("BlockData.print() is called") { + THEN("Nothing is printed") { + BlockData b; + b = std::vector{}; + + // with no indentation + std::ostringstream oss; + b.print(oss,0); + CHECK(oss.str() == ""); + + // the same (nothing is printed) even if indentation is nonzero + oss.str(""); + b.print(oss,2); + CHECK(oss.str() == ""); + } + } + } + + // vector is active, and contains values + GIVEN("A BlockData with a non-empty vector") { + WHEN("BlockData.print() is called") { + THEN("The vector and a newline are printed") { + BlockData b; + b = std::vector{{2, 3, 5, 7, 11, 13, 17, 19, 21, 23}}; + std::ostringstream oss; + + // Cases: + // indent: 0, 3 (number of spaces per indentation level) + // columns: 0, 1, 2, 5, 10, 11 (note that 10 == vector size) + // level: 0, 1, 2 (indentation level) + // Note: columns <= 0 means unlimited: so, all values on one line. + // Lots of cases, but we want to check that our prettyprinting + // functionality works perfectly, and doesn't do anything that's + // unexpected around "boundaries" like columns==10 with 10 values. + + oss.str(""); indent = 0; columns = 0; b.print(oss,0); + CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); + + oss.str(""); indent = 0; columns = 0; b.print(oss,1); + CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); + + oss.str(""); indent = 0; columns = 0; b.print(oss,2); + CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); + + oss.str(""); indent = 0; columns = 1; b.print(oss,0); + CHECK(oss.str() == "2\n3\n5\n7\n11\n13\n17\n19\n21\n23\n"); + + oss.str(""); indent = 0; columns = 1; b.print(oss,1); + CHECK(oss.str() == "2\n3\n5\n7\n11\n13\n17\n19\n21\n23\n"); + + oss.str(""); indent = 0; columns = 1; b.print(oss,2); + CHECK(oss.str() == "2\n3\n5\n7\n11\n13\n17\n19\n21\n23\n"); + + oss.str(""); indent = 0; columns = 2; b.print(oss,0); + CHECK(oss.str() == "2 3\n5 7\n11 13\n17 19\n21 23\n"); + + oss.str(""); indent = 0; columns = 2; b.print(oss,1); + CHECK(oss.str() == "2 3\n5 7\n11 13\n17 19\n21 23\n"); + + oss.str(""); indent = 0; columns = 2; b.print(oss,2); + CHECK(oss.str() == "2 3\n5 7\n11 13\n17 19\n21 23\n"); + + oss.str(""); indent = 0; columns = 5; b.print(oss,0); + CHECK(oss.str() == "2 3 5 7 11\n13 17 19 21 23\n"); + + oss.str(""); indent = 0; columns = 5; b.print(oss,1); + CHECK(oss.str() == "2 3 5 7 11\n13 17 19 21 23\n"); + + oss.str(""); indent = 0; columns = 5; b.print(oss,2); + CHECK(oss.str() == "2 3 5 7 11\n13 17 19 21 23\n"); + + oss.str(""); indent = 0; columns = 10; b.print(oss,0); + CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); + + oss.str(""); indent = 0; columns = 10; b.print(oss,1); + CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); + + oss.str(""); indent = 0; columns = 10; b.print(oss,2); + CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); + + oss.str(""); indent = 0; columns = 11; b.print(oss,0); + CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); + + oss.str(""); indent = 0; columns = 11; b.print(oss,1); + CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); + + oss.str(""); indent = 0; columns = 11; b.print(oss,2); + CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); + + oss.str(""); indent = 3; columns = 0; b.print(oss,0); + CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); + + oss.str(""); indent = 3; columns = 0; b.print(oss,1); + CHECK(oss.str() == " 2 3 5 7 11 13 17 19 21 23\n"); + + oss.str(""); indent = 3; columns = 0; b.print(oss,2); + CHECK(oss.str() == " 2 3 5 7 11 13 17 19 21 23\n"); + + oss.str(""); indent = 3; columns = 1; b.print(oss,0); + CHECK(oss.str() == "2\n3\n5\n7\n11\n13\n17\n19\n21\n23\n"); + + oss.str(""); indent = 3; columns = 1; b.print(oss,1); + CHECK(oss.str() == + " 2\n 3\n 5\n 7\n 11\n" + " 13\n 17\n 19\n 21\n 23\n"); + + oss.str(""); indent = 3; columns = 1; b.print(oss,2); + CHECK(oss.str() == + " 2\n 3\n 5\n 7\n 11\n" + " 13\n 17\n 19\n 21\n 23\n"); + + oss.str(""); indent = 3; columns = 2; b.print(oss,0); + CHECK(oss.str() == "2 3\n5 7\n11 13\n17 19\n21 23\n"); + + oss.str(""); indent = 3; columns = 2; b.print(oss,1); + CHECK( + oss.str() == + " 2 3\n 5 7\n 11 13\n 17 19\n 21 23\n" + ); + + oss.str(""); indent = 3; columns = 2; b.print(oss,2); + CHECK( + oss.str() == + " 2 3\n 5 7\n 11 13\n 17 19\n 21 23\n" + ); + + oss.str(""); indent = 3; columns = 5; b.print(oss,0); + CHECK(oss.str() == "2 3 5 7 11\n13 17 19 21 23\n"); + + oss.str(""); indent = 3; columns = 5; b.print(oss,1); + CHECK(oss.str() == " 2 3 5 7 11\n 13 17 19 21 23\n"); + + oss.str(""); indent = 3; columns = 5; b.print(oss,2); + CHECK(oss.str() == " 2 3 5 7 11\n 13 17 19 21 23\n"); + + oss.str(""); indent = 3; columns = 10; b.print(oss,0); + CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); + + oss.str(""); indent = 3; columns = 10; b.print(oss,1); + CHECK(oss.str() == " 2 3 5 7 11 13 17 19 21 23\n"); + + oss.str(""); indent = 3; columns = 10; b.print(oss,2); + CHECK(oss.str() == " 2 3 5 7 11 13 17 19 21 23\n"); + + oss.str(""); indent = 3; columns = 11; b.print(oss,0); + CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); + + oss.str(""); indent = 3; columns = 11; b.print(oss,1); + CHECK(oss.str() == " 2 3 5 7 11 13 17 19 21 23\n"); + + oss.str(""); indent = 3; columns = 11; b.print(oss,2); + CHECK(oss.str() == " 2 3 5 7 11 13 17 19 21 23\n"); + } + } + } +} + + + +// ----------------------------------------------------------------------------- +// Scenario: vector is active; test GNDStk::truncate +// ----------------------------------------------------------------------------- + +// Helper: test_truncate +template +void test_truncate( + const BlockData &b, + const int indent, + const std::size_t columns, + const int level, + const long truncate, + const std::string &want +) { + njoy::GNDStk::indent = indent; + njoy::GNDStk::columns = columns; + njoy::GNDStk::truncate = truncate; + + std::ostringstream oss; + b.print(oss,level); + + std::cout << "test_truncate:" << std::endl; + std::cout << oss.str() << std::endl; + + CHECK(oss.str() == want); +} + +SCENARIO("BlockData print(), vector, trying GNDStk::truncate") +{ + // vector is active, but empty + GIVEN("A BlockData with an empty vector") { + WHEN("BlockData.print() is called") { + THEN("Nothing is printed") { + BlockData b; + b = std::vector{}; + + using njoy::GNDStk::truncate; + for (truncate = -10; truncate <= 10; ++truncate) { + // with no indentation + std::ostringstream oss; + b.print(oss,0); + CHECK(oss.str() == ""); + + // the same (nothing is printed) even if indentation is nonzero + oss.str(""); + b.print(oss,2); + CHECK(oss.str() == ""); + } + } + } + } + + // vector is active, and contains values + GIVEN("A BlockData with a non-empty vector") { + WHEN("BlockData.print() is called") { + THEN("The vector and a newline are printed") { + BlockData b; + b = std::vector{{2.3, 5.7, 11.13, 17.19, 21.23}}; + + // Cases: + // indent: 3 (number of spaces per indentation level) + // columns: 0, 2, 3 (0 means unlimited) + // level: 0, 1, 2 (indentation level) + // truncate: -1, 0, 1, 2, 3 (-1 means none; so, print all values) + // Lots of cases; we want prettyprinting to be perfect. + + // Integral parameters below are: indent, columns, level, truncate + test_truncate(b, 3, 0, 0, -1, + "2.3 5.7 11.13 17.19 21.23\n"); + test_truncate(b, 3, 0, 0, +0, + "// truncated; total #values == 5\n"); + test_truncate(b, 3, 0, 0, +1, + "2.3\n" + "// truncated; total #values == 5\n"); + test_truncate(b, 3, 0, 0, +2, + "2.3 5.7\n" + "// truncated; total #values == 5\n"); + test_truncate(b, 3, 0, 0, +3, + "2.3 5.7 11.13\n" + "// truncated; total #values == 5\n"); + test_truncate(b, 3, 0, 1, -1, + " 2.3 5.7 11.13 17.19 21.23\n"); + test_truncate(b, 3, 0, 1, +0, + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 0, 1, +1, + " 2.3\n" + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 0, 1, +2, + " 2.3 5.7\n" + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 0, 1, +3, + " 2.3 5.7 11.13\n" + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 0, 2, -1, + " 2.3 5.7 11.13 17.19 21.23\n"); + test_truncate(b, 3, 0, 2, +0, + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 0, 2, +1, + " 2.3\n" + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 0, 2, +2, + " 2.3 5.7\n" + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 0, 2, +3, + " 2.3 5.7 11.13\n" + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 2, 0, -1, + "2.3 5.7\n" + "11.13 17.19\n" + "21.23\n"); + test_truncate(b, 3, 2, 0, +0, + "// truncated; total #values == 5\n"); + test_truncate(b, 3, 2, 0, +1, + "2.3\n" + "// truncated; total #values == 5\n"); + test_truncate(b, 3, 2, 0, +2, + "2.3 5.7\n" + "// truncated; total #values == 5\n"); + test_truncate(b, 3, 2, 0, +3, + "2.3 5.7\n" + "11.13\n" + "// truncated; total #values == 5\n"); + test_truncate(b, 3, 2, 1, -1, + " 2.3 5.7\n" + " 11.13 17.19\n" + " 21.23\n"); + test_truncate(b, 3, 2, 1, +0, + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 2, 1, +1, + " 2.3\n" + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 2, 1, +2, + " 2.3 5.7\n" + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 2, 1, +3, + " 2.3 5.7\n" + " 11.13\n" + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 2, 2, -1, + " 2.3 5.7\n" + " 11.13 17.19\n" + " 21.23\n"); + test_truncate(b, 3, 2, 2, +0, + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 2, 2, +1, + " 2.3\n" + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 2, 2, +2, + " 2.3 5.7\n" + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 2, 2, +3, + " 2.3 5.7\n" + " 11.13\n" + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 3, 0, -1, + "2.3 5.7 11.13\n" + "17.19 21.23\n"); + test_truncate(b, 3, 3, 0, +0, + "// truncated; total #values == 5\n"); + test_truncate(b, 3, 3, 0, +1, + "2.3\n" + "// truncated; total #values == 5\n"); + test_truncate(b, 3, 3, 0, +2, + "2.3 5.7\n" + "// truncated; total #values == 5\n"); + test_truncate(b, 3, 3, 0, +3, + "2.3 5.7 11.13\n" + "// truncated; total #values == 5\n"); + test_truncate(b, 3, 3, 1, -1, + " 2.3 5.7 11.13\n" + " 17.19 21.23\n"); + test_truncate(b, 3, 3, 1, +0, + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 3, 1, +1, + " 2.3\n" + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 3, 1, +2, + " 2.3 5.7\n" + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 3, 1, +3, + " 2.3 5.7 11.13\n" + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 3, 2, -1, + " 2.3 5.7 11.13\n" + " 17.19 21.23\n"); + test_truncate(b, 3, 3, 2, +0, + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 3, 2, +1, + " 2.3\n" + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 3, 2, +2, + " 2.3 5.7\n" + " // truncated; total #values == 5\n"); + test_truncate(b, 3, 3, 2, +3, + " 2.3 5.7 11.13\n" + " // truncated; total #values == 5\n"); + } + } + } +} diff --git a/src/GNDStk/BodyText/test/string.test.cpp b/src/GNDStk/BlockData/test/string.test.cpp similarity index 79% rename from src/GNDStk/BodyText/test/string.test.cpp rename to src/GNDStk/BlockData/test/string.test.cpp index 549b38041..fb8e8ed39 100644 --- a/src/GNDStk/BodyText/test/string.test.cpp +++ b/src/GNDStk/BlockData/test/string.test.cpp @@ -2,20 +2,20 @@ #include "catch.hpp" #include "GNDStk.hpp" -using namespace njoy::GNDStk::core; +using namespace njoy::GNDStk; // ----------------------------------------------------------------------------- // Helper // ----------------------------------------------------------------------------- -template +template void scenario_string() { // Default value of raw string is as expected WHEN("We examine the raw string") { THEN("It is as expected") { - BodyText b; + BlockData b; CHECK(b.string() == ""); } } @@ -23,7 +23,7 @@ void scenario_string() // Raw string setter/getter works WHEN("We set the raw string") { THEN("It has the correct value, and vector size() == 0 too") { - BodyText b; + BlockData b; // to ensure it clears below... b = std::vector(10); @@ -40,7 +40,7 @@ void scenario_string() // Test in conjunction with length, start, and valueType WHEN("We set string, length, start, and valueType together") { THEN("All values check out") { - BodyText b; + BlockData b; b.string("3 4 5 6").length(10).start(2).valueType("Integer32"); CHECK(b.length() == 10); @@ -56,14 +56,14 @@ void scenario_string() // Scenarios // ----------------------------------------------------------------------------- -SCENARIO("BodyText string()") { - GIVEN("A default-constructed BodyText object") { +SCENARIO("BlockData string()") { + GIVEN("A default-constructed BlockData object") { scenario_string(); } } -SCENARIO("BodyText string()") { - GIVEN("A default-constructed BodyText object") { +SCENARIO("BlockData string()") { + GIVEN("A default-constructed BlockData object") { scenario_string(); } } diff --git a/src/GNDStk/BlockData/test/sync.test.cpp b/src/GNDStk/BlockData/test/sync.test.cpp new file mode 100644 index 000000000..9a088d851 --- /dev/null +++ b/src/GNDStk/BlockData/test/sync.test.cpp @@ -0,0 +1,345 @@ + +#include "catch.hpp" +#include "GNDStk.hpp" + +using namespace njoy::GNDStk; + + +// ----------------------------------------------------------------------------- +// Scenario: pull +// Content == any of {length,start,valueType} +// ----------------------------------------------------------------------------- + +// Helper +template +void scenario_pull() +{ + WHEN("pullFromDerived() is called") { + // none of length, start, valueType + THEN("Push to Content{} works") { + struct : public BlockData { + struct { + } Content; + } derived; + BlockData &b = derived; + b.length(100).start(200).valueType("300"); + b.pullFromDerived(derived); // should do nothing here + CHECK(b.length() == 100); + CHECK(b.start() == 200); + CHECK(b.valueType() == "300"); + } + + // length only + THEN("Push to Content{length} works") { + struct : public BlockData { + struct { + int length = 10; + } Content; + const int &length() const { return Content.length; } + int &length() { return Content.length; } + } derived; + BlockData &b = derived; + b.length(11).start(12).valueType("13"); + b.pullFromDerived(derived); + CHECK(b.length() == 10); + CHECK(b.start() == 12); + CHECK(b.valueType() == "13"); + } + + // start only + THEN("Push to Content{start} works") { + struct : public BlockData { + struct { + int start = 14; + } Content; + const int &start() const { return Content.start; } + int &start() { return Content.start; } + } derived; + BlockData &b = derived; + b.length(15).start(16).valueType("17"); + b.pullFromDerived(derived); + CHECK(b.length() == 15); + CHECK(b.start() == 14); + CHECK(b.valueType() == "17"); + } + + // valueType only + THEN("Push to Content{valueType} works") { + struct : public BlockData { + struct { + std::string valueType = "18"; + } Content; + const std::string &valueType() const { return Content.valueType; } + std::string &valueType() { return Content.valueType; } + } derived; + BlockData &b = derived; + b.length(19).start(20).valueType("21"); + b.pullFromDerived(derived); + CHECK(b.length() == 19); + CHECK(b.start() == 20); + CHECK(b.valueType() == "18"); + } + + // all but length + THEN("Push to Content{start,valueType} works") { + struct : public BlockData { + struct { + int start = 22; + std::string valueType = "23"; + } Content; + const int &start() const { return Content.start; } + int &start() { return Content.start; } + const std::string &valueType() const { return Content.valueType; } + std::string &valueType() { return Content.valueType; } + } derived; + BlockData &b = derived; + b.length(24).start(25).valueType("26"); + b.pullFromDerived(derived); + CHECK(b.length() == 24); + CHECK(b.start() == 22); + CHECK(b.valueType() == "23"); + } + + // all but start + THEN("Push to Content{length,valueType} works") { + struct : public BlockData { + struct { + int length = 27; + std::string valueType = "28"; + } Content; + const int &length() const { return Content.length; } + int &length() { return Content.length; } + const std::string &valueType() const { return Content.valueType; } + std::string &valueType() { return Content.valueType; } + } derived; + BlockData &b = derived; + b.length(29).start(30).valueType("31"); + b.pullFromDerived(derived); + CHECK(b.length() == 27); + CHECK(b.start() == 30); + CHECK(b.valueType() == "28"); + } + + // all but valueType + THEN("Push to Content{length,start} works") { + struct : public BlockData { + struct { + int length = 32; + int start = 33; + } Content; + const int &length() const { return Content.length; } + int &length() { return Content.length; } + const int &start() const { return Content.start; } + int &start() { return Content.start; } + } derived; + BlockData &b = derived; + b.length(34).start(35).valueType("36"); + b.pullFromDerived(derived); + CHECK(b.length() == 32); + CHECK(b.start() == 33); + CHECK(b.valueType() == "36"); + } + + // all three + THEN("Push to Content{length,start,valueType} works") { + struct : public BlockData { + struct { + int length = 37; + int start = 38; + std::string valueType = "39"; + } Content; + const int &length() const { return Content.length; } + int &length() { return Content.length; } + const int &start() const { return Content.start; } + int &start() { return Content.start; } + const std::string &valueType() const { return Content.valueType; } + std::string &valueType() { return Content.valueType; } + } derived; + BlockData &b = derived; + b.length(40).start(41).valueType("42"); + b.pullFromDerived(derived); + CHECK(b.length() == 37); + CHECK(b.start() == 38); + CHECK(b.valueType() == "39"); + } + } +} + + +SCENARIO("BlockData pull from Content") { + GIVEN("A BlockData object") { + scenario_pull(); + } +} + +SCENARIO("BlockData pull from Content") { + GIVEN("A BlockData object") { + scenario_pull(); + } +} + + +// ----------------------------------------------------------------------------- +// Scenario: push +// Content == any of {length,start,valueType} +// ----------------------------------------------------------------------------- + +// Helper +template +void scenario_push() +{ + WHEN("pushToDerived() is called") { + // none of length, start, valueType + THEN("Push to Content{} works") { + struct : public BlockData { + struct { + int ignored = 123456; // not length, start, or valueType + } Content; + const int &ignored() const { return Content.ignored; } + int &ignored() { return Content.ignored; } + } derived; + BlockData &b = derived; + b.length(0).start(0).valueType("0"); + b.pushToDerived(derived); // should do nothing here + CHECK(derived.ignored() == 123456); + } + + // length only + THEN("Push to Content{length} works") { + struct : public BlockData { + struct { + int length = 10; + } Content; + const int &length() const { return Content.length; } + int &length() { return Content.length; } + } derived; + BlockData &b = derived; + b.length(11).start(12).valueType("13"); + b.pushToDerived(derived); + CHECK(derived.length() == 11); + } + + // start only + THEN("Push to Content{start} works") { + struct : public BlockData { + struct { + int start = 14; + } Content; + const int &start() const { return Content.start; } + int &start() { return Content.start; } + } derived; + BlockData &b = derived; + b.length(15).start(16).valueType("17"); + b.pushToDerived(derived); + CHECK(derived.start() == 16); + } + + // valueType only + THEN("Push to Content{valueType} works") { + struct : public BlockData { + struct { + std::string valueType = "18"; + } Content; + const std::string &valueType() const { return Content.valueType; } + std::string &valueType() { return Content.valueType; } + } derived; + BlockData &b = derived; + b.length(19).start(20).valueType("21"); + b.pushToDerived(derived); + CHECK(derived.valueType() == "21"); + } + + // all but length + THEN("Push to Content{start,valueType} works") { + struct : public BlockData { + struct { + int start = 22; + std::string valueType = "23"; + } Content; + const int &start() const { return Content.start; } + int &start() { return Content.start; } + const std::string &valueType() const { return Content.valueType; } + std::string &valueType() { return Content.valueType; } + } derived; + BlockData &b = derived; + b.length(24).start(25).valueType("26"); + b.pushToDerived(derived); + CHECK(derived.start() == 25); + CHECK(derived.valueType() == "26"); + } + + // all but start + THEN("Push to Content{length,valueType} works") { + struct : public BlockData { + struct { + int length = 27; + std::string valueType = "28"; + } Content; + const int &length() const { return Content.length; } + int &length() { return Content.length; } + const std::string &valueType() const { return Content.valueType; } + std::string &valueType() { return Content.valueType; } + } derived; + BlockData &b = derived; + b.length(29).start(30).valueType("31"); + b.pushToDerived(derived); + CHECK(derived.length() == 29); + CHECK(derived.valueType() == "31"); + } + + // all but valueType + THEN("Push to Content{length,start} works") { + struct : public BlockData { + struct { + int length = 32; + int start = 33; + } Content; + const int &length() const { return Content.length; } + int &length() { return Content.length; } + const int &start() const { return Content.start; } + int &start() { return Content.start; } + } derived; + BlockData &b = derived; + b.length(34).start(35).valueType("36"); + b.pushToDerived(derived); + CHECK(derived.length() == 34); + CHECK(derived.start() == 35); + } + + // all three + THEN("Push to Content{length,start,valueType} works") { + struct : public BlockData { + struct { + int length = 37; + int start = 38; + std::string valueType = "39"; + } Content; + const int &length() const { return Content.length; } + int &length() { return Content.length; } + const int &start() const { return Content.start; } + int &start() { return Content.start; } + const std::string &valueType() const { return Content.valueType; } + std::string &valueType() { return Content.valueType; } + } derived; + BlockData &b = derived; + b.length(40).start(41).valueType("42"); + b.pushToDerived(derived); + CHECK(derived.length() == 40); + CHECK(derived.start() == 41); + CHECK(derived.valueType() == "42"); + } + } +} + + +SCENARIO("BlockData push to Content") { + GIVEN("A BlockData object") { + scenario_push(); + } +} + +SCENARIO("BlockData push to Content") { + GIVEN("A BlockData object") { + scenario_push(); + } +} diff --git a/src/GNDStk/BlockData/test/toNode.test.cpp b/src/GNDStk/BlockData/test/toNode.test.cpp new file mode 100644 index 000000000..6bd63314a --- /dev/null +++ b/src/GNDStk/BlockData/test/toNode.test.cpp @@ -0,0 +1,248 @@ + +#include "catch.hpp" +#include "GNDStk.hpp" + +using namespace njoy::GNDStk; + + +// ----------------------------------------------------------------------------- +// Helper +// ----------------------------------------------------------------------------- + +// Tests use either void for each template parameter, or int, double, +// std::string, and char, in that order. In the former case, we're testing +// toNode() for the generic BlockData<...,void>. In the latter case, we're +// testing toNode() for non-generic BlockData. +template +void scenario_toNode() +{ + // Default-constructed BlockData + GIVEN("A default-constructed BlockData") { + WHEN("toNode() is called") { + THEN("The computed text string is empty") { + std::string text = "abc"; + struct : public BlockData { + struct { + } Content; + } derived; + BlockData &b = derived; + + // w/trim == true (shouldn't matter here; applies to vector) + b.trim = true; + b.toNode(text); + CHECK(text == ""); + + // w/trim == false (shouldn't matter here; applies to vector) + b.trim = false; + b.toNode(text); + CHECK(text == ""); + } + } + } + + // BlockData, after being given a particular raw string and parameters + GIVEN("A BlockData, with given raw string and parameters") { + WHEN("toNode() is called") { + THEN("The computed text string is as expected, " + "and the parameters remain as given" + ) { + struct : public BlockData { + struct { + } Content; + } derived; + BlockData &b = derived; + + b.string("0 12 34 56 0 0") + .start(100).length(200).valueType("hello"); + + // Someone who sets the raw string directly (as opposed to using + // a vector) is stating that they want *exactly* that raw string, + // including any 0s or anything else. To have BlockData's trim flag + // be relevant, use a vector. + + // w/trim == true (shouldn't matter here; applies to vector) + std::string text = "abc"; + b.trim = true; + b.toNode(text); + CHECK(text == "0 12 34 56 0 0"); + CHECK(b.start() == 100); + CHECK(b.length() == 200); + CHECK(b.valueType() == "hello"); + + // w/trim == false (shouldn't matter here; applies to vector) + text = "abc"; + b.trim = false; + b.toNode(text); + CHECK(text == "0 12 34 56 0 0"); + CHECK(b.start() == 100); + CHECK(b.length() == 200); + CHECK(b.valueType() == "hello"); + } + } + } + + // BlockData, after being given a particular vector + GIVEN("A BlockData, assigned from a particular vector") { + WHEN("toNode() is called") { + THEN("The computed text string is as expected, " + "and the parameters were computed properly" + ) { + struct : public BlockData { + struct { + } Content; + } derived; + BlockData &b = derived; + + // what's set here should be replaced upon assignment from vector + b.string("a b c").start(10).length(20).valueType("foobar"); + + // assign from vector + b = std::vector{{0, 0, 12, 34, 56, 78, 0, 0, 0, 0, 0}}; + + // w/trim == true + std::string text = "this should be replaced"; + b.trim = true; + b.toNode(text); + CHECK(text == "12 34 56 78"); + CHECK(b.start() == 2); + CHECK(b.length() == 11); + CHECK(b.valueType() == "Integer32"); + + // w/trim == false + text = "this should be replaced"; + b.trim = false; + b.toNode(text); + CHECK(text == "0 0 12 34 56 78 0 0 0 0 0"); + CHECK(b.start() == 0); + CHECK(b.length() == 11); + CHECK(b.valueType() == "Integer32"); + } + } + } + + // BlockData, after being given a particular vector + GIVEN("A BlockData, assigned from a particular vector") { + WHEN("toNode() is called") { + THEN("The computed text string is as expected, " + "and the parameters were computed properly" + ) { + struct : public BlockData { + struct { + } Content; + } derived; + BlockData &b = derived; + + // what's set here should be replaced upon assignment from vector + b.string("d e f").start(100).length(200).valueType("foobar"); + + // assign from vector + b = std::vector{{0, 0, 0, 1.234, 5.678, 0, 0 }}; + + // w/trim == true + std::string text = "this should be replaced"; + b.trim = true; + b.toNode(text); + CHECK(text == "1.234 5.678"); + CHECK(b.start() == 3); + CHECK(b.length() == 7); + CHECK(b.valueType() == "Float64"); + + // w/trim == false + text = "this should be replaced"; + b.trim = false; + b.toNode(text); + CHECK(text == "0 0 0 1.234 5.678 0 0"); + CHECK(b.start() == 0); + CHECK(b.length() == 7); + CHECK(b.valueType() == "Float64"); + } + } + } + + // BlockData, after being given a particular vector + // A key point here is to ensure that ""s (string "zeros") are properly + // trimmed at the beginning and end. + GIVEN("A BlockData, assigned from a particular vector") { + WHEN("toNode() is called") { + THEN("The computed text string is as expected, " + "and the parameters were computed properly" + ) { + struct : public BlockData { + struct { + } Content; + } derived; + BlockData &b = derived; + + // what's set here should be replaced upon assignment from vector + b.string("d e f").start(100).length(200).valueType("foobar"); + + // assign from vector + b = std::vector{{"","","","foo","bar","baz","",""}}; + + // w/trim == true + std::string text = "this should be replaced"; + b.trim = true; + b.toNode(text); + CHECK(text == "foo bar baz"); + CHECK(b.start() == 3); + CHECK(b.length() == 8); + CHECK(b.valueType() == "UTF8Text"); + + // w/trim == false + // toNode() should treat this (the std::string) case as if trim + // were true. If it didn't, we'd end up with, well, leading and + // trailing *empty* strings, which, well, amount to leading and + // trailing nothing. + text = "this should be replaced"; + b.trim = false; + b.toNode(text); + CHECK(text == "foo bar baz"); + CHECK(b.start() == 3); + CHECK(b.length() == 8); + CHECK(b.valueType() == "UTF8Text"); + } + } + } + + // BlockData, after being given a particular vector + // For T something other than int, double, and std::string + GIVEN("A BlockData, assigned from a particular vector") { + WHEN("toNode() is called") { + THEN("The computed text string is as expected, " + "and the parameters were computed properly" + ) { + struct : public BlockData { + struct { + } Content; + } derived; + BlockData &b = derived; + + // what's set here should be replaced upon assignment from vector + b.string("x y z").start(100).length(200).valueType("foobar"); + + // assign from vector + b = std::vector{{0,0,0,0,0,'a','b','c','d',0}}; + + std::string text = "this should be replaced"; + b.toNode(text); + CHECK(text == "a b c d"); + CHECK(b.start() == 5); + CHECK(b.length() == 10); + CHECK(b.valueType() == "char"); + } + } + } +} + + +// ----------------------------------------------------------------------------- +// Scenario +// ----------------------------------------------------------------------------- + +SCENARIO("BlockData toNode()") { + scenario_toNode(); +} + +SCENARIO("BlockData toNode()") { + scenario_toNode(); +} diff --git a/src/GNDStk/BlockData/test/types.test.cpp b/src/GNDStk/BlockData/test/types.test.cpp new file mode 100644 index 000000000..ffbee513b --- /dev/null +++ b/src/GNDStk/BlockData/test/types.test.cpp @@ -0,0 +1,121 @@ + +#include "catch.hpp" +#include "GNDStk.hpp" + +using namespace njoy::GNDStk; + +// ----------------------------------------------------------------------------- +// Scenario +// ----------------------------------------------------------------------------- + +SCENARIO("BlockData data types") { + GIVEN("std::vector for certain specific Ts") { + + WHEN("Via BlockData, we make variants of vectors and of scalars") { + // vector type + using vv = BlockData::VariantOfVectors; + THEN("The variant-of-vector size should be correct") { + CHECK(std::variant_size_v == 15); + } + vv vectors; + + // scalar type + using vs = BlockData::VariantOfScalars; + THEN("The variant-of-scalar size should be correct") { + CHECK(std::variant_size_v == 15); + } + vs scalars; + + THEN("Transforming to vector, and access, work") { + vectors = std::vector(10,"a"); + scalars = std::get>(vectors)[0]; + CHECK(std::get(scalars) == "a"); + } + + THEN("Transforming to vector, and access, work") { + vectors = std::vector(10,'b'); + scalars = std::get>(vectors)[0]; + CHECK(std::get(scalars) == 'b'); + } + + THEN("Transforming to vector, and access, work") { + vectors = std::vector(10,-100); + scalars = std::get>(vectors)[0]; + CHECK(std::get(scalars) == -100); + } + + THEN("Transforming to vector, and access, work") { + vectors = std::vector(10,-200); + scalars = std::get>(vectors)[0]; + CHECK(std::get(scalars) == -200); + } + + THEN("Transforming to vector, and access, work") { + vectors = std::vector(10,-300); + scalars = std::get>(vectors)[0]; + CHECK(std::get(scalars) == -300); + } + + THEN("Transforming to vector, and access, work") { + vectors = std::vector(10,-400); + scalars = std::get>(vectors)[0]; + CHECK(std::get(scalars) == -400); + } + + THEN("Transforming to vector, and access, work") { + vectors = std::vector(10,-500); + scalars = std::get>(vectors)[0]; + CHECK(std::get(scalars) == -500); + } + + THEN("Transforming to vector, and access, work") { + vectors = std::vector(10,100); + scalars = std::get>(vectors)[0]; + CHECK(std::get(scalars) == 100); + } + + THEN("Transforming to vector, and access, work") { + vectors = std::vector(10,200); + scalars = std::get>(vectors)[0]; + CHECK(std::get(scalars) == 200); + } + + THEN("Transforming to vector, and access, work") { + vectors = std::vector(10,300); + scalars = std::get>(vectors)[0]; + CHECK(std::get(scalars) == 300); + } + + THEN("Transforming to vector, and access, work") { + vectors = std::vector(10,400); + scalars = std::get>(vectors)[0]; + CHECK(std::get(scalars) == 400); + } + + THEN("Transforming to vector, and access, work") { + vectors = std::vector(10,500); + scalars = std::get>(vectors)[0]; + CHECK(std::get(scalars) == 500); + } + + THEN("Transforming to vector, and access, work") { + vectors = std::vector(10,-1.2f); + scalars = std::get>(vectors)[0]; + CHECK(std::get(scalars) == -1.2f); + } + + THEN("Transforming to vector, and access, work") { + vectors = std::vector(10,3.4); + scalars = std::get>(vectors)[0]; + CHECK(std::get(scalars) == 3.4); + } + + THEN("Transforming to vector, and access, work") { + vectors = std::vector(10,-5.6); + scalars = std::get>(vectors)[0]; + CHECK(std::get(scalars) == -5.6); + } + } // WHEN + + } // GIVEN +} // SCENARIO diff --git a/src/GNDStk/BodyText.hpp b/src/GNDStk/BodyText.hpp deleted file mode 100644 index 7b963fd0c..000000000 --- a/src/GNDStk/BodyText.hpp +++ /dev/null @@ -1,148 +0,0 @@ - -// Printing-related colors. -// todo Eventually, this probably belongs in a more context-agnostic -// location, such as GNDStk's utility.hpp file or something like it. -#include "GNDStk/BodyText/src/colors.hpp" - -// Miscellaneous helper constructs. -#include "GNDStk/BodyText/src/detail.hpp" - - -// ----------------------------------------------------------------------------- -// BodyText -// The case is specialized and has the fun stuff. This one needs -// just a bit of content, in order to facilitate uniform treatment of BodyText. -// ----------------------------------------------------------------------------- - -template -class BodyText { -public: - using VariantOfVectors = std::variant; - using VariantOfScalars = std::variant; - static inline constexpr bool runtime = false; - template - static inline constexpr bool supported = false; -}; - - -// ----------------------------------------------------------------------------- -// BodyText -// -// Designed to be flexible, smart, and safe. Does lots of checks, and, for the -// DATA == void case, can essentially re-form itself depending on what type of -// data someone tries to extract. -// -// For efficiency in the DATA == void case, an application might want to copy -// to its own vector (e.g. auto myvec = mybodytext.get>()) -// in order to do work on (or with) the vector there, before copying it back. -// ----------------------------------------------------------------------------- - -template -class BodyText { -public: - - #include "GNDStk/BodyText/src/types.hpp" - - // For convenience in various SFINAE and if-constexpr constructs - static inline constexpr bool runtime = detail::isVoid; - template - struct is_supported { - static inline constexpr bool value = - ( runtime && detail::isAlternative) || - (!runtime && ( - std::is_constructible_v || - std::is_convertible_v - )); - }; - template - static inline constexpr bool supported = is_supported::value; - - enum class Active { string, vector }; - -private: - - // For internal use - mutable Active act = Active::string; - - // Raw string, directly from "plain character data" in a GNDS file. - // We'll allow callers to set this by using a setter. - std::string rawstring; - - // Vector of . - // Mutable, so that we can defer processing of the raw string into - // a vector until, and unless, a caller *asks* for the vector. - // This will be used if, and only if, DATA == void. - mutable VariantOfVectors variant; - - // Vector of - // This will be used if, and only if, DATA != void. - // data_t is used in a few places where, without it, we'd create compilation - // errors by using "void" in invalid ways. The "int" below is arbitrary - - // essentially a placeholder; the following is only used when !runtime. - using data_t = std::conditional_t; - mutable std::vector vector; - -public: - - // Parameters that affect interpretation of the raw string: - // struct vars { length, start, valueType } - // Includes public getters and setters for those. - // We won't use valueType if DATA != void. - #include "GNDStk/BodyText/src/params.hpp" - - // trim - // Flag: should the conversion of BodyText data back into textual data, - // in a Node, trim zeros from the start and end of the output? - mutable bool trim = true; - - // Getters and setters for the raw string: - #include "GNDStk/BodyText/src/string.hpp" - - // active() - Active active() const { return act; } - - // clear() - // Clears the vector, or the active vector alternative in the variant. - BodyText &clear() - { - if constexpr (runtime) - std::visit([](auto &&alt) { alt.clear(); }, variant); - else - vector.clear(); - - act = Active::vector; - return *this; - } - - // size() - // Returns the size of the vector, or of the active vector alternative in - // the variant. Depending on what someone may or may not have done with the - // current BodyText object, size() might or might not reflect the values of - // length and/or start, or reflect the current contents of the raw string. - std::size_t size() const - { - if constexpr (runtime) - return std::visit([](auto &&alt) { return alt.size(); }, variant); - else - return vector.size(); - } - - // Various vector get() functions, and the type-specific doubles() etc. - #include "GNDStk/BodyText/src/get.hpp" - - // Read/write data, from/to a Node - #include "GNDStk/BodyText/src/fromNode.hpp" - #include "GNDStk/BodyText/src/toNode.hpp" - - // Write to ostream - // Not to be confused with the process of writing data to a Node - #include "GNDStk/BodyText/src/write.hpp" - - // Pull/push length/start/valueType from/to derived-class struct content - #include "GNDStk/BodyText/src/sync.hpp" - - // Assignment - // From string or vector; the former == calling our raw string setter - #include "GNDStk/BodyText/src/assign.hpp" - -}; // class BodyText diff --git a/src/GNDStk/BodyText/src/assign.hpp b/src/GNDStk/BodyText/src/assign.hpp deleted file mode 100644 index b1b975822..000000000 --- a/src/GNDStk/BodyText/src/assign.hpp +++ /dev/null @@ -1,75 +0,0 @@ - -// ----------------------------------------------------------------------------- -// Assignment from string -// Same effect as the string(new string) setter -// ----------------------------------------------------------------------------- - -BodyText &operator=(const std::string &str) -{ - return string(str); -} - - -// ----------------------------------------------------------------------------- -// Assignment from vector -// ----------------------------------------------------------------------------- - -/* -DISCUSSION - -Elsewhere, a BodyText object can be made from a GNDS node. From GNDS, we get -a text string (copied to the rawstring field), from which a vector of values -can be created on an as-needed basis. A GNDS node might also give us any of -length, start, and valueType, which, when pulling data from the Node, we'll -use if they're there, or otherwise assume to be our defaults. - -Here, we're allowing for an assignment BodyText = vector. For this assignment, -the caller should send the full, complete vector of values that's appropriate -for the GNDS Node whose data this BodyText object is intended to represent. - -Specifically: the vector should contain whatever leading and/or trailing 0s -the full data vector is supposed to have. The length and start values are -completely ignored by this function; they're neither used nor set. Future -vector accesses though our various get() functions simply access the vector -exactly as-is. Length and start won't come into play until - and unless - a -caller uses the string setter (or assignment to string) and subsequently -triggers a remake of the vector. (Which would then be a newly-created vector, -based on the value of the raw string - not the vector from which we're -assigning here.) - -As for valueType, this function attempts to guess it from the vector's element -type, and sets it to "", the empty string, if we don't recognize that type. - -If a vector that's assigned from, here, is still in play when this BodyText's -data are written to a Node (see the toNode() function), then toNode() will -recompute length and start automatically, based on the vector's beginning and -ending content, if the "trim" flag is set. See toNode() for more information. -*/ - -template -std::enable_if_t, BodyText &> -operator=(const std::vector &vec) -{ - // set the raw string to "", because it's no longer considered meaningful - rawstring = ""; - - // length, start, valueType - length(vec.size()); - start(0); - valueType(detail::MapTypeString::value[0]); - - // assign vector - if constexpr (runtime) - variant = vec; - else if constexpr (std::is_same_v) - vector = vec; - else { - vector.clear(); - vector.reserve(vec.size()); - for (const T &element : vec) - vector.push_back(DATA(element)); - } - - act = Active::vector; - return *this; -} diff --git a/src/GNDStk/BodyText/src/detail.hpp b/src/GNDStk/BodyText/src/detail.hpp deleted file mode 100644 index dd5053e9e..000000000 --- a/src/GNDStk/BodyText/src/detail.hpp +++ /dev/null @@ -1,170 +0,0 @@ - -namespace detail { - -// ----------------------------------------------------------------------------- -// Miscellaneous -// ----------------------------------------------------------------------------- - -// scalarize -template -auto scalarize(const std::variant) -{ - return std::variant{}; -} - -// decays, decays_t -// Like std::decay and std::decay_t, but for tuple -template -struct decays { }; -template -struct decays> { - using type = std::tuple ...>; -}; - -template -using decays_t = typename decays::type; - - - -// ----------------------------------------------------------------------------- -// SFINAE constructs for detecting whether or not a class has certain members. -// Adapted from an answer here: https://stackoverflow.com/questions/1005476 -// ----------------------------------------------------------------------------- - -// ------------------------ -// Helpers -// ------------------------ - -// has_length -template -struct has_length - : std::false_type { }; - -template -struct has_length - : std::true_type { }; - -// has_start -template -struct has_start - : std::false_type { }; - -template -struct has_start - : std::true_type { }; - -// has_valueType -template -struct has_valueType - : std::false_type { }; - -template -struct has_valueType - : std::true_type { }; - -// has_index -template -struct has_index - : std::false_type { }; - -template -struct has_index - : std::true_type { }; - -template -struct has_index> { - // for variant: does any alternative have index? - static constexpr bool value = (has_index::value || ...); -}; - -// has_label -template -struct has_label - : std::false_type { }; - -template -struct has_label - : std::true_type { }; - -template -struct has_label> { - // for variant: does any alternative have label? - static constexpr bool value = (has_label::value || ...); -}; - - -// ------------------------ -// Prefer these. -// They apply std::decay, -// and don't need ::value -// ------------------------ - -template -inline constexpr bool hasLength = has_length >::value; -template -inline constexpr bool hasStart = has_start >::value; -template -inline constexpr bool hasValueType = has_valueType>::value; -template -inline constexpr bool hasIndex = has_index >::value; -template -inline constexpr bool hasLabel = has_label >::value; - - - -// ----------------------------------------------------------------------------- -// element2element -// ----------------------------------------------------------------------------- - -// Remark: PrecisionContext::data, not PrecisionContext::metadata, is the right -// precision context (in terms of our functionality for handling floating-point -// precision) in the code for which element2element() is called. We could bypass -// element2element() entirely, using convert_t{}(...) instead, except that then -// PrecisionContext::metadata would ultimately get used for floating-point T. -// So, below, we recognize floating-point T directly, and handle it correctly. - -// string ==> arithmetic -template>> -void element2element(const std::string &str, T &value) -{ - if constexpr (std::is_floating_point_v) - value = Precision{}.read(str); - else - convert_t{}(str,value); -} - -// arithmetic ==> arithmetic -template -void element2element(const FROM &from, TO &to) -{ - convert_t{}(from,to); -} - -// arithmetic ==> string -template>> -void element2element(const T &value, std::string &str) -{ - if constexpr (std::is_floating_point_v) - str = Precision{}.write(value); - else - convert_t{}(value,str); -} - - - -// ----------------------------------------------------------------------------- -// getBounds -// ----------------------------------------------------------------------------- - -template -auto getBounds(const std::vector &vec) -{ - T zero; - if constexpr (std::is_same_v) zero = ""; else zero = T(0); - std::pair bnd(0,vec.size()); - while (bnd.first < bnd.second && vec[bnd.first ] == zero) ++bnd.first; - while (bnd.first < bnd.second && vec[bnd.second-1] == zero) --bnd.second; - return bnd; -} - -} // namespace detail diff --git a/src/GNDStk/BodyText/src/fromNode.hpp b/src/GNDStk/BodyText/src/fromNode.hpp deleted file mode 100644 index c54b50027..000000000 --- a/src/GNDStk/BodyText/src/fromNode.hpp +++ /dev/null @@ -1,39 +0,0 @@ - -// ----------------------------------------------------------------------------- -// BodyText::fromNode(Node) -// ----------------------------------------------------------------------------- - -void fromNode(const Node &node) -{ - // length, start, and valueType might be present in the Node, but we won't - // fetch any of them here. Elsewhere, the current BodyText object should have - // its length, start, and valueType pulled from those respective values in - // an object of a class derived from Component (which in turn derives from - // BodyText). That object's content will have been pulled from the same Node. - // Here, we just get the Node's values: "plain character data" in XML terms. - - bool found = false; - rawstring = node.pcdata(found); - - if (!found) { - rawstring = ""; - - // Warning, re: why are we in BodyText if there's no body text? - // Perhaps it's possible that the Node has a non-default length and/or - // start, so that the values are all supposed to be...zero. Until and - // unless we discover otherwise, however, we doubt that that would be - // the case, and will consider a Node's lack of plain character data, - // in the present context, to be something that merits a warning. - log::warning( - "Component marked as having \"body text\", a.k.a. XML \"pcdata\" " - "(plain\ncharacter data), " - "but no such content was found in the GNDS node." - ); - log::member("BodyText::fromNode(Node, with name \"{}\")", node.name); - } - - // Above, we set the raw string. The following reflects this, so that the - // vector, or a vector in the variant, will be rebuilt from the raw string - // if and when a caller asks for it. - act = Active::string; -} diff --git a/src/GNDStk/BodyText/src/string.hpp b/src/GNDStk/BodyText/src/string.hpp deleted file mode 100644 index 6ffef6fca..000000000 --- a/src/GNDStk/BodyText/src/string.hpp +++ /dev/null @@ -1,25 +0,0 @@ - -// ----------------------------------------------------------------------------- -// Getters and setters for the raw string -// ----------------------------------------------------------------------------- - -// getter -// string() -// Not to be confused with strings() (plural), which returns vector. -// Returns const &; the raw string can be *changed* only through the setter. -const std::string &string() const -{ - return rawstring; -} - -// setter -// string(new string) -// Builder pattern: return *this, so callers can use this function smoothly -// in conjunction with the setters for length, start, and valueType. -BodyText &string(const std::string &str) -{ - clear(); // <== the vector, because it's no longer considered meaningful - rawstring = str; - act = Active::string; - return *this; -} diff --git a/src/GNDStk/BodyText/src/sync.hpp b/src/GNDStk/BodyText/src/sync.hpp deleted file mode 100644 index 98fa02830..000000000 --- a/src/GNDStk/BodyText/src/sync.hpp +++ /dev/null @@ -1,28 +0,0 @@ - -// pullFromDerived(derived) -// Make this BodyText's length, start, and valueType be consistent with any or -// all such parameters that exist in the given object. Remember that this class, -// BodyText, is a base of Component, which is a base of some other class. -template -void pullFromDerived(const T &obj) -{ - if constexpr (detail::hasLength) - length(obj.content.length); - if constexpr (detail::hasStart) - start(obj.content.start); - if constexpr (detail::hasValueType) - valueType(obj.content.valueType); -} - -// pushToDerived(derived) -// The reverse of the above. -template -void pushToDerived(T &obj) const -{ - if constexpr (detail::hasLength) - obj.content.length = length(); - if constexpr (detail::hasStart) - obj.content.start = start(); - if constexpr (detail::hasValueType) - obj.content.valueType = valueType(); -} diff --git a/src/GNDStk/BodyText/src/write.hpp b/src/GNDStk/BodyText/src/write.hpp deleted file mode 100644 index 98dbb4a64..000000000 --- a/src/GNDStk/BodyText/src/write.hpp +++ /dev/null @@ -1,72 +0,0 @@ - -// ----------------------------------------------------------------------------- -// write -// To an ostream (not to a Node; that a different thing) -// ----------------------------------------------------------------------------- - -std::ostream &write(std::ostream &os, const int level) const -{ - // If empty, don't even write a newline - if ((active() == Active::string && rawstring == "") || - (active() == Active::vector && size() == 0)) - return os; - - // ------------------------ - // If string is active - // ------------------------ - - if (active() == Active::string) { - // write the string exactly as-is, without our column formatting - // or any indentation; then also write a newline - GNDStk::color && GNDStk::colors::value != "" - ? os << colors::value << rawstring << colors::reset - : os << rawstring; - return os << std::endl; - } - - // ------------------------ - // If vector is active - // ------------------------ - - // Indentation (string, with some number of spaces) - const auto indent = std::string(GNDStk::indent*level,' '); - - const auto writeLambda = - [&os,&indent](auto &&alt) - { - std::size_t count = 0; - using T = std::decay_t; - - // use our column formatting - for (auto &element : alt) { - count == 0 - ? os << indent - : GNDStk::across == 0 || count % GNDStk::across != 0 - ? os << ' ' - : os << '\n' << indent; - - if (GNDStk::color && GNDStk::colors::value != "") - os << colors::value; - - if constexpr (std::is_floating_point_v) - os << detail::Precision< - detail::PrecisionContext::data, - T - >{}.write(element); - else - os << element; - - if (GNDStk::color && GNDStk::colors::value != "") - os << colors::reset; - - count++; - }; - }; - - if constexpr (runtime) - std::visit(writeLambda,variant); - else - writeLambda(vector); - - return os << std::endl; -} diff --git a/src/GNDStk/BodyText/test/BodyText.test.cpp b/src/GNDStk/BodyText/test/BodyText.test.cpp deleted file mode 100644 index 09cb28cc8..000000000 --- a/src/GNDStk/BodyText/test/BodyText.test.cpp +++ /dev/null @@ -1,192 +0,0 @@ - -#define CATCH_CONFIG_MAIN - -#include "catch.hpp" -#include "GNDStk.hpp" - -using namespace njoy::GNDStk::core; - - -// ----------------------------------------------------------------------------- -// Scenario for DATA == void -// ----------------------------------------------------------------------------- - -SCENARIO("Testing GNDStk BodyText with DATA == void") { - // Most BodyText functionality is tested in the individual test files. - // There are just a few things we'll do here. - - // Ensure that we can make const and non-const and BodyText - // objects. Note that BodyText has only a default constructor. - - GIVEN("A const BodyText cbtextt") { - const BodyText cbtextt; - THEN("It constructed correctly, and its data are as expected") { - CHECK(cbtextt.length () == 0); - CHECK(cbtextt.size () == 0); - CHECK(cbtextt.valueType() == ""); - CHECK(cbtextt.string () == ""); - } - } - - GIVEN("A const BodyText cbtextf") { - const BodyText cbtextf; - THEN("It constructed correctly") { - // no data for - } - } - - GIVEN("A non-const BodyText nbtextt") { - BodyText nbtextt; - THEN("It constructed correctly, and its data are as expected") { - CHECK(nbtextt.length () == 0); - CHECK(nbtextt.size () == 0); - CHECK(nbtextt.valueType() == ""); - CHECK(nbtextt.string () == ""); - } - } - - GIVEN("A non-const BodyText nbtextf") { - BodyText nbtextf; - THEN("It constructed correctly") { - // no data for - } - } - - // clear() and size() are defined (at the time of this writing) in the - // BodyText.hpp file itself, so we'll test them here. size() actually - // was used in various tests, and thus was indirectly tested elsewhere. - - GIVEN("A BodyText") { - // clear - WHEN("We test clear()") { - BodyText b; - - // try int - THEN("size() works correctly for vector") { - b = std::vector{1,2,3,4,5}; - CHECK(b.size() == 5); - b.clear(); - CHECK(b.size() == 0); - } - - // try double - THEN("size() works correctly for vector") { - b = std::vector{1.1, 2.2, 3.3, 4.4, 5.5}; - CHECK(b.size() == 5); - b.clear(); - CHECK(b.size() == 0); - } - - // try string - THEN("size() works correctly for vector") { - b = std::vector{"one","two","three","four","five"}; - CHECK(b.size() == 5); - b.clear(); - CHECK(b.size() == 0); - } - } - - // size - WHEN("We test size()") { - BodyText b; - - // try int - THEN("size() works correctly for vector") { - b = std::vector{1,2,3,4,5}; - CHECK(b.size() == 5); - b = std::vector{1}; - CHECK(b.size() == 1); - b = std::vector{}; - CHECK(b.size() == 0); - } - - // try double - THEN("size() works correctly for vector") { - b = std::vector{1.1, 2.2, 3.3, 4.4, 5.5}; - CHECK(b.size() == 5); - b = std::vector{1.1}; - CHECK(b.size() == 1); - b = std::vector{}; - CHECK(b.size() == 0); - } - - // try string - THEN("size() works correctly for vector") { - b = std::vector{"one","two","three","four","five"}; - CHECK(b.size() == 5); - b = std::vector{"one"}; - CHECK(b.size() == 1); - b = std::vector{}; - CHECK(b.size() == 0); - } - } - } -} // SCENARIO - - -// ----------------------------------------------------------------------------- -// Scenario for DATA != void -// ----------------------------------------------------------------------------- - -SCENARIO("Testing GNDStk BodyText with DATA != void") { - - GIVEN("A const BodyText cbtextt") { - const BodyText cbtextt; - THEN("It constructed correctly, and its data are as expected") { - CHECK(cbtextt.length () == 0); - CHECK(cbtextt.size () == 0); - CHECK(cbtextt.valueType() == ""); - CHECK(cbtextt.string () == ""); - } - } - - GIVEN("A const BodyText cbtextf") { - const BodyText cbtextf; - THEN("It constructed correctly") { - // no data for - } - } - - GIVEN("A non-const BodyText nbtextt") { - BodyText nbtextt; - THEN("It constructed correctly, and its data are as expected") { - CHECK(nbtextt.length () == 0); - CHECK(nbtextt.size () == 0); - CHECK(nbtextt.valueType() == ""); - CHECK(nbtextt.string () == ""); - } - } - - GIVEN("A non-const BodyText nbtextf") { - BodyText nbtextf; - THEN("It constructed correctly") { - // no data for - } - } - - GIVEN("A BodyText") { - // clear - WHEN("We test clear()") { - BodyText b; - THEN("size() works correctly") { - b = std::vector{1,2,3,4,5}; - CHECK(b.size() == 5); - b.clear(); - CHECK(b.size() == 0); - } - } - - // size - WHEN("We test size()") { - BodyText b; - THEN("size() works correctly") { - b = std::vector{"one","two","three","four","five"}; - CHECK(b.size() == 5); - b = std::vector{"one"}; - CHECK(b.size() == 1); - b = std::vector{}; - CHECK(b.size() == 0); - } - } - } -} // SCENARIO diff --git a/src/GNDStk/BodyText/test/CMakeLists.txt b/src/GNDStk/BodyText/test/CMakeLists.txt deleted file mode 100644 index 37cdf9076..000000000 --- a/src/GNDStk/BodyText/test/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ - -add_executable( GNDStk.BodyText.test - BodyText.test.cpp - assign.test.cpp - detail.test.cpp - fromNode.test.cpp - get.test.cpp - params.test.cpp - string.test.cpp - sync.test.cpp - toNode.test.cpp - types.test.cpp - write.test.cpp ) -target_compile_options( GNDStk.BodyText.test PRIVATE ${${PREFIX}_common_flags} -$<$:${${PREFIX}_strict_flags}>$<$: -${${PREFIX}_DEBUG_flags} -$<$:${${PREFIX}_coverage_flags}>> -$<$: -${${PREFIX}_RELEASE_flags} -$<$:${${PREFIX}_link_time_optimization_flags}> -$<$:${${PREFIX}_nonportable_optimization_flags}>> - -${CXX_appended_flags} ${GNDStk_appended_flags} ) -target_link_libraries( GNDStk.BodyText.test PUBLIC GNDStk ) -add_test( NAME GNDStk.BodyText COMMAND GNDStk.BodyText.test ) diff --git a/src/GNDStk/BodyText/test/detail.test.cpp b/src/GNDStk/BodyText/test/detail.test.cpp deleted file mode 100644 index 5083a4f2e..000000000 --- a/src/GNDStk/BodyText/test/detail.test.cpp +++ /dev/null @@ -1,421 +0,0 @@ - -#include "catch.hpp" -#include "GNDStk.hpp" - -using namespace njoy::GNDStk::core; -inline std::string bar = "bar"; - -// ----------------------------------------------------------------------------- -// Scenario -// ----------------------------------------------------------------------------- - -SCENARIO("Testing various BodyText-related detail:: constructs") { - - // ------------------------ - // scalarize - // ------------------------ - - GIVEN("Some variants of vectors") { - using vc = std::variant< - std::vector - >; - using vci = std::variant< - std::vector, - std::vector - >; - using vcid = std::variant< - std::vector, - std::vector, - std::vector - >; - - // Double parenthesis are needed for the CHECK macro, - // because of the commas... - THEN("detail::scalarize() works correctly") { - CHECK(( - std::is_same_v< - decltype(detail::scalarize(vc{})), - std::variant - > - )); - CHECK(( - std::is_same_v< - decltype(detail::scalarize(vci{})), - std::variant - > - )); - CHECK(( - std::is_same_v< - decltype(detail::scalarize(vcid{})), - std::variant - > - )); - } - } // GIVEN - - - // ------------------------ - // decays - // ------------------------ - - GIVEN("Testing detail::decays") { - using tup1 = std::tuple<>; - using tup2 = std::tuple; - using tup3 = std::tuple; - using tup4 = std::tuple; - using tup5 = std::tuple; - - CHECK((std::is_same_v, std::tuple<>>)); - CHECK((std::is_same_v, std::tuple>)); - CHECK((std::is_same_v, std::tuple>)); - CHECK((std::is_same_v, std::tuple>)); - CHECK((std::is_same_v, std::tuple>)); - } // GIVEN - - - // ------------------------ - // hasLength, hasStart, - // hasValueType - // ------------------------ - - GIVEN("Testing detail::hasLength, hasStart, and hasValueType") { - WHEN("A struct's content has length, start, and valueType") { - struct { - struct { - int length; - const double start = 0; - const std::string &valueType = bar; - } content; - } foo; - THEN("Our SFINAE helpers detect this") { - CHECK((detail::hasLength == true)); - CHECK((detail::hasStart == true)); - CHECK((detail::hasValueType == true)); - } - } - - WHEN("A struct's content has start and valueType") { - struct { - struct { - const double start = 0; - const std::string &valueType = bar; - } content; - } foo; - THEN("Our SFINAE helpers detect this") { - CHECK((detail::hasLength == false)); - CHECK((detail::hasStart == true)); - CHECK((detail::hasValueType == true)); - } - } - - WHEN("A struct's content has length and valueType") { - struct { - struct { - int length; - const std::string &valueType = bar; - } content; - } foo; - THEN("Our SFINAE helpers detect this") { - CHECK((detail::hasLength == true)); - CHECK((detail::hasStart == false)); - CHECK((detail::hasValueType == true)); - } - } - - WHEN("A struct's content has length and start") { - struct { - struct { - int length; - const double start = 0; - } content; - } foo; - THEN("Our SFINAE helpers detect this") { - CHECK((detail::hasLength == true)); - CHECK((detail::hasStart == true)); - CHECK((detail::hasValueType == false)); - } - } - - WHEN("A struct's content has length") { - struct { - struct { - int length; - } content; - } foo; - THEN("Our SFINAE helpers detect this") { - CHECK((detail::hasLength == true)); - CHECK((detail::hasStart == false)); - CHECK((detail::hasValueType == false)); - } - } - - WHEN("A struct's content has start") { - struct { - struct { - const double start = 0; - } content; - } foo; - THEN("Our SFINAE helpers detect this") { - CHECK((detail::hasLength == false)); - CHECK((detail::hasStart == true)); - CHECK((detail::hasValueType == false)); - } - } - - WHEN("A struct's content has valueType") { - struct { - struct { - const std::string &valueType = bar; - } content; - } foo; - THEN("Our SFINAE helpers detect this") { - CHECK((detail::hasLength == false)); - CHECK((detail::hasStart == false)); - CHECK((detail::hasValueType == true)); - } - } - - WHEN("A struct's content has none of length, start, or valueType") { - struct { - struct { - } content; - } foo; - THEN("Our SFINAE helpers detect this") { - CHECK((detail::hasLength == false)); - CHECK((detail::hasStart == false)); - CHECK((detail::hasValueType == false)); - } - } - } // GIVEN - - - // ------------------------ - // element2element - // ------------------------ - - GIVEN("Testing detail::element2element") { - WHEN("We use element2element(from int, to string)") { - const int from = 123; - std::string to; - detail::element2element(from,to); - CHECK(to == "123"); - } - - WHEN("We use element2element(from double, to string)") { - const double from = 4.56; - std::string to; - detail::element2element(from,to); - CHECK(to == "4.56"); - } - - WHEN("We use element2element(from string, to int)") { - const std::string from = "987"; - int to; - detail::element2element(from,to); - CHECK(to == 987); - } - - WHEN("We use element2element(from string, to double)") { - const std::string from = "6.54"; - double to; - detail::element2element(from,to); - CHECK(Approx(to) == 6.54); - } - - WHEN("We use element2element(from int, to double)") { - const int from = 345; - double to; - detail::element2element(from,to); - CHECK(to == double(345)); - } - - WHEN("We use element2element(from double, to int)") { - const double from = 6.78; - int to; - detail::element2element(from,to); - CHECK(to == 6); - } - } - - - // ------------------------ - // getBounds - // ------------------------ - - GIVEN("Testing detail::getBounds") { - - // ------------------------ - // Various vectors - // ------------------------ - - WHEN("We try vectors of varying sizes") { - - THEN("Bounds are correct when size == 0") { - std::vector v = {}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 0); - CHECK(bounds.second == 0); - } - - THEN("Bounds are correct when size == 1, with a 0") { - std::vector v = {0}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 1); - CHECK(bounds.second == 1); - } - - THEN("Bounds are correct when size == 2, all 0") { - std::vector v = {0, 0}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 2); - CHECK(bounds.second == 2); - } - - THEN("Bounds are correct when size == 3, all non-0") { - std::vector v = {2, 3, 5}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 0); - CHECK(bounds.second == 3); - } - - THEN("Bounds are correct when there are trailing 0s") { - std::vector v = {2, 3, 5, 0, 0, 0}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 0); - CHECK(bounds.second == 3); - } - - THEN("Bounds are correct when there are leading 0s") { - std::vector v = {0, 0, 2, 3, 5}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 2); - CHECK(bounds.second == 5); - } - - THEN("Bounds are correct when there are leading and trailing 0s") { - std::vector v = {0, 0, 2, 3, 5, 0, 0, 0}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 2); - CHECK(bounds.second == 5); - } - - } // WHEN - - - // ------------------------ - // Various vectors - // ------------------------ - - WHEN("We try vectors of varying sizes") { - - THEN("Bounds are correct when size == 0") { - std::vector v = {}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 0); - CHECK(bounds.second == 0); - } - - THEN("Bounds are correct when size == 1, with a 0") { - std::vector v = {0}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 1); - CHECK(bounds.second == 1); - } - - THEN("Bounds are correct when size == 3, all 0") { - std::vector v = {0, 0, 0}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 3); - CHECK(bounds.second == 3); - } - - THEN("Bounds are correct when size == 3, all non-0") { - std::vector v = {1.2, 3.4, 5.6}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 0); - CHECK(bounds.second == 3); - } - - THEN("Bounds are correct when there are trailing 0s") { - std::vector v = {1.2, 3.4, 5.6, 0, 0}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 0); - CHECK(bounds.second == 3); - } - - THEN("Bounds are correct when there are leading 0s") { - std::vector v = {0, 0, 0, 1.2, 3.4, 5.6}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 3); - CHECK(bounds.second == 6); - } - - THEN("Bounds are correct when there are leading and trailing 0s") { - std::vector v = {0, 0, 0, 1.2, 3.4, 5.6, 0, 0}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 3); - CHECK(bounds.second == 6); - } - - } - - - // ------------------------ - // Various vectors - // ------------------------ - - WHEN("We try vectors of varying sizes") { - - THEN("Bounds are correct when size == \"\"") { - std::vector v = {}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 0); - CHECK(bounds.second == 0); - } - - THEN("Bounds are correct when size == 1, with a \"\"") { - std::vector v = {""}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 1); - CHECK(bounds.second == 1); - } - - THEN("Bounds are correct when size == 2, all \"\"") { - std::vector v = {"", ""}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 2); - CHECK(bounds.second == 2); - } - - THEN("Bounds are correct when size == 2, all non-\"\"") { - std::vector v = {"abc", "def"}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 0); - CHECK(bounds.second == 2); - } - - THEN("Bounds are correct when there are trailing \"\"s") { - std::vector v = {"abc", "def", "", "", ""}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 0); - CHECK(bounds.second == 2); - } - - THEN("Bounds are correct when there are leading \"\"s") { - std::vector v = {"", "", "abc", "def"}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 2); - CHECK(bounds.second == 4); - } - - THEN("Bounds are correct when there are leading and trailing \"\"s") { - std::vector v = {"", "", "abc", "def", "", "", ""}; - const auto bounds = detail::getBounds(v); - CHECK(bounds.first == 2); - CHECK(bounds.second == 4); - } - - } // WHEN - } // GIVEN - -} // SCENARIO diff --git a/src/GNDStk/BodyText/test/fromNode.test.cpp b/src/GNDStk/BodyText/test/fromNode.test.cpp deleted file mode 100644 index 25e6c5059..000000000 --- a/src/GNDStk/BodyText/test/fromNode.test.cpp +++ /dev/null @@ -1,115 +0,0 @@ - -#include "catch.hpp" -#include "GNDStk.hpp" - -using namespace njoy::GNDStk::core; - - -// ----------------------------------------------------------------------------- -// Scenario for DATA == void -// ----------------------------------------------------------------------------- - -SCENARIO("BodyText fromNode()") { - - GIVEN("A Node with no \"body text\"") { - WHEN("BodyText.fromNode(the node) is called") { - THEN("The BodyText's raw string is \"\", as expected") { - BodyText b; - b.string("This string should be replaced"); - CHECK(b.string() != ""); - - Node node; - node << ""; - b.fromNode(node); - CHECK(b.string() == ""); - } - } - } - - GIVEN("A Node with some \"body text\"") { - WHEN("BodyText.fromNode(the node) is called") { - THEN("The BodyText's raw string equals the text from the Node") { - BodyText b; - b.string("This string should be replaced"); - CHECK(b.string() != ""); - - Node node; - - node << "some plain character data"; - b.fromNode(node); - CHECK(b.string() == "some plain character data"); - - // it shouldn't matter, but leading spaces are preserved - node << " pcdata with leading spaces"; - b.fromNode(node); - CHECK(b.string() == " pcdata with leading spaces"); - - // ditto for trailing spaces - node << "pcdata with trailing spaces "; - b.fromNode(node); - CHECK(b.string() == "pcdata with trailing spaces "); - - // ditto for both together - node << " pcdata "; - b.fromNode(node); - CHECK(b.string() == " pcdata "); - } - } - } - -} // SCENARIO - - -// ----------------------------------------------------------------------------- -// Scenario for DATA != void -// ----------------------------------------------------------------------------- - -SCENARIO("BodyText fromNode()") { - - GIVEN("A Node with no \"body text\"") { - WHEN("BodyText.fromNode(the node) is called") { - THEN("The BodyText's raw string is \"\", as expected") { - BodyText b; - b.string("This string should be replaced"); - CHECK(b.string() != ""); - - Node node; - node << ""; - b.fromNode(node); - CHECK(b.string() == ""); - } - } - } - - GIVEN("A Node with some \"body text\"") { - WHEN("BodyText.fromNode(the node) is called") { - THEN("The BodyText's raw string equals the text from the Node") { - BodyText b; - b.string("This string should be replaced"); - CHECK(b.string() != ""); - - Node node; - - node << "some plain character data"; - b.fromNode(node); - CHECK(b.string() == "some plain character data"); - - // it shouldn't matter, but leading spaces are preserved - node << " pcdata with leading spaces"; - b.fromNode(node); - CHECK(b.string() == " pcdata with leading spaces"); - - // ditto for trailing spaces - node << "pcdata with trailing spaces "; - b.fromNode(node); - CHECK(b.string() == "pcdata with trailing spaces "); - - // ditto for both together - node << " pcdata "; - b.fromNode(node); - CHECK(b.string() == " pcdata "); - } - } - } - -} // SCENARIO diff --git a/src/GNDStk/BodyText/test/get.test.cpp b/src/GNDStk/BodyText/test/get.test.cpp deleted file mode 100644 index 4179ce9af..000000000 --- a/src/GNDStk/BodyText/test/get.test.cpp +++ /dev/null @@ -1,693 +0,0 @@ - -#include "catch.hpp" -#include "GNDStk.hpp" - -using namespace njoy::GNDStk::core; - - - -// ----------------------------------------------------------------------------- -// 1. Scenario: get() -// ----------------------------------------------------------------------------- - -// Helper -template -void scenario_get_vector() -{ - // We'll deal with these vector types for the test. They should cover - // sufficient cases (int, double, string, and none of the above) - // that we get good coverage, without this test being excessively long. - using ivec = std::vector; - using fvec = std::vector; - using svec = std::vector; - using uvec = std::vector; - - // We'll leave valueType at its default of "", which is compatible with - // every possible get type T. This simply means we won't get spammed - // with warnings about the asked-for T possibly being incompatible with - // valueType. Either way - with or without a "" for valueType - get - // gives us back a vector. - - // ------------------------ - // vector - // ------------------------ - - // 0 elements in string - { BodyText b; b.start(0).length(0).string(""); - CHECK((b.template get() == ivec{})); } - { BodyText b; b.start(0).length(4).string(""); - CHECK((b.template get() == ivec{{0,0,0,0}})); } - { BodyText b; b.start(1).length(5).string(""); - CHECK((b.template get() == ivec{{0,0,0,0,0}})); } - { BodyText b; b.start(2).length(6).string(""); - CHECK((b.template get() == ivec{{0,0,0,0,0,0}})); } - - // 1 element in string - { BodyText b; b.start(0).length(0).string("-12"); - CHECK((b.template get() == ivec(1,-12))); } - { BodyText b; b.start(0).length(4).string("-12"); - CHECK((b.template get() == ivec{{-12,0,0,0}})); } - { BodyText b; b.start(1).length(5).string("-12"); - CHECK((b.template get() == ivec{{0,-12,0,0,0}})); } - { BodyText b; b.start(2).length(6).string("-12"); - CHECK((b.template get() == ivec{{0,0,-12,0,0,0}})); } - - // 3 elements in string - { BodyText b; b.start(0).length(0).string("-12 34 -56"); - CHECK((b.template get() == ivec{{-12,34,-56}})); } - { BodyText b; b.start(0).length(4).string("-12 34 -56"); - CHECK((b.template get() == ivec{{-12,34,-56,0}})); } - { BodyText b; b.start(1).length(5).string("-12 34 -56"); - CHECK((b.template get() == ivec{{0,-12,34,-56,0}})); } - { BodyText b; b.start(2).length(6).string("-12 34 -56"); - CHECK((b.template get() == ivec{{0,0,-12,34,-56,0}})); } - - // ------------------------ - // vector - // ------------------------ - - // 0 elements in string - { BodyText b; b.start(0).length(0).string(""); - CHECK((b.template get() == fvec{})); } - { BodyText b; b.start(0).length(4).string(""); - CHECK((b.template get() == fvec{{0,0,0,0}})); } - { BodyText b; b.start(1).length(5).string(""); - CHECK((b.template get() == fvec{{0,0,0,0,0}})); } - { BodyText b; b.start(2).length(6).string(""); - CHECK((b.template get() == fvec{{0,0,0,0,0,0}})); } - - // 1 element in string - { BodyText b; b.start(0).length(0).string("1.2"); - CHECK((b.template get() == fvec(1,1.2))); } - { BodyText b; b.start(0).length(4).string("1.2"); - CHECK((b.template get() == fvec{{1.2,0,0,0}})); } - { BodyText b; b.start(1).length(5).string("1.2"); - CHECK((b.template get() == fvec{{0,1.2,0,0,0}})); } - { BodyText b; b.start(2).length(6).string("1.2"); - CHECK((b.template get() == fvec{{0,0,1.2,0,0,0}})); } - - // 3 elements in string - { BodyText b; b.start(0).length(0).string("1.2 3.4 5.6"); - CHECK((b.template get() == fvec{{1.2,3.4,5.6}})); } - { BodyText b; b.start(0).length(4).string("1.2 3.4 5.6"); - CHECK((b.template get() == fvec{{1.2,3.4,5.6,0}})); } - { BodyText b; b.start(1).length(5).string("1.2 3.4 5.6"); - CHECK((b.template get() == fvec{{0,1.2,3.4,5.6,0}})); } - { BodyText b; b.start(2).length(6).string("1.2 3.4 5.6"); - CHECK((b.template get() == fvec{{0,0,1.2,3.4,5.6,0}})); } - - // ------------------------ - // vector - // ------------------------ - - // 0 elements in string - { BodyText b; b.start(0).length(0).string(""); - CHECK((b.template get() == svec{})); } - { BodyText b; b.start(0).length(4).string(""); - CHECK((b.template get() == svec{{"","","",""}})); } - { BodyText b; b.start(1).length(5).string(""); - CHECK((b.template get() == svec{{"","","","",""}})); } - { BodyText b; b.start(2).length(6).string(""); - CHECK((b.template get() == svec{{"","","","","",""}})); } - - // 1 element in string - { BodyText b; b.start(0).length(0).string("ab"); - CHECK((b.template get() == svec(1,"ab"))); } - { BodyText b; b.start(0).length(4).string("ab"); - CHECK((b.template get() == svec{{"ab","","",""}})); } - { BodyText b; b.start(1).length(5).string("ab"); - CHECK((b.template get() == svec{{"","ab","","",""}})); } - { BodyText b; b.start(2).length(6).string("ab"); - CHECK((b.template get() == svec{{"","","ab","","",""}})); } - - // 3 elements in string - { BodyText b; b.start(0).length(0).string("ab cd ef"); - CHECK((b.template get() == svec{{"ab","cd","ef"}})); } - { BodyText b; b.start(0).length(4).string("ab cd ef"); - CHECK((b.template get() == svec{{"ab","cd","ef",""}})); } - { BodyText b; b.start(1).length(5).string("ab cd ef"); - CHECK((b.template get() == svec{{"","ab","cd","ef",""}})); } - { BodyText b; b.start(2).length(6).string("ab cd ef"); - CHECK((b.template get() == svec{{"","","ab","cd","ef",""}})); } - - // ------------------------ - // vector - // ------------------------ - - // 0 elements in string - { BodyText b; b.start(0).length(0).string(""); - CHECK((b.template get() == uvec{})); } - { BodyText b; b.start(0).length(4).string(""); - CHECK((b.template get() == uvec{{0,0,0,0}})); } - { BodyText b; b.start(1).length(5).string(""); - CHECK((b.template get() == uvec{{0,0,0,0,0}})); } - { BodyText b; b.start(2).length(6).string(""); - CHECK((b.template get() == uvec{{0,0,0,0,0,0}})); } - - // 1 element in string - { BodyText b; b.start(0).length(0).string("12"); - CHECK((b.template get() == uvec(1,12))); } - { BodyText b; b.start(0).length(4).string("12"); - CHECK((b.template get() == uvec{{12,0,0,0}})); } - { BodyText b; b.start(1).length(5).string("12"); - CHECK((b.template get() == uvec{{0,12,0,0,0}})); } - { BodyText b; b.start(2).length(6).string("12"); - CHECK((b.template get() == uvec{{0,0,12,0,0,0}})); } - - // 3 elements in string - { BodyText b; b.start(0).length(0).string("12 34 56"); - CHECK((b.template get() == uvec{{12,34,56}})); } - { BodyText b; b.start(0).length(4).string("12 34 56"); - CHECK((b.template get() == uvec{{12,34,56,0}})); } - { BodyText b; b.start(1).length(5).string("12 34 56"); - CHECK((b.template get() == uvec{{0,12,34,56,0}})); } - { BodyText b; b.start(2).length(6).string("12 34 56"); - CHECK((b.template get() == uvec{{0,0,12,34,56,0}})); } -} - -// For BodyText -SCENARIO("BodyText get()") { - GIVEN("A BodyText object") { - scenario_get_vector(); - } -} - -// For BodyText -SCENARIO("BodyText get()") { - GIVEN("A BodyText object") { - scenario_get_vector(); - } -} - - - -// ----------------------------------------------------------------------------- -// 2. Scenario: get(n) -// ----------------------------------------------------------------------------- - -// Helper -template -void scenario_get_template_n() -{ - // ------------------------ - // vector - // ------------------------ - - // 0 elements in string - { BodyText b; b.start(0).length(0).string(""); /* no elements */ } - { BodyText b; b.start(0).length(4).string(""); - CHECK(b.template get(1) == 0); } - { BodyText b; b.start(1).length(5).string(""); - CHECK(b.template get(2) == 0); } - { BodyText b; b.start(2).length(6).string(""); - CHECK(b.template get(3) == 0); } - - // 1 element in string - { BodyText b; b.start(0).length(0).string("-12"); - CHECK(b.template get(0) == -12); } - { BodyText b; b.start(0).length(4).string("-12"); - CHECK(b.template get(1) == 0); } - { BodyText b; b.start(1).length(5).string("-12"); - CHECK(b.template get(2) == 0); } - { BodyText b; b.start(2).length(6).string("-12"); - CHECK(b.template get(3) == 0); } - - // 3 elements in string - { BodyText b; b.start(0).length(0).string("-12 34 -56"); - CHECK(b.template get(0) == -12); } - { BodyText b; b.start(0).length(4).string("-12 34 -56"); - CHECK(b.template get(1) == 34); } - { BodyText b; b.start(1).length(5).string("-12 34 -56"); - CHECK(b.template get(2) == 34); } - { BodyText b; b.start(2).length(6).string("-12 34 -56"); - CHECK(b.template get(3) == 34); } - - // ------------------------ - // vector - // ------------------------ - - // 0 elements in string - { BodyText b; b.start(0).length(0).string(""); /* no elements */ } - { BodyText b; b.start(0).length(4).string(""); - CHECK(b.template get(1) == 0); } - { BodyText b; b.start(1).length(5).string(""); - CHECK(b.template get(2) == 0); } - { BodyText b; b.start(2).length(6).string(""); - CHECK(b.template get(3) == 0); } - - // 1 element in string - { BodyText b; b.start(0).length(0).string("1.2"); - CHECK(b.template get(0) == 1.2); } - { BodyText b; b.start(0).length(4).string("1.2"); - CHECK(b.template get(1) == 0); } - { BodyText b; b.start(1).length(5).string("1.2"); - CHECK(b.template get(2) == 0); } - { BodyText b; b.start(2).length(6).string("1.2"); - CHECK(b.template get(3) == 0); } - - // 3 elements in string - { BodyText b; b.start(0).length(0).string("1.2 3.4 5.6"); - CHECK(b.template get(0) == 1.2); } - { BodyText b; b.start(0).length(4).string("1.2 3.4 5.6"); - CHECK(b.template get(1) == 3.4); } - { BodyText b; b.start(1).length(5).string("1.2 3.4 5.6"); - CHECK(b.template get(2) == 3.4); } - { BodyText b; b.start(2).length(6).string("1.2 3.4 5.6"); - CHECK(b.template get(3) == 3.4); } - - // ------------------------ - // vector - // ------------------------ - - // 0 elements in string - { BodyText b; b.start(0).length(0).string(""); /* no elements */ } - { BodyText b; b.start(0).length(4).string(""); - CHECK(b.template get(1) == ""); } - { BodyText b; b.start(1).length(5).string(""); - CHECK(b.template get(2) == ""); } - { BodyText b; b.start(2).length(6).string(""); - CHECK(b.template get(3) == ""); } - - // 1 element in string - { BodyText b; b.start(0).length(0).string("ab"); - CHECK(b.template get(0) == "ab"); } - { BodyText b; b.start(0).length(4).string("ab"); - CHECK(b.template get(1) == ""); } - { BodyText b; b.start(1).length(5).string("ab"); - CHECK(b.template get(2) == ""); } - { BodyText b; b.start(2).length(6).string("ab"); - CHECK(b.template get(3) == ""); } - - // 3 elements in string - { BodyText b; b.start(0).length(0).string("ab cd ef"); - CHECK(b.template get(0) == "ab"); } - { BodyText b; b.start(0).length(4).string("ab cd ef"); - CHECK(b.template get(1) == "cd"); } - { BodyText b; b.start(1).length(5).string("ab cd ef"); - CHECK(b.template get(2) == "cd"); } - { BodyText b; b.start(2).length(6).string("ab cd ef"); - CHECK(b.template get(3) == "cd"); } - - // ------------------------ - // vector - // ------------------------ - - // 0 elements in string - { BodyText b; b.start(0).length(0).string(""); /* no elements */ } - { BodyText b; b.start(0).length(4).string(""); - CHECK(b.template get(1) == 0); } - { BodyText b; b.start(1).length(5).string(""); - CHECK(b.template get(2) == 0); } - { BodyText b; b.start(2).length(6).string(""); - CHECK(b.template get(3) == 0); } - - // 1 element in string - { BodyText b; b.start(0).length(0).string("12"); - CHECK(b.template get(0) == 12); } - { BodyText b; b.start(0).length(4).string("12"); - CHECK(b.template get(1) == 0); } - { BodyText b; b.start(1).length(5).string("12"); - CHECK(b.template get(2) == 0); } - { BodyText b; b.start(2).length(6).string("12"); - CHECK(b.template get(3) == 0); } - - // 3 elements in string - { BodyText b; b.start(0).length(0).string("12 34 56"); - CHECK(b.template get(0) == 12); } - { BodyText b; b.start(0).length(4).string("12 34 56"); - CHECK(b.template get(1) == 34); } - { BodyText b; b.start(1).length(5).string("12 34 56"); - CHECK(b.template get(2) == 34); } - { BodyText b; b.start(2).length(6).string("12 34 56"); - CHECK(b.template get(3) == 34); } -} - -// For BodyText -SCENARIO("BodyText get(n)") { - GIVEN("A BodyText object") { - scenario_get_template_n(); - } -} - -// For BodyText -SCENARIO("BodyText get(n)") { - GIVEN("A BodyText object") { - scenario_get_template_n(); - } -} - - - -// ----------------------------------------------------------------------------- -// 3. Scenario: get() -// ----------------------------------------------------------------------------- - -// For BodyText -SCENARIO("BodyText get()") { - GIVEN("A BodyText object") { - - using ivec = std::vector; - using fvec = std::vector; - using svec = std::vector; - - BodyText b; - - b.start(2).length(6).string("-12 34 -56"); - b.valueType("Integer32"); - CHECK(( std::holds_alternative(b.get()))); - CHECK((!std::holds_alternative(b.get()))); - CHECK((!std::holds_alternative(b.get()))); - CHECK((std::get(b.get()) == ivec{{0,0,-12,34,-56,0}})); - - b.start(2).length(6).string("1.2 3.4 5.6"); - b.valueType("Float64"); - CHECK((!std::holds_alternative(b.get()))); - CHECK(( std::holds_alternative(b.get()))); - CHECK((!std::holds_alternative(b.get()))); - CHECK((std::get(b.get()) == fvec{{0,0,1.2,3.4,5.6,0}})); - - b.start(2).length(6).string("ab cd ef"); - b.valueType(""); - CHECK((!std::holds_alternative(b.get()))); - CHECK((!std::holds_alternative(b.get()))); - CHECK(( std::holds_alternative(b.get()))); - CHECK((std::get(b.get()) == svec{{"","","ab","cd","ef",""}})); - - } // GIVEN -} // SCENARIO - - -// For BodyText -SCENARIO("BodyText get()") { - GIVEN("A BodyText object") { - - using ivec = std::vector; - using fvec = std::vector; - using svec = std::vector; - - { - BodyText b; - b.start(2).length(6).string("-12 34 -56"); - CHECK((b.get() == ivec{{0,0,-12,34,-56,0}})); - } - - { - BodyText b; - b.start(2).length(6).string("1.2 3.4 5.6"); - CHECK((b.get() == fvec{{0,0,1.2,3.4,5.6,0}})); - } - - { - BodyText b; - b.start(2).length(6).string("ab cd ef"); - CHECK((b.get() == svec{{"","","ab","cd","ef",""}})); - } - - } // GIVEN -} // SCENARIO - - - -// ----------------------------------------------------------------------------- -// 4. Scenario: get(n) -// ----------------------------------------------------------------------------- - -// For BodyText -SCENARIO("BodyText get(n)") { - GIVEN("A BodyText object") { - - BodyText b; - - // ------------------------ - // get(n) form - // ------------------------ - - b.start(2).length(6).string("-12 34 -56"); - b.valueType("Integer32"); - CHECK(( std::holds_alternative(b.get(0)))); - CHECK((!std::holds_alternative(b.get(0)))); - CHECK((!std::holds_alternative(b.get(0)))); - CHECK(( std::get( b.get(0) ) == 0 )); - CHECK(( std::get( b.get(1) ) == 0 )); - CHECK(( std::get( b.get(2) ) == -12 )); - CHECK(( std::get( b.get(3) ) == 34 )); - CHECK(( std::get( b.get(4) ) == -56 )); - CHECK(( std::get( b.get(5) ) == 0 )); - // test type changes (inefficient, but they work)... - CHECK(b.get(2) == -12); - CHECK(b.get(3) == double(34)); - CHECK(b.get(4) == "-56"); - - b.start(2).length(6).string("1.2 3.4 5.6"); - b.valueType("Float64"); - CHECK((!std::holds_alternative(b.get(0)))); - CHECK(( std::holds_alternative(b.get(0)))); - CHECK((!std::holds_alternative(b.get(0)))); - CHECK(( std::get( b.get(0) ) == 0 )); - CHECK(( std::get( b.get(1) ) == 0 )); - CHECK(( std::get( b.get(2) ) == 1.2 )); - CHECK(( std::get( b.get(3) ) == 3.4 )); - CHECK(( std::get( b.get(4) ) == 5.6 )); - CHECK(( std::get( b.get(5) ) == 0 )); - // test type changes... - CHECK(b.get(2) == 1); // truncated from 1.2 - // having converted to vector, the .#s aren't there any longer... - CHECK(b.get(2) == "1"); - CHECK(b.get(3) == 3); - CHECK(b.get(4) == "5"); - - b.start(2).length(8).string("ab cd ef 123 4.5"); - b.valueType(""); - CHECK((!std::holds_alternative(b.get(0)))); - CHECK((!std::holds_alternative(b.get(0)))); - CHECK(( std::holds_alternative(b.get(0)))); - CHECK(( std::get( b.get(0) ) == "" )); - CHECK(( std::get( b.get(1) ) == "" )); - CHECK(( std::get( b.get(2) ) == "ab" )); - CHECK(( std::get( b.get(3) ) == "cd" )); - CHECK(( std::get( b.get(4) ) == "ef" )); - CHECK(( std::get( b.get(5) ) == "123")); - CHECK(( std::get( b.get(6) ) == "4.5")); - CHECK(( std::get( b.get(7) ) == "" )); - - // ------------------------ - // operator[] form - // ------------------------ - - b.start(2).length(6).string("-12 34 -56"); - b.valueType("Integer32"); - CHECK(( std::holds_alternative(b[0]))); - CHECK((!std::holds_alternative(b[0]))); - CHECK((!std::holds_alternative(b[0]))); - CHECK(( std::get( b[0] ) == 0 )); - CHECK(( std::get( b[1] ) == 0 )); - CHECK(( std::get( b[2] ) == -12 )); - CHECK(( std::get( b[3] ) == 34 )); - CHECK(( std::get( b[4] ) == -56 )); - CHECK(( std::get( b[5] ) == 0 )); - - b.start(2).length(6).string("1.2 3.4 5.6"); - b.valueType("Float64"); - CHECK((!std::holds_alternative(b[0]))); - CHECK(( std::holds_alternative(b[0]))); - CHECK((!std::holds_alternative(b[0]))); - CHECK(( std::get( b[0] ) == 0 )); - CHECK(( std::get( b[1] ) == 0 )); - CHECK(( std::get( b[2] ) == 1.2 )); - CHECK(( std::get( b[3] ) == 3.4 )); - CHECK(( std::get( b[4] ) == 5.6 )); - CHECK(( std::get( b[5] ) == 0 )); - - b.start(2).length(6).string("ab cd ef"); - b.valueType(""); - CHECK((!std::holds_alternative(b[0]))); - CHECK((!std::holds_alternative(b[0]))); - CHECK(( std::holds_alternative(b[0]))); - CHECK(( std::get( b[0] ) == "" )); - CHECK(( std::get( b[1] ) == "" )); - CHECK(( std::get( b[2] ) == "ab" )); - CHECK(( std::get( b[3] ) == "cd" )); - CHECK(( std::get( b[4] ) == "ef" )); - CHECK(( std::get( b[5] ) == "" )); - - } // GIVEN -} // SCENARIO - - -// For BodyText -SCENARIO("BodyText get(n)") { - GIVEN("A BodyText object") { - - // ------------------------ - // get(n) form - // ------------------------ - - { - BodyText b; - b.start(2).length(6).string("-12 34 -56"); - CHECK(( b.get(0) == 0 )); - CHECK(( b.get(1) == 0 )); - CHECK(( b.get(2) == -12 )); - CHECK(( b.get(3) == 34 )); - CHECK(( b.get(4) == -56 )); - CHECK(( b.get(5) == 0 )); - } - - { - BodyText b; - b.start(2).length(6).string("1.2 3.4 5.6"); - CHECK(( b.get(0) == 0 )); - CHECK(( b.get(1) == 0 )); - CHECK(( b.get(2) == 1.2 )); - CHECK(( b.get(3) == 3.4 )); - CHECK(( b.get(4) == 5.6 )); - CHECK(( b.get(5) == 0 )); - } - - { - BodyText b; - b.start(2).length(8).string("ab cd ef 123 4.5"); - CHECK(( b.get(0) == "" )); - CHECK(( b.get(1) == "" )); - CHECK(( b.get(2) == "ab" )); - CHECK(( b.get(3) == "cd" )); - CHECK(( b.get(4) == "ef" )); - CHECK(( b.get(5) == "123")); - CHECK(( b.get(6) == "4.5")); - CHECK(( b.get(7) == "" )); - } - - // ------------------------ - // operator[] form - // ------------------------ - - { - BodyText b; - b.start(2).length(6).string("-12 34 -56"); - CHECK(( b[0] == 0 )); - CHECK(( b[1] == 0 )); - CHECK(( b[2] == -12 )); - CHECK(( b[3] == 34 )); - CHECK(( b[4] == -56 )); - CHECK(( b[5] == 0 )); - } - - { - BodyText b; - b.start(2).length(6).string("1.2 3.4 5.6"); - CHECK(( b[0] == 0 )); - CHECK(( b[1] == 0 )); - CHECK(( b[2] == 1.2 )); - CHECK(( b[3] == 3.4 )); - CHECK(( b[4] == 5.6 )); - CHECK(( b[5] == 0 )); - } - - { - BodyText b; - b.start(2).length(6).string("ab cd ef"); - CHECK(( b[0] == "" )); - CHECK(( b[1] == "" )); - CHECK(( b[2] == "ab" )); - CHECK(( b[3] == "cd" )); - CHECK(( b[4] == "ef" )); - CHECK(( b[5] == "" )); - } - - } // GIVEN -} // SCENARIO - - - -// ----------------------------------------------------------------------------- -// 5. Scenario: doubles() etc. -// ----------------------------------------------------------------------------- - -// Helper -template -void scenario_get_named() -{ - { - BodyText b; - - b.start(2).length(6).string("-12 34 -56"); - auto result = b.ints(); - CHECK((std::is_same_v>)); - - CHECK(result[0] == 0 ); - CHECK(result[1] == 0 ); - CHECK(result[2] == -12 ); - CHECK(result[3] == 34 ); - CHECK(result[4] == -56 ); - CHECK(result[5] == 0 ); - - CHECK(result[0] == b.ints(0) ); - CHECK(result[1] == b.ints(1) ); - CHECK(result[2] == b.ints(2) ); - CHECK(result[3] == b.ints(3) ); - CHECK(result[4] == b.ints(4) ); - CHECK(result[5] == b.ints(5) ); - } - - { - BodyText b; - - b.start(2).length(6).string("1.2 3.4 5.6"); - const BodyText &bconst = b; // ensure it works with const - const auto result = bconst.doubles(); - CHECK((std::is_same_v>)); - - CHECK(result[0] == 0 ); - CHECK(result[1] == 0 ); - CHECK(result[2] == 1.2 ); - CHECK(result[3] == 3.4 ); - CHECK(result[4] == 5.6 ); - CHECK(result[5] == 0 ); - - CHECK(result[0] == bconst.doubles(0) ); - CHECK(result[1] == bconst.doubles(1) ); - CHECK(result[2] == bconst.doubles(2) ); - CHECK(result[3] == bconst.doubles(3) ); - CHECK(result[4] == bconst.doubles(4) ); - CHECK(result[5] == bconst.doubles(5) ); - } - - { - BodyText b; - - b.start(2).length(6).string("ab cd ef"); - const auto &result = b.strings(); - CHECK((std::is_same_v &>)); - - CHECK(result[0] == "" ); - CHECK(result[1] == "" ); - CHECK(result[2] == "ab" ); - CHECK(result[3] == "cd" ); - CHECK(result[4] == "ef" ); - CHECK(result[5] == "" ); - - CHECK(result[0] == b.strings(0) ); - CHECK(result[1] == b.strings(1) ); - CHECK(result[2] == b.strings(2) ); - CHECK(result[3] == b.strings(3) ); - CHECK(result[4] == b.strings(4) ); - CHECK(result[5] == b.strings(5) ); - } -} - -// For BodyText -SCENARIO("BodyText type-specific get functions: doubles() etc.") { - GIVEN("A BodyText object") { - scenario_get_named(); - } -} - -// For BodyText -SCENARIO("BodyText type-specific get functions: doubles() etc.") { - GIVEN("A BodyText object") { - scenario_get_named(); - } -} diff --git a/src/GNDStk/BodyText/test/sync.test.cpp b/src/GNDStk/BodyText/test/sync.test.cpp deleted file mode 100644 index 24df290c7..000000000 --- a/src/GNDStk/BodyText/test/sync.test.cpp +++ /dev/null @@ -1,295 +0,0 @@ - -#include "catch.hpp" -#include "GNDStk.hpp" - -using namespace njoy::GNDStk::core; - - -// ----------------------------------------------------------------------------- -// Scenario: pull -// content == any of {length,start,valueType} -// ----------------------------------------------------------------------------- - -// Helper -template -void scenario_pull() -{ - WHEN("pullFromDerived() is called") { - // none of length, start, valueType - THEN("Push to content{} works") { - const struct { - struct { - } content; - } derived; - BodyText b; - b.length(100).start(200).valueType("300"); - b.pullFromDerived(derived); // should do nothing here - CHECK(b.length() == 100); - CHECK(b.start() == 200); - CHECK(b.valueType() == "300"); - } - - // length only - THEN("Push to content{length} works") { - const struct { - struct { - int length = 10; - } content; - } derived; - BodyText b; - b.length(11).start(12).valueType("13"); - b.pullFromDerived(derived); - CHECK(b.length() == 10); - CHECK(b.start() == 12); - CHECK(b.valueType() == "13"); - } - - // start only - THEN("Push to content{start} works") { - const struct { - struct { - int start = 14; - } content; - } derived; - BodyText b; - b.length(15).start(16).valueType("17"); - b.pullFromDerived(derived); - CHECK(b.length() == 15); - CHECK(b.start() == 14); - CHECK(b.valueType() == "17"); - } - - // valueType only - THEN("Push to content{valueType} works") { - const struct { - struct { - std::string valueType = "18"; - } content; - } derived; - BodyText b; - b.length(19).start(20).valueType("21"); - b.pullFromDerived(derived); - CHECK(b.length() == 19); - CHECK(b.start() == 20); - CHECK(b.valueType() == "18"); - } - - // all but length - THEN("Push to content{start,valueType} works") { - const struct { - struct { - int start = 22; - std::string valueType = "23"; - } content; - } derived; - BodyText b; - b.length(24).start(25).valueType("26"); - b.pullFromDerived(derived); - CHECK(b.length() == 24); - CHECK(b.start() == 22); - CHECK(b.valueType() == "23"); - } - - // all but start - THEN("Push to content{length,valueType} works") { - const struct { - struct { - int length = 27; - std::string valueType = "28"; - } content; - } derived; - BodyText b; - b.length(29).start(30).valueType("31"); - b.pullFromDerived(derived); - CHECK(b.length() == 27); - CHECK(b.start() == 30); - CHECK(b.valueType() == "28"); - } - - // all but valueType - THEN("Push to content{length,start} works") { - const struct { - struct { - int length = 32; - int start = 33; - } content; - } derived; - BodyText b; - b.length(34).start(35).valueType("36"); - b.pullFromDerived(derived); - CHECK(b.length() == 32); - CHECK(b.start() == 33); - CHECK(b.valueType() == "36"); - } - - // all three - THEN("Push to content{length,start,valueType} works") { - const struct { - struct { - int length = 37; - int start = 38; - std::string valueType = "39"; - } content; - } derived; - BodyText b; - b.length(40).start(41).valueType("42"); - b.pullFromDerived(derived); - CHECK(b.length() == 37); - CHECK(b.start() == 38); - CHECK(b.valueType() == "39"); - } - } -} - - -SCENARIO("BodyText pull from content") { - GIVEN("A BodyText object") { - scenario_pull(); - } -} - -SCENARIO("BodyText pull from content") { - GIVEN("A BodyText object") { - scenario_pull(); - } -} - - -// ----------------------------------------------------------------------------- -// Scenario: push -// content == any of {length,start,valueType} -// ----------------------------------------------------------------------------- - -// Helper -template -void scenario_push() -{ - WHEN("pushToDerived() is called") { - // none of length, start, valueType - THEN("Push to content{} works") { - struct { - struct { - int ignored = 123456; // not length, start, or valueType - } content; - } derived; - BodyText b; - b.length(0).start(0).valueType("0"); - b.pushToDerived(derived); // should do nothing here - CHECK(derived.content.ignored == 123456); - } - - // length only - THEN("Push to content{length} works") { - struct { - struct { - int length = 10; - } content; - } derived; - BodyText b; - b.length(11).start(12).valueType("13"); - b.pushToDerived(derived); - CHECK(derived.content.length == 11); - } - - // start only - THEN("Push to content{start} works") { - struct { - struct { - int start = 14; - } content; - } derived; - BodyText b; - b.length(15).start(16).valueType("17"); - b.pushToDerived(derived); - CHECK(derived.content.start == 16); - } - - // valueType only - THEN("Push to content{valueType} works") { - struct { - struct { - std::string valueType = "18"; - } content; - } derived; - BodyText b; - b.length(19).start(20).valueType("21"); - b.pushToDerived(derived); - CHECK(derived.content.valueType == "21"); - } - - // all but length - THEN("Push to content{start,valueType} works") { - struct { - struct { - int start = 22; - std::string valueType = "23"; - } content; - } derived; - BodyText b; - b.length(24).start(25).valueType("26"); - b.pushToDerived(derived); - CHECK(derived.content.start == 25); - CHECK(derived.content.valueType == "26"); - } - - // all but start - THEN("Push to content{length,valueType} works") { - struct { - struct { - int length = 27; - std::string valueType = "28"; - } content; - } derived; - BodyText b; - b.length(29).start(30).valueType("31"); - b.pushToDerived(derived); - CHECK(derived.content.length == 29); - CHECK(derived.content.valueType == "31"); - } - - // all but valueType - THEN("Push to content{length,start} works") { - struct { - struct { - int length = 32; - int start = 33; - } content; - } derived; - BodyText b; - b.length(34).start(35).valueType("36"); - b.pushToDerived(derived); - CHECK(derived.content.length == 34); - CHECK(derived.content.start == 35); - } - - // all three - THEN("Push to content{length,start,valueType} works") { - struct { - struct { - int length = 37; - int start = 38; - std::string valueType = "39"; - } content; - } derived; - BodyText b; - b.length(40).start(41).valueType("42"); - b.pushToDerived(derived); - CHECK(derived.content.length == 40); - CHECK(derived.content.start == 41); - CHECK(derived.content.valueType == "42"); - } - } -} - - -SCENARIO("BodyText push to content") { - GIVEN("A BodyText object") { - scenario_push(); - } -} - -SCENARIO("BodyText push to content") { - GIVEN("A BodyText object") { - scenario_push(); - } -} diff --git a/src/GNDStk/BodyText/test/toNode.test.cpp b/src/GNDStk/BodyText/test/toNode.test.cpp deleted file mode 100644 index c54fb43ad..000000000 --- a/src/GNDStk/BodyText/test/toNode.test.cpp +++ /dev/null @@ -1,367 +0,0 @@ - -#include "catch.hpp" -#include "GNDStk.hpp" - -using namespace njoy::GNDStk::core; - - -// ----------------------------------------------------------------------------- -// Helper -// ----------------------------------------------------------------------------- - -// Tests use either void for each template parameter, or int, double, -// std::string, and char, in that order. In the former case, we're testing -// toNode() for the generic BodyText<...,void>. In the latter case, we're -// testing toNode() for non-generic BodyText. -template -void scenario_toNode() -{ - // Default-constructed BodyText - GIVEN("A default-constructed BodyText") { - WHEN("toNode() is called") { - THEN("The computed text string is empty") { - const BodyText b; - - std::string text = "abc"; - struct { - struct { - } content; - } derived; - // w/trim == true (shouldn't matter here; applies to vector) - b.trim = true; - b.toNode(text,derived); - CHECK(text == ""); - - // w/trim == false (shouldn't matter here; applies to vector) - b.trim = false; - b.toNode(text,derived); - CHECK(text == ""); - } - } - } - - // BodyText, after being given a particular raw string and parameters - GIVEN("A BodyText, with given raw string and parameters") { - WHEN("toNode() is called") { - THEN("The computed text string is as expected, " - "and the parameters remain as given" - ) { - BodyText b; - b.string("0 12 34 56 0 0") - .start(100).length(200).valueType("hello"); - - std::string text = "abc"; - struct { - struct { - } content; - } derived; - - // Someone who sets the raw string directly (as opposed to using - // a vector) is stating that they want *exactly* that raw string, - // including any 0s or anything else. To have BodyText's trim flag - // be relevant, use a vector. - - // w/trim == true (shouldn't matter here; applies to vector) - b.trim = true; - b.toNode(text,derived); - CHECK(text == "0 12 34 56 0 0"); - CHECK(b.start() == 100); - CHECK(b.length() == 200); - CHECK(b.valueType() == "hello"); - - // w/trim == false (shouldn't matter here; applies to vector) - b.trim = false; - b.toNode(text,derived); - CHECK(text == "0 12 34 56 0 0"); - CHECK(b.start() == 100); - CHECK(b.length() == 200); - CHECK(b.valueType() == "hello"); - } - } - } - - // BodyText, after being given a particular vector - GIVEN("A BodyText, assigned from a particular vector") { - WHEN("toNode() is called") { - THEN("The computed text string is as expected, " - "and the parameters were computed properly" - ) { - BodyText b; - // what's set here should be replaced upon assignment from vector - b.string("a b c").start(10).length(20).valueType("foobar"); - - // assign from vector - b = std::vector{{0, 0, 12, 34, 56, 78, 0, 0, 0, 0, 0}}; - - std::string text = "this should be replaced"; - struct { - struct { - } content; - } derived; - - // w/trim == true - b.trim = true; - b.toNode(text,derived); - CHECK(text == "12 34 56 78"); - CHECK(b.start() == 2); - CHECK(b.length() == 11); - CHECK(b.valueType() == "Integer32"); - - // w/trim == false - b.trim = false; - b.toNode(text,derived); - CHECK(text == "0 0 12 34 56 78 0 0 0 0 0"); - CHECK(b.start() == 0); - CHECK(b.length() == 11); - CHECK(b.valueType() == "Integer32"); - } - } - } - - // BodyText, after being given a particular vector - GIVEN("A BodyText, assigned from a particular vector") { - WHEN("toNode() is called") { - THEN("The computed text string is as expected, " - "and the parameters were computed properly" - ) { - BodyText b; - // what's set here should be replaced upon assignment from vector - b.string("d e f").start(100).length(200).valueType("foobar"); - - // assign from vector - b = std::vector{{0, 0, 0, 1.234, 5.678, 0, 0 }}; - - std::string text = "this should be replaced"; - struct { - struct { - } content; - } derived; - - // w/trim == true - b.trim = true; - b.toNode(text,derived); - CHECK(text == "1.234 5.678"); - CHECK(b.start() == 3); - CHECK(b.length() == 7); - CHECK(b.valueType() == "Float64"); - - // w/trim == false - b.trim = false; - b.toNode(text,derived); - CHECK(text == "0 0 0 1.234 5.678 0 0"); - CHECK(b.start() == 0); - CHECK(b.length() == 7); - CHECK(b.valueType() == "Float64"); - } - } - } - - // BodyText, after being given a particular vector - // A key point here is to ensure that ""s (string "zeros") are properly - // trimmed at the beginning and end. - GIVEN("A BodyText, assigned from a particular vector") { - WHEN("toNode() is called") { - THEN("The computed text string is as expected, " - "and the parameters were computed properly" - ) { - BodyText b; - // what's set here should be replaced upon assignment from vector - b.string("d e f").start(100).length(200).valueType("foobar"); - - // assign from vector - b = std::vector{{"","","","foo","bar","baz","",""}}; - - std::string text = "this should be replaced"; - struct { - struct { - } content; - } derived; - - // w/trim == true - b.trim = true; - b.toNode(text,derived); - CHECK(text == "foo bar baz"); - CHECK(b.start() == 3); - CHECK(b.length() == 8); - CHECK(b.valueType() == "UTF8Text"); - - // w/trim == false - // toNode() should treat this (the std::string) case as if trim - // were true. If it didn't, we'd end up with, well, leading and - // trailing *empty* strings, which, well, amount to leading and - // trailing nothing. - b.trim = false; - b.toNode(text,derived); - CHECK(text == "foo bar baz"); - CHECK(b.start() == 3); - CHECK(b.length() == 8); - CHECK(b.valueType() == "UTF8Text"); - } - } - } - - // BodyText, after being given a particular vector - // For T something other than int, double, and std::string - GIVEN("A BodyText, assigned from a particular vector") { - WHEN("toNode() is called") { - THEN("The computed text string is as expected, " - "and the parameters were computed properly" - ) { - BodyText b; - // what's set here should be replaced upon assignment from vector - b.string("x y z").start(100).length(200).valueType("foobar"); - - // assign from vector - b = std::vector{{0,0,0,0,0,'a','b','c','d',0}}; - - std::string text = "this should be replaced"; - struct { - struct { - } content; - } derived; - - b.toNode(text,derived); - CHECK(text == "a b c d"); - CHECK(b.start() == 5); - CHECK(b.length() == 10); - CHECK(b.valueType() == "char"); - } - } - } - - // Test various configurations of content{} when calling toNode(). Basically, - // these test whether toNode properly updates whichever of length, start, and - // valueType are in .content of toNode()'s second argument. - GIVEN("A BodyText, with vector") { - WHEN("toNode() is called") { - - // none of length, start, valueType - THEN("Push to content{} works") { - struct { - struct { - int ignored = 12345; - } content; - } derived; - BodyText b; std::string text; - b = std::vector{{0,0,10,20,30,0,0,0}}; - b.toNode(text,derived); - // toNode doesn't care about what's *not* length/start/valueType... - CHECK(derived.content.ignored == 12345); // same as before toNode() - } - - // length only - THEN("Push to content{length} works") { - struct { - struct { - int length = 0; - } content; - } derived; - BodyText b; std::string text; - b = std::vector{{0,0,10,20,30,0,0,0}}; - b.toNode(text,derived); - CHECK(derived.content.length == 8); - } - - // start only - THEN("Push to content{start} works") { - struct { - struct { - int start = 0; - } content; - } derived; - BodyText b; std::string text; - b = std::vector{{0,0,10,20,30,0,0,0}}; - b.toNode(text,derived); - CHECK(derived.content.start == 2); - } - - // valueType only - THEN("Push to content{valueType} works") { - struct { - struct { - std::string valueType = ""; - } content; - } derived; - BodyText b; std::string text; - b = std::vector{{0,0,10,20,30,0,0,0}}; - b.toNode(text,derived); - CHECK(derived.content.valueType == "Integer32"); - } - - // all but length - THEN("Push to content{start,valueType} works") { - struct { - struct { - int start = 0; - std::string valueType = ""; - } content; - } derived; - BodyText b; std::string text; - b = std::vector{{0,0,10,20,30,0,0,0}}; - b.toNode(text,derived); - CHECK(derived.content.start == 2); - CHECK(derived.content.valueType == "Integer32"); - } - - // all but start - THEN("Push to content{length,valueType} works") { - struct { - struct { - int length = 0; - std::string valueType = ""; - } content; - } derived; - BodyText b; std::string text; - b = std::vector{{0,0,10,20,30,0,0,0}}; - b.toNode(text,derived); - CHECK(derived.content.length == 8); - CHECK(derived.content.valueType == "Integer32"); - } - - // all but valueType - THEN("Push to content{length,start} works") { - struct { - struct { - int length = 0; - int start = 0; - } content; - } derived; - BodyText b; std::string text; - b = std::vector{{0,0,10,20,30,0,0,0}}; - b.toNode(text,derived); - CHECK(derived.content.length == 8); - CHECK(derived.content.start == 2); - } - - // all three - THEN("Push to content{length,start,valueType} works") { - struct { - struct { - int length = 0; - int start = 0; - std::string valueType = ""; - } content; - } derived; - BodyText b; std::string text; - b = std::vector{{0,0,10,20,30,0,0,0}}; - b.toNode(text,derived); - CHECK(derived.content.length == 8); - CHECK(derived.content.start == 2); - CHECK(derived.content.valueType == "Integer32"); - } - } - } -} - - -// ----------------------------------------------------------------------------- -// Scenario -// ----------------------------------------------------------------------------- - -SCENARIO("BodyText toNode()") { - scenario_toNode(); -} - -SCENARIO("BodyText toNode()") { - scenario_toNode(); -} diff --git a/src/GNDStk/BodyText/test/types.test.cpp b/src/GNDStk/BodyText/test/types.test.cpp deleted file mode 100644 index 57274301f..000000000 --- a/src/GNDStk/BodyText/test/types.test.cpp +++ /dev/null @@ -1,121 +0,0 @@ - -#include "catch.hpp" -#include "GNDStk.hpp" - -using namespace njoy::GNDStk::core; - -// ----------------------------------------------------------------------------- -// Scenario -// ----------------------------------------------------------------------------- - -SCENARIO("BodyText data types") { - GIVEN("std::vector for certain specific Ts") { - - WHEN("Via BodyText, we make variants of vectors and of scalars") { - // vector type - using vv = BodyText::VariantOfVectors; - THEN("The variant-of-vector size should be correct") { - CHECK(std::variant_size_v == 15); - } - vv vectors; - - // scalar type - using vs = BodyText::VariantOfScalars; - THEN("The variant-of-scalar size should be correct") { - CHECK(std::variant_size_v == 15); - } - vs scalars; - - THEN("Transformation to vector, and access, work") { - vectors = std::vector(10,"a"); - scalars = std::get>(vectors)[0]; - CHECK(std::get(scalars) == "a"); - } - - THEN("Transformation to vector, and access, work") { - vectors = std::vector(10,'b'); - scalars = std::get>(vectors)[0]; - CHECK(std::get(scalars) == 'b'); - } - - THEN("Transformation to vector, and access, work") { - vectors = std::vector(10,-100); - scalars = std::get>(vectors)[0]; - CHECK(std::get(scalars) == -100); - } - - THEN("Transformation to vector, and access, work") { - vectors = std::vector(10,-200); - scalars = std::get>(vectors)[0]; - CHECK(std::get(scalars) == -200); - } - - THEN("Transformation to vector, and access, work") { - vectors = std::vector(10,-300); - scalars = std::get>(vectors)[0]; - CHECK(std::get(scalars) == -300); - } - - THEN("Transformation to vector, and access, work") { - vectors = std::vector(10,-400); - scalars = std::get>(vectors)[0]; - CHECK(std::get(scalars) == -400); - } - - THEN("Transformation to vector, and access, work") { - vectors = std::vector(10,-500); - scalars = std::get>(vectors)[0]; - CHECK(std::get(scalars) == -500); - } - - THEN("Transformation to vector, and access, work") { - vectors = std::vector(10,100); - scalars = std::get>(vectors)[0]; - CHECK(std::get(scalars) == 100); - } - - THEN("Transformation to vector, and access, work") { - vectors = std::vector(10,200); - scalars = std::get>(vectors)[0]; - CHECK(std::get(scalars) == 200); - } - - THEN("Transformation to vector, and access, work") { - vectors = std::vector(10,300); - scalars = std::get>(vectors)[0]; - CHECK(std::get(scalars) == 300); - } - - THEN("Transformation to vector, and access, work") { - vectors = std::vector(10,400); - scalars = std::get>(vectors)[0]; - CHECK(std::get(scalars) == 400); - } - - THEN("Transformation to vector, and access, work") { - vectors = std::vector(10,500); - scalars = std::get>(vectors)[0]; - CHECK(std::get(scalars) == 500); - } - - THEN("Transformation to vector, and access, work") { - vectors = std::vector(10,-1.2f); - scalars = std::get>(vectors)[0]; - CHECK(std::get(scalars) == -1.2f); - } - - THEN("Transformation to vector, and access, work") { - vectors = std::vector(10,3.4); - scalars = std::get>(vectors)[0]; - CHECK(std::get(scalars) == 3.4); - } - - THEN("Transformation to vector, and access, work") { - vectors = std::vector(10,-5.6); - scalars = std::get>(vectors)[0]; - CHECK(std::get(scalars) == -5.6); - } - } // WHEN - - } // GIVEN -} // SCENARIO diff --git a/src/GNDStk/BodyText/test/write.test.cpp b/src/GNDStk/BodyText/test/write.test.cpp deleted file mode 100644 index ac0095b27..000000000 --- a/src/GNDStk/BodyText/test/write.test.cpp +++ /dev/null @@ -1,226 +0,0 @@ - -#include "catch.hpp" -#include "GNDStk.hpp" - -using namespace njoy::GNDStk::core; - - -// ----------------------------------------------------------------------------- -// Scenario: raw string -// ----------------------------------------------------------------------------- - -// Helper -template -void scenario_write_string_active() -{ - GIVEN("A BodyText with an empty raw string") { - WHEN("BodyText.write() is called") { - THEN("Nothing is printed") { - BodyText b; - b = std::vector{{'a','b','c'}}; - b.string(""); // should make string (not vector) active - std::ostringstream oss; - b.write(oss,0); - CHECK(oss.str() == ""); - - // same (nothing printed) if indentation is non-0 - b.write(oss,2); - CHECK(oss.str() == ""); - } - } - } - - GIVEN("A BodyText with a non-empty raw string") { - WHEN("BodyText.write() is called") { - THEN("The raw string and a newline are printed") { - BodyText b; - b = std::vector{{'a','b','c'}}; - b.string("foo bar"); // should make string (not vector) active - - std::ostringstream oss; - b.write(oss,0); - CHECK(oss.str() == "foo bar\n"); - - // indentation isn't applied when the raw string is active - oss.str(""); - b.write(oss,2); - CHECK(oss.str() == "foo bar\n"); - } - } - } -} - -// For DATA == void -SCENARIO("BodyText write(), when the raw string is active") { - scenario_write_string_active(); -} - -// For DATA != void -SCENARIO("BodyText write(), when the raw string is active") { - scenario_write_string_active(); -} - - -// ----------------------------------------------------------------------------- -// Scenario: vector -// ----------------------------------------------------------------------------- - -// Helper -template -void scenario_write_vector_active() -{ - GIVEN("A BodyText with an empty vector") { - WHEN("BodyText.write() is called") { - THEN("Nothing is printed") { - BodyText b; - b.string("should be ignored"); // because vector is forthcoming... - b = std::vector{}; - std::ostringstream oss; - b.write(oss,0); - CHECK(oss.str() == ""); - - // same (nothing printed) if indentation is non-0 - b.write(oss,2); - CHECK(oss.str() == ""); - } - } - } - - GIVEN("A BodyText with a non-empty vector") { - WHEN("BodyText.write() is called") { - THEN("The vector and a newline are printed") { - BodyText b; - b.string("should be ignored"); // because vector is forthcoming... - b = std::vector{{2,3,5,7,11,13,17,19,21,23}}; - std::ostringstream oss; - - // Cases: - // indent: 0, 3 (number of spaces per indentation level) - // across: 0, 1, 2, 5, 10, 11 (note that 10 == vector size) - // level: 0, 1, 2 (indentation level) - // Note: across == 0 ==> unlimited. - // Lots of cases, but we want to check that our pretty-printing - // functionality works perfectly, and doesn't do anything that's - // unexpected around "boundaries" like across==10 with 10 values. - - oss.str(""); indent = 0; across = 0; b.write(oss,0); - CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); - - oss.str(""); indent = 0; across = 0; b.write(oss,1); - CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); - - oss.str(""); indent = 0; across = 0; b.write(oss,2); - CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); - - oss.str(""); indent = 0; across = 1; b.write(oss,0); - CHECK(oss.str() == "2\n3\n5\n7\n11\n13\n17\n19\n21\n23\n"); - - oss.str(""); indent = 0; across = 1; b.write(oss,1); - CHECK(oss.str() == "2\n3\n5\n7\n11\n13\n17\n19\n21\n23\n"); - - oss.str(""); indent = 0; across = 1; b.write(oss,2); - CHECK(oss.str() == "2\n3\n5\n7\n11\n13\n17\n19\n21\n23\n"); - - oss.str(""); indent = 0; across = 2; b.write(oss,0); - CHECK(oss.str() == "2 3\n5 7\n11 13\n17 19\n21 23\n"); - - oss.str(""); indent = 0; across = 2; b.write(oss,1); - CHECK(oss.str() == "2 3\n5 7\n11 13\n17 19\n21 23\n"); - - oss.str(""); indent = 0; across = 2; b.write(oss,2); - CHECK(oss.str() == "2 3\n5 7\n11 13\n17 19\n21 23\n"); - - oss.str(""); indent = 0; across = 5; b.write(oss,0); - CHECK(oss.str() == "2 3 5 7 11\n13 17 19 21 23\n"); - - oss.str(""); indent = 0; across = 5; b.write(oss,1); - CHECK(oss.str() == "2 3 5 7 11\n13 17 19 21 23\n"); - - oss.str(""); indent = 0; across = 5; b.write(oss,2); - CHECK(oss.str() == "2 3 5 7 11\n13 17 19 21 23\n"); - - oss.str(""); indent = 0; across = 10; b.write(oss,0); - CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); - - oss.str(""); indent = 0; across = 10; b.write(oss,1); - CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); - - oss.str(""); indent = 0; across = 10; b.write(oss,2); - CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); - - oss.str(""); indent = 0; across = 11; b.write(oss,0); - CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); - - oss.str(""); indent = 0; across = 11; b.write(oss,1); - CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); - - oss.str(""); indent = 0; across = 11; b.write(oss,2); - CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); - - oss.str(""); indent = 3; across = 0; b.write(oss,0); - CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); - - oss.str(""); indent = 3; across = 0; b.write(oss,1); - CHECK(oss.str() == " 2 3 5 7 11 13 17 19 21 23\n"); - - oss.str(""); indent = 3; across = 0; b.write(oss,2); - CHECK(oss.str() == " 2 3 5 7 11 13 17 19 21 23\n"); - - oss.str(""); indent = 3; across = 1; b.write(oss,0); - CHECK(oss.str() == "2\n3\n5\n7\n11\n13\n17\n19\n21\n23\n"); - - oss.str(""); indent = 3; across = 1; b.write(oss,1); - CHECK(oss.str() == " 2\n 3\n 5\n 7\n 11\n 13\n 17\n 19\n 21\n 23\n"); - - oss.str(""); indent = 3; across = 1; b.write(oss,2); - CHECK(oss.str() == " 2\n 3\n 5\n 7\n 11\n 13\n 17\n 19\n 21\n 23\n"); - - oss.str(""); indent = 3; across = 2; b.write(oss,0); - CHECK(oss.str() == "2 3\n5 7\n11 13\n17 19\n21 23\n"); - - oss.str(""); indent = 3; across = 2; b.write(oss,1); - CHECK(oss.str() == " 2 3\n 5 7\n 11 13\n 17 19\n 21 23\n"); - - oss.str(""); indent = 3; across = 2; b.write(oss,2); - CHECK(oss.str() == " 2 3\n 5 7\n 11 13\n 17 19\n 21 23\n"); - - oss.str(""); indent = 3; across = 5; b.write(oss,0); - CHECK(oss.str() == "2 3 5 7 11\n13 17 19 21 23\n"); - - oss.str(""); indent = 3; across = 5; b.write(oss,1); - CHECK(oss.str() == " 2 3 5 7 11\n 13 17 19 21 23\n"); - - oss.str(""); indent = 3; across = 5; b.write(oss,2); - CHECK(oss.str() == " 2 3 5 7 11\n 13 17 19 21 23\n"); - - oss.str(""); indent = 3; across = 10; b.write(oss,0); - CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); - - oss.str(""); indent = 3; across = 10; b.write(oss,1); - CHECK(oss.str() == " 2 3 5 7 11 13 17 19 21 23\n"); - - oss.str(""); indent = 3; across = 10; b.write(oss,2); - CHECK(oss.str() == " 2 3 5 7 11 13 17 19 21 23\n"); - - oss.str(""); indent = 3; across = 11; b.write(oss,0); - CHECK(oss.str() == "2 3 5 7 11 13 17 19 21 23\n"); - - oss.str(""); indent = 3; across = 11; b.write(oss,1); - CHECK(oss.str() == " 2 3 5 7 11 13 17 19 21 23\n"); - - oss.str(""); indent = 3; across = 11; b.write(oss,2); - CHECK(oss.str() == " 2 3 5 7 11 13 17 19 21 23\n"); - } - } - } -} - -// For DATA == void -SCENARIO("BodyText write(), when a vector is active") { - scenario_write_vector_active(); -} - -// For DATA != void -SCENARIO("BodyText write(), when a vector is active") { - scenario_write_vector_active(); -} diff --git a/src/GNDStk/CInterface.hpp b/src/GNDStk/CInterface.hpp new file mode 100644 index 000000000..83023ac34 --- /dev/null +++ b/src/GNDStk/CInterface.hpp @@ -0,0 +1,3 @@ + +// Miscellaneous helper constructs +#include "GNDStk/CInterface/src/detail.hpp" diff --git a/src/GNDStk/CInterface/src/detail.hpp b/src/GNDStk/CInterface/src/detail.hpp new file mode 100644 index 000000000..e08961576 --- /dev/null +++ b/src/GNDStk/CInterface/src/detail.hpp @@ -0,0 +1,699 @@ + +namespace detail { + +// ----------------------------------------------------------------------------- +// Helpers +// ----------------------------------------------------------------------------- + +// ------------------------ +// tocpp +// ------------------------ + +// const +template +const CPP &tocpp(const C *const This) +{ + if (This == nullptr) { + log::error( + "detail::tocpp(pointer to const): pointer is null; " + "it cannot be dereferenced" + ); + throw std::exception{}; + } + return reinterpret_cast(*This); +} + +// non-const +template +CPP &tocpp(C *const This) +{ + if (This == nullptr) { + log::error( + "detail::tocpp(pointer): pointer is null; " + "it cannot be dereferenced" + ); + throw std::exception{}; + } + return reinterpret_cast(*This); +} + +// ------------------------ +// getAllHandles +// findHandle +// ------------------------ + +// getAllHandles +// Returns a container +template +auto &getAllHandles() +{ + try { + static std::set> pointers; + return pointers; + } catch (...) { + log::error("Exception thrown in detail::getAllHandles()"); + throw; + } +} + +// findHandle +// Returns an iterator +template +auto findHandle(const C *const want) +{ + try { + auto &pointers = getAllHandles(); + return std::find_if( + pointers.begin(), pointers.end(), + [want](const std::shared_ptr &have) + { + return have.get() == &tocpp(want); + } + ); + } catch (...) { + log::error("Exception thrown in detail::findHandle()"); + throw; + } +} + + +// ----------------------------------------------------------------------------- +// create, assign, delete +// ----------------------------------------------------------------------------- + +// createHandle +template +C *createHandle( + const std::string &classname, + const std::string &funname, + ARGS &&...args +) { + try { + return reinterpret_cast( + &(**getAllHandles().insert( + std::make_shared(std::forward(args)...) + ).first) + ); + } catch (...) { + log::error("Unable to create {} handle", classname); + log::function("{}", funname); + return nullptr; + } +} + +// assignHandle +template +void assignHandle( + const std::string &classname, + const std::string &funname, + C *const lhs, const C *const rhs +) { + static const std::string remark = + "\nIgnoring the assignment and continuing (but you should" + "\nprobably look into this, and fix something)."; + + static const std::string + bothNull = "The \"to\" and \"from\" {} handles are null." + remark, + leftNull = "The \"to\" {} handle is null." + remark, + rightNull = "The \"from\" {} handle is null." + remark, + leftUnk = "Unknown \"to\" {} handle {}." + remark, + rightUnk = "Unknown \"from\" {} handle {}." + remark; + + try { + auto &pointers = getAllHandles(); + bool good = true; + + // nullptr anywhere? + if (lhs == nullptr && rhs == nullptr) { + good = false; log::error(bothNull, classname); + } else if (lhs == nullptr) { + good = false; log::error(leftNull, classname); + } else if (rhs == nullptr) { + good = false; log::error(rightNull, classname); + } + + // check lhs + if (lhs && findHandle(lhs) == pointers.end()) { + log::error(leftUnk, classname, reinterpret_cast(lhs)); + good = false; + } + + // check rhs + if (rhs && findHandle(rhs) == pointers.end()) { + log::error(rightUnk, classname, reinterpret_cast(rhs)); + good = false; + } + + if (!good) + throw std::exception{}; + + tocpp(lhs) = tocpp(rhs); + + } catch (...) { + log::function("{}(to,from)", funname); + } +} + +// deleteHandle +template +void deleteHandle( + const std::string &classname, + const std::string &funname, + const C *const ptr +) { + static const std::string ignore = "Ignoring call to delete {} handle {}."; + + if (ptr == nullptr) { + log::warning( + ignore + "\nHandle is null.", + classname, reinterpret_cast(ptr) + ); + return; + } + + try { + auto &pointers = getAllHandles(); + const auto iter = findHandle(ptr); + + if (iter != pointers.end()) { + pointers.erase(iter); + } else { + log::warning( + ignore + "\nHandle is unknown, or was already deleted.", + classname, reinterpret_cast(ptr) + ); + } + } catch (...) { + log::function("{}({} handle = {})", funname, classname, (void *)ptr); + } +} + + +// ----------------------------------------------------------------------------- +// read, write, print +// ----------------------------------------------------------------------------- + +// readHandle +template +int readHandle( + const std::string &classname, + const std::string &funname, + C *const ptr, const std::string &filename +) { + try { + tocpp(ptr).baseComponent().read(filename); + return 1; // success + } catch (...) { + log::context( + "C function for reading {} from file. " + "File name is \"{}\".", classname, filename + ); + log::function("{}({} handle = {})", funname, classname, (void *)ptr); + return 0; // failure + } +} + +// writeHandle +template +int writeHandle( + const std::string &classname, + const std::string &funname, + const C *const ptr, const std::string &filename +) { + try { + tocpp(ptr).baseComponent().write(filename); + return 1; // success + } catch (...) { + log::context( + "C function for writing {} to file.\n" + "File name is \"{}\".", classname, filename + ); + log::function("{}({} handle = {})", funname, classname, (void *)ptr); + return 0; // failure + } +} + +// printHandle +template +int printHandle( + const std::string &classname, + const std::string &funname, + const C *const ptr, const std::string &format = "" +) { + try { + if (format == "") { + tocpp(ptr).baseComponent().print(); + // Component's print() already prints a newline + } else { + tocpp(ptr).baseComponent().write(std::cout,format); + // Component's write() intentionally doesn't already print a newline. + // For this print(), for our C language interface, print one. + std::cout << std::endl; + } + return 1; // success + } catch (...) { + if (format == "") { + log::context( + "C function for printing {}.", classname); + } else { + log::context( + "C function for printing {} in {} format.", classname, format); + } + log::function("{}({} handle = {})", funname, classname, (void *)ptr); + return 0; // failure + } +} + + +// ----------------------------------------------------------------------------- +// has, get, set +// ----------------------------------------------------------------------------- + +// hasField +template +bool hasField( + const std::string &classname, + const std::string &funname, + const C *const ptr, + const EXTRACT &extract +) { + try { + const auto &field = *extract(tocpp(ptr)); + return field.has(); + } catch (...) { + log::function("{}({} handle = {})", funname, classname, (void *)ptr); + return false; + } +} + +// getField +template +auto getField( + const std::string &classname, + const std::string &funname, + const C *const ptr, + const EXTRACT &extract +) { + using T = std::decay_t(ptr))->value())>; + + try { + const auto &field = *extract(tocpp(ptr)); + const T &ret = field.value(); // .value() gets us into any std::optional + if constexpr (std::is_same_v) { + // metadatum + if constexpr (std::is_same_v) { + return ret.c_str(); + } else { + return ret; + } + } else { + // child + return (HANDLE)(&ret); + } + } catch (...) { + log::function("{}({} handle = {})", funname, classname, (void *)ptr); + if constexpr (std::is_same_v) { + // metadatum + if constexpr (std::is_same_v) { + return ""; + } else { + return T{}; + } + } else { + // child + return (HANDLE)nullptr; + } + } +} + +// setField +template +void setField( + const std::string &classname, + const std::string &funname, + C *const ptr, + const EXTRACT &extract, + const T &newvalue +) { + try { + auto &field = *extract(tocpp(ptr)); + if constexpr (std::is_same_v) { + // metadatum + field.replace(newvalue); + } else { + // child + field.replace(tocpp(newvalue)); + } + } catch (...) { + log::function( + "{}({} handle = {}, value)", funname, classname, (void *)ptr); + } +} + + +// ----------------------------------------------------------------------------- +// clear, size +// ----------------------------------------------------------------------------- + +// clearContainer +template +void clearContainer( + const std::string &classname, + const std::string &funname, + C *const ptr, + const EXTRACT &extract +) { + try { + auto &container = (*extract(tocpp(ptr)))(); + if constexpr (isOptional) { + if (container) + container->clear(); + } else + container.clear(); + } catch (...) { + log::error("Exception thrown in detail::clearContainer"); + log::function( + "{}({} handle = {})", funname, classname, (void *)ptr); + } +} + +// sizeOfContainer +template +size_t sizeOfContainer( + const std::string &classname, + const std::string &funname, + C *const ptr, + const EXTRACT &extract +) { + try { + auto &container = (*extract(tocpp(ptr)))(); + if constexpr (isOptional) + return container ? container->size() : 0; + else + return container.size(); + } catch (...) { + log::error("Exception thrown in detail::sizeOfContainer"); + log::function( + "{}({} handle = {})", funname, classname, (void *)ptr); + return 0; + } +} + + +// ----------------------------------------------------------------------------- +// add +// ----------------------------------------------------------------------------- + +// addToContainer +template +void addToContainer( + const std::string &classname, + const std::string &funname, + C *const ptr, + const EXTRACT &extract, + const T &value +) { + try { + auto &field = *extract(tocpp(ptr)); + field.add(tocpp(value)); + } catch (...) { + log::error("Exception thrown in detail::addToContainer"); + log::function( + "{}({} handle = {}, value)", funname, classname, (void *)ptr); + } +} + + +// ----------------------------------------------------------------------------- +// getByIndex +// setByIndex +// ----------------------------------------------------------------------------- + +// getByIndex +template +HANDLE getByIndex( + const std::string &classname, + const std::string &funname, + const C *const ptr, + const EXTRACT &extract, + const size_t index +) { + try { + const auto &field = *extract(tocpp(ptr)); + return (HANDLE)&field(index); + } catch (...) { + log::function( + "{}({} handle = {}, index = {})", funname, classname, + (void *)ptr, index + ); + return (HANDLE)nullptr; + } +} + +// setByIndex +template +void setByIndex( + const std::string &classname, + const std::string &funname, + C *const ptr, + const EXTRACT &extract, + const size_t index, + const V *const newvalue +) { + try { + auto &field = *extract(tocpp(ptr)); + field.replace(index,tocpp(newvalue)); + } catch (...) { + log::function( + "{}({} handle = {}, value)", funname, classname, (void *)ptr); + } +} + + +// ----------------------------------------------------------------------------- +// hasByMetadatum +// getByMetadatum +// setByMetadatum +// ----------------------------------------------------------------------------- + +// hasByMetadatum +template +bool hasByMetadatum( + const std::string &classname, + const std::string &funname, + const C *const ptr, + const EXTRACT &extract, + const META &meta, + const T &value +) { + try { + const auto &field = *extract(tocpp(ptr)); + return field.has(meta(value)); + } catch (...) { + log::function("{}({} handle = {}, value)", funname, classname, + (void *)ptr); + return false; + } +} + +// getByMetadatum +template +HANDLE getByMetadatum( + const std::string &classname, + const std::string &funname, + const C *const ptr, + const EXTRACT &extract, + const META &meta, + const T &value +) { + try { + const auto &field = *extract(tocpp(ptr)); + return (HANDLE)&field(meta(value)); + } catch (...) { + log::function( + "{}({} handle = {}, value)", funname, classname, (void *)ptr); + return (HANDLE)nullptr; + } +} + +// setByMetadatum +template +void setByMetadatum( + const std::string &classname, + const std::string &funname, + C *const ptr, + const EXTRACT &extract, + const META &meta, + const T &value, + const V *const newvalue +) { + try { + auto &field = *extract(tocpp(ptr)); + field.replace(meta(value),tocpp(newvalue)); + } catch (...) { + log::function( + "{}({} handle = {}, value)", funname, classname, (void *)ptr); + } +} + + +// ----------------------------------------------------------------------------- +// Re: data vectors +// For when a Component-derived class has BlockData +// ----------------------------------------------------------------------------- + +// ------------------------ +// clear, size +// ------------------------ + +// clear +template +void vectorClear( + const std::string &classname, + const std::string &funname, + C *const ptr +) { + try { + tocpp(ptr).clear(); + } catch (...) { + log::error("Exception thrown in detail::vectorClear"); + log::function("{}({} handle = {})", funname, classname, (void *)ptr); + } +} + +// size +template +size_t vectorSize( + const std::string &classname, + const std::string &funname, + const C *const ptr +) { + try { + return tocpp(ptr).size(); + } catch (...) { + log::error("Exception thrown in detail::vectorSize"); + log::function("{}({} handle = {})", funname, classname, (void *)ptr); + return 0; + } +} + +// ------------------------ +// get, set +// One value +// ------------------------ + +// get +template +T vectorGet( + const std::string &classname, + const std::string &funname, + const C *const ptr, + const size_t index +) { + using VECTOR = std::vector; + bool rangeErr = false; + + try { + const VECTOR &vec = tocpp(ptr).template get(); + if (index < vec.size()) + return vec[index]; + + rangeErr = true; + log::error( + "Vector index {} not in range 0..size-1 (0..{})", + index, vec.size()-1 + ); + throw std::exception{}; + } catch (...) { + if (!rangeErr) // else error was already printed + log::error("Exception thrown in detail::vectorGet"); + log::function( + "{}({} handle = {}, index = {})", + funname, classname, (void *)ptr, index + ); + return T{}; + } +} + +// set +template +void vectorSet( + const std::string &classname, + const std::string &funname, + C *const ptr, + const size_t index, + const T &value +) { + using VECTOR = std::vector; + bool rangeErr = false; + + try { + VECTOR &vec = tocpp(ptr).template get(); + if (index < vec.size()) + vec[index] = value; + else { + rangeErr = true; + log::error( + "Vector index {} not in range 0..size-1 (0..{})", + index, vec.size()-1 + ); + throw std::exception{}; + } + } catch (...) { + if (!rangeErr) // else error was already printed + log::error("Exception thrown in detail::vectorSet"); + log::function( + "{}({} handle = {}, index = {}, value)", + funname, classname, (void *)ptr, index + ); + } +} + +// ------------------------ +// get, set +// All values +// ------------------------ + +// get +template +auto *vectorGet( + const std::string &classname, + const std::string &funname, + C *const ptr +) { + using VECTOR = std::vector; + using RETURN = decltype(&(tocpp(ptr).template get())[0]); + + try { + auto &vec = tocpp(ptr).template get(); + return vec.size() ? &vec[0] : nullptr; + } catch (...) { + log::error("Exception thrown in detail::vectorGet"); + log::function("{}({} handle = {})", funname, classname, (void *)ptr); + return RETURN(nullptr); + } +} + +// set +template +void vectorSet( + const std::string &classname, + const std::string &funname, + C *const ptr, + const size_t size, + const T *const values +) { + using VECTOR = std::vector; + + try { + tocpp(ptr).template get().assign(values,values+size); + } catch (...) { + log::error("Exception thrown in detail::vectorSet"); + log::function( + "{}({} handle = {}, size = {}, values*)", + funname, classname, (void *)ptr, size + ); + } +} + +} // namespace detail diff --git a/src/GNDStk/Child.hpp b/src/GNDStk/Child.hpp index 4cb0bc77c..22f0a8477 100644 --- a/src/GNDStk/Child.hpp +++ b/src/GNDStk/Child.hpp @@ -10,9 +10,9 @@ TYPE - The type to which GNDStk should convert a Node that's extracted from a Tree - with the Child object. If TYPE is void, then GNDStk uses Node - the child - node, in its original form in the tree. + The type to which GNDStk should convert a Node that's extracted, via our + query system, with the Child object. If TYPE is void, then GNDStk uses + type Node - the child node in its original form. ALLOW @@ -29,13 +29,13 @@ ALLOW In other words: there are (or can be) any number of nodes within an enclosing context (here, ). ALLOW is a template parameter because - it affects the *type* that's pulled from the Tree when the Child object - is used for a query. For example, + it affects the *type* that's extracted when the Child object is used for a + query. For example, tree(...,axes,axis) gives back a container of axis objects, not a single axis object, because - our Child axis keyword has ALLOW == Allow::any. Note that axes, not to be + our Child axis object has ALLOW == Allow::any. Note that axes, not to be confused with axis, has ALLOW == Allow::one because it's expected just once. CONVERTER @@ -49,7 +49,6 @@ FILTER */ - // ----------------------------------------------------------------------------- // default // ----------------------------------------------------------------------------- @@ -57,7 +56,7 @@ FILTER template< class TYPE = void, // default means current Node type Allow ALLOW = Allow::one, // one, or any number allowed? - class CONVERTER = typename detail::default_converter::type, + class CONVERTER = detail::default_converter_t, class FILTER = detail::noFilter > class Child { @@ -67,56 +66,25 @@ class Child { // data // ------------------------ - // name, object, converter, filter + // name, converter, filter std::string name; - const TYPE object; CONVERTER converter; // optional custom converter; needs operator() FILTER filter; // optional custom filter; needs operator() -private: - // allowable as top-level? - // We make this private, with a setter and a getter, so that the setter - // can register the name as "allowable as top-level" if we set to true. - bool canBeTopLevel; -public: // ------------------------ // constructors // ------------------------ // name - // name, type - // name, type, converter - // name, type, converter, filter - // name, type, converter, filter, top + // name, converter + // name, converter, filter explicit Child( const std::string &n, - const TYPE &t = TYPE{}, - const CONVERTER &c = CONVERTER{}, - const FILTER &f = FILTER{}, - const bool canbetop = false + const CONVERTER &c = detail::make_once(), + const FILTER &f = detail::make_once() ) : - name(n), object(t), converter(c), filter(f) - { - top(canbetop); - } - - // ------------------------ - // top(): allowable - // as a top-level node? - // ------------------------ - - // top() - bool top() const - { - return canBeTopLevel; - } - - // top(bool) - void top(const bool t) - { - if (t) detail::AllowedTop.insert(name); - canBeTopLevel = t; - } + name(n), converter(c), filter(f) + { } // ------------------------ // simple functions @@ -127,32 +95,26 @@ class Child { // See remarks for Meta's basic(); similar remarks apply here auto basic() const { - return Child( - name, filter, canBeTopLevel // converter not possible here - ); + // converter isn't possible here + return Child(name, filter); } // one() // Produce an equivalent Child, but formulated as Allow::one auto one() const { - return Child( - name, object, converter, filter, canBeTopLevel - ); + return Child(name, converter, filter); } // many() // Produce an equivalent Child, but formulated as Allow::many auto many() const { - return Child( - name, object, converter, filter, canBeTopLevel - ); + return Child(name, converter, filter); } }; - // ----------------------------------------------------------------------------- // void // ----------------------------------------------------------------------------- @@ -173,10 +135,6 @@ class Child { // name, filter std::string name; FILTER filter; // optional custom filter; needs operator() -private: - // allowable as top-level? - bool canBeTopLevel; -public: // ------------------------ // constructors @@ -184,34 +142,12 @@ class Child { // name // name, filter - // name, filter, top explicit Child( const std::string &n, - const FILTER &f = FILTER{}, - const bool t = false + const FILTER &f = detail::make_once() ) : name(n), filter(f) - { - top(t); - } - - // ------------------------ - // top(): allowable - // as a top-level node? - // ------------------------ - - // top() - bool top() const - { - return canBeTopLevel; - } - - // top(bool) - void top(const bool t) - { - if (t) detail::AllowedTop.insert(name); - canBeTopLevel = t; - } + { } // ------------------------ // simple functions @@ -222,43 +158,40 @@ class Child { // we're already void; this is here for consistency with the general case. auto basic() const { - return Child(name,filter,canBeTopLevel); + return Child(name,filter); } // one() // Produce an equivalent Child, but formulated as Allow::one auto one() const { - return Child(name,filter,canBeTopLevel); + return Child(name,filter); } // many() // Produce an equivalent Child, but formulated as Allow::many auto many() const { - return Child(name,filter,canBeTopLevel); + return Child(name,filter); } }; - // ----------------------------------------------------------------------------- // Macro // ----------------------------------------------------------------------------- -// For Child building. This macro doesn't handle the optional "top-level" -// flag, the converter, or the filter; we don't believe those will be needed -// very often. If you do need to provide one or both, construct a Child -// in some other way than by using this macro. +// For Child building. This macro doesn't handle the converter or the filter; +// we don't believe those will be needed very often. If you do need to provide +// one or both, construct a Child in some other way than by using this macro. #define GNDSTK_MAKE_CHILD(TYPE,name,ALLOW) \ - inline const Child name(#name) + inline const njoy::GNDStk::Child name(#name) // Note: we don't #undef this after we use it within GNDStk, as we might // normally do, because users might find it handy. - // ----------------------------------------------------------------------------- // Operators // ----------------------------------------------------------------------------- diff --git a/src/GNDStk/Child/src/operator.hpp b/src/GNDStk/Child/src/operator.hpp index 0bbe2c677..12c3ae001 100644 --- a/src/GNDStk/Child/src/operator.hpp +++ b/src/GNDStk/Child/src/operator.hpp @@ -15,43 +15,6 @@ inline auto operator-(const Child &kwd) } - -// ----------------------------------------------------------------------------- -// operator~: Allow as top-level -// operator!: Disallow as top-level -// -// We don't expect much use of these, but someone may occasionally find the -// first (more likely) or the second (less likely) to be helpful. The unary -// operators that we chose for these purposes seemed like the best, given a -// limited selection. One could think: (T)ilde for (T)op; Not for Not. -// ----------------------------------------------------------------------------- - -// operator~ -template -inline auto operator~(const Child &kwd) -{ - auto ret = kwd; - ret.top(true); - return ret; -} - -// operator! -// fixme This switches off the canBeTopLevel flag in an individual Child, -// but we actually use the namespace-scope set AllowedTop when we -// determine if a particular name is allowed as a top-level node. So, turning -// of a Child's previously-true top-level designator does not, at the moment, -// have any meaningful effect anywhere. We'll look at this more carefully -// sometime. For now, this just isn't a super important issue. -template -inline auto operator!(const Child &kwd) -{ - auto ret = kwd; - ret.top(false); - return ret; -} - - - // ----------------------------------------------------------------------------- // T/Child // Change type to T @@ -61,36 +24,31 @@ inline auto operator!(const Child &kwd) // T/Child template inline auto operator/( - const T &object, + const T &, const Child &kwd ) { return Child( kwd.name, - object, kwd.converter, - kwd.filter, - kwd.top() + kwd.filter ); } // T/Child template inline auto operator/( - const T &object, + const T &, const Child &kwd ) { - using CONVERTER = typename detail::default_converter::type; + using CONVERTER = detail::default_converter_t; return Child( kwd.name, - object, CONVERTER{}, // because the input Child didn't have one - kwd.filter, - kwd.top() + kwd.filter ); } - // ----------------------------------------------------------------------------- // Child/string // Child/char* @@ -139,7 +97,6 @@ inline auto operator/( } - // ----------------------------------------------------------------------------- // * // regex match-anything @@ -152,7 +109,6 @@ inline auto operator*(const Child &kwd) } - // ----------------------------------------------------------------------------- // Child/C // Change converter to C @@ -172,10 +128,8 @@ inline Child< ) { return Child( kwd.name, - kwd.object, converter, // the new one; not kwd.converter! - kwd.filter, - kwd.top() + kwd.filter ); } @@ -198,7 +152,6 @@ inline Child< } - // ----------------------------------------------------------------------------- // post-- // Change converter to its default @@ -210,13 +163,11 @@ inline auto operator--( const Child &kwd, const int ) { - using C = typename detail::default_converter::type; + using C = detail::default_converter_t; return Child( kwd.name, - kwd.object, C{}, - kwd.filter, - kwd.top() + kwd.filter ); } @@ -230,7 +181,6 @@ inline auto operator--( } - // ----------------------------------------------------------------------------- // --pre, ++pre // Downgrade/upgrade to Allow::one/many @@ -251,7 +201,6 @@ inline auto operator++(const Child &kwd) } - // ----------------------------------------------------------------------------- // Child + F // Change filter to F @@ -265,10 +214,8 @@ inline auto operator+( ) { return Child( kwd.name, - kwd.object, kwd.converter, - filter, // the new one - kwd.top() + filter // the new one ); } @@ -280,13 +227,11 @@ inline auto operator+( ) { return Child( kwd.name, - filter, // the new one - kwd.top() + filter // the new one ); } - // ----------------------------------------------------------------------------- // Child || Child // Create a Child that represents one or the other of two children @@ -305,9 +250,7 @@ inline auto operator||( // both names, space-separated; this gets special treatment elsewhere a.name + " " + b.name, // need a filter; use the first Child's - a.filter, - // if either is top-level enabled - a.top() || b.top() + a.filter ); } @@ -328,9 +271,8 @@ inline auto operator||( return Child,ALLOW,CONVERTER,FILTER>( // both names, space-separated; this gets special treatment elsewhere a.name + " " + b.name, - // need an object, converter, and filter; use the first Child's - a.object, a.converter, a.filter, - // if either is top-level enabled - a.top() || b.top() + // we need a converter and a filter; use the first Child's + a.converter, + a.filter ); } diff --git a/src/GNDStk/Child/test/Child.test.cpp b/src/GNDStk/Child/test/Child.test.cpp index ac43846b9..176d689e5 100644 --- a/src/GNDStk/Child/test/Child.test.cpp +++ b/src/GNDStk/Child/test/Child.test.cpp @@ -24,28 +24,18 @@ SCENARIO("Testing GNDStk Child") { const Child foo("foo"); CHECK(foo.name == "foo"); - CHECK(!foo.top()); } WHEN("Constructed with (name,converter)") { const Child - foo("foo", 0.0, converter{}); + foo("foo", converter{}); CHECK(foo.name == "foo"); - CHECK(!foo.top()); } WHEN("Constructed with (name,converter,filter)") { const Child - foo("foo", 0.0, converter{}, filter); + foo("foo", converter{}, filter); CHECK(foo.name == "foo"); - CHECK(!foo.top()); - } - - WHEN("Constructed with (name,converter,filter,top)") { - const Child - foo("foo", 0.0, converter{}, filter, true); - CHECK(foo.name == "foo"); - CHECK(foo.top()); } } @@ -55,21 +45,18 @@ SCENARIO("Testing GNDStk Child") { const Child foo("foo"); CHECK(foo.name == "foo"); - CHECK(!foo.top()); } WHEN("Constructed with (name,filter)") { const Child foo("foo", filter); CHECK(foo.name == "foo"); - CHECK(!foo.top()); } WHEN("Constructed with (name,filter,top)") { const Child - foo("foo", filter, true); + foo("foo", filter); CHECK(foo.name == "foo"); - CHECK(foo.top()); } } } diff --git a/src/GNDStk/Child/test/operator.test.cpp b/src/GNDStk/Child/test/operator.test.cpp index 1ec2af774..af7646875 100644 --- a/src/GNDStk/Child/test/operator.test.cpp +++ b/src/GNDStk/Child/test/operator.test.cpp @@ -128,45 +128,6 @@ SCENARIO("Testing GNDStk Child operators") { } } - // ------------------------ - // ~Child - // !Child - // top() - // top(bool) - // ------------------------ - - GIVEN("Some Child objects") { - const Child foo("foo"); - const Child bar("bar"); - Child one("one"); - one.top(true); - Child two("two"); - two.top(true); - - CHECK(!foo.top()); - CHECK(!bar.top()); - CHECK(one.top()); - CHECK(two.top()); - - WHEN("We apply ~Child") { - THEN("Top-level is enabled") { - CHECK((~foo).top()); - CHECK((~bar).top()); - CHECK((~one).top()); - CHECK((~two).top()); - } - } - - WHEN("We apply !Child") { - THEN("Top-level is disabled") { - CHECK(!(!foo).top()); - CHECK(!(!bar).top()); - CHECK(!(!one).top()); - CHECK(!(!two).top()); - } - } - } - // ------------------------ // type/Child // ------------------------ diff --git a/src/GNDStk/Component.hpp b/src/GNDStk/Component.hpp index 942acea86..c12052ad8 100644 --- a/src/GNDStk/Component.hpp +++ b/src/GNDStk/Component.hpp @@ -13,16 +13,22 @@ using helpMap = std::map; // Component // ----------------------------------------------------------------------------- -template -class Component : public BodyText +template +class Component : public BlockData { // For convenience - using body = BodyText; - using typename body::VariantOfVectors; - using typename body::VariantOfScalars; + using BLOCKDATA = BlockData; + using typename BLOCKDATA::VariantOfVectors; + using typename BLOCKDATA::VariantOfScalars; + + static const auto &Keys() + { + static const auto value = makeKeyTuple(DERIVED::KEYS()); + return value; + } // Links to fields in the object of the derived class. I can't find a way - // to do this in a decltype(DERIVED::keys())-aware manner, because DERIVED + // to do this in a decltype(DERIVED::KEYS())-aware manner, because DERIVED // is generally an incomplete type *here* - outside of Component's member // functions. So, we'll do it the old-fashioned way. std::vector links; @@ -35,12 +41,12 @@ class Component : public BodyText // Copy and move *assignments* have the right behavior, however. Component &operator=(const Component &other) { - body::operator=(other); + BLOCKDATA::operator=(other); return *this; } Component &operator=(Component &&other) { - body::operator=(std::move(other)); + BLOCKDATA::operator=(std::move(other)); return *this; } @@ -51,22 +57,35 @@ class Component : public BodyText // See comments in finish.hpp #include "GNDStk/Component/src/finish.hpp" - // Intermediaries between derived-class getters, and getter functions - // in detail::. These shorten the code in the derived classes. + // Helpers for derived-class getters/setters. + // These allow us to shorten some other code. #include "GNDStk/Component/src/getter.hpp" + #include "GNDStk/Component/src/setter.hpp" // Fallback for documentation() if DERIVED doesn't have help static inline helpMap help; public: + #include "GNDStk/Component/src/read.hpp" + #include "GNDStk/Component/src/write.hpp" + #include "GNDStk/Component/src/print.hpp" #include "GNDStk/Component/src/fromNode.hpp" #include "GNDStk/Component/src/sort.hpp" #include "GNDStk/Component/src/toNode.hpp" // conversion to Node - #include "GNDStk/Component/src/write.hpp" - // You can (but don't need to) override the following in DERIVED - static std::string namespaceName() { return ""; } + // Namespace + static std::string Namespace() { return DERIVED::NAMESPACE(); } + + // baseBlockData + // Convenient access to the BlockData base class + BLOCKDATA &baseBlockData() { return *this; } + const BLOCKDATA &baseBlockData() const { return *this; } + + // baseComponent + // Convenient access to the Component base class (of the derived class) + Component &baseComponent() { return *this; } + const Component &baseComponent() const { return *this; } // derived // Convenient access to the derived class @@ -80,15 +99,36 @@ class Component : public BodyText { try { return DERIVED::help.at(subject); - } - catch ( ... ) { + } catch (...) { return "No help information is available"; } } - // Component << std::string - // Meaning: read the string's content (currently XML or JSON) into an object - // of the Component's DERIVED class. Uses Node's << std::string capability. + // has + // Usable in C++ "compile-time if" (a.k.a. "if constexpr") statements + template< + class EXTRACTOR, class THIS = DERIVED, + class = decltype(std::declval()(THIS{})) + > + static constexpr bool has(const Lookup &) + { + return true; + } + + template< + class EXTRACTOR, bool F, + class = std::enable_if_t + > + static constexpr bool has(const Lookup &) + { + return false; + } + + // Class + static std::string Class() { return DERIVED::CLASS(); } + + // Component << string + // Like Node << string, but for Component's derived class. void operator<<(const std::string &str) { try { @@ -96,22 +136,61 @@ class Component : public BodyText node << str; derived() = DERIVED(node); } catch (...) { - log::function(std::string(DERIVED::className()) + " << string"); + log::function("{} << string", Class()); + throw; + } + } + + // Component >> string + // Like Node >> string, but for Component's derived class. + void operator>>(std::string &str) const + { + try { + Node(*this) >> str; + } catch (...) { + log::function("{} >> string", Class()); throw; } } + // Forwards, where viable and unambiguous, to certain capabilities + // in DERIVED's fields + #include "GNDStk/Component/src/forward.hpp" + + // Wrapper for derived-class fields + #include "GNDStk/Component/src/field.hpp" + }; // class Component // ----------------------------------------------------------------------------- -// ostream << Component +// Stream I/O // ----------------------------------------------------------------------------- -template +// operator>> +template +std::istream &operator>>( + std::istream &is, + Component &comp +) { + try { + return comp.read(is); + } catch (...) { + log::function("istream >> {}", comp.Class()); + throw; + } +} + +// operator<< +template std::ostream &operator<<( std::ostream &os, - const Component &obj + const Component &comp ) { - return obj.write(os); + try { + return comp.print(os,0); + } catch (...) { + log::function("ostream << {}", comp.Class()); + throw; + } } diff --git a/src/GNDStk/Component/src/ctor.hpp b/src/GNDStk/Component/src/ctor.hpp index f289a5058..dec66b874 100644 --- a/src/GNDStk/Component/src/ctor.hpp +++ b/src/GNDStk/Component/src/ctor.hpp @@ -6,41 +6,28 @@ friend DERIVED; -// ctor: fields +// ctor: BlockData<...>, fields template -Component(const body &other, ARGS &...args) : body(other) +Component(const BLOCKDATA &other, ARGS &...args) : BLOCKDATA(other) { - // static_assert needs string literal - #define pairing_error \ - "The number and/or types of the fields sent to Component's " \ - "constructor is inconsistent with the query result implied " \ - "by the derived class' keys()" - // I'd have preferred to achieve the following check by using SFINAE // in the constructor's signature, but couldn't find a way to do that // without again running into the issue of DERIVED being incomplete. - // The parameters that are sent to this constructor must EXACTLY reflect - // what we'd get from a DERIVED::keys() multi-query. - if constexpr (std::is_same_v>) { - // keys is "empty" (std::tuple<>); that's OK, as long as ARGS is too - static_assert( - std::is_same_v, std::tuple<>>, - pairing_error - ); - } else { - // keys are *not* empty, so... - // The following is the *type* that a multi-query with DERIVED::keys() - // will produce. - using multi_t = - detail::decays_t; - static_assert( - std::is_same_v, multi_t>, - pairing_error - ); - // Create links - (links.push_back(&args), ...); - } + // Type that a multi-query with DERIVED::KEYS() will produce. + using multi_t = typename detail::queryResult::type; + + // The types in ARGS should exactly reflect what we'd get from + // a DERIVED::KEYS() multi-query, except that an ARG of Field + // is accepted in place of a T. + static_assert( + std::is_same_v::type...>, multi_t>, + "The number and/or types of the fields sent to Component's " + "constructor is inconsistent with the query result implied " + "by the KEYS() function in the derived class" + ); - #undef pairing_error + // Create links + links.reserve(sizeof...(args)); + (links.push_back(fieldAddress(args)), ...); } diff --git a/src/GNDStk/Component/src/detail-getter.hpp b/src/GNDStk/Component/src/detail-getter.hpp new file mode 100644 index 000000000..1df608eb7 --- /dev/null +++ b/src/GNDStk/Component/src/detail-getter.hpp @@ -0,0 +1,450 @@ + +// ----------------------------------------------------------------------------- +// getter(vector, index, names...) +// Element of the vector that has .index() == index. +// Or, use C++ [index] if the element type doesn't have an .index() getter. +// ----------------------------------------------------------------------------- + +template +const T &getter( + const std::vector &vec, + const std::size_t &index, + // for the Component-derived class: names of namespace, class, relevant field + const std::string &nname, const std::string &cname, const std::string &fn +) { + static const std::string context = "getter {}::{}.{}({}) on vector"; + const std::string fname = fn != "" ? fn : ""; + + try { + + if constexpr (hasIndex) { + // hasIndex + // T (or at least one of its alternatives, if T is a variant) has + // a metadatum called "index". In this case, this function's index + // parameter is interpreted to mean: find the object with an "index" + // metadatum that matches the parameter. Importantly, then, index + // in this case is ***NOT*** a C++ [index] index! + + // fixme Make this more efficient, e.g. by assuming that the vector's + // elements are sorted by index, so that the wanted value is probably + // at [index], even though a vector [index] is not the interpretation. + const T *object = nullptr; + + for (auto &elem : vec) { + const T *ptr = nullptr; + + if constexpr (isVariant::value) { + // T == variant + std::visit( + [&elem,&index,&ptr](auto &&alternative) + { + if constexpr (hasIndex) + if (alternative.index() == index) + ptr = &elem; + }, + elem + ); + } else { + // T != variant + if constexpr (hasIndex) + if (elem.index() == index) + ptr = &elem; + } + + if (ptr) { + if (object) { + log::warning( + "Element with metadatum \"index\" {} was already found " + "in the vector.\n" + "Keeping the first element that was found.", + index + ); + log::member(context, nname, cname, fname, index); + } else + object = ptr; + } + } // for + + if (object) + return *object; + + log::error( + "Element with metadatum index == {} was not found in the vector" + + std::string(vec.size() ? "." : ";\nin fact the vector is empty."), + index + ); + throw std::exception{}; + + } else { + // !hasIndex + // No "index" is anywhere to be found in T. Here, then, we interpret + // this function's index parameter to be a C++ vector [index]. + if (index < vec.size()) + return vec[index]; + + if (vec.size() == 0) + log::error( + "Index {} is out of range; vector is empty.", + index); + else + log::error( + "Index {} is out of range; vector has [0..{}].", + index, vec.size()-1); + + throw std::exception{}; + } + + } catch (...) { + // context + log::member(context, nname, cname, fname, index); + throw; + } +} + + +// ----------------------------------------------------------------------------- +// getter(vector, label, names...) +// Element of the vector that has .label() == label. +// Assumes that the element type has a .label() getter. +// ----------------------------------------------------------------------------- + +template +const T &getter( + const std::vector &vec, + const std::string &label, + const std::string &nname, const std::string &cname, const std::string &fn +) { + static const std::string context = "getter {}::{}.{}(\"{}\") on vector"; + const std::string fname = fn != "" ? fn : ""; + + try { + const T *object = nullptr; + + for (auto &elem : vec) { + const T *ptr = nullptr; + + if constexpr (isVariant::value) { + // T == variant + std::visit( + [&elem,&label,&ptr](auto &&alternative) + { + if constexpr (hasLabel) + if (alternative.label() == label) + ptr = &elem; + }, + elem + ); + } else { + // T != variant + if constexpr (hasLabel) + if (elem.label() == label) + ptr = &elem; + } + + if (ptr) { + if (object) { + log::warning( + "Element with label \"{}\" was already found in the vector.\n" + "Keeping the first element that was found.", + label + ); + log::member(context, nname, cname, fname, label); + } else + object = ptr; + } + } // for + + if (object) + return *object; + + log::error( + "Element with metadatum label == \"{}\" was not found in the vector" + + std::string(vec.size() ? "." : ";\nin fact the vector is empty."), + label + ); + throw std::exception{}; + + } catch (...) { + // context + log::member(context, nname, cname, fname, label); + throw; + } +} + + +// ----------------------------------------------------------------------------- +// getter(vector, Lookup, names...) +// ----------------------------------------------------------------------------- + +template +bool getter( + const std::vector &vec, + const Lookup &look, + const std::string &nname, const std::string &cname, const std::string &fn +) { + const std::string fname = fn != "" ? fn : ""; + + try { + for (auto &elem : vec) + if constexpr (isVariant::value) { + // T == variant + if (std::visit( + [&look](auto &&alternative) + { + return look.extractor(alternative) == look.placeholder; + }, + elem + )) + return true; + } else + // T != variant + if (look.extractor(elem) == look.placeholder) + return true; + } catch (...) { + // context + log::member( + "getter {}::{}.{}(has({}({}))) on vector", + nname, cname, fname, look.name, look.placeholder); + throw; + } + + return false; +} + + +// ----------------------------------------------------------------------------- +// getter(vector, Lookup, names...) +// ----------------------------------------------------------------------------- + +template +const T &getter( + const std::vector &vec, + const Lookup &look, + const std::string &nname, const std::string &cname, const std::string &fn +) { + static const std::string context = "getter {}::{}.{}({}({})) on vector"; + const std::string fname = fn != "" ? fn : ""; + + try { + const T *object = nullptr; + + for (auto &elem : vec) { + const T *ptr = nullptr; + + if constexpr (isVariant::value) { + // T == variant + std::visit( + [&elem,&look,&ptr](auto &&alternative) + { + if (look.extractor(alternative) == look.placeholder) + ptr = &elem; + }, + elem + ); + } else { + // T != variant + if (look.extractor(elem) == look.placeholder) + ptr = &elem; + } + + if (ptr) { + if (object) { + log::warning( + "Element with {}({}) was already found in the vector.\n" + "Keeping the first element that was found.", + look.name, look.placeholder + ); + log::member(context, nname, cname, fname, look.name, look.placeholder); + } else + object = ptr; + } + } // for + + if (object) + return *object; + + log::error( + "Element with metadatum {} == {} was not found in the vector" + + std::string(vec.size() ? "." : ";\nin fact the vector is empty."), + look.name, look.placeholder + ); + throw std::exception{}; + + } catch (...) { + // context + log::member(context, nname, cname, fname, look.name, look.placeholder); + throw; + } +} + + +// ----------------------------------------------------------------------------- +// getter(vector, Lookup, names...) +// ----------------------------------------------------------------------------- + +template +bool getter( + const std::vector &, + const Lookup &, + const std::string &, const std::string &, const std::string & +) { + return has_field::value; +} + + +// ----------------------------------------------------------------------------- +// getter(vector, Lookup, names...) +// ----------------------------------------------------------------------------- + +template +auto getter( + const std::vector &vec, + const Lookup &look, + const std::string &nname, const std::string &cname, const std::string &fn +) { + const std::string fname = fn != "" ? fn : ""; + + std::vector::type{})) + >> ret; + + try { + for (auto &elem : vec) { + if constexpr (isVariant::value) { + // T == variant + std::visit( + [&look,&ret](auto &&alternative) + { + ret.push_back(look.extractor(alternative)); + }, + elem + ); + } else { + // T != variant + ret.push_back(look.extractor(elem)); + } + } // for + } catch (...) { + // context + log::member( + "getter {}::{}.{}({}) on vector", + nname, cname, fname, look.name); + throw; + } + + return ret; +} + + +// ----------------------------------------------------------------------------- +// getter(optional, index/label/Lookup, names...) +// As earlier, but for optional data member. +// ----------------------------------------------------------------------------- + +template< + class T, class KEY, + class = isSearchKey +> +decltype(auto) getter( + const std::optional> &optvec, + const KEY &key, + const std::string &nname, const std::string &cname, const std::string &fn +) { + const std::string fname = fn != "" ? fn : ""; + + try { + // optional must have value + if (!optvec.has_value()) { + log::error("optional vector {} does not have a value", fname); + throw std::exception{}; + } + return getter(*optvec, key, nname, cname, fname); + } catch (...) { + // context + if constexpr (isLookup::value) { + // nname::cname.fname(field(value)) + if constexpr (!KEY::Has && !KEY::Void) + log::member("getter {}::{}.{}({}({})) on optional", + nname, cname, fname, key.name, key.placeholder); + // nname::cname.fname(has(field(value))) + if constexpr ( KEY::Has && !KEY::Void) + log::member("getter {}::{}.{}(has({}({}))) on optional", + nname, cname, fname, key.name, key.placeholder); + // nname::cname.fname(field) + if constexpr (!KEY::Has && KEY::Void) + log::member("getter {}::{}.{}({}) on optional", + nname, cname, fname, key.name); + // nname::cname.fname(has(field)) + if constexpr ( KEY::Has && KEY::Void) + log::member("getter {}::{}.{}(has({})) on optional", + nname, cname, fname, key.name); + } else { + log::member( + std::is_convertible_v + ? "getter {}::{}.{}({}) on optional" + : "getter {}::{}.{}(\"{}\") on optional", + nname, cname, fname, key); + } + throw; + } +} + + +// ----------------------------------------------------------------------------- +// getter(variant, names...) +// ----------------------------------------------------------------------------- + +template< + class T, class... Ts, + class = std::enable_if_t>> +> +const T *getter( + const std::variant &var, + const std::string &nname, const std::string &cname, const std::string &fn +) { + const std::string fname = fn != "" ? fn : ""; + + try { + return std::holds_alternative(var) + ? &std::get(var) + : nullptr; + } catch (...) { + // context + log::member("getter {}::{}.{}() on variant", nname, cname, fname); + throw; + } +} + + +// ----------------------------------------------------------------------------- +// getter(vector, index/label/Lookup, names...) +// ----------------------------------------------------------------------------- + +template< + class T, class KEY, class... Ts, + class = isSearchKey, + class = std::enable_if_t>> +> +const T *getter( + const std::vector> &vecvar, + const KEY &key, + const std::string &nname, const std::string &cname, const std::string &fn +) { + const std::string fname = fn != "" ? fn : ""; + + try { + return getter( + // no , so it calls getter(generic vector); it isn't recursive + getter(vecvar, key, nname, cname, fname), // scalar variant + nname, cname, fname + ); + } catch (...) { + // context + log::member( + std::is_convertible_v + ? "getter {}::{}.{}({}) on vector" + : "getter {}::{}.{}(\"{}\") on vector", + nname, cname, fname, key); + throw; + } +} diff --git a/src/GNDStk/Component/src/detail-sfinae.hpp b/src/GNDStk/Component/src/detail-sfinae.hpp new file mode 100644 index 000000000..471408620 --- /dev/null +++ b/src/GNDStk/Component/src/detail-sfinae.hpp @@ -0,0 +1,347 @@ + +// ----------------------------------------------------------------------------- +// Re: [optional] vector [of variant] +// ----------------------------------------------------------------------------- + +// ------------------------ +// isVector +// ------------------------ + +// general +template +struct isVector + : public std::false_type +{ }; + +// for std::vector +template +struct isVector> + : public std::true_type +{ }; + +// isVector_v +template +inline constexpr bool isVector_v = isVector::value; + +// isVector_t +template +using isVector_t = std::enable_if_t>; + +// ------------------------ +// isOptionalVector +// ------------------------ + +// general +template +struct isOptionalVector + : public std::false_type +{ }; + +// for std::vector +template +struct isOptionalVector>> + : public std::true_type +{ }; + +template +using isOptionalVector_t = std::enable_if_t::value>; + +// ------------------------ +// isVectorOrOptionalVector +// ------------------------ + +// general +template +struct isVectorOrOptionalVector + : public std::false_type +{ }; + +// for std::vector +template +struct isVectorOrOptionalVector> + : public std::true_type +{ + using value_type = T; +}; + +// for std::optional +template +struct isVectorOrOptionalVector>> + : public std::true_type +{ + using value_type = T; +}; + +template +using isVectorOrOptionalVector_t = + std::enable_if_t::value>; + +// ------------------------ +// isVectorVariant +// ------------------------ + +// general +template +struct isVectorVariant + : public std::false_type +{ }; + +// for std::vector> +template +struct isVectorVariant,Alloc>> + : public std::true_type +{ }; + +template +using isVectorVariant_t = std::enable_if_t::value>; + + +// ----------------------------------------------------------------------------- +// Re: Defaulted +// ----------------------------------------------------------------------------- + +// ------------------------ +// isDefaulted +// ------------------------ + +// general +template +struct isDefaulted + : public std::false_type +{ }; + +// for Defaulted +template +struct isDefaulted> + : public std::true_type +{ }; + +template +using isDefaulted_t = std::enable_if_t::value>; + + +// ----------------------------------------------------------------------------- +// Re: Lookup +// ----------------------------------------------------------------------------- + +// ------------------------ +// isLookup +// ------------------------ + +// general +template +struct isLookup + : public std::false_type +{ }; + +// for Lookup +template +struct isLookup> + : public std::true_type +{ }; + +// ------------------------ +// isLookupRefReturn +// ------------------------ + +// general +template +struct isLookupRefReturn + : public std::false_type +{ }; + +// for Lookup, with TYPE != void wanted +template +struct isLookupRefReturn> +{ + static inline constexpr bool value = !isVoid; +}; + +// ------------------------ +// isLookupBoolReturn +// ------------------------ + +template +inline constexpr bool isLookupBoolReturn = + detail::isLookup::value && + !detail::isLookupRefReturn::value; + + +// ----------------------------------------------------------------------------- +// Re: SearchKey +// ----------------------------------------------------------------------------- + +// ------------------------ +// isSearchKey +// isSearchKeyRefReturn +// ------------------------ + +// isSearchKey +// Type is one of: +// - convertible to std::size_t, for use as an index +// - convertible to std::string, for use as a label +// - of type Lookup<...> +template +using isSearchKey = std::enable_if_t< + std::is_convertible_v || + std::is_convertible_v || + isLookup::value // any Lookup +>; + +// isSearchKeyRefReturn +// Like the above, but allowing only a Lookup that triggers a reference return +template +using isSearchKeyRefReturn = std::enable_if_t< + std::is_convertible_v || + std::is_convertible_v || + isLookupRefReturn::value // not any Lookup; must give a reference return +>; + + +// ----------------------------------------------------------------------------- +// Re: Component's "forwards" +// ----------------------------------------------------------------------------- + +// ------------------------ +// isMatchExact +// ------------------------ + +// general +template +struct isMatchExact { + static constexpr int count = 0; +}; + +// FROM, vector +template +struct isMatchExact> { + static constexpr int count = 1; +}; + +// FROM, optional> +template +struct isMatchExact>> + : public isMatchExact> +{ }; + +// ------------------------ +// MatchesExact +// ------------------------ + +// general +template +struct MatchesExact { + static constexpr std::size_t count = 0; +}; + +// FROM, tuple<...> +template +struct MatchesExact> { + static constexpr std::size_t count = ( + isMatchExact< + FROM, + std::decay_t()))> + >::count + + ... + ); +}; + +// ------------------------ +// isMatchViable +// ------------------------ + +// general +template +struct isMatchViable { + static constexpr int count = 0; +}; + +// FROM, vector +template +struct isMatchViable> { + static constexpr int count = std::is_convertible_v; +}; + +// FROM, optional> +template +struct isMatchViable>> + : public isMatchViable> +{ }; + +// ------------------------ +// MatchesViable +// ------------------------ + +// general +template +struct MatchesViable { + static constexpr std::size_t count = 0; +}; + +// FROM, tuple<...> +template +struct MatchesViable> { + static constexpr std::size_t count = ( + isMatchViable< + FROM, + std::decay_t()))> + >::count + + ... + ); +}; + + +// ----------------------------------------------------------------------------- +// Miscellaneous +// ----------------------------------------------------------------------------- + +// ------------------------ +// firstOrOnly +// ------------------------ + +// general +template +struct firstOrOnly { + using type = T; +}; + +// for variant +template +struct firstOrOnly> { + using type = T; +}; + +// ------------------------ +// has_field +// Compare with has_index, +// as defined elsewhere +// ------------------------ + +// default +template +struct has_field + : std::false_type { }; + +// general +template +struct has_field< + EXTRACTOR, + T, + decltype( + (void)std::declval()( + std::conditional_t::value,void,T>{} + ), + 0 + ) +> + : std::true_type { }; + +// for variant +template +struct has_field< + EXTRACTOR, + std::variant +> { + // does any alternative have the field? + static constexpr bool value = (has_field::value || ...); +}; diff --git a/src/GNDStk/Component/src/detail.hpp b/src/GNDStk/Component/src/detail.hpp index 05cf4322d..315b1fe29 100644 --- a/src/GNDStk/Component/src/detail.hpp +++ b/src/GNDStk/Component/src/detail.hpp @@ -1,37 +1,10 @@ // Forward declaration, needed by some things later -template +template class Component; - namespace detail { -// ----------------------------------------------------------------------------- -// colorize_*(text) -// ----------------------------------------------------------------------------- - -#define gndstkPaste(one,two) one ## two -#define gndstkColorFun(part) \ - inline std::string gndstkPaste(colorize_,part)(const std::string &text) \ - { \ - return GNDStk::color && colors::part != "" \ - ? colors::part + text + colors::reset \ - : text; \ - } - - // colorize_label() etc. - gndstkColorFun(label) - gndstkColorFun(colon) - gndstkColorFun(component) - gndstkColorFun(brace) - gndstkColorFun(bracket) - gndstkColorFun(comment) - -#undef gndstkColorFun -#undef gndstkPaste - - - // ----------------------------------------------------------------------------- // Functions: miscellaneous // ----------------------------------------------------------------------------- @@ -91,10 +64,10 @@ inline std::string colorize( // ------------------------ inline std::string fullName( - const std::string &nsname, - const std::string &clname + const std::string &nname, // name of namespace + const std::string &cname // name of class ) { - return (nsname == "" ? "" : nsname + "::") + clname; + return (nname == "" ? "" : nname + "::") + cname; } @@ -110,57 +83,55 @@ inline void indentString( // ------------------------ -// hasWriteOneArg -// hasWriteTwoArg +// hasPrint* // ------------------------ // These are adapted from an answer here: // https://stackoverflow.com/questions/87372 -// class +// hasPrintOneArg template -class HasWriteOneArg +class HasPrintOneArg { template< class U, std::ostream &(U::*)(std::ostream &) const > struct SFINAE {}; - template static char test(SFINAE *); + template static char test(SFINAE *); template static long test(...); public: - static const bool has = sizeof(test(0)) == sizeof(char); + static constexpr bool has = sizeof(test(0)) == sizeof(char); }; -// variable - use this +// HasPrintTwoArg template -inline constexpr bool hasWriteOneArg = HasWriteOneArg::has; - -// class -template -class HasWriteTwoArg +class HasPrintTwoArg { template< class U, std::ostream &(U::*)(std::ostream &, const int) const > struct SFINAE {}; - template static char test(SFINAE *); + template static char test(SFINAE *); template static long test(...); public: - static const bool has = sizeof(test(0)) == sizeof(char); + static constexpr bool has = sizeof(test(0)) == sizeof(char); }; -// variable - use this +// Variable templates for the above; prefer these +template +inline constexpr bool hasPrintOneArg = HasPrintOneArg::has; + template -inline constexpr bool hasWriteTwoArg = HasWriteTwoArg::has; +inline constexpr bool hasPrintTwoArg = HasPrintTwoArg::has; // ----------------------------------------------------------------------------- -// writeComponentPart +// printComponentPart // ----------------------------------------------------------------------------- // Cases: @@ -170,33 +141,33 @@ inline constexpr bool hasWriteTwoArg = HasWriteTwoArg::has; // Defaulted // std::vector -bool writeComponentPart( +bool printComponentPart( std::ostream &os, const int level, const std::string &str, const std::string &label, const std::size_t maxlen, const std::string &color = "" ); template -bool writeComponentPart( +bool printComponentPart( std::ostream &os, const int level, const T &value, const std::string &label, const std::size_t maxlen, const std::string &color = "" ); template -bool writeComponentPart( +bool printComponentPart( std::ostream &os, const int level, const std::optional &opt, const std::string &label, const std::size_t maxlen ); template -bool writeComponentPart( +bool printComponentPart( std::ostream &os, const int level, const Defaulted &def, const std::string &label, const std::size_t maxlen ); template -bool writeComponentPart( +bool printComponentPart( std::ostream &os, const int level, const std::vector &vec, const std::string &label, const std::size_t maxlen, const std::string &color = "" @@ -207,7 +178,7 @@ bool writeComponentPart( // for string // ------------------------ -inline bool writeComponentPart( +inline bool printComponentPart( std::ostream &os, const int level, const std::string &str, const std::string &label, const std::size_t maxlen, const std::string &color @@ -243,11 +214,11 @@ inline bool writeComponentPart( // ------------------------ // helper -// is_base_of_Component +// isDerivedFromComponent // Adapted from an answer here: // https://stackoverflow.com/questions/34672441 template -class is_base_of_Component { +class isDerivedFromComponent { template static constexpr std::true_type test(Component *); static constexpr std::false_type test(...); @@ -257,18 +228,21 @@ class is_base_of_Component { }; template -bool writeComponentPart( +bool printComponentPart( std::ostream &os, const int level, const T &value, const std::string &label, const std::size_t maxlen, const std::string &color ) { - if constexpr (is_base_of_Component::value) { - // T is derived from Component, and thus inherits a write() - value.write(os,level); + if constexpr (isDerivedFromComponent::value) { + // Suppress "unused parameter" warnings + (void)value; (void)maxlen; + (void)label; (void)color; + // T is derived from Component, and thus inherits a print() + value.baseComponent().print(os,level); } else { // T is any old type, not derived from Component if constexpr (std::is_floating_point_v) { - writeComponentPart( + printComponentPart( os, level, detail::Precision< detail::PrecisionContext::metadata, @@ -281,7 +255,7 @@ bool writeComponentPart( // if the printed value has internal newlines. std::string str; convert_t{}(value,str); - writeComponentPart(os, level, str, label, maxlen, color); + printComponentPart(os, level, str, label, maxlen, color); } } return true; @@ -293,17 +267,17 @@ bool writeComponentPart( // ------------------------ template -bool writeComponentPart( +bool printComponentPart( std::ostream &os, const int level, const std::optional &opt, const std::string &label, const std::size_t maxlen ) { if (opt.has_value()) - writeComponentPart( + printComponentPart( os, level, opt.value(), label, maxlen, colors::optional ); else if (comments) - writeComponentPart( + printComponentPart( os, level, colorize_comment("// optional; has no value"), label, maxlen, colors::optional ); @@ -318,19 +292,19 @@ bool writeComponentPart( // ------------------------ template -bool writeComponentPart( +bool printComponentPart( std::ostream &os, const int level, const Defaulted &def, const std::string &label, const std::size_t maxlen ) { if (def.has_value()) { - writeComponentPart( + printComponentPart( os, level, def.value(), label, maxlen, colors::defaulted ); } else if (comments) { std::string str; convert_t{}(def.get_default(),str); - writeComponentPart( + printComponentPart( os, level, colorize_comment("// defaulted; is its default (" + str + ")"), label, maxlen, colors::defaulted @@ -351,7 +325,7 @@ bool writeComponentPart( // ... // ] template -bool writeComponentPart( +bool printComponentPart( std::ostream &os, const int level, const std::vector &vec, const std::string &label, const std::size_t maxlen, const std::string &color @@ -368,7 +342,7 @@ bool writeComponentPart( ); for (auto &value : vec) { - writeComponentPart(os, level+1, value, "", 0); + printComponentPart(os, level+1, value, "", 0); os << '\n'; // between elements } @@ -382,330 +356,14 @@ bool writeComponentPart( -// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // getter() // Various cases. -// Intended for use in our auto-generated Standard Interface classes. -// ----------------------------------------------------------------------------- +// Intended for use in our Standard Interface classes. // ----------------------------------------------------------------------------- -// ----------------------------------------------------------------------------- -// getter(vector, index, ...) -// Index into vector data member of class. -// ----------------------------------------------------------------------------- - -// const -template -const T &getter( - const std::vector &vec, - const std::size_t index, - const std::string &nsname, // enclosing class' namespace - const std::string &clname, // enclosing class - const std::string &field // enclosing class' field we're accessing -) { - static const std::string context = "getter {}::{}.{}({}) on vector"; - - try { - // todo Make this more efficient, e.g. by assuming that the vector's - // elements are sorted by index, so that the wanted value is likely - // to be found at [index]. - - const T *selected = nullptr; - - for (auto &v : vec) { - const T *ptr = nullptr; - - if constexpr (isVariant::value) { - // T == variant - std::visit( - [&v,&index,&ptr](auto &&alternative) - { - if constexpr (hasIndex) - if (alternative.index() == index) - ptr = &v; - }, - v - ); - } else { - // T != variant - if constexpr (hasIndex) - if (v.index() == index) - ptr = &v; - } - - if (!ptr) - continue; - - if (selected) { - log::warning( - "Element with index {} was already found in the vector.\n" - "Keeping the first element that was found.", - index - ); - log::member(context, nsname, clname, field, index); - } else - selected = ptr; - } // for - - if (!selected) { - log::error( - "Element with index {} was not found in the vector" + - std::string(vec.size() ? "." : ";\nin fact the vector is empty."), - index - ); - throw std::exception{}; - } - - return *selected; - - } catch (...) { - // context - // Example: prints "getter containers::Axes.axis(100)" - log::member(context, nsname, clname, field, index); - throw; - } -} - -// non-const -template -T &getter( - std::vector &vec, - const std::size_t index, - const std::string &nsname, - const std::string &clname, - const std::string &field -) { - return const_cast( - getter(std::as_const(vec), index, nsname, clname, field) - ); -} - - - -// ----------------------------------------------------------------------------- -// getter(vector, label, ...) -// Element of the vector that has .label() == label. -// Assumes that the element type has a .label() getter. -// ----------------------------------------------------------------------------- - -// const -template -const T &getter( - const std::vector &vec, - const std::string &label, - const std::string &nsname, - const std::string &clname, - const std::string &field -) { - static const std::string context = "getter {}::{}.{}(\"{}\") on vector"; - - try { - const T *selected = nullptr; - - for (auto &v : vec) { - const T *ptr = nullptr; - - if constexpr (isVariant::value) { - // T == variant - std::visit( - [&v,&label,&ptr](auto &&alternative) - { - if constexpr (hasLabel) - if (alternative.label() == label) - ptr = &v; - }, - v - ); - } else { - // T != variant - if constexpr (hasLabel) - if (v.label() == label) - ptr = &v; - } - - if (!ptr) - continue; - - if (selected) { - log::warning( - "Element with label \"{}\" was already found in the vector.\n" - "Keeping the first element that was found.", - label - ); - log::member(context, nsname, clname, field, label); - } else - selected = ptr; - } // for - - if (!selected) { - log::error( - "Element with label \"{}\" was not found in the vector" + - std::string(vec.size() ? "." : ";\nin fact the vector is empty."), - label - ); - throw std::exception{}; - } - - return *selected; - - } catch (...) { - // context - log::member(context, nsname, clname, field, label); - throw; - } -} - -// non-const -template -T &getter( - std::vector &vec, - const std::string &label, - const std::string &nsname, - const std::string &clname, - const std::string &field -) { - return const_cast( - getter(std::as_const(vec), label, nsname, clname, field) - ); -} - - - -// ----------------------------------------------------------------------------- -// getter(optional, index or label, ...) -// As earlier, but for optional data member. -// ----------------------------------------------------------------------------- - -// const -template< - class T, class LOOKUP, - class = std::enable_if_t< - std::is_convertible_v || - std::is_convertible_v - > -> -const T &getter( - const std::optional> &opt, - const LOOKUP &index_or_label, - const std::string &nsname, - const std::string &clname, - const std::string &field -) { - try { - // optional must have value - if (!opt.has_value()) { - log::error("optional vector {} does not have a value", field); - throw std::exception{}; - } - return getter((*opt), index_or_label, nsname, clname, field); - } catch (...) { - // context - log::member( - std::is_convertible_v - ? "getter {}::{}.{}({}) on optional" - : "getter {}::{}.{}(\"{}\") on optional", - nsname, clname, field, index_or_label); - throw; - } -} - -// non-const -template< - class T, class LOOKUP, - class = std::enable_if_t< - std::is_convertible_v || - std::is_convertible_v - > -> -T &getter( - std::optional> &opt, - const LOOKUP &index_or_label, - const std::string &nsname, - const std::string &clname, - const std::string &field -) { - return const_cast( - getter(std::as_const(opt), index_or_label, nsname, clname, field) - ); -} - - - -// ----------------------------------------------------------------------------- -// getter(...) -// With caller-specified type, when variant is involved -// ----------------------------------------------------------------------------- - -// ------------------------ -// variant,... -// ------------------------ - -template< - class T, - class... Ts, - class = std::enable_if_t>> -> -const T *getter( - const std::variant &var, - const std::string &nsname, - const std::string &clname, - const std::string &field -) { - try { - return std::holds_alternative(var) - ? &std::get(var) - : nullptr; - } catch (...) { - // context - log::member( - "getter {}::{}.{}() on variant", - nsname, clname, field); - throw; - } -} - - -// ------------------------ -// vector, -// index or label, -// ... -// ------------------------ - -// The (size_t index) and (string label) cases were similar enough that -// we were able to combine them into one function. - -template< - class T, class LOOKUP, - class = std::enable_if_t< - std::is_convertible_v || - std::is_convertible_v - >, - class... Ts -> -const T *getter( - const std::vector> &vec, - const LOOKUP &index_or_label, - const std::string &nsname, - const std::string &clname, - const std::string &field -) { - try { - return getter( - // no , so it calls getter(generic vector); it isn't recursive - getter(vec, index_or_label, nsname, clname, field), // scalar variant - nsname, clname, field - ); - } catch (...) { - // context - log::member( - std::is_convertible_v - ? "getter {}::{}.{}({}) on vector" - : "getter {}::{}.{}(\"{}\") on vector", - nsname, clname, field, index_or_label); - throw; - } -} +#include "GNDStk/Component/src/detail-sfinae.hpp" +#include "GNDStk/Component/src/detail-getter.hpp" @@ -713,7 +371,7 @@ const T *getter( // For sorting derived-class fields based on index and label, if and when one // or the other of those is determined to be present. That determination hinges // on both a compile-time check that the classes involved even *have* index or -// label fields in their content struct, and if they do, if either of those is +// label fields in their Content struct, and if they do, if either of those is // possibly a std::optional that may or may not contain a value at the moment. // ----------------------------------------------------------------------------- @@ -731,46 +389,46 @@ bool compareRegular(const A &a, const B &b) // index? std::size_t aindex = 0; bool ahasindex = false; if constexpr (hasIndex) { - if constexpr (isOptional) { - if ((ahasindex = a.content.index.has_value())) - aindex = a.content.index.value(); + if constexpr (isOptional) { + if ((ahasindex = a.index().has_value())) + aindex = a.index().value(); } else { ahasindex = true; - aindex = a.content.index; + aindex = a.index(); } } std::size_t bindex = 0; bool bhasindex = false; if constexpr (hasIndex) { - if constexpr (isOptional) { - if ((bhasindex = b.content.index.has_value())) - bindex = b.content.index.value(); + if constexpr (isOptional) { + if ((bhasindex = b.index().has_value())) + bindex = b.index().value(); } else { bhasindex = true; - bindex = b.content.index; + bindex = b.index(); } } // label? std::string alabel = ""; bool ahaslabel = false; if constexpr (hasLabel) { - if constexpr (isOptional) { - if ((ahaslabel = a.content.label.has_value())) - alabel = a.content.label.value(); + if constexpr (isOptional) { + if ((ahaslabel = a.label().has_value())) + alabel = a.label().value(); } else { ahaslabel = true; - alabel = a.content.label; + alabel = a.label(); } } std::string blabel = ""; bool bhaslabel = false; if constexpr (hasLabel) { - if constexpr (isOptional) { - if ((bhaslabel = b.content.label.has_value())) - blabel = b.content.label.value(); + if constexpr (isOptional) { + if ((bhaslabel = b.label().has_value())) + blabel = b.label().value(); } else { bhaslabel = true; - blabel = b.content.label; + blabel = b.label(); } } @@ -848,4 +506,28 @@ void sort(std::optional> &opt) sort(opt.value()); } + + +// ----------------------------------------------------------------------------- +// queryResult +// ----------------------------------------------------------------------------- + +// default +template +struct queryResult { + using type = std::decay_t()))>; +}; + +// For Meta +template +struct queryResult,CONVERTER>> { + using type = Defaulted; +}; + +// For std::tuple +template +struct queryResult> { + using type = std::tuple::type...>; +}; + } // namespace detail diff --git a/src/GNDStk/Component/src/field.hpp b/src/GNDStk/Component/src/field.hpp new file mode 100644 index 000000000..5cc4f82ac --- /dev/null +++ b/src/GNDStk/Component/src/field.hpp @@ -0,0 +1,736 @@ + +template +class FieldPart { + // Nothing; see the partial specialization later in this file +}; + + +// ----------------------------------------------------------------------------- +// Field +// ----------------------------------------------------------------------------- + +template +class Field { + + // friends + friend DERIVED; + + template + friend class FieldPart; + + // data + DERIVED &parent; + T wrappedValue; + +public: + + // ------------------------ + // Constructors + // ------------------------ + + // Because parent would be wrong + Field(const Field &) = delete; // no copy + Field(Field &&) = delete; // no move + + // The following accept DERIVED*, not DERIVED&, so that we can write "this", + // not "*this", where Field objects are constructed. It's just a bit shorter. + + // parent + // This could be rolled into the (parent, value) constructor below, but the + // compiler seems to be better able to optimize the construction of objects + // with class Field data members if we split it out. + explicit Field(DERIVED *const parent) : + parent(*parent), + wrappedValue(T{}) + { } + + // parent, value + explicit Field(DERIVED *const parent, const T &v) : + parent(*parent), + wrappedValue(v) + { } + + // parent, other Field object + Field(DERIVED *const parent, const Field &other) : + parent(*parent), + wrappedValue(other.wrappedValue) + { } + + // parent, default value, current value + // If T == Defaulted + template> + Field( + DERIVED *const parent, const typename TEE::value_type &def, + const std::optional &v = {} + ) : + parent(*parent), + wrappedValue(def,v) + { } + + // ------------------------ + // has + // ------------------------ + + // has() + // With no arguments. + // Relates to std::optional, not to the question of what metadata or metadata + // values the present Field might contain. (See the below function for that.) + // Returns true iff T is either *not* std::optional, or is std::optional and + // has a value. + bool has() const + { + if constexpr (detail::isOptional) + return wrappedValue.has_value(); + else + return true; + } + + // has() + // With one argument. + // Forwards to [operator()(const KEY &key) const], below, essentially to + // provide an alternative form of a "has" query. Instead of, for example, + // H.isotope(has(mass_number(2))) + // to inquire as to whether element H's vector of isotopes has one with + // a mass number of 2, one could instead write: + // H.isotope.has(mass_number(2)) + // to make exactly the same query. (The example assumes that H is of a + // class - say, Element - that contains a vector of isotopes, and that + // the Isotope class contains an integer metadatum called mass_number.) + // Note: the SFINAE is such that this function is enabled iff a call to + // operator()(key) of the present class would be valid, and return bool. + template< + class KEY, + class = std::enable_if_t()(GNDStk::has(std::declval()))), + bool + >> + > + bool has(const KEY &key) const + { + return (*this)(GNDStk::has(key)); + } + + // ------------------------ + // value() + // Get past std::optional + // where necessary + // ------------------------ + + // Note: the parentheses in "return (wrappedValue)" are necessary in + // these, so that the decltype(auto) return types produce references! + + // const + decltype(auto) value() const + { + if constexpr (detail::isOptional) + return wrappedValue.value(); + else + return (wrappedValue); + } + + // non-const + decltype(auto) value() + { + if constexpr (detail::isOptional) + return wrappedValue.value(); + else + return (wrappedValue); + } + + // ------------------------ + // Getters + // ------------------------ + + // () + // Get exactly the wrapped value, whatever it is (including std::optional) + const T &operator()() const { return wrappedValue; } + T &operator()() { return wrappedValue; } + + // index/label/Lookup, including Lookup (via the "has" function) + // If T == vector + template< + class KEY, class = detail::isSearchKey, + class TEE = T, class = detail::isVectorOrOptionalVector_t + > + decltype(auto) operator()(const KEY &key) const + { return parent.getter(wrappedValue,key); } + + template< + class KEY, class = detail::isSearchKey, + class TEE = T, class = detail::isVectorOrOptionalVector_t + > + decltype(auto) operator()(const KEY &key) + { return parent.getter(wrappedValue,key); } + + // ------------------------ + // Conversions + // ------------------------ + + // To T + // Same as () + operator const T &() const { return (*this)(); } + operator T &() { return (*this)(); } + + // To vector, if T == optional + template> + operator const typename TEE::value_type &() const + { + if (!wrappedValue) { + log::error( + "Cannot give valueless optional a vector value\n" + "when the object is const"); + log::member("Field:: conversion to vector"); + throw std::exception{}; + } + return *wrappedValue; + } + + template> + operator typename TEE::value_type &() + { + return *( + wrappedValue + ? wrappedValue + : wrappedValue = typename TEE::value_type{} + ); + } + + // ------------------------ + // Setters + // ------------------------ + + // replace(T) + // Replace existing value with another. + DERIVED &replace(const T &val) + { + wrappedValue = val; + return parent; + } + + DERIVED &operator()(const T &val) + { + return replace(val); + } + + DERIVED &operator=(const T &val) + { + return replace(val); + } + + // replace(optional) + // If T == Defaulted + // Replace existing Defaulted's value with the given optional value. + template> + DERIVED &replace(const std::optional &opt) + { + wrappedValue = opt; + return parent; + } + + template> + DERIVED &operator()(const std::optional &opt) + { + return replace(opt); + } + + template> + DERIVED &operator=(const std::optional &opt) + { + return replace(opt); + } + + // add(element) + // If T == [optional] vector + // Add (via push_back) to this->wrappedValue, which in this context + // is a vector. + template> + DERIVED &add( + const typename detail::isVectorOrOptionalVector::value_type &elem + ) { + parent.setter(wrappedValue, elem); + return parent; + } + + template> + DERIVED &operator()( + const typename detail::isVectorOrOptionalVector::value_type &elem + ) { + return add(elem); + } + + template> + DERIVED &operator+=( + const typename detail::isVectorOrOptionalVector::value_type &elem + ) { + return add(elem); + } + + // replace(index/label/Lookup, element) + // If T == [optional] vector + // Find the vector's element that has the given index, label, or Lookup, + // and replace it with the given replacement element. + template< + class KEY, class = detail::isSearchKeyRefReturn, + class TEE = T, class = detail::isVectorOrOptionalVector_t + > + DERIVED &replace( + const KEY &key, + const typename detail::isVectorOrOptionalVector::value_type &elem + ) { + (*this)(key) = elem; + return parent; + } + + template< + class KEY, class = detail::isSearchKeyRefReturn, + class TEE = T, class = detail::isVectorOrOptionalVector_t + > + DERIVED &operator()( + const KEY &key, + const typename detail::isVectorOrOptionalVector::value_type &elem + ) { + return replace(key,elem); + } + + // ------------------------ + // Assignment + // ------------------------ + + // copy + Field &operator=(const Field &other) + { + wrappedValue = other.wrappedValue; + return *this; + } + + // move + Field &operator=(Field &&other) + { + wrappedValue = std::move(other.wrappedValue); + return *this; + } +}; // class Field + + +// ----------------------------------------------------------------------------- +// FieldPart +// ----------------------------------------------------------------------------- + +template +class FieldPart,PART> { + Field &whole; + + static_assert( + detail::isVariant::value || detail::isVectorVariant::value, + "FieldPart,PART>: " + "WHOLE must be variant or vector" + ); + +public: + + // ------------------------ + // Constructors + // ------------------------ + + // Because [Field &whole] would be wrong + FieldPart(const FieldPart &) = delete; // no copy + FieldPart(FieldPart &&) = delete; // no move + + explicit FieldPart(Field &whole) : + whole(whole) + { } + + // ------------------------ + // Getters: + // If WHOLE == variant + // ------------------------ + + // ptr() + // Get as PART * + template> + const PART *ptr() const + { + return whole.parent.template getter(whole()); + } + + template> + PART *ptr() + { + return whole.parent.template getter(whole()); + } + + // ref() + // Get as PART & + template> + const PART &ref() const + { + const PART *const p = ptr(); + if (p) return *p; + log::error( + "Cannot get reference; variant contains a different alternative"); + log::member("FieldPart::ref()"); + throw std::exception{}; + } + + template> + PART &ref() + { + return const_cast(std::as_const(*this).template ref()); + } + + // opt() + // Makes an optional. So, we must return by value, + // and then only the const version is needed. + template> + const std::optional opt() const + { + const PART *const p = ptr(); + return p ? std::optional{*p} : std::optional{}; + } + + // operator() + // Get as PART & + template> + const PART &operator()() const + { + try { + return ref(); + } catch (...) { + log::member("FieldPart::operator()"); + throw; + } + } + + template> + PART &operator()() + { + return const_cast(std::as_const(*this)()); + } + + // ------------------------ + // Conversions + // If WHOLE == variant + // ------------------------ + + // To PART * + template> + operator const PART *() const { return ptr(); } + + template> + operator PART *() { return ptr(); } + + // To PART & + template> + operator const PART &() const + { + try { + return ref(); + } catch (...) { + log::member("FieldPart:: conversion to variant alternative"); + throw; + } + } + + template> + operator PART &() + { + return const_cast(std::as_const(*this).operator const PART &()); + } + + // To optional + template> + operator std::optional() const { return opt(); } + + // ------------------------ + // has + // Similar to Field's + // ------------------------ + + /* + // todo I'm not sure that this would have a clear meaning for FieldPart. + // For Field, it means whether or not a value exists - either it's not + // std::optional, or is std::optional but has a value. Here, that meaning + // could be confused with the concept of whether or not the variant + // contains the "PART" represented by this FieldPart. Think about this. + + // has() + bool has() const + { + if constexpr (detail::isOptional) + return wrappedValue.has_value(); + else + return true; + } + */ + + // has(key) + template< + class KEY, + class = std::enable_if_t()(GNDStk::has(std::declval()))), + bool + >> + > + bool has(const KEY &key) const + { + return (*this)(GNDStk::has(key)); + } + + // ------------------------ + // Getters: + // If WHOLE == vector + // ------------------------ + + // ptr(index/label/Lookup) + // Get as PART * + template< + class KEY, class = detail::isSearchKeyRefReturn, + class T = WHOLE, class = detail::isVector_t + > + const PART *ptr(const KEY &key) const + { + return whole.parent.template getter(whole(),key); + } + + template< + class KEY, class = detail::isSearchKeyRefReturn, + class T = WHOLE, class = detail::isVector_t + > + PART *ptr(const KEY &key) + { + return whole.parent.template getter(whole(),key); + } + + // ref(index/label/Lookup) + // Get as PART & + template< + class KEY, class = detail::isSearchKeyRefReturn, + class T = WHOLE, class = detail::isVector_t + > + const PART &ref(const KEY &key) const + { + const PART *const p = ptr(key); + if (p) return *p; + log::error( + "Cannot get reference; variant contains a different alternative"); + log::member("FieldPart::ref(key)"); + throw std::exception{}; + } + + template< + class KEY, class = detail::isSearchKeyRefReturn, + class T = WHOLE, class = detail::isVector_t + > + PART &ref(const KEY &key) + { + return const_cast(std::as_const(*this).template ref(key)); + } + + // opt(index/label/Lookup) + template< + class KEY, class = detail::isSearchKeyRefReturn, + class T = WHOLE, class = detail::isVector_t + > + const std::optional opt(const KEY &key) const + { + const PART *const p = ptr(key); + return p ? std::optional{*p} : std::optional{}; + } + + // index/label/Lookup, including Lookup (via the "has" function) + template< + class KEY, class = detail::isSearchKey, + class T = WHOLE, class = detail::isVector_t + > + decltype(auto) operator()(const KEY &key) const + { + if constexpr (detail::isLookupBoolReturn) { + // a bool + return whole(key); + } else { + // a reference + try { + return ref(key); + } catch (...) { + log::member("FieldPart::operator()(key)"); + throw; + } + } + } + + template< + class KEY, class = detail::isSearchKey, + class T = WHOLE, class = detail::isVector_t + > + decltype(auto) operator()(const KEY &key) + { + if constexpr (detail::isLookupBoolReturn) { + // a bool + return whole(key); + } else { + // a reference + return const_cast(std::as_const(*this)(key)); + } + } + + // ------------------------ + // Setters + // ------------------------ + + // replace(value) + // If WHOLE == variant + template> + DERIVED &replace(const std::optional &opt) + { + if (opt) whole.replace(opt.value()); + return whole.parent; + } + + template, int> = 0> + DERIVED &operator()(const std::optional &opt) + { + return replace(opt); + } + + template, int> = 0> + DERIVED &operator=(const std::optional &opt) + { + return replace(opt); + } + + // add(value) + // If WHOLE == vector + template> + DERIVED &add(const std::optional &opt) + { + if (opt) whole.add(opt.value()); + return whole.parent; + } + + template, int> = 0> + DERIVED &operator()(const std::optional &opt) + { + return add(opt); + } + + template> + DERIVED &operator+=(const std::optional &opt) + { + return add(opt); + } + + // replace(index/label/Lookup, element) + // If WHOLE == vector + // Find the vector's element that has the given index, label, or Lookup, + // and replace it with the given replacement value. + template< + class KEY, class = detail::isSearchKeyRefReturn, + class T = WHOLE, class = detail::isVector_t> + DERIVED &replace(const KEY &key, const std::optional &opt) + { + if (opt) whole(key,opt.value()); + return whole.parent; + } + + template< + class KEY, class = detail::isSearchKeyRefReturn, + class T = WHOLE, class = detail::isVector_t> + DERIVED &operator()(const KEY &key, const std::optional &opt) + { + return replace(key,opt); + } + + // ------------------------ + // Assignment + // ------------------------ + + // Intentional: don't assign [referenced] whole; doing so would be wrong + FieldPart &operator=(const FieldPart &) { return *this; } + FieldPart &operator=(FieldPart &&) { return *this; } +}; // class FieldPart + + +// ----------------------------------------------------------------------------- +// wrapper +// ----------------------------------------------------------------------------- + +template +struct wrapper { + T value; + + // wrapper(from) + template< + class FROM = T, + class = std::enable_if_t< + std::is_constructible_v || std::is_convertible_v + > + > + wrapper(const FROM &v = FROM{}) : + value(T(v)) + { } + + // wrapper(initializer_list) + // If T == vector + template< + class TEE = T, + class = std::enable_if_t::value> + > + wrapper(const std::initializer_list &v) : + value(v) + { } + + // wrapper(optional::value_type) + // If T == optional + template>> + wrapper(const typename TEE::value_type &v) : + value(v) + { } + + // wrapper(nullopt_t) + // If T == optional + template>> + wrapper(const std::nullopt_t &v) : + value(v) + { } + + // Conversions + operator const T &() const { return value; } + operator T &() { return value; } +}; // class wrapper + + +// ----------------------------------------------------------------------------- +// Helpers +// ----------------------------------------------------------------------------- + +private: + +// ------------------------ +// fieldAddress +// ------------------------ + +template +void *fieldAddress(T &value) +{ + return &value; +} + +template +void *fieldAddress(Field &field) +{ + return &field(); +} + +// ------------------------ +// stripField +// ------------------------ + +template +struct stripField { + using type = T; +}; + +template +struct stripField> { + using type = T; +}; diff --git a/src/GNDStk/Component/src/finish.hpp b/src/GNDStk/Component/src/finish.hpp index 864f5d5bf..b5bbaf665 100644 --- a/src/GNDStk/Component/src/finish.hpp +++ b/src/GNDStk/Component/src/finish.hpp @@ -32,8 +32,8 @@ thus can, but does not need to, provide a construct(). Arguments are received where (1) the derived-class constructor receives the argument, but (2) the argument is transitory - it's used in the constructor, -but it doesn't go into the autogenerated "content" struct in the derived class. -(If it did go into the content struct then we'd simply extract it from there, +but it doesn't go into the autogenerated Content struct in the derived class. +(If it did go into the Content struct then we'd simply extract it from there, instead of having finish() receive it as a parameter.) Specifically, the constructors in the auto-generated classes call: @@ -48,11 +48,11 @@ Specifically, the constructors in the auto-generated classes call: Constructor from a Node: Component::finish(the Node) - Constructors involving a vector of "body text" data: + Constructors involving a vector of block data: Component::finish(the vector) Note: In the last case, we're speaking of a vector that's specifically for -body text, not a vector that might be there for a different reason. +block data, not a vector that might be there for a different reason. */ @@ -73,7 +73,7 @@ void construct(const Node &) { } // return void. We use bool, here, for technical reasons, relating to the test // used in the template finish() function (as opposed to the non-template cases) // to determine whether or not someone has provided a custom construct(). -template>> +template>> bool construct(const std::vector &) { return true; } @@ -88,13 +88,13 @@ bool construct(const std::vector &) { return true; } void finish() { - // If hasBodyText == true (else no-op), have Component's BodyText base + // If hasBlockData == true (else no-op), have Component's BlockData base // get length, start, and valueType, as available, from the derived class - if constexpr (hasBodyText) - body::pullFromDerived(derived()); + if constexpr (hasBlockData) + BLOCKDATA::pullFromDerived(derived()); - // Based on the derived class' keys(), locate and sort derived-class fields - // that are vectors, with vector elements that have index and/or label. + // Automatically locate and sort derived-class fields that are vectors + // with elements that have index and/or label. sort(); // construct @@ -109,16 +109,19 @@ void finish() void finish(const DERIVED &other) { // length, start, valueType - if constexpr (hasBodyText) - body::pullFromDerived(derived()); + if constexpr (hasBlockData) + BLOCKDATA::pullFromDerived(derived()); // derived-class vector fields sort(); // construct - void (Component::*stub)(const DERIVED &) = &Component::construct; - void (DERIVED::*custom)(const DERIVED &) = &DERIVED::construct; - if (custom != stub) + void (Component::*componentConstruct) + (const DERIVED &) = &Component::construct; + void (DERIVED::*derivedConstruct) + (const DERIVED &) = &DERIVED::construct; + + if (derivedConstruct != componentConstruct) derived().construct(other); else derived().construct(); @@ -131,28 +134,7 @@ void finish(const DERIVED &other) void finish(const Node &node) { - // Read fields from the Node into the derived object. This applies the keys() - // multi-query in the derived class, and also runs BodyText::fromNode() if - // the Node has body text, in order to get the Node's string of "body text". - fromNode(node); - - if constexpr (hasBodyText) { - // length, start, valueType - body::pullFromDerived(derived()); - // make vector - body::get(); - } - - // derived-class vector fields - sort(); - - // construct - void (Component::*stub)(const Node &) = &Component::construct; - void (DERIVED::*custom)(const Node &) = &DERIVED::construct; - if (custom != stub) - derived().construct(node); - else - derived().construct(); + read(node); } @@ -160,15 +142,15 @@ void finish(const Node &node) // finish(vector) // ------------------------ -template>> +template>> void finish(const std::vector &vector) { // assign from the vector - body::operator=(vector); + BLOCKDATA::operator=(vector); // length, start, valueType: push back up to derived, // as they would have been computed above in operator=. - body::pushToDerived(derived()); + BLOCKDATA::pushToDerived(derived()); // derived-class vector fields sort(); diff --git a/src/GNDStk/Component/src/forward.hpp b/src/GNDStk/Component/src/forward.hpp new file mode 100644 index 000000000..4886f7f2a --- /dev/null +++ b/src/GNDStk/Component/src/forward.hpp @@ -0,0 +1,187 @@ + +/* +Remark about terminology. + +Elsewhere in GNDStk, we often refer to objects of type Meta or Child as "keys". + +However, in the context of classes generated by our code generator, and in +general when working with classes that derive from Component, we sometimes use +the term "key" to mean some kind of "lookup key". + +Code that appears later in this file involves both of the above contexts. So, +in order to keep confusion to a minimum, we'll write "MC" or "mc" (where we +might otherwise write "KEY" or "key") when Meta/Child are involved, and KEY +or "key" where lookup keys are involved. + +Optionally continue reading, if you care.... + +Example. Say that an object of class Element has a vector, where each +object of type Isotope contains an int called mass_number. In this scenario, the +code generator will create mechanisms by which we can look up a specific Isotope +in an Element's vector, given the wanted Isotope's mass_number. + +We'll also get functionality, via functions called replace(), to look up and +replace an isotope, given a lookup key like mass_number. Here's an admittedly +very contrived example of how such a replace function might be called: + + // Helium! + Element He("He",2); // element #2 + + // Give it some Isotopes + He += Isotope(2); // <== oops, Helium 2 doesn't really exist + He += Isotope(4); + + // We meant to create Helium 3, not Helium 2, so let's replace the bad value + He.isotope.replace(mass_number(2),Isotope(3)); + +The last line will search through He.isotope (a vector), find the +element (the Isotope) with mass_number == 2, and replace that entire Isotope +with an Isotope that has the correct mass_number. (While the above example is +very contrived, one could imagine a real-world example in which we look up an +object that's known to have faulty data, and replace it with a fixed object.) + +The replace() function later in this file allows the last line of code, above, +to be rewritten with something shorter: + + // He.replace, not He.isotope.replace + He.replace(mass_number(2),Isotope(3)); + +in the event that the code can determine, unambiguously, via some SFINAE +shenanigans, that we must mean He.isotope, not other member data that an +Element (like He) might happen to contain. + +To make a long story short (glossing over the fact that the above story is +perhaps already somewhat long :-/), the term "key" will relate to the mass +number lookup here. Whereas, Meta/Child objects are involved in the process +of examining what metadatum and child-node member data appear in class Element, +this examination being to determine that He.isotope is intended. +*/ + + +// ----------------------------------------------------------------------------- +// Helpers +// ----------------------------------------------------------------------------- + +private: + +// Matches +template +static inline constexpr bool Matches = + detail::MatchesExact ::count == 1 || + detail::MatchesViable::count == 1; + +// added +// MC = Meta or Child +template +bool added( + const FROM &elem, const MC &mc, + const bool exact, const std::size_t n +) { + // Silence warnings that seem to crop up with some compilers, when neither + // of the below constexpr ifs passes. + (void)n; + + // Remark. The below conditional code (involving both runtime and constexpr + // ifs) doesn't simplify in what may seem like obvious ways. Note that bool + // exact is runtime, and came from looking over all types in the caller's + // fold expression. For a given type from the fold expression, either or both + // of the following constexpr ifs may fail, and their bodies not make sense + // or not be something we'd necessarily want to call. (Specifically, if exact + // and viable matches both == 1, and the viable match is found before the + // exact one, we want to skip the [return setter] and wait for the exact.) + using T = std::decay_t; + if ( exact) if constexpr (detail::isMatchExact ::count) + return setter(*(T *)links[n],elem), true; + if (!exact) if constexpr (detail::isMatchViable::count) + return setter(*(T *)links[n],elem), true; + return false; +} + +// replaced +template +bool replaced( + const KEY &key, const FROM &elem, const MC &mc, + const bool exact, const std::size_t n +) { + using T = std::decay_t; + if ( exact) if constexpr (detail::isMatchExact ::count) + return getter(*(T *)links[n],key) = elem, true; + if (!exact) if constexpr (detail::isMatchViable::count) + return getter(*(T *)links[n],key) = elem, true; + return false; +} + +public: + + +// ----------------------------------------------------------------------------- +// add(element) +// ----------------------------------------------------------------------------- + +// add +template>> +DERIVED &add(const FROM &elem) +{ + // match exact? (else viable, per SFINAE requirement) + using TUP = decltype(Keys().tup); + const bool exact = detail::MatchesExact::count == 1; + + // scan until match + std::apply( + [this,&elem,exact](const auto &... mc) { + std::size_t n = 0; bool found = false; + ((found || (found = this->added(elem,mc,exact,n++))), ...); + }, + Keys().tup + ); + + // done + return derived(); +} + +// () +template>> +DERIVED &operator()(const FROM &elem) { return add(elem); } + +// += +template>> +DERIVED &operator+=(const FROM &elem) { return add(elem); } + + +// ----------------------------------------------------------------------------- +// replace(index/label/Lookup, element) +// ----------------------------------------------------------------------------- + +// replace +template< + class KEY, class = detail::isSearchKeyRefReturn, + class FROM, class = std::enable_if_t> +> +DERIVED &replace(const KEY &key, const FROM &elem) +{ + // match exact? (else viable, per SFINAE requirement) + using TUP = decltype(Keys().tup); + const bool exact = detail::MatchesExact::count == 1; + + // scan until match + std::apply( + [this,&key,&elem,exact](const auto &... mc) { + std::size_t n = 0; bool found = false; + ((found || (found = this->replaced(key,elem,mc,exact,n++))), ...); + }, + Keys().tup + ); + + // done + return derived(); +} + +// () +template< + class KEY, class = detail::isSearchKeyRefReturn, + class FROM, class = std::enable_if_t> +> +DERIVED &operator()(const KEY &key, const FROM &elem) +{ + return replace(key,elem); +} diff --git a/src/GNDStk/Component/src/fromNode.hpp b/src/GNDStk/Component/src/fromNode.hpp index f7760b4ca..ab7fbcab0 100644 --- a/src/GNDStk/Component/src/fromNode.hpp +++ b/src/GNDStk/Component/src/fromNode.hpp @@ -1,4 +1,113 @@ +// ----------------------------------------------------------------------------- +// Helpers +// ----------------------------------------------------------------------------- + +private: + +// ------------------------ +// Transfer Meta +// ------------------------ + +template +void transferMeta( + const Node &node, DEST &to, + const Meta &key +) { + node.meta(to, key); +} + + +// ------------------------ +// Transfer Child +// ------------------------ + +template +void transferChild( + const Node &node, DEST &to, + const Child &key +) { + // Absolutely respect any non-default converter in the Child key, by doing + // a Core Interface child-node query in the usual manner. Note that we can + // still use the more-efficient "node.child(to,key)" rather than the less- + // efficient "to = node(key)", because, in the present context, we do have + // a specific destination for the query result. + if constexpr (!std::is_same_v) { + node.child(to, key); + return; + } + + // In the following conditionals, assume that Foo derives from Component, + // while Bar does not, i.e.: + // Foo: Component + // Bar + // Comments, below, reflect various situations. + + if constexpr (detail::isDerivedFromComponent::value) { + // *** Foo + // Derives from Component, so we know that it has, via Component, + // a .read(node) function, which should be most efficient to use + // for "conversion" of the Node to a Foo. + node.child(to, key/[](const Node &node, DEST &to) { to.read(node); }); + + } else if constexpr (detail::isOptional) { + using OPT = typename DEST::value_type; // type the optional may contain + + if constexpr (detail::isVector_v) { + using ELEM = typename OPT::value_type; // vector element type + if constexpr (detail::isDerivedFromComponent::value) { + // *** optional> + if (!to.has_value()) + to = OPT{}; + node.child(to, key/[](const Node &node, ELEM &e) { e.read(node); }); + } else { + // *** optional> + node.child(to, key); + } + } else { + if constexpr (detail::isDerivedFromComponent::value) { + // *** optional + node.child(to, key/[](const Node &node, OPT &to) { to.read(node); }); + } else { + // *** optional + node.child(to, key); + } + } + } else if constexpr (detail::isVector_v) { + using ELEM = typename DEST::value_type; // vector element type + if constexpr (detail::isDerivedFromComponent::value) { + // *** vector + node.child(to, key/[](const Node &node, ELEM &e) { e.read(node); }); + } else { + // *** vector + node.child(to, key); + } + } else { + // *** Bar + node.child(to, key); + } +} + + +// ------------------------ +// Transfer +// ------------------------ + +template +void transfer(const std::size_t n, const Node &node, const KEY &key) +{ + using DEST = typename detail::queryResult::type; + DEST &to = *(DEST *)links[n]; + + if constexpr (detail::IsMeta::value) + transferMeta(node, to, key); + else if constexpr (detail::IsChild::value) + transferChild(node, to, key); + else + to = node(key); +} + + // ----------------------------------------------------------------------------- // Component::fromNode(Node) // ----------------------------------------------------------------------------- @@ -17,45 +126,35 @@ // new(), below, but to no real effect: the result would be replaced, anyway, // when the derived class' own members are initialized in its constructor. +public: + void fromNode(const Node &node) { try { // does the node have the name we expect? - if (node.name != DERIVED::GNDSName()) { + if (node.name != DERIVED::FIELD()) { log::error( - "Name \"{}\" in Node sent to Component::fromNode() is not the " - "expected GNDS name \"{}\"", - node.name, DERIVED::GNDSName() + "Node name \"{}\" is not the expected name \"{}\"", + node.name, DERIVED::FIELD() ); throw std::exception{}; } - if constexpr (std::is_same_v>) { - // consistency check; then nothing further to do - assert(0 == links.size()); - } else { - // retrieve the node's data by doing a multi-query - const auto tup = node(toKeywordTup(DERIVED::keys())); - - // consistency check - assert(std::tuple_size::value == links.size()); - - // apply links: - // Node ==> derived-class data - // Below, each apply'd "result" is one particular element - one - // retrieved value - from the above multi-query on the node. - std::apply( - [this](const auto &... result) { - std::size_t n = 0; - ((*(std::decay_t *)links[n++] = result), ...); - }, - tup - ); - } + // consistency check + assert(std::tuple_size_v == links.size()); + + // apply links: + // Node ==> derived-class data + std::apply( + [this,node](const auto &... key) { + std::size_t n = 0; (this->transfer(n++, node, key), ...); + }, + Keys().tup + ); - // body text, a.k.a. XML "pcdata" (plain character data), if any - if constexpr (hasBodyText) - body::fromNode(node); + // block data, a.k.a. XML "pcdata" (plain character data), if any + if constexpr (hasBlockData) + BLOCKDATA::fromNode(node); } catch (...) { log::member("Component.fromNode(Node(\"{}\"))", node.name); diff --git a/src/GNDStk/Component/src/getter.hpp b/src/GNDStk/Component/src/getter.hpp index 1f8228830..63a40658f 100644 --- a/src/GNDStk/Component/src/getter.hpp +++ b/src/GNDStk/Component/src/getter.hpp @@ -1,117 +1,121 @@ -// The getter() functions of class Component get some names from the derived -// class (those are used when printing diagnostics, if applicable), and then -// call getter() functions in the detail:: namespace to do most of the work. -// -// The motivation for having the following at all is to simplify the retrieval, -// in the derived-class getters, of certain information in the content{} struct -// of the derived class object. For simple data, e.g. an int or a std::string -// in the derived class' content struct, a derived-class getter will simply -// do a "return content.something", because nothing more complicated is needed. -// So, the below functions involve circumstances where something more involved -// needs to be done. See the various remarks below for more information. +// Component::getter() +// These retrieve names from the derived class (for use in printing diagnostics, +// if applicable), then call detail::getter() functions to do most of the work. // ----------------------------------------------------------------------------- -// (field, key, name) -// FIELD in this context is either a vector or an optional, and KEY -// is either an integral index or a string label. (If FIELD were just a plain -// data type, not an [optional] vector, then there would be no reason to bother -// with a getter() function for it; we'd just return content.field in the -// derived class, instead of calling getter() to do something more complicated. -// And, besides, the fact that we're looking up by index or label suggests that -// we're dealing with a vector, not something simple like an int or a string.) +// getter(vector, key) +// getter(optional, key) +// Remark: while two getter() functions that appear later in this file work +// specifically on a vector, those require that the caller provide +// a template argument. The following two can, in fact, also be called with +// vector. Also, note that depending on which detail::getter() these +// forward to, the return type might be a reference to something, or might be +// a bool. Hence the decltype(auto) return type. // ----------------------------------------------------------------------------- // const -template // KEY: for index or label -const auto &getter( - const FIELD &field, - const KEY &key, - const std::string &fieldName +template< + class VEC, class KEY, class = detail::isSearchKey, + class = std::enable_if_t< + detail::isVector::value || + detail::isOptionalVector::value> +> +decltype(auto) getter( + const VEC &vec, // vector, or optional vector + const KEY &key, // index, label, or Lookup + const std::string &fieldName = "" ) const { - return detail::getter( - field, key, - DERIVED::namespaceName(), DERIVED::className(), fieldName - ); + return detail::getter(vec, key, Namespace(), Class(), fieldName); } // non-const -template -auto &getter( - FIELD &field, +template< + class VEC, class KEY, class = detail::isSearchKey, + class = std::enable_if_t< + detail::isVector::value || + detail::isOptionalVector::value> +> +decltype(auto) getter( + VEC &vec, const KEY &key, - const std::string &fieldName + const std::string &fieldName = "" ) { - return detail::getter( - field, key, - DERIVED::namespaceName(), DERIVED::className(), fieldName - ); + using RET = decltype( + std::as_const(*this).template getter(vec, key, fieldName)); + + if constexpr (std::is_reference_v) + return const_cast &>( + std::as_const(*this).template getter(vec, key, fieldName)); + else + return std::as_const(*this).template getter(vec, key, fieldName); } // ----------------------------------------------------------------------------- -// (variant, name) -// These, in contrast to the getter()s above, don't involve a vector or an -// optional vector, or an index or a label. We bother having these only because -// of the (admittedly small, in this case) extra complexity of checking that -// the variant holds the requested alternative, and of producing diagnostics -// if it doesn't. +// getter(variant) +// The caller must specify RETURN // ----------------------------------------------------------------------------- // const -template +template< + class RETURN, class... Ts, + class = std::enable_if_t>> +> const RETURN *getter( const std::variant &var, - const std::string &fieldName + const std::string &fieldName = "" ) const { - return detail::getter( - var, - DERIVED::namespaceName(), DERIVED::className(), fieldName - ); + return detail::getter(var, Namespace(), Class(), fieldName); } // non-const -template +template< + class RETURN, class... Ts, + class = std::enable_if_t>> +> RETURN *getter( std::variant &var, - const std::string &fieldName + const std::string &fieldName = "" ) { return const_cast( - std::as_const(*this).template - getter(std::as_const(var), fieldName) + std::as_const(*this).template getter(var, fieldName) ); } // ----------------------------------------------------------------------------- -// (vector, key, name) -// The motivation for these essentially amounts to the combined motivations -// for the above two sets of getter() functions. +// getter(vector, key) +// The caller must specify RETURN // ----------------------------------------------------------------------------- // const -template +template< + class RETURN, class KEY, class... Ts, + class = detail::isSearchKey, + class = std::enable_if_t>> +> const RETURN *getter( - const std::vector> &var, + const std::vector> &vecvar, const KEY &key, - const std::string &fieldName + const std::string &fieldName = "" ) const { - return detail::getter( - var, key, - DERIVED::namespaceName(), DERIVED::className(), fieldName - ); + return detail::getter(vecvar, key, Namespace(), Class(), fieldName); } // non-const -template +template< + class RETURN, class KEY, class... Ts, + class = detail::isSearchKey, + class = std::enable_if_t>> +> RETURN *getter( - std::vector> &var, + std::vector> &vecvar, const KEY &key, - const std::string &fieldName -) const { + const std::string &fieldName = "" +) { return const_cast( - std::as_const(*this).template - getter(std::as_const(var), key, fieldName) + std::as_const(*this).template getter(vecvar, key, fieldName) ); } diff --git a/src/GNDStk/Component/src/print.hpp b/src/GNDStk/Component/src/print.hpp new file mode 100644 index 000000000..466f97063 --- /dev/null +++ b/src/GNDStk/Component/src/print.hpp @@ -0,0 +1,209 @@ + +// ----------------------------------------------------------------------------- +// REMARK +// Regarding "write" vs. "print", and newlines +// ----------------------------------------------------------------------------- + +/* +Python has print(), and we anticipate having many Python-aware users. First and +foremost, this is why we provide these print() functions. + +Elsewhere, we've given Component a set of write() (not print()) functions that +mirror Node's functions of the same name. These first make use of Component's +ability to convert objects of its derived classes to Node, then they call Node's +write() functions. Node's write() functions can do a number of things, such as +writing to XML, or to GNDStk's debug format. + +Someone who wishes to print the contents of a Component-derived class may prefer +to see our print() function's "prettyprinting" output. Not XML, not our internal +debug format, not the various other things that the write() functions can do. + +The name print(), then, not only aligns with what a Python user might expect, +but also reflects the difference from its - really, Node's - write() functions. +Note, in particular, that write() (called with no argument) behaves as it does +for Node, while print() (called with no argument) does something completely +different: prettyprint to standard output. + +Our no-argument print() functions also print a newline at the end - which, when +prettyprinting, a user probably expects. + +The write() functions, being arguably more "low level", don't emit that newline, +and shouldn't. Just as C++ doesn't automatically print something basic (an int, +for example, or a floating-point number) with a newline, neither should a well- +mannered system for writing class objects. Whether a newline is really wanted, +or not, depends on context. + +If you write std::cout << 1.23 << std::endl, you expect one line, with "1.23", +followed by a newline via std::endl, then the cursor ready at the beginning of +the very next line. Write std::cout << obj << std::endl, where obj is of some +user-defined type whose stream output operator already prints its own newline, +and the cursor will end up *two* lines down, after an intervening blank line. +It may seem convenient for "large" objects to print with their own newline, but +doing so creates inconsistent behavior between them and more-basic object types. +Inconsistencies beget unpredictability. + +Moreover, Component-derived classes often contain instances of other Component- +derived classes. An enclosing object should place its own newlines - only where +appropriate, and not where not appropriate - between its constituent parts. If +those parts did their own thing in this respect, they'd stymie the ability of +the enclosing class to do the right thing. +*/ + + +// ----------------------------------------------------------------------------- +// print(ostream,level) +// Low-level version, possibly building on other Component-derived objects. +// Doesn't print the trailing newline. +// ----------------------------------------------------------------------------- + +std::ostream &print(std::ostream &os, const int level) const +{ + try { + // Indent, header, newline + detail::indentString( + os, level, + detail::colorize_component( + detail::fullName(Namespace(), Class()) + ) + " " + + detail::colorize_brace("{") + "\n" + ); + + // Consistency check + assert(std::tuple_size_v == links.size()); + + // Compute maximum length of key names, if aligning. Note that we + // could - but don't - take into account that keys associated with + // optional or Defaulted values *might* not in fact show up in the + // final printed text. In such cases, and if values of those types + // happen to have longer names, then the printing that does appear + // might use more spacing than it really needs to. By choosing not + // to factor this in, on a case-by-case basis, all objects of this + // particular Component<...> type will print with consistent spacing. + // We prefer this behavior, and its code is also slightly simpler. + std::size_t maxlen = 0; + if (GNDStk::align) + std::apply( + [&maxlen](const auto &... key) { + ((maxlen = std::max(maxlen,detail::getName(key).size())), ...); + }, + Keys().tup + ); + + // Apply links: + // derived-class data ==> print + std::apply( + [this,&os,&level,maxlen](const auto &... key) { + std::size_t n = 0; + ( + ( + // indent, value, newline + detail::printComponentPart( + os, + level+1, + *( + typename detail::queryResult< + std::decay_t + >::type + *)links[n++], + detail::getName(key), + maxlen + ) && (os << '\n') // no if()s in fold expressions :-/ + ), + ... + ); + }, + Keys().tup + ); + + // Custom derived-class print()s, if any. + // To be recognized here, derived-class print() functions must be public, + // and have signatures that are *exactly* as we expect, including their + // constness. + if constexpr (detail::hasPrintTwoArg) { + // Derived class has: + // std::ostream &print(std::ostream &os, const int level) const; + // and handles indentation level in its own way; we won't here. + std::ostringstream tmp; + derived().print(tmp,level+1); + const std::string &str = tmp.str(); + + std::size_t size = str.size(); + if (size) { + // expect that customizations may have spurious newlines :-/ + if (str[size-1] == '\n') size--; + for (std::size_t i = 0; i < size; ++i) + os << str[i]; + std::cout << std::endl; + } + } else if constexpr (detail::hasPrintOneArg) { + // Derived class has: + // std::ostream &print(std::ostream &os) const; + // and we'll detect newlines and handle indentation automatically. + std::ostringstream tmp; + derived().print(tmp); + const std::string &str = tmp.str(); + + std::size_t size = str.size(); + if (size) { + // remark as above + if (str[size-1] == '\n') size--; + if (size) + os << indentTo(level+1); + for (std::size_t i = 0; i < size; ++i) + os << str[i] << (str[i] == '\n' ? indentTo(level+1) : ""); + std::cout << std::endl; + } + } + + // BlockData, if any + if constexpr (hasBlockData) + BLOCKDATA::print(os,level+1); + + // Indent, footer, NO trailing newline + detail::indentString( + os, level, + detail::colorize_brace("}") + + (comments + ? " " + + detail::colorize_comment( + std::string("// ") + detail::fullName(Namespace(), Class()) + ) + : "" + ) + ); + + return os; + + } catch (...) { + log::member("Component.print()"); + throw; + } +} + + +// ----------------------------------------------------------------------------- +// print +// print(ostream) +// Print trailing newlines. +// ----------------------------------------------------------------------------- + +// We'll give these const and non-const versions (one would normally expect only +// const versions of print functions), and with a "builder pattern" that mirrors +// that of the setters that GNDStk's code generator gives its generated classes. +// This way, someone can prettyprint an object while it's being built, builder +// style. Some users may find this to be useful for visualizing what's happening +// as they create an object. + +// const +const DERIVED &print(std::ostream &os = std::cout) const +{ + print(os,0) << std::endl; + return *static_cast(this); +} + +// non-const +DERIVED &print(std::ostream &os = std::cout) +{ + print(os,0) << std::endl; + return *static_cast(this); +} diff --git a/src/GNDStk/Component/src/read.hpp b/src/GNDStk/Component/src/read.hpp new file mode 100644 index 000000000..313579f02 --- /dev/null +++ b/src/GNDStk/Component/src/read.hpp @@ -0,0 +1,90 @@ + +// ----------------------------------------------------------------------------- +// Read this object, in-place, from a Node +// ----------------------------------------------------------------------------- + +void read(const Node &node) +{ + // todo Maybe we don't really need/want a separate fromNode() function...? + + // Read fields from the Node into the derived object. This applies the KEYS() + // multi-query in the derived class, and also runs BlockData::fromNode() - if + // the Node has block data - in order to get the Node's string of block data. + fromNode(node); + + if constexpr (hasBlockData) { + // length, start, valueType + BLOCKDATA::pullFromDerived(derived()); + // make vector + BLOCKDATA::get(); + } + + // derived-class vector fields + sort(); + + // construct + void (Component::*componentConstruct) + (const Node &) = &Component::construct; + void (DERIVED::*derivedConstruct) + (const Node &) = &DERIVED::construct; + + if (derivedConstruct != componentConstruct) + derived().construct(node); + else + derived().construct(); +} + + +// ----------------------------------------------------------------------------- +// Component::read() +// Via Node, and using Node's available read() functions. +// So, autogenerated classes can directly use .read(...). +// ----------------------------------------------------------------------------- + +// read(istream, FileType) +std::istream &read( + std::istream &is, + const FileType format = FileType::guess, + const bool decl = false +) { + Node node; + std::istream &ret = node.read(is, format, decl); + read(node); + return ret; +} + +// read(file, FileType) +bool read( + const std::string &filename, + const FileType format = FileType::guess, + const bool decl = false +) { + Node node; + bool ret = node.read(filename, format, decl); + read(node); + return ret; +} + +// read(istream, string) +std::istream &read( + std::istream &is, + const std::string &format, + const bool decl = false +) { + Node node; + std::istream &ret = node.read(is, format, decl); + read(node); + return ret; +} + +// read(file, string) +bool read( + const std::string &filename, + const std::string &format, + const bool decl = false +) { + Node node; + bool ret = node.read(filename, format, decl); + read(node); + return ret; +} diff --git a/src/GNDStk/Component/src/setter.hpp b/src/GNDStk/Component/src/setter.hpp new file mode 100644 index 000000000..58b4a1e96 --- /dev/null +++ b/src/GNDStk/Component/src/setter.hpp @@ -0,0 +1,29 @@ + +// Like getter.hpp, but to help with *setters* in Component-derived classes. + +// push_back a value into the vector. +template< + class T, class FROM, + class = std::enable_if_t< + std::is_constructible_v || std::is_convertible_v + > +> +void setter(std::vector &vec, const FROM &value) +{ + vec.push_back(value); +} + +// Create an empty vector in the optional if it has no value, then +// push_back a value into the vector. +template< + class T, class FROM, + class = std::enable_if_t< + std::is_constructible_v || std::is_convertible_v + > +> +void setter(std::optional> &opt, const FROM &value) +{ + if (!opt.has_value()) + opt = std::vector{}; + opt->push_back(value); +} diff --git a/src/GNDStk/Component/src/sort.hpp b/src/GNDStk/Component/src/sort.hpp index 68dd7b309..5e4bf9b1b 100644 --- a/src/GNDStk/Component/src/sort.hpp +++ b/src/GNDStk/Component/src/sort.hpp @@ -5,31 +5,31 @@ void sort() { + if (!njoy::GNDStk::sort) + return; + try { - if constexpr (std::is_same_v>) { - // Consistency check; then nothing further to do - assert(0 == links.size()); - } else { - // Make tuple (of individual keys) from DERIVED::keys() - const auto tup = toKeywordTup(DERIVED::keys()).tup; + // Consistency check + assert(std::tuple_size_v == links.size()); - // Consistency check - assert(std::tuple_size::value == links.size()); + // Apply links + std::apply( + [this](const auto &... key) { + std::size_t n = 0; + ( + detail::sort( + *( + typename detail::queryResult< + std::decay_t + >::type + *)links[n++] + ), + ... + ); + }, + Keys().tup + ); - // Apply links - std::apply( - [this](const auto &... key) { - std::size_t n = 0; - ( - detail::sort( - *(std::decay_t *)links[n++] - ), - ... - ); - }, - tup - ); - } } catch (...) { log::member("Component.sort()"); throw; diff --git a/src/GNDStk/Component/src/toNode.hpp b/src/GNDStk/Component/src/toNode.hpp index 52c291d5b..3b8702334 100644 --- a/src/GNDStk/Component/src/toNode.hpp +++ b/src/GNDStk/Component/src/toNode.hpp @@ -1,43 +1,69 @@ // ----------------------------------------------------------------------------- // Component -// conversion to Node +// Conversion to Node. // ----------------------------------------------------------------------------- -// Normally we'd need just a const version of a conversion operator, and, if -// we needed a non-const version at all, it could build on the const version. -// A glitch in the present circumstances is that BodyText::toNode(), which is -// called from within these, splits const and non-const cases, and that needs -// to be preserved here. So, then, why does BodyText::toNode() have a non-const -// version? The issue is that in the non-const case, BodyText::toNode() may -// need to deal with a vector (not just an original "body text" string as may -// have been read into a const BodyText). And, dealing with a vector means -// computing a proper length, start, and valueType while doing toNode() - and -// pushing those up to the class derived from Component, as it's from that -// class that those fields are written to the Node. The need to compute proper -// values for those parameters is why we need the non-const case. (And we can't -// just make length etc. mutable in BodyText, as the length etc. in the derived -// class come into play too.) Maybe we'll work out a different way to handle -// all this, but for now, we have the following. - -// const operator Node() const { + // Initialize a Node, with the necessary name + Node node(DERIVED::FIELD()); + try { - #include "GNDStk/Component/src/toNodeBody.hpp" + // Handle block data, if applicable + if constexpr (hasBlockData) { + // GNDStk uses a TEXT metadatum of a PCDATA child node for this + std::string &text = + node.add(special::pcdata).add(special::text,"").second; + BLOCKDATA::toNode(text); + } + + // Write fields... + + // consistency check + assert(std::tuple_size_v == links.size()); + + // apply links: + // derived-class data ==> Node + // Below, each apply'd "key" is one value from DERIVED::KEYS(), and + // is a Meta, Child, or pair. The cast gives the + // underlying raw data type - int, say, or std::string - so that we + // can correctly use our generic void* link to a derived-class field. + std::apply( + [this,&node](const auto &... key) { + std::size_t n = 0; + ( + node.add( + key, + *( + typename detail::queryResult< + std::decay_t + >::type + *)links[n++] + ), + ... + ); + }, + Keys().tup + ); } catch (...) { log::member("Component.operator Node() const"); throw; } + + return node; } -// non-const -operator Node() + +// ----------------------------------------------------------------------------- +// Component +// Conversion to Tree. +// Like conversion to Node, but with a proper root Node. +// ----------------------------------------------------------------------------- + +operator Tree() const { - try { - #include "GNDStk/Component/src/toNodeBody.hpp" - } catch (...) { - log::member("Component.operator Node()"); - throw; - } + Tree tree; + tree.add(Node(*this)); + return tree; } diff --git a/src/GNDStk/Component/src/toNodeBody.hpp b/src/GNDStk/Component/src/toNodeBody.hpp deleted file mode 100644 index a5182a737..000000000 --- a/src/GNDStk/Component/src/toNodeBody.hpp +++ /dev/null @@ -1,40 +0,0 @@ - -// 1. Initialize a Node, with the necessary name -Node node(DERIVED::GNDSName()); - -// 2. Body text, if applicable -if constexpr (hasBodyText) { - // GNDStk uses a "text" metadatum of a "pcdata" child node for this - std::string &text = node.add("pcdata").add("text","").second; - // Note: the following call might compute length, start, and valueType; - // so we need all of this before the upcoming writing of fields. - body::toNode(text,derived().content); -} - -// 3. Write fields -if constexpr (std::is_same_v>) { - // consistency check - assert(0 == links.size()); -} else { - // make tuple (of individual keys) from DERIVED::keys() - const auto tup = toKeywordTup(DERIVED::keys()).tup; - - // consistency check - assert(std::tuple_size::value == links.size()); - - // apply links: - // derived-class data ==> Node - // Below, each apply'd "key" is one value from DERIVED::keys(), and - // is a Meta, Child, or pair. The cast gives the - // underlying raw data type - int, say, or std::string - so that we - // can correctly use our generic void* link to a derived-class field. - std::apply( - [this,&node](const auto &... key) { - std::size_t n = 0; - (node.add(key,*(std::decay_t*)links[n++]), ...); - }, - tup - ); -} - -return node; diff --git a/src/GNDStk/Component/src/write.hpp b/src/GNDStk/Component/src/write.hpp index a2a8507bb..49cdcad8e 100644 --- a/src/GNDStk/Component/src/write.hpp +++ b/src/GNDStk/Component/src/write.hpp @@ -1,126 +1,42 @@ // ----------------------------------------------------------------------------- // Component::write() +// Via Node, and using Node's write()s. +// So, Component-derived classes can use .write(...) directly. // ----------------------------------------------------------------------------- -std::ostream &write(std::ostream &os = std::cout, const int level = 0) const -{ - try { - // Indent, write header, newline - detail::indentString( - os, level, - detail::colorize_component( - detail::fullName(DERIVED::namespaceName(), DERIVED::className()) - ) + " " + - detail::colorize_brace("{") + - (comments - ? " " + - detail::colorize_comment( - std::string("// GNDS: ") + DERIVED::GNDSName() - ) - : "" - ) + "\n" - ); - - if constexpr (std::is_same_v>) { - // Consistency check - assert(0 == links.size()); - } else { - // Make tuple (of individual keys) from DERIVED::keys() - const auto tup = toKeywordTup(DERIVED::keys()).tup; - - // Consistency check - assert(std::tuple_size::value == links.size()); - - // Compute maximum length of key names, if aligning. Note that we - // could - but don't - take into account that keys associated with - // optional or Defaulted values *might* not in fact show up in the - // final printed text. In such cases, and if values of those types - // happen to have longer names, then the printing that does appear - // might use more spacing than it really needs to. By choosing not - // to factor this in, on a case-by-case basis, all objects of this - // particular Component<...> type will print with consistent spacing. - // We prefer this behavior, and it's also slightly simpler to write. - std::size_t maxlen = 0; - if (GNDStk::align) - std::apply( - [&maxlen](const auto &... key) { - ((maxlen=std::max(maxlen,detail::getName(key).size())), ...); - }, - tup - ); - - // Apply links: - // derived-class data ==> print - std::apply( - [this,&os,&level,maxlen](const auto &... key) { - std::size_t n = 0; - ( - ( - // indent, write internal value, newline - detail::writeComponentPart( - os, - level+1, - *(std::decay_t *)links[n++], - detail::getName(key), - maxlen - ) && (os << '\n') // no if()s in fold expressions :-/ - ), - ... - ); - }, - tup - ); - } - - // Derived class write()s, if any. - // Note that neither, either, or both can be provided. - // To be recognized here, signatures must be exactly what we expect. - if constexpr (detail::hasWriteOneArg) { - // DERIVED::write() doesn't take an indentation level; we handle here - std::ostringstream tmp; - derived().write(tmp); - if (tmp.str().size() != 0) - os << indentTo(level+1); - for (char c : tmp.str()) - os << c << (c == '\n' ? indentTo(level+1) : ""); - if (tmp.str().size()) - os << std::endl; - } - if constexpr (detail::hasWriteTwoArg) { - // DERIVED::write() takes an indentation level - std::ostringstream tmp; - derived().write(tmp,level+1); - os << tmp.str(); - if (tmp.str().size()) - os << std::endl; - } - - // BodyText, if any - if constexpr (hasBodyText) - body::write(os,level+1); +// write(ostream, FileType) +std::ostream &write( + std::ostream &os = std::cout, + const FileType format = FileType::guess, + const bool decl = false +) const { + return Node(*this).write(os, format, decl); +} - // Indent, write footer, NO newline - detail::indentString( - os, level, - detail::colorize_brace("}") - + (comments - ? " " + - detail::colorize_comment( - std::string("// ") + - detail::fullName( - DERIVED::namespaceName(), - DERIVED::className() - ) - ) - : "" - ) - ); +// write(file, FileType) +bool write( + const std::string &filename, + const FileType format = FileType::guess, + const bool decl = false +) const { + return Node(*this).write(filename, format, decl); +} - return os; +// write(ostream, string) +std::ostream &write( + std::ostream &os, + const std::string &format, + const bool decl = false +) const { + return Node(*this).write(os, format, decl); +} - } catch (...) { - log::member("Component.write()"); - throw; - } +// write(file, string) +bool write( + const std::string &filename, + const std::string &format, + const bool decl = false +) const { + return Node(*this).write(filename, format, decl); } diff --git a/src/GNDStk/Component/test/CMakeLists.txt b/src/GNDStk/Component/test/CMakeLists.txt index a81b982ff..178fbe81a 100644 --- a/src/GNDStk/Component/test/CMakeLists.txt +++ b/src/GNDStk/Component/test/CMakeLists.txt @@ -7,7 +7,7 @@ add_executable( GNDStk.Component.test fromNode.test.cpp getter.test.cpp toNode.test.cpp - write.test.cpp ) + print.test.cpp ) target_compile_options( GNDStk.Component.test PRIVATE ${${PREFIX}_common_flags} $<$:${${PREFIX}_strict_flags}>$<$: ${${PREFIX}_DEBUG_flags} diff --git a/src/GNDStk/Component/test/Component.test.cpp b/src/GNDStk/Component/test/Component.test.cpp index 5c524cc2c..593da9097 100644 --- a/src/GNDStk/Component/test/Component.test.cpp +++ b/src/GNDStk/Component/test/Component.test.cpp @@ -4,7 +4,7 @@ #include "catch.hpp" #include "GNDStk.hpp" -using namespace njoy::GNDStk::core; +using namespace njoy::GNDStk; @@ -21,11 +21,11 @@ class DerivedT : public Component { "", "class DerivedT" }, { "foo", "Help for foo" } }; - static auto namespaceName() { return "hello"; } - static auto className() { return "DerivedT"; } - static auto GNDSName() { return "none"; } - static auto keys() { return std::tuple<>{}; } - DerivedT() : Component(BodyText{}) { } + static auto NAMESPACE() { return "hello"; } + static auto CLASS() { return "DerivedT"; } + static auto FIELD() { return "none"; } + static auto KEYS() { return std::tuple<>{}; } + DerivedT() : Component(BlockData{}) { } }; @@ -38,27 +38,27 @@ class DerivedF : public Component { "", "class DerivedF" }, { "bar", "Help for bar" } }; - static auto namespaceName() { return "world"; } - static auto className() { return "DerivedF"; } - static auto GNDSName() { return "none"; } - static auto keys() { return std::tuple<>{}; } - DerivedF() : Component(BodyText{}) { } + static auto NAMESPACE() { return "world"; } + static auto CLASS() { return "DerivedF"; } + static auto FIELD() { return "none"; } + static auto KEYS() { return std::tuple<>{}; } + DerivedF() : Component(BlockData{}) { } }; // DerivedData // A Component-derived class with some data in it. -// Note that this class doesn't have help or namespaceName(); so we'll also use -// this class to test that Component's functionality that uses those still works -// properly, as it should in that case. +// Note that this class doesn't have help. So, we'll also use this class +// to test that Component's functionality that uses it still works properly, +// as it should in that case. class DerivedData : public Component { public: friend class Component; - static auto className() { return "DerivedData"; } - static auto GNDSName() { return "data"; } - - static auto keys() + static auto NAMESPACE() { return ""; } + static auto CLASS() { return "DerivedData"; } + static auto FIELD() { return "data"; } + static auto KEYS() { return int {} / Meta<>("foo") | @@ -69,22 +69,27 @@ class DerivedData : public Component struct { int foo; double bar; - } content; + } Content; + + const int &foo() const { return Content.foo; } + int &foo() { return Content.foo; } + const double &bar() const { return Content.bar; } + double &bar() { return Content.bar; } DerivedData() : Component( - BodyText{}, - content.foo, - content.bar + BlockData{}, + foo(), + bar() ) { } DerivedData(const Node &node) : Component( - BodyText{}, - content.foo, - content.bar + BlockData{}, + foo(), + bar() ) { Component::finish(node); @@ -140,17 +145,15 @@ SCENARIO("Testing GNDStk Component") { CHECK(der.documentation("bar") == "No help information is available"); } - // namespaceName() - WHEN("We test namespaceName()") { + // NAMESPACE() + WHEN("We test NAMESPACE()") { // For these two we need the std::string() only because the functions // were written (above, in the class definitions) with an auto return - // of a plain character string. Where Component needs namespaceName(), - // it converts to std::string, so it's fine to write it that way. Here, - // though, in this test file, it means we need the std::string(). - CHECK(der1.namespaceName() == std::string("hello")); - CHECK(der2.namespaceName() == std::string("world")); + // of a plain character string. + CHECK(der1.NAMESPACE() == std::string("hello")); + CHECK(der2.NAMESPACE() == std::string("world")); DerivedData der; - CHECK(der.namespaceName() == ""); + CHECK(der.NAMESPACE() == std::string("")); } // Component << string @@ -158,13 +161,13 @@ SCENARIO("Testing GNDStk Component") { // // Don't confuse the above two. Component << string reads from an XML // or JSON snippet into an object of the class that's derived from - // Component. ostream << Component writes (to the ostream) the object. + // Component. ostream << Component prints the object to the ostream. WHEN("We test (Component << string) and (ostream << Component)") { DerivedData der; color = false; // avoid cluttering the checked output below const std::string expected = - "DerivedData { // GNDS: data\n" + "DerivedData {\n" " foo : 12\n" " bar : 34.56\n" "} // DerivedData" @@ -174,7 +177,7 @@ SCENARIO("Testing GNDStk Component") { WHEN("We read a Component-derived object << XML text") { der << ""; - // write & check + // print, check THEN("The result is as expected") { std::ostringstream oss; oss << der; @@ -187,14 +190,14 @@ SCENARIO("Testing GNDStk Component") { der << "{" " \"data\": {" - " \"attributes\": {" + " \"#metadata\": {" " \"foo\": \"12\"," " \"bar\": \"34.56\"" " }" " }" "}"; - // write & check + // print, check THEN("The result is as expected") { std::ostringstream oss; oss << der; diff --git a/src/GNDStk/Component/test/ctor.test.cpp b/src/GNDStk/Component/test/ctor.test.cpp index 74e5ed7b0..a0e2f7b22 100644 --- a/src/GNDStk/Component/test/ctor.test.cpp +++ b/src/GNDStk/Component/test/ctor.test.cpp @@ -2,7 +2,7 @@ #include "catch.hpp" #include "GNDStk.hpp" -using namespace njoy::GNDStk::core; +using namespace njoy::GNDStk; // ----------------------------------------------------------------------------- @@ -17,7 +17,7 @@ using namespace njoy::GNDStk::core; // situations mentioned below: a class with no fields, and a class with fields. // We don't anticipate that people will need Component-derived classes that have // no fields, but still illustrate such a beast, for completeness. Note that the -// keys() function should return a std::tuple<>{} in that situation. +// KEYS() function should return a std::tuple<>{} in that situation. // ----------------------------------------------------------------------------- // DerivedNothing @@ -26,14 +26,16 @@ class DerivedNothing : public Component { friend class Component; - static auto keys() + static auto NAMESPACE() { return ""; } + static auto CLASS() { return "DerivedNothing"; } + static auto KEYS() { return std::tuple<>{}; } public: - DerivedNothing() : Component(BodyText{}) + DerivedNothing() : Component(BlockData{}) { Component::finish(); } @@ -46,7 +48,9 @@ class DerivedSomething : public Component { friend class Component; - static auto keys() + static auto NAMESPACE() { return ""; } + static auto CLASS() { return "DerivedSomething"; } + static auto KEYS() { return int {} / Meta<>("foo") | @@ -56,15 +60,20 @@ class DerivedSomething : public Component struct { int foo; double bar; - } content; + } Content; + + const int &foo() const { return Content.foo; } + int &foo() { return Content.foo; } + const double &bar() const { return Content.bar; } + double &bar() { return Content.bar; } public: DerivedSomething() : Component( - BodyText{}, - content.foo, - content.bar + BlockData{}, + foo(), + bar() ) { Component::finish(); diff --git a/src/GNDStk/Component/test/detail.test.cpp b/src/GNDStk/Component/test/detail.test.cpp index 3011e0182..85a6fabef 100644 --- a/src/GNDStk/Component/test/detail.test.cpp +++ b/src/GNDStk/Component/test/detail.test.cpp @@ -2,21 +2,21 @@ #include "catch.hpp" #include "GNDStk.hpp" -using namespace njoy::GNDStk::core; +using namespace njoy::GNDStk; // ----------------------------------------------------------------------------- -// Classes for testing the hasWrite*() functions +// Classes for testing the hasPrint*() functions // ----------------------------------------------------------------------------- struct Neither { - // has neither of the write()s seen in the upcoming classes + // has neither of the print()s seen in the upcoming classes }; struct One { // (ostream) only - std::ostream &write(std::ostream &os) const + std::ostream &print(std::ostream &os) const { return os; } @@ -24,7 +24,7 @@ struct One { struct Two { // (ostream,int) only - std::ostream &write(std::ostream &os, const int) const + std::ostream &print(std::ostream &os, const int) const { return os; } @@ -32,12 +32,12 @@ struct Two { struct Both { // (ostream) - std::ostream &write(std::ostream &os) const + std::ostream &print(std::ostream &os) const { return os; } // (ostream,int) - std::ostream &write(std::ostream &os, const int) const + std::ostream &print(std::ostream &os, const int) const { return os; } @@ -57,7 +57,12 @@ struct FooBar { struct { int foo; double bar; - } content; + } Content; + + const int &foo() const { return Content.foo; } + int &foo() { return Content.foo; } + const double &bar() const { return Content.bar; } + double &bar() { return Content.bar; } }; @@ -65,17 +70,18 @@ struct FooBar { // ----------------------------------------------------------------------------- // class Derived // Is derived from Component -// Used in the tests of writeComponentPart() +// Used in the tests of printComponentPart() // ----------------------------------------------------------------------------- class Derived : public Component { public: friend class Component; - static auto className() { return "Derived"; } - static auto GNDSName() { return "none"; } + static auto NAMESPACE() { return ""; } + static auto CLASS() { return "Derived"; } + static auto FIELD() { return "none"; } - static auto keys() + static auto KEYS() { return // metadata @@ -87,7 +93,7 @@ class Derived : public Component { int foo = 56; double bar = 7.8; - Derived() : Component(BodyText{},foo,bar) { } + Derived() : Component(BlockData{},foo,bar) { } }; @@ -103,7 +109,7 @@ class NonDerived { double bar = 3.4; }; -// Needs << in order to participate in writeComponentPart() - which it does, +// Needs << in order to participate in printComponentPart() - which it does, // because we're using it as a test subject there. inline std::ostream &operator<<(std::ostream &s, const NonDerived &obj) @@ -228,20 +234,20 @@ SCENARIO("Testing Component detail:: miscellaneous functions") { CHECK(oss.str() == " foo"); } // GIVEN - // hasWrite* + // hasPrint* // Test some SFINAE constructs - GIVEN("Functions: hasWriteOneArg(), hasWriteTwoArg()") { - CHECK(detail::hasWriteOneArg == false); - CHECK(detail::hasWriteTwoArg == false); + GIVEN("Functions: hasPrintOneArg(), hasPrintTwoArg()") { + CHECK(detail::hasPrintOneArg == false); + CHECK(detail::hasPrintTwoArg == false); - CHECK(detail::hasWriteOneArg == true); - CHECK(detail::hasWriteTwoArg == false); + CHECK(detail::hasPrintOneArg == true); + CHECK(detail::hasPrintTwoArg == false); - CHECK(detail::hasWriteOneArg == false); - CHECK(detail::hasWriteTwoArg == true); + CHECK(detail::hasPrintOneArg == false); + CHECK(detail::hasPrintTwoArg == true); - CHECK(detail::hasWriteOneArg == true); - CHECK(detail::hasWriteTwoArg == true); + CHECK(detail::hasPrintOneArg == true); + CHECK(detail::hasPrintTwoArg == true); } // GIVEN } @@ -260,66 +266,66 @@ SCENARIO("Testing Component detail:: miscellaneous functions") { // ostream, level, vector, label, maxlen, color = "" // All return bool. -SCENARIO("Testing Component detail:: writeComponentPart()") { +SCENARIO("Testing Component detail:: printComponentPart()") { // for clarity below int level; std::size_t maxlen; std::ostringstream oss; indent = 2; - using detail::writeComponentPart; + using detail::printComponentPart; // For string - GIVEN("writeComponentPart() for string") { + GIVEN("printComponentPart() for string") { oss.str(""); - writeComponentPart(oss, level=2, "foo\nbar", "label", maxlen=0); + printComponentPart(oss, level=2, "foo\nbar", "label", maxlen=0); CHECK(oss.str() == " label : foo\n" " bar"); oss.str(""); - writeComponentPart(oss, level=2, "foo\nbar", "label", maxlen=10); + printComponentPart(oss, level=2, "foo\nbar", "label", maxlen=10); CHECK(oss.str() == " label : foo\n" " bar"); oss.str(""); - writeComponentPart(oss, level=2, "foo\nbar", "", maxlen=0); + printComponentPart(oss, level=2, "foo\nbar", "", maxlen=0); CHECK(oss.str() == " foo\n" " bar"); oss.str(""); - writeComponentPart(oss, level=2, "foo\nbar", "", maxlen=10); + printComponentPart(oss, level=2, "foo\nbar", "", maxlen=10); CHECK(oss.str() == " foo\n" " bar"); } // GIVEN // For general types T - GIVEN("writeComponentPart() for T") { + GIVEN("printComponentPart() for T") { // For double WHEN("T is double") { double value = 1.234; oss.str(""); - writeComponentPart(oss, level=2, value, "label", maxlen=0); + printComponentPart(oss, level=2, value, "label", maxlen=0); CHECK(oss.str() == " label : 1.234"); oss.str(""); - writeComponentPart(oss, level=2, value, "label", maxlen=10); + printComponentPart(oss, level=2, value, "label", maxlen=10); CHECK(oss.str() == " label : 1.234"); oss.str(""); - writeComponentPart(oss, level=2, value, "", maxlen=0); + printComponentPart(oss, level=2, value, "", maxlen=0); CHECK(oss.str() == " 1.234"); oss.str(""); - writeComponentPart(oss, level=2, value, "", maxlen=10); + printComponentPart(oss, level=2, value, "", maxlen=10); CHECK(oss.str() == " 1.234"); } - // writeComponentPart() for general T has an if-constexpr that + // printComponentPart() for general T has an if-constexpr that // distinguished classes that *are* derived from Component from // those that aren't, so we'll test both cases. (double, above, // in fact falls into the latter category.) ... @@ -330,28 +336,28 @@ SCENARIO("Testing Component detail:: writeComponentPart()") { // label and maxlen don't get used in this case. // The Component-derived nature of the class causes - // value.write(stream,level) to be called instead. + // value.print(stream,level) to be called instead. // So we get the same result from each call. const std::string expected = - " Derived { // GNDS: none\n" + " Derived {\n" " foo : 56\n" " bar : 7.8\n" " } // Derived"; oss.str(""); - writeComponentPart(oss, level=2, value, "label", maxlen=0); + printComponentPart(oss, level=2, value, "label", maxlen=0); CHECK(oss.str() == expected); oss.str(""); - writeComponentPart(oss, level=2, value, "label", maxlen=10); + printComponentPart(oss, level=2, value, "label", maxlen=10); CHECK(oss.str() == expected); oss.str(""); - writeComponentPart(oss, level=2, value, "", maxlen=0); + printComponentPart(oss, level=2, value, "", maxlen=0); CHECK(oss.str() == expected); oss.str(""); - writeComponentPart(oss, level=2, value, "", maxlen=10); + printComponentPart(oss, level=2, value, "", maxlen=10); CHECK(oss.str() == expected); } @@ -360,42 +366,42 @@ SCENARIO("Testing Component detail:: writeComponentPart()") { NonDerived value; oss.str(""); - writeComponentPart(oss, level=2, value, "label", maxlen=0); + printComponentPart(oss, level=2, value, "label", maxlen=0); CHECK(oss.str() == " label : {12,3.4}"); oss.str(""); - writeComponentPart(oss, level=2, value, "label", maxlen=10); + printComponentPart(oss, level=2, value, "label", maxlen=10); CHECK(oss.str() == " label : {12,3.4}"); oss.str(""); - writeComponentPart(oss, level=2, value, "", maxlen=0); + printComponentPart(oss, level=2, value, "", maxlen=0); CHECK(oss.str() == " {12,3.4}"); oss.str(""); - writeComponentPart(oss, level=2, value, "", maxlen=10); + printComponentPart(oss, level=2, value, "", maxlen=10); CHECK(oss.str() == " {12,3.4}"); } } // GIVEN // For optional - GIVEN("writeComponentPart() for optional") { + GIVEN("printComponentPart() for optional") { WHEN("The optional has a value") { std::optional opt = 1.234; oss.str(""); - writeComponentPart(oss, level=2, opt, "label", maxlen=0); + printComponentPart(oss, level=2, opt, "label", maxlen=0); CHECK(oss.str() == " label : 1.234"); oss.str(""); - writeComponentPart(oss, level=2, opt, "label", maxlen=10); + printComponentPart(oss, level=2, opt, "label", maxlen=10); CHECK(oss.str() == " label : 1.234"); oss.str(""); - writeComponentPart(oss, level=2, opt, "", maxlen=0); + printComponentPart(oss, level=2, opt, "", maxlen=0); CHECK(oss.str() == " 1.234"); oss.str(""); - writeComponentPart(oss, level=2, opt, "", maxlen=10); + printComponentPart(oss, level=2, opt, "", maxlen=10); CHECK(oss.str() == " 1.234"); } @@ -405,19 +411,19 @@ SCENARIO("Testing Component detail:: writeComponentPart()") { comments = false; oss.str(""); - writeComponentPart(oss, level=2, opt, "label", maxlen=0); + printComponentPart(oss, level=2, opt, "label", maxlen=0); CHECK(oss.str() == ""); oss.str(""); - writeComponentPart(oss, level=2, opt, "label", maxlen=10); + printComponentPart(oss, level=2, opt, "label", maxlen=10); CHECK(oss.str() == ""); oss.str(""); - writeComponentPart(oss, level=2, opt, "", maxlen=0); + printComponentPart(oss, level=2, opt, "", maxlen=0); CHECK(oss.str() == ""); oss.str(""); - writeComponentPart(oss, level=2, opt, "", maxlen=10); + printComponentPart(oss, level=2, opt, "", maxlen=10); CHECK(oss.str() == ""); } @@ -427,25 +433,25 @@ SCENARIO("Testing Component detail:: writeComponentPart()") { comments = true; oss.str(""); - writeComponentPart(oss, level=2, opt, "label", maxlen=0); + printComponentPart(oss, level=2, opt, "label", maxlen=0); CHECK(oss.str() == " label : // optional; has no value"); oss.str(""); - writeComponentPart(oss, level=2, opt, "label", maxlen=10); + printComponentPart(oss, level=2, opt, "label", maxlen=10); CHECK(oss.str() == " label : // optional; has no value"); oss.str(""); - writeComponentPart(oss, level=2, opt, "", maxlen=0); + printComponentPart(oss, level=2, opt, "", maxlen=0); CHECK(oss.str() == " // optional; has no value"); oss.str(""); - writeComponentPart(oss, level=2, opt, "", maxlen=10); + printComponentPart(oss, level=2, opt, "", maxlen=10); CHECK(oss.str() == " // optional; has no value"); } } // GIVEN // For Defaulted - GIVEN("writeComponentPart() for Defaulted") { + GIVEN("printComponentPart() for Defaulted") { WHEN("The Defaulted has an explicitly provided value") { // For the following: // 5.6 is the default @@ -453,19 +459,19 @@ SCENARIO("Testing Component detail:: writeComponentPart()") { Defaulted def(5.6,7.8); oss.str(""); - writeComponentPart(oss, level=2, def, "label", maxlen=0); + printComponentPart(oss, level=2, def, "label", maxlen=0); CHECK(oss.str() == " label : 7.8"); oss.str(""); - writeComponentPart(oss, level=2, def, "label", maxlen=10); + printComponentPart(oss, level=2, def, "label", maxlen=10); CHECK(oss.str() == " label : 7.8"); oss.str(""); - writeComponentPart(oss, level=2, def, "", maxlen=0); + printComponentPart(oss, level=2, def, "", maxlen=0); CHECK(oss.str() == " 7.8"); oss.str(""); - writeComponentPart(oss, level=2, def, "", maxlen=10); + printComponentPart(oss, level=2, def, "", maxlen=10); CHECK(oss.str() == " 7.8"); } @@ -475,19 +481,19 @@ SCENARIO("Testing Component detail:: writeComponentPart()") { comments = false; oss.str(""); - writeComponentPart(oss, level=2, def, "label", maxlen=0); + printComponentPart(oss, level=2, def, "label", maxlen=0); CHECK(oss.str() == ""); oss.str(""); - writeComponentPart(oss, level=2, def, "label", maxlen=10); + printComponentPart(oss, level=2, def, "label", maxlen=10); CHECK(oss.str() == ""); oss.str(""); - writeComponentPart(oss, level=2, def, "", maxlen=0); + printComponentPart(oss, level=2, def, "", maxlen=0); CHECK(oss.str() == ""); oss.str(""); - writeComponentPart(oss, level=2, def, "", maxlen=10); + printComponentPart(oss, level=2, def, "", maxlen=10); CHECK(oss.str() == ""); } @@ -497,47 +503,49 @@ SCENARIO("Testing Component detail:: writeComponentPart()") { comments = true; oss.str(""); - writeComponentPart(oss, level=2, def, "label", maxlen=0); - CHECK(oss.str() == " label : // defaulted; is its default (2.72)"); + printComponentPart(oss, level=2, def, "label", maxlen=0); + CHECK(oss.str() == + " label : // defaulted; is its default (2.72)"); oss.str(""); - writeComponentPart(oss, level=2, def, "label", maxlen=10); - CHECK(oss.str() == " label : // defaulted; is its default (2.72)"); + printComponentPart(oss, level=2, def, "label", maxlen=10); + CHECK(oss.str() == + " label : // defaulted; is its default (2.72)"); oss.str(""); - writeComponentPart(oss, level=2, def, "", maxlen=0); + printComponentPart(oss, level=2, def, "", maxlen=0); CHECK(oss.str() == " // defaulted; is its default (2.72)"); oss.str(""); - writeComponentPart(oss, level=2, def, "", maxlen=10); + printComponentPart(oss, level=2, def, "", maxlen=10); CHECK(oss.str() == " // defaulted; is its default (2.72)"); } } // GIVEN // For variant - GIVEN("writeComponentPart() for variant") { + GIVEN("printComponentPart() for variant") { oss.str(""); std::variant var(9.87); oss.str(""); - writeComponentPart(oss, level=2, var, "label", maxlen=0); + printComponentPart(oss, level=2, var, "label", maxlen=0); CHECK(oss.str() == " label : 9.87"); oss.str(""); - writeComponentPart(oss, level=2, var, "label", maxlen=10); + printComponentPart(oss, level=2, var, "label", maxlen=10); CHECK(oss.str() == " label : 9.87"); oss.str(""); - writeComponentPart(oss, level=2, var, "", maxlen=0); + printComponentPart(oss, level=2, var, "", maxlen=0); CHECK(oss.str() == " 9.87"); oss.str(""); - writeComponentPart(oss, level=2, var, "", maxlen=10); + printComponentPart(oss, level=2, var, "", maxlen=10); CHECK(oss.str() == " 9.87"); } // GIVEN // For vector - GIVEN("writeComponentPart() for vector") { + GIVEN("printComponentPart() for vector") { oss.str(""); const std::vector vec{{"a","b","c","d","e"}}; @@ -551,11 +559,11 @@ SCENARIO("Testing Component detail:: writeComponentPart()") { " ]"; oss.str(""); - writeComponentPart(oss, level=2, vec, "label", maxlen=0); + printComponentPart(oss, level=2, vec, "label", maxlen=0); CHECK(oss.str() == expected); oss.str(""); - writeComponentPart(oss, level=2, vec, "label", maxlen=10); + printComponentPart(oss, level=2, vec, "label", maxlen=10); CHECK(oss.str() == expected); } // GIVEN } @@ -658,13 +666,14 @@ SCENARIO("Testing Component detail:: getter() functions") { GIVEN("A vector of objects that have both index and label") { // look for specific index THEN("getter() based on index works properly") { - CHECK((detail::getter(vec,0,"name","class","field").value() == "0a")); - CHECK((detail::getter(vec,1,"name","class","field").value() == "1b")); - CHECK((detail::getter(vec,2,"name","class","field").value() == "2c")); - CHECK((detail::getter(vec,3,"name","class","field").value() == "3d")); - CHECK((detail::getter(vec,4,"name","class","field").value() == "4e")); + using detail::getter; + CHECK((getter(vec, 0, "name", "class", "field").value() == "0a")); + CHECK((getter(vec, 1, "name", "class", "field").value() == "1b")); + CHECK((getter(vec, 2, "name", "class", "field").value() == "2c")); + CHECK((getter(vec, 3, "name", "class", "field").value() == "3d")); + CHECK((getter(vec, 4, "name", "class", "field").value() == "4e")); try { - detail::getter(vec,100,"name","class","field"); + getter(vec, 100, "name", "class", "field"); // the above should throw, so we shouldn't get here... CHECK(false); } catch (...) { @@ -673,13 +682,14 @@ SCENARIO("Testing Component detail:: getter() functions") { // look for specific label THEN("getter() based on label works properly") { - CHECK((detail::getter(vec,"a","name","class","field").value() == "0a")); - CHECK((detail::getter(vec,"b","name","class","field").value() == "1b")); - CHECK((detail::getter(vec,"c","name","class","field").value() == "2c")); - CHECK((detail::getter(vec,"d","name","class","field").value() == "3d")); - CHECK((detail::getter(vec,"e","name","class","field").value() == "4e")); + using detail::getter; + CHECK((getter(vec, "a", "name", "class", "field").value() == "0a")); + CHECK((getter(vec, "b", "name", "class", "field").value() == "1b")); + CHECK((getter(vec, "c", "name", "class", "field").value() == "2c")); + CHECK((getter(vec, "d", "name", "class", "field").value() == "3d")); + CHECK((getter(vec, "e", "name", "class", "field").value() == "4e")); try { - detail::getter(vec,"z","name","class","field"); + getter(vec, "z", "name", "class", "field"); // the above should throw, so we shouldn't get here... CHECK(false); } catch (...) { @@ -698,13 +708,14 @@ SCENARIO("Testing Component detail:: getter() functions") { // look for specific index THEN("getter() based on index works properly") { - CHECK((detail::getter(opt,0UL,"name","class","field").value() == "0a")); - CHECK((detail::getter(opt,1UL,"name","class","field").value() == "1b")); - CHECK((detail::getter(opt,2UL,"name","class","field").value() == "2c")); - CHECK((detail::getter(opt,3UL,"name","class","field").value() == "3d")); - CHECK((detail::getter(opt,4UL,"name","class","field").value() == "4e")); + using detail::getter; + CHECK((getter(opt, 0UL, "name", "class", "field").value() == "0a")); + CHECK((getter(opt, 1UL, "name", "class", "field").value() == "1b")); + CHECK((getter(opt, 2UL, "name", "class", "field").value() == "2c")); + CHECK((getter(opt, 3UL, "name", "class", "field").value() == "3d")); + CHECK((getter(opt, 4UL, "name", "class", "field").value() == "4e")); try { - detail::getter(opt,100UL,"name","class","field"); + getter(opt, 100UL, "name", "class", "field"); // the above should throw, so we shouldn't get here... CHECK(false); } catch (...) { @@ -713,13 +724,14 @@ SCENARIO("Testing Component detail:: getter() functions") { // look for specific label THEN("getter() based on label works properly") { - CHECK((detail::getter(opt,"a","name","class","field").value() == "0a")); - CHECK((detail::getter(opt,"b","name","class","field").value() == "1b")); - CHECK((detail::getter(opt,"c","name","class","field").value() == "2c")); - CHECK((detail::getter(opt,"d","name","class","field").value() == "3d")); - CHECK((detail::getter(opt,"e","name","class","field").value() == "4e")); + using detail::getter; + CHECK((getter(opt, "a", "name", "class", "field").value() == "0a")); + CHECK((getter(opt, "b", "name", "class", "field").value() == "1b")); + CHECK((getter(opt, "c", "name", "class", "field").value() == "2c")); + CHECK((getter(opt, "d", "name", "class", "field").value() == "3d")); + CHECK((getter(opt, "e", "name", "class", "field").value() == "4e")); try { - detail::getter(opt,"z","name","class","field"); + getter(opt, "z", "name", "class", "field"); // the above should throw, so we shouldn't get here... CHECK(false); } catch (...) { @@ -739,7 +751,7 @@ SCENARIO("Testing Component detail:: getter() functions") { // look for specific index THEN("getter() based on index works properly") { try { - detail::getter(opt,0,"name","class","field"); + detail::getter(opt, 0, "name", "class", "field"); // the above should throw, so we shouldn't get here... CHECK(false); } catch (...) { @@ -749,7 +761,7 @@ SCENARIO("Testing Component detail:: getter() functions") { // look for specific label THEN("getter() based on label works properly") { try { - detail::getter(opt,"a","name","class","field"); + detail::getter(opt, "a", "name", "class", "field"); // the above should throw, so we shouldn't get here... CHECK(false); } catch (...) { diff --git a/src/GNDStk/Component/test/finish.test.cpp b/src/GNDStk/Component/test/finish.test.cpp index 59d7edab3..0cb05a749 100644 --- a/src/GNDStk/Component/test/finish.test.cpp +++ b/src/GNDStk/Component/test/finish.test.cpp @@ -2,13 +2,13 @@ #include "catch.hpp" #include "GNDStk.hpp" -using namespace njoy::GNDStk::core; +using namespace njoy::GNDStk; // ----------------------------------------------------------------------------- // DerivedValue -// Has body text +// Has block data // ----------------------------------------------------------------------------- namespace test { @@ -17,14 +17,17 @@ namespace test { struct IndexStruct { struct { std::size_t index; - } content; - IndexStruct(const std::size_t i = 0) { content.index = i; } + } Content; + const std::size_t &index() const { return Content.index; } + std::size_t &index() { return Content.index; } + + IndexStruct(const std::size_t i = 0) { index() = i; } IndexStruct(const Node &) : IndexStruct(0) { } }; inline bool operator==(const IndexStruct &one, const IndexStruct &two) { - return one.content.index == two.content.index; + return one.index() == two.index(); } @@ -42,12 +45,12 @@ class DerivedValue : public Component friend class Component; // names - static auto namespaceName() { return "test"; } - static auto className() { return "DerivedValue"; } - static auto GNDSName() { return "value"; } + static auto NAMESPACE() { return "test"; } + static auto CLASS() { return "DerivedValue"; } + static auto FIELD() { return "value"; } // keys - static auto keys() + static auto KEYS() { return int{} / Meta<>("length") | @@ -59,12 +62,13 @@ class DerivedValue : public Component public: - // content + // Content // Typically doesn't need to be public, but we make it public here because // one of the tests involves checking these struct { // Initialize these to specific values, so that we can ensure that - // Component's finish() functions properly call body::pullFromDerived() + // Component's finish() functions properly call + // BLOCKDATA::pullFromDerived() int length = 11; int start = 3; std::string valueType = "foobar"; @@ -73,7 +77,21 @@ class DerivedValue : public Component // functions detect and sort it. std::optional> indices = {{3,2,17,7,5,9,13,11}}; - } content; + } Content; + + const int &length() const { return Content.length; } + int &length() { return Content.length; } + + const int &start() const { return Content.start; } + int &start() { return Content.start; } + + const std::string &valueType() const { return Content.valueType; } + std::string &valueType() { return Content.valueType; } + + const std::optional> &indices() const + { return Content.indices; } + std::optional> &indices() + { return Content.indices; } private: @@ -106,8 +124,8 @@ class DerivedValue : public Component // ctor: default DerivedValue() : Component( - BodyText{}, - content.length, content.start, content.valueType, content.indices + BlockData{}, + length(), start(), valueType(), indices() ) { // finish() @@ -118,9 +136,9 @@ class DerivedValue : public Component DerivedValue(const DerivedValue &other) : Component{ other, - content.length, content.start, content.valueType, content.indices + length(), start(), valueType(), indices() }, - content{other.content} + Content{other.Content} { // finish(derived) Component::finish(other); @@ -129,8 +147,8 @@ class DerivedValue : public Component // ctor: node DerivedValue(const Node &node) : Component{ - BodyText{}, - content.length, content.start, content.valueType, content.indices + BlockData{}, + length(), start(), valueType(), indices() } { // finish(node) @@ -140,8 +158,8 @@ class DerivedValue : public Component // ctor: vector DerivedValue(const std::vector &vec) : Component{ - BodyText{}, - content.length, content.start, content.valueType, content.indices + BlockData{}, + length(), start(), valueType(), indices() } { // finish(vector) @@ -155,7 +173,7 @@ class DerivedValue : public Component // ----------------------------------------------------------------------------- // DerivedPlain -// Does not have body text +// Does not have block data // ----------------------------------------------------------------------------- namespace test { @@ -164,18 +182,21 @@ namespace test { struct LabelStruct { struct { std::string label; - } content; + } Content; + const std::string &label() const { return Content.label; } + std::string &label() { return Content.label; } + // apparently need a char* ctor for initializer-list initialization to work - LabelStruct(const char *const str = "") { content.label = str; } + LabelStruct(const char *const str = "") { label() = str; } LabelStruct(const Node &node) { - content.label = node(std::string{}/Meta<>("label")); + label() = node(std::string{}/Meta<>("label")); } }; inline bool operator==(const LabelStruct &one, const LabelStruct &two) { - return one.content.label == two.content.label; + return one.label() == two.label(); } @@ -191,12 +212,12 @@ class DerivedPlain : public Component friend class Component; // names - static auto namespaceName() { return "test"; } - static auto className() { return "DerivedPlain"; } - static auto GNDSName() { return "plain"; } + static auto NAMESPACE() { return "test"; } + static auto CLASS() { return "DerivedPlain"; } + static auto FIELD() { return "plain"; } // keys - static auto keys() + static auto KEYS() { return int {} / Meta<>("foo") | @@ -207,7 +228,7 @@ class DerivedPlain : public Component public: - // content + // Content struct { int foo; double bar; @@ -216,7 +237,18 @@ class DerivedPlain : public Component // functions detect and sort it. std::optional> labels = {{"bc","a","p","efg","d","hi","no","jklm"}}; - } content; + } Content; + + const int &foo() const { return Content.foo; } + int &foo() { return Content.foo; } + + const double &bar() const { return Content.bar; } + double &bar() { return Content.bar; } + + const std::optional> &labels() const + { return Content.labels; } + std::optional> &labels() + { return Content.labels; } private: @@ -243,8 +275,8 @@ class DerivedPlain : public Component // ctor: default DerivedPlain() : Component( - BodyText{}, - content.foo, content.bar, content.labels + BlockData{}, + foo(), bar(), labels() ) { // finish() @@ -255,9 +287,9 @@ class DerivedPlain : public Component DerivedPlain(const DerivedPlain &other) : Component{ other, - content.foo, content.bar, content.labels + foo(), bar(), labels() }, - content{other.content} + Content{other.Content} { // finish(derived) Component::finish(other); @@ -266,8 +298,8 @@ class DerivedPlain : public Component // ctor: node DerivedPlain(const Node &node) : Component{ - BodyText{}, - content.foo, content.bar, content.labels + BlockData{}, + foo(), bar(), labels() } { // finish(node) @@ -288,8 +320,9 @@ class DerivedPlain : public Component // Detailed tests of those other functions aren't done *here*. SCENARIO("Component finish()") { + njoy::GNDStk::sort = true; - GIVEN("A component-derived class that has body text") { + GIVEN("A component-derived class that has block data") { const std::vector sorted = {{2,3,5,7,9,11,13,17}}; @@ -300,15 +333,15 @@ SCENARIO("Component finish()") { // Ensure that finish() called the construct() in the derived class... CHECK(test::construct1DerivedValue == true); - // Ensure that finish() did a BodyText::pullFromDerived() + // Ensure that finish() did a BlockData::pullFromDerived() CHECK(d.length() == 11); CHECK(d.start() == 3); CHECK(d.valueType() == "foobar"); // Ensure that finish() did a sort() - CHECK(d.content.indices.has_value() == true); - CHECK(d.content.indices->size() == 8); - CHECK(*d.content.indices == sorted); + CHECK(d.indices().has_value() == true); + CHECK(d.indices()->size() == 8); + CHECK(*d.indices() == sorted); } // ctor: copy @@ -340,9 +373,9 @@ SCENARIO("Component finish()") { CHECK(d.valueType() == "foobar"); // Ensure that finish() did a sort() - CHECK(d.content.indices.has_value() == true); - CHECK(d.content.indices->size() == 8); - CHECK(*d.content.indices == sorted); + CHECK(d.indices().has_value() == true); + CHECK(d.indices()->size() == 8); + CHECK(*d.indices() == sorted); } // ctor: from node @@ -357,7 +390,7 @@ SCENARIO("Component finish()") { test::DerivedValue d(node); CHECK(test::construct3DerivedValue == true); - // Here, the following values in the underlying BodyText should + // Here, the following values in the underlying BlockData should // reflect those that were brought in through the above string. CHECK(d.length() == 10); CHECK(d.start() == 2); @@ -375,9 +408,9 @@ SCENARIO("Component finish()") { CHECK(d.get(8) == 0); CHECK(d.get(9) == 0); - // The node from which we read had body text, not child nodes, + // The node from which we read had block data, not child nodes, // and thus would give us nothing for (std::optional) indices... - CHECK(d.content.indices.has_value() == false); + CHECK(d.indices().has_value() == false); } // ctor: from vector @@ -388,7 +421,7 @@ SCENARIO("Component finish()") { CHECK(test::construct4DerivedValue == true); // Here, the finish(vector) function was called, which in turn called - // BodyText's operator=(vector), which sets the following according + // BlockData's operator=(vector), which sets the following according // to what's actually in the vector CHECK(d.length() == 3); CHECK(d.start() == 0); // <== always the case in this context @@ -400,22 +433,22 @@ SCENARIO("Component finish()") { CHECK(Approx(d.get(1)) == 2.71828); CHECK(Approx(d.get(2)) == 1.41421); - // And, BodyText's operator=(vector) as mentioned above should also + // And, BlockData's operator=(vector) as mentioned above should also // have changed the corresponding values back up in the derived class - CHECK(d.content.length == 3); - CHECK(d.content.start == 0); - CHECK(d.content.valueType == "Float64"); + CHECK(d.length() == 3); + CHECK(d.start() == 0); + CHECK(d.valueType() == "Float64"); // Ensure that finish() did a sort() - CHECK(d.content.indices.has_value() == true); - CHECK(d.content.indices->size() == 8); - CHECK(*d.content.indices == sorted); + CHECK(d.indices().has_value() == true); + CHECK(d.indices()->size() == 8); + CHECK(*d.indices() == sorted); } } // GIVEN - GIVEN("A component-derived class that does not have body text") { + GIVEN("A component-derived class that does not have block data") { const std::vector sorted = {{"a","bc","d","efg","hi","jklm","no","p"}}; @@ -425,9 +458,9 @@ SCENARIO("Component finish()") { test::DerivedPlain d; CHECK(test::construct1DerivedPlain == true); - CHECK(d.content.labels.has_value() == true); - CHECK(d.content.labels->size() == 8); - CHECK(*d.content.labels == sorted); + CHECK(d.labels().has_value() == true); + CHECK(d.labels()->size() == 8); + CHECK(*d.labels() == sorted); } // ctor: copy @@ -438,9 +471,9 @@ SCENARIO("Component finish()") { test::DerivedPlain d(dfrom); CHECK(test::construct2DerivedPlain == true); - CHECK(d.content.labels.has_value() == true); - CHECK(d.content.labels->size() == 8); - CHECK(*d.content.labels == sorted); + CHECK(d.labels().has_value() == true); + CHECK(d.labels()->size() == 8); + CHECK(*d.labels() == sorted); } // ctor: from node, case 1 @@ -454,7 +487,7 @@ SCENARIO("Component finish()") { test::DerivedPlain d(node); CHECK(test::construct3DerivedPlain == true); - CHECK(d.content.labels.has_value() == false); + CHECK(d.labels().has_value() == false); } // ctor: from node, case 2 @@ -472,10 +505,10 @@ SCENARIO("Component finish()") { test::DerivedPlain d(node); CHECK(test::construct3DerivedPlain == true); - CHECK(d.content.labels.has_value() == true); - CHECK(d.content.labels->size() == 4); + CHECK(d.labels().has_value() == true); + CHECK(d.labels()->size() == 4); CHECK(( - *d.content.labels == + *d.labels() == std::vector{{"abc","def","ghi","jkl"}} )); } diff --git a/src/GNDStk/Component/test/fromNode.test.cpp b/src/GNDStk/Component/test/fromNode.test.cpp index 55a9e5cae..9c1bf456c 100644 --- a/src/GNDStk/Component/test/fromNode.test.cpp +++ b/src/GNDStk/Component/test/fromNode.test.cpp @@ -3,9 +3,12 @@ #include "GNDStk.hpp" #include "prototype.hpp" -using namespace njoy::GNDStk::core; +using namespace njoy::GNDStk; using namespace GNDStk::proto; +#include "GNDStk/test/keys.hpp" +using namespace basic; + // ----------------------------------------------------------------------------- // DISCUSSION @@ -19,9 +22,9 @@ Component does the following: - Calls Component's fromNode() function to read known fields from the Node into the derived class object. - - If the Node has "body text," syncs certain fields in the BodyText (base + - If the Node has block data, syncs certain fields in the BlockData (base of Component) class, with fields in the derived class. Then, converts a - raw body-text string into a vector of values. + raw block data string into a vector of values. - Performs a sort() of derived-class vectors that are known to Component, and that have an index and/or a label. @@ -35,7 +38,7 @@ The tests in this file make use of a particular GNDS file with a reactionSuite. We use a prototype ReactionSuite class (with content that's pared down from what's in the full GNDS spec) that's derived from Component. -The reaction suite itself doesn't (directly) have any body text or sort-able +The reaction suite itself doesn't (directly) have any block data or sort-able fields, and doesn't have a construct(). So, our first test (1) constructs from a Node, (2) uses fromNode() to read from @@ -53,10 +56,10 @@ give different results: the former sorts, the latter doesn't. After the results from (2) are sorted, however, the two Reactions objects are the same. Finally, our third test works with Values objects. Objects of this type have -body text. Construction from Node does a get(), which takes the original, raw -body text in the Node, and makes a vector (in this case vector) from +block data. Construction from Node does a get(), which takes the original, raw +block data in the Node, and makes a vector (in this case vector) from it. fromNode() doesn't do that until, and unless, we ask for it by calling get() -directly. Values objects with only raw text write differently than those with +directly. Values objects with only raw text print differently than those with text that was processed into a vector. So, this test first ensures that the two Values objects print differently. Then it does an explicit get() for the object that used fromNode(), and ensures that the results are identical thereafter. @@ -162,7 +165,7 @@ SCENARIO("Component fromNode()") { oss2 << values2; CHECK(oss1.str() != oss2.str()); // not equal (yet) - // *** Apply get() *** to transform the raw string of body-text + // *** Apply get() *** to transform the raw string of block data // values into a vector values2.get(); oss2.str(""); diff --git a/src/GNDStk/Component/test/getter.test.cpp b/src/GNDStk/Component/test/getter.test.cpp index 46e815e43..7d1bdbf11 100644 --- a/src/GNDStk/Component/test/getter.test.cpp +++ b/src/GNDStk/Component/test/getter.test.cpp @@ -3,7 +3,7 @@ #include "GNDStk.hpp" #include "indexnlabel.hpp" -using namespace njoy::GNDStk::core; +using namespace njoy::GNDStk; // ----------------------------------------------------------------------------- @@ -18,9 +18,10 @@ class TestGetter : public Component { friend class Component; - static auto className() { return "TestGetter"; } - // static auto GNDSName() - not actually needed here - static auto keys() + static auto NAMESPACE() { return ""; } + static auto CLASS() { return "TestGetter"; } + // static auto FIELD() - not actually needed here + static auto KEYS() { return std::tuple<>{}; } @@ -38,7 +39,7 @@ class TestGetter : public Component // ------------------------ // See earlier remark. We don't bother linking these with GNDS fields, via - // Component's capabilities and the keys() function, because doing so isn't + // Component's capabilities and the KEYS() function, because doing so isn't // necessary for the present tests. // some vectors @@ -56,7 +57,7 @@ class TestGetter : public Component // constructor: default // ------------------------ - TestGetter() : Component{ BodyText{} } + TestGetter() : Component{ BlockData{} } { // Component::finish(); = not needed here } @@ -98,15 +99,24 @@ class TestGetter : public Component CHECK( getter(vecIndexLabel,7,"vecIndexLabel").value() == "7 (seven)" ); // re: vecIndexLabel, lookup by label - CHECK( getter(vecIndexLabel,"five","vecIndexLabel").index() == 5 ); - CHECK( getter(vecIndexLabel,"five","vecIndexLabel").label() == "five" ); - CHECK( getter(vecIndexLabel,"five","vecIndexLabel").value() == "5 (five)" ); - CHECK( getter(vecIndexLabel,"six","vecIndexLabel").index() == 6 ); - CHECK( getter(vecIndexLabel,"six","vecIndexLabel").label() == "six" ); - CHECK( getter(vecIndexLabel,"six","vecIndexLabel").value() == "6 (six)" ); - CHECK( getter(vecIndexLabel,"seven","vecIndexLabel").index() == 7 ); - CHECK( getter(vecIndexLabel,"seven","vecIndexLabel").label() == "seven" ); - CHECK( getter(vecIndexLabel,"seven","vecIndexLabel").value() == "7 (seven)" ); + CHECK( getter(vecIndexLabel,"five","vecIndexLabel").index() + == 5 ); + CHECK( getter(vecIndexLabel,"five","vecIndexLabel").label() + == "five" ); + CHECK( getter(vecIndexLabel,"five","vecIndexLabel").value() + == "5 (five)" ); + CHECK( getter(vecIndexLabel,"six","vecIndexLabel").index() + == 6 ); + CHECK( getter(vecIndexLabel,"six","vecIndexLabel").label() + == "six" ); + CHECK( getter(vecIndexLabel,"six","vecIndexLabel").value() + == "6 (six)" ); + CHECK( getter(vecIndexLabel,"seven","vecIndexLabel").index() + == 7 ); + CHECK( getter(vecIndexLabel,"seven","vecIndexLabel").label() + == "seven" ); + CHECK( getter(vecIndexLabel,"seven","vecIndexLabel").value() + == "7 (seven)" ); } // non-const @@ -156,27 +166,36 @@ class TestGetter : public Component IndexLabel{ 11, "eleven", "11 (eleven)" }; // verify the new value - CHECK( getter(vecIndexLabel,11,"vecIndexLabel").index() == 11 ); - CHECK( getter(vecIndexLabel,11,"vecIndexLabel").label() == "eleven" ); - CHECK( getter(vecIndexLabel,11,"vecIndexLabel").value() == "11 (eleven)" ); + CHECK( getter(vecIndexLabel,11,"vecIndexLabel").index() + == 11 ); + CHECK( getter(vecIndexLabel,11,"vecIndexLabel").label() + == "eleven" ); + CHECK( getter(vecIndexLabel,11,"vecIndexLabel").value() + == "11 (eleven)" ); // ------------------------ // re: vecIndexLabel, lookup by label // ------------------------ // verify an existing value - CHECK( getter(vecIndexLabel,"six","vecIndexLabel").index() == 6 ); - CHECK( getter(vecIndexLabel,"six","vecIndexLabel").label() == "six" ); - CHECK( getter(vecIndexLabel,"six","vecIndexLabel").value() == "6 (six)" ); + CHECK( getter(vecIndexLabel,"six","vecIndexLabel").index() + == 6 ); + CHECK( getter(vecIndexLabel,"six","vecIndexLabel").label() + == "six" ); + CHECK( getter(vecIndexLabel,"six","vecIndexLabel").value() + == "6 (six)" ); // change getter(vecIndexLabel,"six","vecIndexLabel") = IndexLabel{ 13, "thirteen", "13 (thirteen)" }; // verify new value - CHECK( getter(vecIndexLabel,"thirteen","vecIndexLabel").index() == 13); - CHECK( getter(vecIndexLabel,"thirteen","vecIndexLabel").label() == "thirteen" ); - CHECK( getter(vecIndexLabel,"thirteen","vecIndexLabel").value() == "13 (thirteen)" ); + CHECK( getter(vecIndexLabel,"thirteen","vecIndexLabel").index() + == 13); + CHECK( getter(vecIndexLabel,"thirteen","vecIndexLabel").label() + == "thirteen" ); + CHECK( getter(vecIndexLabel,"thirteen","vecIndexLabel").value() + == "13 (thirteen)" ); } // ------------------------ @@ -223,14 +242,20 @@ class TestGetter : public Component CHECK( getter