Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
geo::part::PartitionContainer< Data > Class Template Referenceabstract

Partition divided in subpartitions (abstract). More...

#include <Partitions.h>

Inheritance diagram for geo::part::PartitionContainer< Data >:
geo::part::PartitionWithData< Data > geo::part::Partition< Data > geo::part::PartitionBase geo::part::AreaOwner geo::part::GridPartition< Data > geo::part::SortedPartition< Data, Sorter >

Public Types

using Base_t = PartitionWithData< Data >
 Base class. More...
 
using Partition_t = Partition< Data >
 Base type of the partition. More...
 
using Data_t = typename Partition_t::Data_t
 
using Area_t = typename Partition_t::Area_t
 
using Subpartitions_t = typename Partition_t::Subpartitions_t
 
- Public Types inherited from geo::part::PartitionWithData< Data >
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...
 
- Public Types inherited from geo::part::Partition< Data >
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...
 
- Public Types inherited from geo::part::PartitionBase
using Area_t = AreaOwner::Area_t
 
using AreaRangeMember_t = AreaOwner::AreaRangeMember_t
 
- Public Types inherited from geo::part::AreaOwner
using Area_t = lar::util::simple_geo::Rectangle< double >
 Type of area covered by the partition. More...
 
using AreaRangeMember_t = Area_t::Range_t(Area_t::*)
 Type of pointer to Area_t data member of type Range_t. More...
 

Public Member Functions

virtual Data_tatPoint (double w, double d) const override
 Returns stored datum only if point is covered, nullptr otherwise. More...
 
- Public Member Functions inherited from geo::part::PartitionWithData< Data >
 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...
 
- Public Member Functions inherited from geo::part::Partition< Data >
 Partition (Area_t const &area)
 Constructor: sets the covered area and no subpartitions. More...
 
virtual ~Partition ()=default
 Destructor (default, virtual). 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...
 
- Public Member Functions inherited from geo::part::PartitionBase
 PartitionBase (Area_t const &area)
 Constructor: sets the covered area and no subpartitions. More...
 
- Public Member Functions inherited from geo::part::AreaOwner
 AreaOwner (Area_t const &area)
 Constructor: sets the covered area and no subpartitions. 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

std::size_t size () const
 Returns the number of contained subpartitions. More...
 
virtual Subpartitions_t const & parts () const override
 Returns a list of the subpartitions owned. More...
 
 PartitionContainer (Area_t const &area, Subpartitions_t &&subpartitions, Data_t *defData=nullptr)
 Constructor: sets the partition. More...
 
virtual Partition_t const * findPart (double w, double d) const =0
 Returns the only partition which could contain the specified width. More...
 
virtual std::string doDescribe (std::string indent, std::string firstIndent) const override
 Describes this and each of the subpartitions. More...
 
virtual std::string describeIntro () const
 Introduction to the description of the subpartitions. More...
 
- Protected Member Functions inherited from geo::part::PartitionBase
std::string describeArea (std::string indent, std::string firstIndent) const
 Returns a description of the partition area. More...
 

Protected Attributes

Subpartitions_t myParts
 List of subpartitions. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from geo::part::Partition< Data >
template<typename Pred >
static void walk (Partition_t const *start, Pred &&pred)
 
- Static Protected Attributes inherited from geo::part::Partition< Data >
static Subpartitions_t const NoSubparts
 Subpartitions (if any). More...
 

Detailed Description

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

Partition divided in subpartitions (abstract).

Definition at line 322 of file Partitions.h.

Member Typedef Documentation

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

Definition at line 330 of file Partitions.h.

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

Base class.

Definition at line 325 of file Partitions.h.

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

Definition at line 329 of file Partitions.h.

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

Base type of the partition.

Definition at line 326 of file Partitions.h.

template<typename Data >
using geo::part::PartitionContainer< Data >::Subpartitions_t = typename Partition_t::Subpartitions_t

Definition at line 331 of file Partitions.h.

Constructor & Destructor Documentation

template<typename Data >
geo::part::PartitionContainer< Data >::PartitionContainer ( Area_t const &  area,
Subpartitions_t &&  subpartitions,
Data_t defData = nullptr 
)
inlineprotected

Constructor: sets the partition.

Parameters
areaoverall area covered
subpartitionslist of subpartitions (pointers)
defDatadatum to be returned for points not covered by subpartitions

The subpartitions will be moved from the argument.

