diff options
author | Mike Buland <eichlan@xagasoft.com> | 2006-05-01 17:11:04 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2006-05-01 17:11:04 +0000 |
commit | f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54 (patch) | |
tree | 53cec4864776e07950e3c72f2a990a1017d08045 /src/programchain.h | |
download | libbu++-f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54.tar.gz libbu++-f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54.tar.bz2 libbu++-f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54.tar.xz libbu++-f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54.zip |
libbu++ is finally laid out the way it should be, trunk, branches, and tags.
Diffstat (limited to 'src/programchain.h')
-rw-r--r-- | src/programchain.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/src/programchain.h b/src/programchain.h new file mode 100644 index 0000000..34f64f8 --- /dev/null +++ b/src/programchain.h | |||
@@ -0,0 +1,88 @@ | |||
1 | #ifndef PROGRAMCHAIN_H | ||
2 | #define PROGRAMCHAIN_H | ||
3 | |||
4 | #include "linkedlist.h" | ||
5 | #include "multilog.h" | ||
6 | #include "programlink.h" | ||
7 | |||
8 | /** The Program Chain links together program "chunks" to more easily facilitate | ||
9 | * a generalized program loop with modular extensions. | ||
10 | *@author Mike Buland | ||
11 | */ | ||
12 | class ProgramChain | ||
13 | { | ||
14 | public: | ||
15 | /** | ||
16 | * Construct an empty chain. | ||
17 | */ | ||
18 | ProgramChain(); | ||
19 | |||
20 | /** | ||
21 | * Destroy your chain. | ||
22 | */ | ||
23 | ~ProgramChain(); | ||
24 | |||
25 | /** Adds a link to the end of the chain. | ||
26 | *@param pLink A pointer to the link to add to the chain. | ||
27 | *@returns True if adding the link was successful, otherwise false | ||
28 | *@author Mike Buland | ||
29 | */ | ||
30 | bool addLink( ProgramLink *pLink ); | ||
31 | |||
32 | /** Gets a link by name. | ||
33 | *@param lpName The name of the link you're looking for. Every link has a | ||
34 | * name, apparently. | ||
35 | *@returns A pointer to the specified ProgramLink, or NULL if none were found | ||
36 | * matching your criteria. | ||
37 | *@author Mike Buland | ||
38 | */ | ||
39 | class ProgramLink *getLink( const char *lpName ); | ||
40 | |||
41 | /** Gets the very first link in the chain. | ||
42 | *@returns A pointer to the first link in the chain. | ||
43 | *@author Mike Buland | ||
44 | */ | ||
45 | class ProgramLink *getBaseLink(); | ||
46 | |||
47 | /** Runs through the chain once. Useful if you want to have more control over | ||
48 | * the operation of the chain. | ||
49 | *@returns true if every link returned true. If at least one link returns false, | ||
50 | * then returns false. | ||
51 | *@author Mike Buland | ||
52 | */ | ||
53 | bool execChainOnce(); | ||
54 | |||
55 | /** Enters the master chain loop, looping over the entire chain and executing | ||
56 | * every link's TimeSlice routine in order, over and over, until a link returns | ||
57 | * a false value. | ||
58 | *@returns False, always. It returns true unless a link returned false, but loops | ||
59 | * until a link does return false. | ||
60 | *@author Mike Buland | ||
61 | **/ | ||
62 | bool enterChainLoop(); | ||
63 | |||
64 | /** Broadcasts an Immediate Response Message to all active links, save the | ||
65 | * sender. Whatever link first responds with a non-null response message | ||
66 | * will have it's messages sent back to the broadcasting link as the returns | ||
67 | * of this function call. Therefore it is very important that all message | ||
68 | * processing code is handled in a fairly timely fasion. | ||
69 | *@param pMsgOut The message to broadcast in hopes of a response. | ||
70 | *@param pSender The message that sent out the message and doesn't want to | ||
71 | * receive it's own message. This should always just be "this". | ||
72 | *@returns The message that was returned by the first link to return a | ||
73 | * non-null response. If all messages return null responses then this also | ||
74 | * returns null. Please note that whoever calls this will be responsible | ||
75 | * for deleting the message returned by it, if non-null. | ||
76 | */ | ||
77 | class LinkMessage *broadcastIRM( LinkMessage *pMsgOut, ProgramLink *pSender ); | ||
78 | |||
79 | private: | ||
80 | /** | ||
81 | * Shuts down all operation no matter what point in the operation we were. | ||
82 | */ | ||
83 | void emergencyShutdown(); | ||
84 | MultiLog *pLog; /**< A pointer to a log. */ | ||
85 | LinkedList lLink; /**< The linked list that contains all of the links. */ | ||
86 | }; | ||
87 | |||
88 | #endif | ||