Loading...
Searching...
No Matches
SBCFunctor Class Reference

This class describes a functor. More...

Constructors and destructors

 SBCFunctor ()
 Constructs a functor.
 
virtual ~SBCFunctor ()
 Destructs the functor.
 

Cloning

virtual SBCFunctorclone () const
 

Detailed Description

This class describes a functor. A functor is an object of a class that acts as a function.

For example, the only purpose of the following class is to compute the distance between two atoms:

class DistanceCalculator : public SBFunctor2<SBQuantity::length, SBAtom*, SBAtom*> {
public:
DistanceCalculator() {}
virtual ~DistanceCalculator() {}
SBQuantity::length operator(SBAtom* atom1, SBAtom atom2) {
return (atom1->getPosition() - atom2->getPosition()).norm();
}
};
This template class defines physical quantity types.
Definition: SBDQuantityType.hpp:43
This class describes an atom in a structural model.
Definition: SBMStructuralModelNodeAtom.hpp:34
SBPosition3 const & getPosition() const
Returns the atom's position.
Definition: SBMStructuralModelNodeAtom.cpp:330

The class SBCFunctor is the base class of all functor classes:

  • SBCFunctor0: a functor which takes no arguments
  • SBCFunctor1: a functor which takes 1 argument
  • ...
  • SBCFunctor16: a functor which takes 16 arguments

Functors are used in several places. In particular, predicates are functors that return a boolean and which may be logically combined.

Short name: SBFunctor

See also
SBCFunctorPredicate