diff options
Diffstat (limited to '')
-rw-r--r-- | src/programlink.h | 165 |
1 files changed, 83 insertions, 82 deletions
diff --git a/src/programlink.h b/src/programlink.h index f93edcc..07d7489 100644 --- a/src/programlink.h +++ b/src/programlink.h | |||
@@ -1,99 +1,100 @@ | |||
1 | #ifndef PROGRAMLINK_H | 1 | #ifndef BU_PROGRAMLINK_H |
2 | #define PROGRAMLINK_H | 2 | #define BU_PROGRAMLINK_H |
3 | 3 | ||
4 | class ProgramLink; | 4 | #include "bu/linkmessage.h" |
5 | #include "queue.h" | 5 | #include "bu/programchain.h" |
6 | #include "linkmessage.h" | ||
7 | #include "programchain.h" | ||
8 | 6 | ||
9 | /** | 7 | namespace Bu |
10 | * Program Link is the base class for any object that will be a piece of the | ||
11 | * main program chain loop. | ||
12 | *@author Mike Buland | ||
13 | */ | ||
14 | class ProgramLink | ||
15 | { | 8 | { |
16 | friend class ProgramChain; | ||
17 | public: | ||
18 | /** | 9 | /** |
19 | * Construct a program link. | 10 | * Program Link is the base class for any object that will be a piece of the |
11 | * main program chain loop. | ||
12 | *@author Mike Buland | ||
20 | */ | 13 | */ |
21 | ProgramLink(); | 14 | class ProgramLink |
15 | { | ||
16 | friend class Bu::ProgramChain; | ||
17 | public: | ||
18 | /** | ||
19 | * Construct a program link. | ||
20 | */ | ||
21 | ProgramLink(); | ||
22 | 22 | ||
23 | /** | 23 | /** |
24 | * Deconstruct. | 24 | * Deconstruct. |
25 | */ | 25 | */ |
26 | virtual ~ProgramLink(); | 26 | virtual ~ProgramLink(); |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * Initialization code required for a link that wasn't performed in the | 29 | * Initialization code required for a link that wasn't performed in the |
30 | * constructor. | 30 | * constructor. |
31 | *@returns true if initialization was successful. A false value will halt | 31 | *@returns true if initialization was successful. A false value will halt |
32 | * the chain. | 32 | * the chain. |
33 | */ | 33 | */ |
34 | virtual bool init()=0; | 34 | virtual bool init()=0; |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * DeInitialization code that should happen, but doesn't belong in the | 37 | * DeInitialization code that should happen, but doesn't belong in the |
38 | * destructor. | 38 | * destructor. |
39 | *@returns true means everything worked, false means failure, but is | 39 | *@returns true means everything worked, false means failure, but is |
40 | * meaningless. | 40 | * meaningless. |
41 | */ | 41 | */ |
42 | virtual bool deInit()=0; | 42 | virtual bool deInit()=0; |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Executed once per link per chain pass. Contains the guts of the program. | 45 | * Executed once per link per chain pass. Contains the guts of the program. |
46 | *@returns true if everything went well. A false value will halt the chain. | 46 | *@returns true if everything went well. A false value will halt the chain. |
47 | */ | 47 | */ |
48 | virtual bool timeSlice()=0; | 48 | virtual bool timeSlice()=0; |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * This must be handled in order to process Instant Response Messages. | 51 | * This must be handled in order to process Instant Response Messages. |
52 | * This function should return null on all messages that it doesn't | 52 | * This function should return null on all messages that it doesn't |
53 | * understand how to handle, and construct new messages to return to sender | 53 | * understand how to handle, and construct new messages to return to sender |
54 | * in the cases where it does understand. | 54 | * in the cases where it does understand. |
55 | *@param pMsgIn The message that must be processed. | 55 | *@param pMsgIn The message that must be processed. |
56 | *@returns Either a new message in cases where a response is required, | 56 | *@returns Either a new message in cases where a response is required, |
57 | * or null if nothing needs to be done by this link. | 57 | * or null if nothing needs to be done by this link. |
58 | */ | 58 | */ |
59 | virtual LinkMessage *processIRM( LinkMessage *pMsgIn ) = 0; | 59 | virtual LinkMessage *processIRM( LinkMessage *pMsgIn ) = 0; |
60 | 60 | ||
61 | /** | 61 | /** |
62 | * Broadcast a LinkMessage to all other links in the system. Each other | 62 | * Broadcast a LinkMessage to all other links in the system. Each other |
63 | * link will get a call of their processIRM function. If the message gets | 63 | * link will get a call of their processIRM function. If the message gets |
64 | * a response then you will regain control immediately, otherwise the system | 64 | * a response then you will regain control immediately, otherwise the system |
65 | * will give all other Links a chance to respond before returning NULL. | 65 | * will give all other Links a chance to respond before returning NULL. |
66 | *@param pMsgOut The message to broadcast. | 66 | *@param pMsgOut The message to broadcast. |
67 | *@returns The message response, or NULL if no Link understood your message. | 67 | *@returns The message response, or NULL if no Link understood your message. |
68 | */ | 68 | */ |
69 | LinkMessage *sendIRM( LinkMessage *pMsgOut ); | 69 | LinkMessage *sendIRM( LinkMessage *pMsgOut ); |
70 | 70 | ||
71 | private: | 71 | private: |
72 | /** | 72 | /** |
73 | * Set which chain we're assosiated with. This is how IRM messages make | 73 | * Set which chain we're assosiated with. This is how IRM messages make |
74 | * it out to the rest of the world. | 74 | * it out to the rest of the world. |
75 | *@param pNewChain A pointer to the containing program chain. | 75 | *@param pNewChain A pointer to the containing program chain. |
76 | */ | 76 | */ |
77 | void setChain( class ProgramChain *pNewChain ); | 77 | void setChain( class ProgramChain *pNewChain ); |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * The pointer to the containing chain. | 80 | * The pointer to the containing chain. |
81 | */ | 81 | */ |
82 | class ProgramChain *pChain; | 82 | class ProgramChain *pChain; |
83 | /* | 83 | /* |
84 | void postMessage( LinkMessage *pMsg, int nLvl ); | 84 | void postMessage( LinkMessage *pMsg, int nLvl ); |
85 | LinkMessage *getMessage( int nLvl ); | 85 | LinkMessage *getMessage( int nLvl ); |
86 | 86 | ||
87 | enum | 87 | enum |
88 | { | 88 | { |
89 | msgToChain, | 89 | msgToChain, |
90 | msgToLink | 90 | msgToLink |
91 | }; | 91 | }; |
92 | 92 | ||
93 | private: | 93 | private: |
94 | Queue qMsgToChain; | 94 | Queue qMsgToChain; |
95 | Queue qMsgToLink; | 95 | Queue qMsgToLink; |
96 | */ | 96 | */ |
97 | }; | 97 | }; |
98 | } | ||
98 | 99 | ||
99 | #endif | 100 | #endif |