sx360::sxEvent Class Reference

#include <sxevent.h>

Collaboration diagram for sx360::sxEvent:

Collaboration graph
[legend]
List of all members.


Public Member Functions

  sxEvent (sxPunchFile *f)
virtual void  execute ()=0
virtual  ~sxEvent ()

Protected Attributes

sxPunchFile pf_

sxEvent is an abstract class that provides the basis for the very basic event handling structure in sx360.  Descendents of this class will override the execute member function.  Clients then derive their own class from that, utilizing their own execute member function to update GUI elements, etc.

While not the most compact way to perform this task, it is not a common event that the this sort of handling will be needed.  As such, there is only one instance of sxEvent in the library.

If the client has assigned a subclass of sxEvent to the recordChangeEvent of sxIterator, then the execute member function will be called every time the record pointer is moved in the sxIterator.  An example:

class MyEvent : public sxEvent
{
public:
    MyEvent(sxPunchFile* f) : sxEvent(f) {}
    virtual void execute()
    {
        cout << "record " << pf_->getIterator()->getCurrentIndex() <<  " of "  << pf_->getRecordCount() << endl;
    }
};


//In the code

    sxEvent*  e = new MyEvent(&f);  //assume f is a valid sxPunchFile, and i is an sxIterator
    i->recordChangeEvent = e;

    //perform processing here.  For every movement of the sxIterator, it will output the current index of the iterator

    delete e;
    i->recordchangeEvent = NULL;


For the most part, you will not need to do this.  A place where this might come in handy is when you are building an index.  In that case, you have no way to access the sxIterator until processing is finished.  If you are using a GUI, this will prevent any updating of elements.  By using the method above, you can update the GUI, etc.

This is also useful if you are wrapping a large traversal of sxRecords in a separate module, and you don't wish to mix that code with GUI toolkit code, etc.


Constructor & Destructor Documentation

sx360::sxEvent::sxEvent ( sxPunchFile f  )  [inline]

virtual sx360::sxEvent::~sxEvent (
 )  [inline, virtual]


Member Function Documentation

virtual void sx360::sxEvent::execute (
 )  [pure virtual]


Member Data Documentation

sxPunchFile* sx360::sxEvent::pf_ [protected]


Generated on Tue Nov 27 03:01:43 2007 for sx360 by  doxygen 1.5.2