LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
geo::part::PartitionWithData< Data > Class Template Reference

Partition also containing data directly. More...

#include "Partitions.h"

Inheritance diagram for geo::part::PartitionWithData< Data >:
geo::part::Partition< Data > geo::part::PartitionBase geo::part::AreaOwner geo::part::PartitionContainer< Data > geo::part::PartitionElement< Data > geo::part::GridPartition< Data > geo::part::SortedPartition< Data, Sorter > geo::part::SortedPartition< Data, details::PartitionSorterByAreaRangeLower< Range > > geo::part::PartitionSortedByRange< Data, Range > geo::part::PartitionSortedByRange< Data,&PartitionBase::Area_t::depth > geo::part::PartitionSortedByRange< Data,&PartitionBase::Area_t::width > geo::part::DepthPartition< Data > geo::part::WidthPartition< Data >

Public Types

using Base_t = Partition< Data >
 Base class. More...
 
using Partition_t = Partition< Data >
 Base type of the partition. More...
 
using Data_t = typename Partition_t::Data_t
 Type of contained data. More...
 
using Area_t = typename Partition_t::Area_t
 Type of covered area. More...
 
using Subpartitions_t = std::vector< std::unique_ptr< Partition_t const >>
 Type of list of subpartitions. It needs to preserve polymorphism. More...
 
using AreaRangeMember_t = AreaOwner::AreaRangeMember_t
 

Public Member Functions

 PartitionWithData (Area_t const &area, Data_t *myData)
 Constructor: sets the covered area and the contained datum. More...
 
virtual Data_tdata () const override
 Returns the datum directly stored (nullptr if none). More...
 
virtual Data_tatPoint (double w, double d) const override
 Returns stored datum only if point is covered, nullptr otherwise. More...
 
std::string describe (std::string indent, std::string firstIndent) const
 Returns a description of the partition. More...
 
std::string describe (std::string indent="") const
 Returns a description of the partition. More...
 
template<typename Pred >
void walk (Pred &&pred) const
 Applies pred to all partitions. More...
 
std::size_t nParts () const
 Returns the number of subparts in the partition (0 if simple element). More...
 
bool contains (double w, double d) const
 Returns whether the specified point is covered by this object. More...
 
Area_t const & area () const
 Returns the covered area. More...
 
template<typename Stream >
void dumpArea (Stream &&out) const
 Output the owned area into an output stream. More...
 

Protected Member Functions

virtual Subpartitions_t const & parts () const
 Returns a list of all subpartitions. More...
 
std::string describeArea (std::string indent, std::string firstIndent) const
 Returns a description of the partition area. More...
 

Static Protected Member Functions

template<typename Pred >
static void walk (Partition_t const *start, Pred &&pred)
 Applies pred to start partition first, and then to all subpartitions. More...
 

Static Protected Attributes

static Subpartitions_t const NoSubparts
 Subpartitions (if any). More...
 

Private Member Functions

virtual std::string doDescribe (std::string indent, std::string firstIndent) const override
 Returns a description of the partition. More...
 

Private Attributes

Data_tmyData
 The contained datum. More...
 

Detailed Description

template<typename Data>
class geo::part::PartitionWithData< Data >

Partition also containing data directly.

Definition at line 259 of file Partitions.h.

Member Typedef Documentation

template<typename Data >
using geo::part::PartitionWithData< Data >::Area_t = typename Partition_t::Area_t

Type of covered area.

Definition at line 265 of file Partitions.h.

template<typename Data >
using geo::part::PartitionWithData< Data >::Base_t = Partition<Data>

Base class.

Definition at line 262 of file Partitions.h.

template<typename Data >
using geo::part::PartitionWithData< Data >::Data_t = typename Partition_t::Data_t

Type of contained data.

Definition at line 264 of file Partitions.h.

template<typename Data >
using geo::part::PartitionWithData< Data >::Partition_t = Partition<Data>

Base type of the partition.

Definition at line 263 of file Partitions.h.

template<typename Data>
using geo::part::Partition< Data >::Subpartitions_t = std::vector<std::unique_ptr<Partition_t const>>
inherited

