#include <RW_algo.h>
Inheritance diagram for RWAlgo:
Public Member Functions | |
RWAlgo (TrapperDoc *pDoc_, std::set< db_recno_t > &recnoList, AlgoParam *param) | |
~RWAlgo () | |
virtual void | start ()=0 |
MAl * | getMAl () |
Private Attributes | |
MAl * | mal |
Derive from this class if you want to write an algorithm which modifies the data in some way. Changes made to the data via the MAl interface will be automatically reflected in the database, without the programmer having to worry about the DB.
The MAl and MAl_readonly functionality is provided by the getMAl() function.
SOP for creating a new RW algorithm (called NewAlgo in this example):
newalgo.h (include guards etc omitted):
#include "RW_algo.h" class NewAlgo : public RWAlgo { public: NewAlgo(TrapperDoc * pDoc_, std::set< db_recno_t >& recnoList, AlgoParam* param) : RWAlgo(pDoc_, recnoList, param) {} void start(); };
That's it. The new algo implements the start() function and has to call RWAlgo's only constructor. start() can be virtual if a family of algos are being constructed.
NOTA BENE! Important that the constructor gets a reference to the recnolist!
newalgo.cpp:
#include "newalgo.h" void NewAlgo::start() { //implementation of NewAlgo::start(). }
newalgomaker.cpp:
#include "algomaker.h" #include "newalgo.h" char newAlgo[]="New Algo";//The text that shows up in the popup const bool newPopsup = true;//true if it should pop up in context menu template const AlgoMakerTP< NewAlgo, newAlgo, newPopsup > AlgoMakerTP< NewAlgo, newAlgo, newPopsup >::registerThis;
Add the new files to src.pro and you're done.
Definition at line 68 of file RW_algo.h.
|
Definition at line 3 of file RW_algo.cc. 00003 : 00004 Algo(pDoc_, recnoList, param), 00005 mal( new MAl(2000, recnoList, pDoc_) ) 00006 { 00007 00008 }
|
|
Definition at line 72 of file RW_algo.h. References mal. 00072 { delete mal; }
|
|
Definition at line 76 of file RW_algo.h. References mal. Referenced by TrashAlgo::check_qual_in_win(), DnpSortAlgo::init(), TrashAlgo::kill_read(), SortAlgo::old_start(), TrashRemoveAlgo::start(), TrashAlgo::start(), SubsetAlgo::start(), SortAlgo::start(), RemoveAlgo::start(), RealignerAlgo::start(), ReadnamesAlgo::start(), PrintAlgo::start(), DnpSortAlgo::start(), DnpAlgo::start(), ConsAlgo::start(), and TrashAlgo::trash(). 00076 { return mal; }
|
|
Implements Algo. Implemented in ConsAlgo, DnpAlgo, DnpSortAlgo, PrintAlgo, ReadnamesAlgo, RealignerAlgo, RemoveAlgo, SortAlgo, SubsetAlgo, TrashAlgo, and TrashRemoveAlgo. |
|
Definition at line 79 of file RW_algo.h. Referenced by getMAl(), DnpAlgo::start(), ConsAlgo::start(), and ~RWAlgo(). |