tesseract  v4.0.0-17-g361f3264
Open Source OCR Engine
UnicityTable< T > Class Template Reference

#include <fontinfo.h>

Inheritance diagram for UnicityTable< T >:
Collaboration diagram for UnicityTable< T >:

Public Member Functions

 UnicityTable ()
 
 ~UnicityTable ()
 Clear the structures and deallocate internal structures. More...
 
void reserve (int size)
 
int size () const
 Return the size used. More...
 
const T & get (int id) const
 Return the object from an id. More...
 
T * get_mutable (int id)
 
int get_id (T object) const
 
bool contains (T object) const
 Return true if T is in the table. More...
 
contains_id (int id) const
 Return true if the id is valid. More...
 
int push_back (T object)
 Add an element in the table. More...
 
void set_clear_callback (TessCallback1< T > *cb)
 
void set_compare_callback (TessResultCallback2< bool, T const &, T const &> *cb)
 
void clear ()
 
void move (UnicityTable< T > *from)
 
bool write (FILE *f, TessResultCallback2< bool, FILE *, T const &> *cb) const
 
bool read (tesseract::TFile *f, TessResultCallback2< bool, tesseract::TFile *, T *> *cb)
 

Private Attributes

GenericVector< T > table_
 
TessResultCallback2< bool, T const &, T const & > * compare_cb_
 

Constructor & Destructor Documentation

◆ UnicityTable()

template<typename T >
UnicityTable< T >::UnicityTable ( )

◆ ~UnicityTable()

template<typename T >
UnicityTable< T >::~UnicityTable ( )

Clear the structures and deallocate internal structures.

Member Function Documentation

◆ clear()

template<typename T >
void UnicityTable< T >::clear ( )

Clear the table, calling the callback function if any. All the owned Callbacks are also deleted. If you don't want the Callbacks to be deleted, before calling clear, set the callback to nullptr.

◆ contains()

template<typename T>
bool UnicityTable< T >::contains ( object) const

Return true if T is in the table.

◆ contains_id()

template<typename T >
T UnicityTable< T >::contains_id ( int  id) const

Return true if the id is valid.

◆ get()

template<typename T >
const T & UnicityTable< T >::get ( int  id) const

Return the object from an id.

◆ get_id()

template<typename T>
int UnicityTable< T >::get_id ( object) const

Return the id of the T object. This method NEEDS a compare_callback to be passed to set_compare_callback.

◆ get_mutable()

template<typename T >
T * UnicityTable< T >::get_mutable ( int  id)

◆ move()

template<typename T>
void UnicityTable< T >::move ( UnicityTable< T > *  from)

This method clear the current object, then, does a shallow copy of its argument, and finally invalidate its argument.

◆ push_back()

template<typename T>
int UnicityTable< T >::push_back ( object)

Add an element in the table.

◆ read()

template<typename T>
bool UnicityTable< T >::read ( tesseract::TFile f,
TessResultCallback2< bool, tesseract::TFile *, T *> *  cb 
)

◆ reserve()

template<typename T >
void UnicityTable< T >::reserve ( int  size)

Reserve some memory. If there is size or more elements, the table will then allocate size * 2 elements.

◆ set_clear_callback()

template<typename T>
void UnicityTable< T >::set_clear_callback ( TessCallback1< T > *  cb)

Add a callback to be called to delete the elements when the table took their ownership.

◆ set_compare_callback()

template<typename T>
void UnicityTable< T >::set_compare_callback ( TessResultCallback2< bool, T const &, T const &> *  cb)

Add a callback to be called to compare the elements when needed (contains, get_id, ...)

◆ size()

template<typename T >
int UnicityTable< T >::size ( ) const

Return the size used.

◆ write()

template<typename T>
bool UnicityTable< T >::write ( FILE *  f,
TessResultCallback2< bool, FILE *, T const &> *  cb 
) const

Read/Write the table to a file. This does NOT read/write the callbacks. The Callback given must be permanent since they will be called more than once. The given callback will be deleted at the end. Returns false on read/write error.

Member Data Documentation

◆ compare_cb_

template<typename T>
TessResultCallback2<bool, T const &, T const &>* UnicityTable< T >::compare_cb_
mutableprivate

◆ table_

template<typename T>
GenericVector<T> UnicityTable< T >::table_
private

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