Type of list of subpartitions. It needs to preserve polymorphism.

Definition at line 180 of file Partitions.h.

Constructor & Destructor Documentation

template<typename Data >
geo::part::PartitionWithData< Data >::PartitionWithData ( Area_t const &  area,
Data_t myData 
)
inline

Constructor: sets the covered area and the contained datum.

Definition at line 268 of file Partitions.h.

268 : Base_t(area), myData(myData) {}
Area_t const & area() const
Returns the covered area.
Definition: Partitions.h:48
Data_t * myData
The contained datum.
Definition: Partitions.h:280
Partition< Data > Base_t
Base class.
Definition: Partitions.h:262

Member Function Documentation

Area_t const& geo::part::AreaOwner::area ( ) const
inlineinherited
template<typename Data >
virtual Data_t* geo::part::PartitionWithData< Data >::atPoint ( double  w,
double  d 
) const
inlineoverridevirtual

Returns stored datum only if point is covered, nullptr otherwise.

Implements geo::part::Partition< Data >.

Reimplemented in geo::part::PartitionContainer< Data >.

Definition at line 274 of file Partitions.h.

275  {
276  return Base_t::contains(w, d) ? myData : nullptr;
277  }
bool contains(double w, double d) const
Returns whether the specified point is covered by this object.
Definition: Partitions.h:45
Float_t d
Definition: plot.C:235
Data_t * myData
The contained datum.
Definition: Partitions.h:280
Float_t w
Definition: plot.C:20
bool geo::part::AreaOwner::contains ( double  w,
double  d 
) const
inlineinherited

Returns whether the specified point is covered by this object.

Definition at line 45 of file Partitions.h.

References geo::part::AreaOwner::area(), and lar::util::simple_geo::Rectangle< Data >::contains().

45 { return area().contains(w, d); }
bool contains(Data_t w, Data_t d) const
Returns whether the specified point is in the area.
Definition: SimpleGeo.h:441
Float_t d
Definition: plot.C:235
Area_t const & area() const
Returns the covered area.
Definition: Partitions.h:48
Float_t w
Definition: plot.C:20
template<typename Data >
virtual Data_t* geo::part::PartitionWithData< Data >::data ( ) const
inlineoverridevirtual

Returns the datum directly stored (nullptr if none).

Reimplemented from geo::part::Partition< Data >.

Definition at line 271 of file Partitions.h.

Referenced by geo::part::GridPartition< Data >::doDescribe().

271 { return myData; }
Data_t * myData
The contained datum.
Definition: Partitions.h:280
template<typename Data>
std::string geo::part::Partition< Data >::describe ( std::string  indent,
std::string  firstIndent 
) const
inlineinherited

Returns a description of the partition.

Definition at line 204 of file Partitions.h.

205  {
206  return doDescribe(indent, firstIndent);
207  }
virtual std::string doDescribe(std::string indent, std::string firstIndent) const
Returns a description of the partition.
Definition: Partitions.h:243
std::string indent(std::size_t const i)
template<typename Data>
std::string geo::part::Partition< Data >::describe ( std::string  indent = "") const
inlineinherited

Returns a description of the partition.

Definition at line 210 of file Partitions.h.

References geo::part::Partition< Data >::describe(), and art::detail::indent().

Referenced by geo::part::Partition< Data >::describe().

210 { return describe(indent, indent); }
std::string indent(std::size_t const i)
std::string describe(std::string indent, std::string firstIndent) const
Returns a description of the partition.
Definition: Partitions.h:204
std::string geo::part::PartitionBase::describeArea ( std::string  indent,
std::string  firstIndent 
) const
inlineprotectedinherited

Returns a description of the partition area.

Definition at line 551 of file Partitions.h.

References geo::part::AreaOwner::dumpArea().

Referenced by geo::part::Partition< Data >::doDescribe().

553 {
554  std::ostringstream sstr;
555  sstr << firstIndent << "partition covers ";
556  dumpArea(sstr);
557  return sstr.str();
558 }
void dumpArea(Stream &&out) const
Output the owned area into an output stream.
Definition: Partitions.h:52
template<typename Data >
std::string geo::part::PartitionWithData< Data >::doDescribe ( std::string  indent,
std::string  firstIndent 
) const
overrideprivatevirtual

