forked from celeritas-project/celeritas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transform refactoring (celeritas-project#1127)
* Use optional bounding zones instead of required bboxes * Rename surface accessor * Define a base class for testing objects * Add transforms to each region * Add streamable variant
- Loading branch information
Showing
16 changed files
with
515 additions
and
406 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
//----------------------------------*-C++-*----------------------------------// | ||
// Copyright 2024 UT-Battelle, LLC, and other Celeritas developers. | ||
// See the top-level COPYRIGHT file for details. | ||
// SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
//---------------------------------------------------------------------------// | ||
//! \file corecel/io/StreamableVariant.hh | ||
//---------------------------------------------------------------------------// | ||
#pragma once | ||
|
||
#include <ostream> | ||
#include <variant> | ||
|
||
#include "corecel/Assert.hh" | ||
|
||
namespace celeritas | ||
{ | ||
//---------------------------------------------------------------------------// | ||
/*! | ||
* Helper class to print a variant to a stream. | ||
* | ||
* Example: | ||
* \code | ||
std::cout << StreamableVariant{surface} << std::endl; | ||
\endcode | ||
*/ | ||
template<class T> | ||
struct StreamableVariant | ||
{ | ||
T value; | ||
}; | ||
|
||
//---------------------------------------------------------------------------// | ||
// Deduction guide | ||
template<class T> | ||
StreamableVariant(T&&) -> StreamableVariant<T>; | ||
|
||
//---------------------------------------------------------------------------// | ||
// IMPLEMENTATION | ||
//---------------------------------------------------------------------------// | ||
namespace detail | ||
{ | ||
struct GenericToStream | ||
{ | ||
std::ostream& os; | ||
|
||
template<class T> | ||
void operator()(T&& obj) const | ||
{ | ||
this->os << obj; | ||
} | ||
}; | ||
} // namespace detail | ||
|
||
//---------------------------------------------------------------------------// | ||
// FREE FUNCTIONS | ||
//---------------------------------------------------------------------------// | ||
/*! | ||
* Write a variant object's value to a stream. | ||
*/ | ||
template<class T> | ||
std::ostream& operator<<(std::ostream& os, StreamableVariant<T> const& svar) | ||
{ | ||
CELER_ASSUME(!svar.value.valueless_by_exception()); | ||
std::visit(detail::GenericToStream{os}, svar.value); | ||
return os; | ||
} | ||
|
||
//---------------------------------------------------------------------------// | ||
} // namespace celeritas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.