It is required and assumed that the subpartitions do not overlap and that the points covered by them are a subset of area. Neither of theses requirements is checked.

Definition at line 358 of file Partitions.h.

363  : Base_t(area, defData), myParts(std::move(subpartitions))
364  {}
PartitionWithData< Data > Base_t
Base class.
Definition: Partitions.h:325
def move(depos, offset)
Definition: depos.py:107
Area_t const & area() const
Returns the covered area.
Definition: Partitions.h:56
Subpartitions_t myParts
List of subpartitions.
Definition: Partitions.h:337

Member Function Documentation

template<typename Data >
auto geo::part::PartitionContainer< Data >::atPoint ( double  w,
double  d 
) const
overridevirtual

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

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

Definition at line 841 of file Partitions.h.

843 {
844  if (!Base_t::contains(w, d)) return nullptr; // not our point at all
845  // it's ours; see if it belongs to a subpart
846  auto part = findPart(w, d);
847  return part? part->atPoint(w, d): Base_t::data();
848 } // geo::part::PartitionContainer<Data>::atPoint()
bool contains(double w, double d) const
Returns whether the specified point is covered by this object.
Definition: Partitions.h:52
virtual Partition_t const * findPart(double w, double d) const =0
Returns the only partition which could contain the specified width.
virtual Data_t * data() const override
Returns the datum directly stored (nullptr if none).
Definition: Partitions.h:289
template<typename Data >
std::string geo::part::PartitionContainer< Data >::describeIntro ( ) const
protectedvirtual

Introduction to the description of the subpartitions.

Definition at line 875 of file Partitions.h.

875  {
876  return std::to_string(parts().size()) + " subpartitions";
877 } // geo::part::PartitionContainer<Data>::describeIntro()
std::size_t size() const
Returns the number of contained subpartitions.
Definition: Partitions.h:340
virtual Subpartitions_t const & parts() const override
Returns a list of the subpartitions owned.
Definition: Partitions.h:343
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
template<typename Data >
std::string geo::part::PartitionContainer< Data >::doDescribe ( std::string  indent,
std::string  firstIndent 
) const
overrideprotectedvirtual

Describes this and each of the subpartitions.

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

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

Definition at line 854 of file Partitions.h.

855 {
856  std::string msg = firstIndent + describeIntro();
857  if (Base_t::data()) {
858  std::ostringstream sstr;
859  sstr << ", and ";
861  msg += sstr.str();
862  }
863 
864  for (auto const& part: parts()) {
865  msg += "\n" + indent + " * ";
866  msg += part->describe(indent + " ", "");
867  }
868 
869  return msg;
870 } // geo::part::PartitionContainer<Data>::doDescribe()
void describePartitionData(Stream &&out, Data const *data, std::string indent="", std::string firstIndent="")
Describes a data object for Partition::describe() method.
Definition: Partitions.h:784
void msg(const char *fmt,...)
Definition: message.cpp:107
std::string string
Definition: nybbler.cc:12
virtual Subpartitions_t const & parts() const override
Returns a list of the subpartitions owned.
Definition: Partitions.h:343
virtual Data_t * data() const override
Returns the datum directly stored (nullptr if none).
Definition: Partitions.h:289
virtual std::string describeIntro() const
Introduction to the description of the subpartitions.
Definition: Partitions.h:875
template<typename Data >
virtual Partition_t const* geo::part::PartitionContainer< Data >::findPart ( double  w,
double  d 
) const
protectedpure virtual

Returns the only partition which could contain the specified width.

Implemented in geo::part::GridPartition< Data >.

template<typename Data >
virtual Subpartitions_t const& geo::part::PartitionContainer< Data >::parts ( ) const
inlineoverrideprotectedvirtual

Returns a list of the subpartitions owned.

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

Definition at line 343 of file Partitions.h.

343 { return myParts; }
Subpartitions_t myParts
List of subpartitions.
Definition: Partitions.h:337
template<typename Data >
std::size_t geo::part::PartitionContainer< Data >::size ( void  ) const
inlineprotected

Returns the number of contained subpartitions.

Definition at line 340 of file Partitions.h.

340 { return parts().size(); }
virtual Subpartitions_t const & parts() const override
Returns a list of the subpartitions owned.
Definition: Partitions.h:343

Member Data Documentation

template<typename Data >
Subpartitions_t geo::part::PartitionContainer< Data >::myParts
protected

List of subpartitions.

Definition at line 337 of file Partitions.h.


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