Returns a description of the partition.

Reimplemented from geo::part::Partition< Data >.

Reimplemented in geo::part::GridPartition< Data >, and geo::part::PartitionContainer< Data >.

Definition at line 729 of file Partitions.h.

References geo::part::describePartitionData().

731 {
732  std::string msg = Base_t::doDescribe(indent, firstIndent);
733  if (data()) {
734  std::ostringstream sstr;
735  sstr << ": ";
737  msg += sstr.str();
738  }
739  else {
740  msg += " (no data)";
741  }
742  return msg;
743 }
void describePartitionData(Stream &&out, Data const *data, std::string indent="", std::string firstIndent="")
Describes a data object for Partition::describe() method.
Definition: Partitions.h:697
virtual std::string doDescribe(std::string indent, std::string firstIndent) const
Returns a description of the partition.
Definition: Partitions.h:243
std::string indent(std::size_t const i)
virtual Data_t * data() const override
Returns the datum directly stored (nullptr if none).
Definition: Partitions.h:271
template<typename Stream >
void geo::part::AreaOwner::dumpArea ( Stream &&  out) const
inlineinherited

Output the owned area into an output stream.

Definition at line 52 of file Partitions.h.

References geo::part::AreaOwner::area().

Referenced by geo::part::PartitionBase::describeArea().

53  {
54  std::forward<Stream>(out) << area();
55  }
Area_t const & area() const
Returns the covered area.
Definition: Partitions.h:48
template<typename Data>
std::size_t geo::part::Partition< Data >::nParts ( ) const
inlineinherited

Returns the number of subparts in the partition (0 if simple element).

Definition at line 234 of file Partitions.h.

Referenced by geo::part::GridPartition< Data >::detectSeparators().

234 { return parts().size(); }
virtual Subpartitions_t const & parts() const
Returns a list of all subpartitions.
Definition: Partitions.h:240
template<typename Data>
virtual Subpartitions_t const& geo::part::Partition< Data >::parts ( ) const
inlineprotectedvirtualinherited

Returns a list of all subpartitions.

Reimplemented in geo::part::PartitionContainer< Data >.

Definition at line 240 of file Partitions.h.

Referenced by geo::part::Partition< Data >::walk().

240 { return NoSubparts; }
static Subpartitions_t const NoSubparts
Subpartitions (if any).
Definition: Partitions.h:237
template<typename Data>
template<typename Pred >
void geo::part::Partition< Data >::walk ( Pred &&  pred) const
inlineinherited

Applies pred to all partitions.

Template Parameters
Preda predicate type
Parameters
predthe predicate to be applied

The predicate pred is applied to this partition first, and then to all subpartitions in no specified order.

The predicate is any object behaving like a unary function of signature:

void predicate(Partition<Data> const& part);

If the predicate returns a value, that value is ignored. The predicate is forwarded while "walking" through the partitions.

Definition at line 228 of file Partitions.h.

229  {
230  walk(this, pred);
231  }
void walk(Pred &&pred) const
Applies pred to all partitions.
Definition: Partitions.h:228
template<typename Data >
template<typename Pred >
void geo::part::Partition< Data >::walk ( Partition_t const *  start,
Pred &&  pred 
)
staticprotectedinherited

Applies pred to start partition first, and then to all subpartitions.

Definition at line 715 of file Partitions.h.

References geo::part::Partition< Data >::parts().

716 {
717  if (!start) return;
718  pred(*start);
719 
720  // recursive implementation
721  for (auto const& subPart : start->parts())
722  subPart->walk(std::forward<Pred>(pred));
723 }

Member Data Documentation

template<typename Data >
Data_t* geo::part::PartitionWithData< Data >::myData
private

The contained datum.

Definition at line 280 of file Partitions.h.

template<typename Data>
geo::part::Partition< Data >::Subpartitions_t const geo::part::Partition< Data >::NoSubparts
staticprotectedinherited

Subpartitions (if any).

Definition at line 237 of file Partitions.h.


The documentation for this class was generated from the following file: