Skip to content

Commit

Permalink
Merge pull request #15539 from marcfehling/legacysignal
Browse files Browse the repository at this point in the history
Remove deprecated LegacySignal.
  • Loading branch information
drwells committed Jul 1, 2023
2 parents 795b803 + ac7c00f commit 6bfb335
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 154 deletions.
5 changes: 5 additions & 0 deletions doc/news/changes/incompatibilities/20230627Fehling
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Removed: The deprecated signal Triangulation::Signals::cell_weight
has been removed along with the deprecated class LegacySignal. Use
Triangulation::Signals::weight instead.
<br>
(Marc Fehling, 2023/06/27)
154 changes: 0 additions & 154 deletions include/deal.II/grid/tria.h
Original file line number Diff line number Diff line change
Expand Up @@ -2242,160 +2242,6 @@ class Triangulation : public Subscriptor
CellWeightSum<unsigned int>>
weight;

/**
* Constructor.
*
* Connects a deprecated signal to its successor.
*/
Signals()
: cell_weight(weight)
{}

/**
* Legacy signal emulation to deprecate the old signal.
*/
class LegacySignal
{
public:
using signature_type = unsigned int(const cell_iterator &,
const CellStatus);
using combiner_type = CellWeightSum<unsigned int>;

using slot_function_type = boost::function<signature_type>;
using slot_type =
boost::signals2::slot<signature_type, slot_function_type>;

/**
* Constructor.
*/
LegacySignal(
boost::signals2::signal<signature_type, combiner_type> &new_signal)
: new_signal(new_signal)
{}

/**
* Destructor.
*/
~LegacySignal()
{
base_weight.disconnect();
}

/**
* Connects a function to the signal.
*
* Connects an additional base weight function if signal was previously
* empty.
*/
DEAL_II_DEPRECATED
boost::signals2::connection
connect(
const slot_type & slot,
boost::signals2::connect_position position = boost::signals2::at_back)
{
if (base_weight.connected() == false)
{
base_weight = new_signal.connect(
[](const cell_iterator &, const CellStatus) -> unsigned int {
return 1000;
});
Assert(base_weight.connected() && new_signal.num_slots() == 1,
ExcInternalError());
}

return new_signal.connect(slot, position);
}

/**
* Returns the number of connected functions <em>without</em> the base
* weight.
*/
DEAL_II_DEPRECATED
std::size_t
num_slots() const
{
return new_signal.num_slots() -
static_cast<std::size_t>(base_weight.connected());
}

/**
* Checks if there are any connected functions to the signal.
*/
DEAL_II_DEPRECATED
bool
empty() const
{
if (num_slots() == 0)
{
Assert(new_signal.num_slots() == 0, ExcInternalError());
return true;
}
return false;
}

/**
* Disconnects a function from the signal.
*
* Also disconnects the base weight function if it is the last connected
* function.
*/
template <typename S>
DEAL_II_DEPRECATED void
disconnect(const S &connection)
{
new_signal.disconnect(connection);

if (num_slots() == 0)
{
Assert(base_weight.connected() && new_signal.num_slots() == 1,
ExcInternalError());
new_signal.disconnect(base_weight);
}
}

/**
* Triggers the signal.
*/
DEAL_II_DEPRECATED
unsigned int
operator()(const cell_iterator &iterator, const CellStatus status)
{
return new_signal(iterator, status);
}

private:
/**
* Monitors the connection of the base weight function.
*/
boost::signals2::connection base_weight;

/**
* Reference to the successor signal.
*/
boost::signals2::signal<signature_type, combiner_type> &new_signal;
};

/**
* @copydoc weight
*
* As a reference, a value of 1000 is added for every cell to the total
* weight. This means a signal return value of 1000 (resulting in a weight
* of 2000) means that it is twice as expensive for a process to handle this
* particular cell.
*
* @deprecated Use the `weight` signal instead which omits the base weight.
* You can invoke the old behavior by connecting a function to the signal
* that returns the base weight as follows. This function should be added
* <em>in addition</em> to the one that actually computes the weight.
* @code{.cc}
* triangulation.signals.weight.connect(
* [](const typename Triangulation<dim>::cell_iterator &,
* const typename Triangulation<dim>::CellStatus)
* -> unsigned int { return 1000; });
* @endcode
*/
LegacySignal cell_weight;

/**
* This signal is triggered at the beginning of execution of the
* parallel::distributed::Triangulation::execute_coarsening_and_refinement()
Expand Down

0 comments on commit 6bfb335

Please sign in to comment.