[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
Classes | Public Member Functions | Public Attributes
KLFPosSearchable::Pos Struct Reference

An abstract position in a searchable object. More...

#include <klfsearchbar.h>

Collaboration diagram for KLFPosSearchable::Pos:
Collaboration graph
[legend]

List of all members.

Classes

struct  PosData
 A Base class for storing abstract position data. More...

Public Member Functions

 Pos ()
 Pos (const Pos &other)
 ~Pos ()
Posoperator= (const Pos &other)
bool valid () const
bool equals (const Pos &other) const
template<class TT >
TT * data () const
 A shorthand for retrieving the posdata cast into the custom type.

Public Attributes

KLFRefPtr< PosDataposdata
 Stores the actual position data, see PosData.

Detailed Description

An abstract position in a searchable object.

Used by KLFPosSearchable to store search result positions.

A position can be invalid, or valid. The actual data representing the position is stored in a custom sub-class of PosData, to which a pointer is held in posdata.

You can construct an invalid position with the default constructor. Then just assign a data pointer to it and it becomes valid, e.g.

   Pos p = Pos();
   // p is invalid
   MyPosData *d = new MyPosData;
   d->somefield = some_data;
   d->someotherfield = some_other_data;
   p.posdata = d;
   // now p is a valid position object, storing the position represented
   // by data stored in 'somefield' and 'someotherfield'

Definition at line 97 of file klfsearchbar.h.


Constructor & Destructor Documentation

Constructs an invalid position. This initializes the data pointer to NULL.

Definition at line 146 of file klfsearchbar.h.

KLFPosSearchable::Pos::Pos ( const Pos other) [inline]

Definition at line 150 of file klfsearchbar.h.

Definition at line 154 of file klfsearchbar.h.


Member Function Documentation

template<class TT >
TT* KLFPosSearchable::Pos::data ( ) const [inline]

A shorthand for retrieving the posdata cast into the custom type.

Example:

   // Instead of:
   MyPosData * myposdata = dynamic_cast<MyPosData*>(pos.posdata);
   // we can use
   MyPosData * myposdata = pos.data<MyPosData>();

Additionally, a warning is issued if posdata is NULL or if posdata cannot by cast (with dynamic_cast<>) to the required type.

Definition at line 212 of file klfsearchbar.h.

References KLFRefPtr< T >::dyn_cast(), and KLF_ASSERT_NOT_NULL.

Referenced by equals().

bool KLFPosSearchable::Pos::equals ( const Pos other) const [inline]

Is equal to other if:

  • both this and the other position are valid, and posdata 's equals() test is true;
  • or both are invalid.
Note:
PosData's equals() test called if and only if both this and the other position are valid, i.e. have non-NULL posdata pointer.

Definition at line 180 of file klfsearchbar.h.

References data(), and valid().

Pos& KLFPosSearchable::Pos::operator= ( const Pos other) [inline]

Definition at line 160 of file klfsearchbar.h.

References KLF_DEBUG_BLOCK, KLF_FUNC_NAME, and posdata.

bool KLFPosSearchable::Pos::valid ( ) const [inline]

A position is valid if it has a non-NULL posdata pointer. It is invalid otherwise.

Definition at line 168 of file klfsearchbar.h.

References KLF_DEBUG_BLOCK, KLF_FUNC_NAME, and klfDbg.

Referenced by KLFSearchBar::emitFoundSignals(), equals(), and KLFSearchable::searchFind().


Member Data Documentation

Stores the actual position data, see PosData.

This pointer is set up by KLFPosSearchable subclasses to instanciate valid Pos objects. They may use this object transparently, just as a regular PosData* pointer, see KLFRefPtr.

Note:
PosData::ref() and PosData::deref() are handled automatically when this field is assigned. See also KLFRefPtr.

Definition at line 196 of file klfsearchbar.h.

Referenced by operator<<(), operator=(), and KLFSearchable::searchFind().


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

Generated by doxygen 1.7.6.1. The KLatexFormula website is hosted on sourceforge.net