Feature Selection Toolbox FST4
UTIA · Czech Academy of Sciences
Loading...
Searching...
No Matches
FST::Clonable_Impl< Derived, Base, DEEP_KIND, SHARING_KIND, STATELESS_KIND > Class Template Reference

CRTP mixin implementing the Clonable protocol for a concrete class. More...

#include <clonable.hpp>

Inheritance diagram for FST::Clonable_Impl< Derived, Base, DEEP_KIND, SHARING_KIND, STATELESS_KIND >:
FST::Classifier_kNN< RETURNTYPE, DATATYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR, DIST_L2 > FST::Classifier_kNN< RETURNTYPE, DATATYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR, DIST_L1 > FST::Classifier_kNN< RETURNTYPE, DATATYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR, DIST_LP > FST::Criterion_Wrapper< RETURNTYPE, SUBSET, REGRESSOR, DATAACCESSOR > FST::Data_Accessor_Splitting_MemARFF< DATATYPE, IDXTYPE, INTERVALLER > FST::Data_Accessor_Splitting_MemCSV< DATATYPE, IDXTYPE, INTERVALLER > FST::Data_Accessor_Splitting_MemTRN< DATATYPE, IDXTYPE, INTERVALLER > FST::Data_Accessor_Universe< DATATYPE, IDXTYPE, INTERVALLER > FST::Data_Splitter_5050< INTERVALLER, IDXTYPE > FST::Data_Splitter_CV< INTERVALLER, IDXTYPE > FST::Data_Splitter_Holdout< INTERVALLER, IDXTYPE > FST::Data_Splitter_Leave1Out< INTERVALLER, IDXTYPE > FST::Data_Splitter_RandomRandom< INTERVALLER, IDXTYPE, BINTYPE > FST::Data_Splitter_Resub< INTERVALLER, IDXTYPE > FST::Data_Splitter_TrainRandom_TestFixed< INTERVALLER, IDXTYPE, BINTYPE > FST::Distance_Lp< DATATYPE, REALTYPE, DIMTYPE, SUBSET, 3, 2 > FST::Regressor_Weighted_Neighbours< RETURNTYPE, DATATYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR, DIST_L2 >

Public Member Functions

Base * clone () const override
 dispatches to the DEEP_KIND mechanism (default CLONE_DEEP: Derived's copy-constructor)
Base * sharing_clone () const override
 dispatches to the SHARING_KIND mechanism (default CLONE_INHERIT: defers to Base, which throws by family convention)
Base * stateless_clone () const override
 dispatches to the STATELESS_KIND mechanism (default CLONE_INHERIT: defers to Base, which throws by family convention)

Private Types

enum  Slot { SLOT_CLONE , SLOT_SHARING , SLOT_STATELESS }
 < inherits Base's constructors, so Derived need not repeat them

Private Member Functions

const Derived & self () const
template<CloneKind K, Slot S>
Base * make () const
 Constructs the clone per CloneKind K, for the override slot S (see Slot). Only the branch selected by K is ever instantiated (if constexpr), so e.g. a class with no weak copy-constructor never instantiates the CLONE_WEAK path just because some OTHER class's Clonable_Impl instantiation elsewhere uses it.

Detailed Description

template<class Derived, class Base, CloneKind DEEP_KIND = CLONE_DEEP, CloneKind SHARING_KIND = CLONE_INHERIT, CloneKind STATELESS_KIND = CLONE_INHERIT>
class FST::Clonable_Impl< Derived, Base, DEEP_KIND, SHARING_KIND, STATELESS_KIND >

CRTP mixin implementing the Clonable protocol for a concrete class.

Usage: class X : public Clonable_Impl<X<args...>, Family_Base<args...> > {...}; Concrete classes never write clone()/sharing_clone()/stateless_clone() bodies of their own – this mixin implements all three uniformly, which is what keeps the clone/sharing flags consistent across the library. The three slot parameters select the mechanism per clone kind; the default is a deep clone via Derived's copy-constructor with the other two kinds deferred to the family base (whose defaults throw).

Notes:

  • Derived's copy-constructor remains responsible for correct member-wise deep-copy semantics (e.g. cloning wrapped Clonable members instead of sharing them).
  • If Derived's copy-constructor is non-public, add 'friend parent;' (where parent is the class-local typedef of this mixin instantiation) to Derived.
  • A class deriving from a Clonable_Impl-using concrete class must insert its own Clonable_Impl layer, otherwise clone() would slice; this is asserted at runtime in debug builds.
  • set_cloned()/set_sharing_cloned() is applied uniformly, so is_clone()/is_sharing() answer correctly for every clone produced through this mixin.
Template Parameters
Derivedthe concrete class being equipped (the CRTP self type)
Basethe family's abstract base, which must itself derive from Clonable
DEEP_KINDmechanism backing clone()
SHARING_KINDmechanism backing sharing_clone()
STATELESS_KINDmechanism backing stateless_clone()

Member Function Documentation

◆ clone()

◆ self()

template<class Derived, class Base, CloneKind DEEP_KIND = CLONE_DEEP, CloneKind SHARING_KIND = CLONE_INHERIT, CloneKind STATELESS_KIND = CLONE_INHERIT>
const Derived & FST::Clonable_Impl< Derived, Base, DEEP_KIND, SHARING_KIND, STATELESS_KIND >::self ( ) const
inlineprivate

Casts to Derived, asserting the dynamic type actually IS Derived (catches a more-derived class that forgot its own Clonable_Impl layer, which would otherwise slice on clone).

◆ sharing_clone()

◆ stateless_clone()


The documentation for this class was generated from the following file:
Copyright © 2000–present ÚTIA, Institute of Information Theory and Automation of the Czech Academy of Sciences · Contacts · This site sets no cookies and uses no analytics.