Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protect TNReaction constructors in NDI_FOUND to suppress unreachable … #819

Merged
merged 1 commit into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cdi_ndi/NDI_Base.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#ifndef cdi_ndi_NDI_Base_hh
#define cdi_ndi_NDI_Base_hh

#include "cdi_ndi/config.h"
#include "cdi_ndi/config.h" // Definition of NDI_FOUND

#include "ds++/Assert.hh"
#include "ds++/path.hh"
Expand Down
44 changes: 35 additions & 9 deletions src/cdi_ndi/NDI_TNReaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
* \note Copyright (C) 2020 Triad National Security, LLC.
* All rights reserved. */
//----------------------------------------------------------------------------//

#include "cdi_ndi/config.h" // definition of NDI_FOUND

#include "NDI_TNReaction.hh"
#include <cmath>

namespace rtt_cdi_ndi {

// Protect actual NDI calls with NDI_FOUND macro:
#ifdef NDI_FOUND
//----------------------------------------------------------------------------//
// CONSTRUCTORS
//----------------------------------------------------------------------------//
Expand All @@ -35,7 +34,7 @@ NDI_TNReaction::NDI_TNReaction(const std::string &gendir_in,

load_ndi();
}

//----------------------------------------------------------------------------//
/*!
* \brief Constructor for NDI reader specific to TN reaction data using default
* gendir file.
Expand All @@ -51,9 +50,6 @@ NDI_TNReaction::NDI_TNReaction(const std::string &library_in,

load_ndi();
}

// Protect actual NDI calls with NDI_FOUND macro:
#ifdef NDI_FOUND
//----------------------------------------------------------------------------//
/*!
* \brief Load NDI dataset. Split off from constructor to allow for both
Expand Down Expand Up @@ -331,10 +327,40 @@ std::vector<double> NDI_TNReaction::get_PDF(const int product_zaid,
return pdf;
}
#else
//----------------------------------------------------------------------------//
// CONSTRUCTORS
//----------------------------------------------------------------------------//
/*!
* \brief Constructor for NDI reader -- base class constructor will throw
* because NDI is not available.
*
* \param[in] gendir_in path to gendir file
* \param[in] library_in name of requested NDI data library
* \param[in] reaction_in name of requested reaction
* \param[in] mg_e_bounds_in energy boundaries of multigroup bins (keV)
*/
NDI_TNReaction::NDI_TNReaction(const std::string &gendir_in,
const std::string &library_in,
const std::string &reaction_in,
const std::vector<double> mg_e_bounds_in)
: NDI_Base(gendir_in, "tn", library_in, reaction_in,
mg_e_bounds_in) { /* ... */
}

void NDI_TNReaction::load_ndi() {
Insist(0, "load_ndi() only available when NDI library is found");
/*!
* \brief Constructor for NDI reader -- base class constructor will throw
* because NDI is not available.
*
* \param[in] library_in name of requested NDI data library
* \param[in] reaction_in name of requested reaction
* \param[in] mg_e_bounds_in energy boundaries of multigroup bins (keV)
*/
NDI_TNReaction::NDI_TNReaction(const std::string &library_in,
const std::string &reaction_in,
const std::vector<double> mg_e_bounds_in)
: NDI_Base("tn", library_in, reaction_in, mg_e_bounds_in) { /* ... */
}

std::vector<double>
NDI_TNReaction::get_PDF(const int /*product_zaid*/,
const double /*temperature*/) const {
Expand Down
3 changes: 3 additions & 0 deletions src/cdi_ndi/NDI_TNReaction.hh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ public:
const double temperature) const;

private:
// Only implemented if NDI is found
#ifdef NDI_FOUND
void load_ndi();
#endif
};

} // namespace rtt_cdi_ndi
Expand Down