1. Using tags
2. Tag list
3. One little example
4. Tag definition
4.1 call
4.2 f
4.3 glocal
4.3.1 Using nested glocals
4.4 mod
4.5 obj
5. Creating components
5.1 Definition
5.2 Implementation
5.3 Taking advantage of the C++ implementation
5.4 Calling functags
5.5 Extending the functor classes
5.6 Adding content to the functor
5.7 Grabbing the functor address
Top Up

5.5 Extending the functor classes


For a component foo, there is a struct _F_foo. We know functags are member functions of a class derived from _F_foo. What differentiate a functag from another member function. Not much in fact. Beside it special declaration (using preprocessor macros) a functag is just a virtual member function. From a functag, we are allowed to call other member function of the class _F_foo. In general, those extra member function are not virtual since Extending class such as _F_foo is convenient to provide a richer runtime environment to functags. This generally offers convenience to the client code of a component (avoid redundant details) and provides more control to the component itself.

Here is a small example. First we have the component definition. In this component (some sort of iterator), we add two member function to offers greater control over the iteration.

#define _TLMP_foo
struct _F_foo {
	// Called if the result set if empty, so there won't be any
	// iteration (no start, loop and end functag called)
	#define _F_foo_empty(n) void n empty()
	virtual _F_foo_sempty( );
	// Called at the start of the iteration
	#define _F_foo_start(n) void n start()
	virtual _F_foo_start( );
	// Called for every step of the iteration
	#define _F_foo_loop(n) void n loop(int count)
	virtual _F_foo_loop( )=0;
	// Called at the end of the iteration
	#define _F_foo_end(n) void n end()
	virtual _F_foo_end( );
	// Restart the iteration
	void rewind();
	// Seek to a specific position
	int seek (int pos);

Then we use the component. In functags, we are allowed to use the rewind and seek function.
Top Up

One big HTML document