LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
geo::part::Partition< Data > Class Template Referenceabstract

Base element of a partitioned structure. More...

#include "Partitions.h"

Inheritance diagram for geo::part::Partition< Data >:
geo::part::PartitionBase geo::part::AreaOwner geo::part::PartitionWithData< Data > 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 Data_t = Data
 Type of data stored in the partition. More...
 
using Partition_t = Partition< Data >
 This type. More...
 
using Area_t = PartitionBase::Area_t
 Type of 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

 Partition (Area_t const &area)
 Constructor: sets the covered area and no subpartitions. More...
 
virtual ~Partition ()=default
 Destructor (default, virtual). More...
 
virtual Data_tdata () const
 Returns the datum directly stored (nullptr if none). More...
 
virtual Data_tatPoint (double w, double d) const =0
 Returns the (sub)partition including the specified coordinates. 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...
 
virtual std::string doDescribe (std::string indent, std::string firstIndent) const
 Returns a description of the partition. 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)
 

Static Protected Attributes

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

Detailed Description

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

Base element of a partitioned structure.

Template Parameters
Datatype of data contained in the partition

An area partition is represented by a hierarchy of partition objects, each one containing a non-owning pointer to the data pertaining its area.

The partition classes all derive from this Partition class, which provides access to the data, the area definition and a few utility functions:

  • mainly for debugging purposes, the hierarchy can be dumped into a stream by the describe() method
  • method walk() applies a specified operation to all the partitions in the hierarchy, in an undefined order
  • method atPoint() returns the data of the partition covering the specified location

The hierarchy is such that a partition object (Partition) knows or can find of all the subpartitions it contains, but it does not have any knowledge of the partition containing it (if any).

The partition classes do not provide algorithms to establish their relations.

Definition at line 183 of file Partitions.h.

Member Typedef Documentation

template<typename Data>
using geo::part::Partition< Data >::Area_t = PartitionBase::Area_t

Type of area.

Definition at line 188 of file Partitions.h.

template<typename Data>
using geo::part::Partition< Data >::Data_t = Data

Type of data stored in the partition.

Definition at line 186 of file Partitions.h.

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

This type.

Definition at line 187 of file Partitions.h.

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

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

Definition at line 191 of file Partitions.h.

Constructor & Destructor Documentation

template<typename Data>
geo::part::Partition< Data >::Partition ( Area_t const &  area)
inline

Constructor: sets the covered area and no subpartitions.

Definition at line 194 of file Partitions.h.

194 : PartitionBase(area) {}
PartitionBase(Area_t const &area)
Constructor: sets the covered area and no subpartitions.
Definition: Partitions.h:148
Area_t const & area() const
Returns the covered area.
Definition: Partitions.h:53
template<typename Data>
virtual geo::part::Partition< Data >::~Partition ( )
virtualdefault

Destructor (default, virtual).

Member Function Documentation

template<typename Data>
virtual Data_t* geo::part::Partition< Data >::atPoint ( double  w,
double  d 
) const
pure virtual

Returns the (sub)partition including the specified coordinates.

Parameters
wwidth coordinate of the point
ddepth coordinate of the point
Returns
a pointer to the partition, or nullptr if none

This method returns a pointer to the datum associated to the area the specified point (w, d) belongs to. The area is searched for among all the included partitions.

Implemented in geo::part::PartitionContainer< Data >, and geo::part::PartitionWithData< Data >.

bool geo::part::AreaOwner::contains ( double  w,
double  d 
) const
inlineinherited

Returns whether the specified point is covered by this object.

Definition at line 50 of file Partitions.h.

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

50 { 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:442
Float_t d
Definition: plot.C:235
Area_t const & area() const
Returns the covered area.
Definition: Partitions.h:53
Float_t w
Definition: plot.C:20
template<typename Data>
virtual Data_t* geo::part::Partition< Data >::data ( ) const
inlinevirtual

Returns the datum directly stored (nullptr if none).

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

Definition at line 200 of file Partitions.h.

References d, and w.

Referenced by geo::DriftPartitions::computeCoverage().

200 { return nullptr; }
template<typename Data>
std::string geo::part::Partition< Data >::describe ( std::string  indent,
std::string  firstIndent 
) const
inline

Returns a description of the partition.

Definition at line 215 of file Partitions.h.

216  {
217  return doDescribe(indent, firstIndent);
218  }
virtual std::string doDescribe(std::string indent, std::string firstIndent) const
Returns a description of the partition.
Definition: Partitions.h:256
std::string indent(std::size_t const i)
template<typename Data>
std::string geo::part::Partition< Data >::describe ( std::string  indent = "") const
inline

Returns a description of the partition.

Definition at line 221 of file Partitions.h.

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

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

221 { 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:215
std::string geo::part::PartitionBase::describeArea ( std::string  indent,
std::string  firstIndent 
) const
inlineprotectedinherited

Returns a description of the partition area.

Definition at line 575 of file Partitions.h.

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

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

577 {
578  std::ostringstream sstr;
579  sstr << firstIndent << "partition covers ";
580  dumpArea(sstr);
581  return sstr.str();
582 } // geo::part::PartitionBase::describeArea()
void dumpArea(Stream &&out) const
Output the owned area into an output stream.
Definition: Partitions.h:57
template<typename Data>
virtual std::string geo::part::Partition< Data >::doDescribe ( std::string  indent,
std::string  firstIndent 
) const
inlineprotectedvirtual

Returns a description of the partition.

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

Definition at line 256 of file Partitions.h.

References geo::part::PartitionBase::describeArea().

257  {
258  return PartitionBase::describeArea(indent, firstIndent);
259  }
std::string indent(std::size_t const i)
std::string describeArea(std::string indent, std::string firstIndent) const
Returns a description of the partition area.
Definition: Partitions.h:575
template<typename Stream >
void geo::part::AreaOwner::dumpArea ( Stream &&  out) const
inlineinherited

Output the owned area into an output stream.

Definition at line 57 of file Partitions.h.

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

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

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

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

Definition at line 247 of file Partitions.h.

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

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

Returns a list of all subpartitions.

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

Definition at line 253 of file Partitions.h.

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

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

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 241 of file Partitions.h.

242  {
243  walk(this, pred);
244  }
void walk(Pred &&pred) const
Applies pred to all partitions.
Definition: Partitions.h:241
template<typename Data >
template<typename Pred >
void geo::part::Partition< Data >::walk ( Partition_t const *  start,
Pred &&  pred 
)
staticprotected

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

Definition at line 748 of file Partitions.h.

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

749 {
750  if (!start) return;
751  pred(*start);
752 
753  // recursive implementation
754  for (auto const& subPart : start->parts())
755  subPart->walk(std::forward<Pred>(pred));
756 
757 } // geo::part::Partition<Data>::walk()

Member Data Documentation

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

Subpartitions (if any).

Definition at line 250 of file Partitions.h.


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