summaryrefslogtreecommitdiffabout
path: root/include/sitecing/acomponent.h
blob: 160e8547e65b2ba1315e583216d59e991ab9b8eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef __SITECING_ACOMPONENT_H
#define __SITECING_ACOMPONENT_H

#include "sitecing/sitecing_interface.h"

/**
 * @file
 * @brief The acomponent class declaration.
 */

namespace sitecing {

    /**
     * An abstract base class for sitecing components.
     */
    class acomponent {
	public:
	    /**
	     * Pointer to the interface object, used to communicate with the
	     * site-C-ing core.
	     */
	    sitecing_interface *__SCIF;

	    acomponent();
	    virtual ~acomponent();

	    /**
	     * Set the interface to core pointer.
	     * @param scif the pointer to the interface object.
	     */
	    virtual void __set_interface(sitecing_interface *scif=0);
	    /**
	     * Invoked if the interface to the core has changed.
	     * @param oscif pointer to the old interface object.
	     */
	    virtual void __on_change_interface(sitecing_interface *oscif);

	    /**
	     * do import components.
	     */
	    virtual void __do_imports();
	    /**
	     * invoked on components imports.
	     */
	    virtual void __on_imports();
	    /**
	     * fetch the pointer to the most derived component.
	     * @returns pointer to the most derived object.
	     */
	    virtual void *__the_most_derived_this() = 0;

	    /**
	     * Do the job.
	     * @param __magic the magic number used as a key to decipher the
	     * rest of parameters.
	     * @param __args the parameters.
	     */
	    virtual void main(int __magic,va_list __args) = 0;

	    /**
	     * Run the component. Convenience helper for calling main().
	     * @param __magic the magic number.
	     * @param ... the rest of parameters.
	     * @see main();
	     */
	    void run(int __magic,...);

	    /**
	     * Helper function (which doesn't necessarily belongs here!) for
	     * reading the file and passing it to the output stream.
	     * @param fn the file name.
	     */
	    void pass_file_through(const char *fn);
    };

}

#endif /* __SITECING_ACOMPONENT_H */