diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-06-25 21:15:55 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-06-25 21:15:55 +0000 |
commit | 3f26c19b0b7a9fa73c58189788972ea43b72f014 (patch) | |
tree | 8f34928a267fb35becdf939d21187a526f235869 /src/programchain.cpp | |
parent | 2b0fa89df615cb4789668014475ae64d99e773b5 (diff) | |
download | libbu++-3f26c19b0b7a9fa73c58189788972ea43b72f014.tar.gz libbu++-3f26c19b0b7a9fa73c58189788972ea43b72f014.tar.bz2 libbu++-3f26c19b0b7a9fa73c58189788972ea43b72f014.tar.xz libbu++-3f26c19b0b7a9fa73c58189788972ea43b72f014.zip |
I think the plugger and programchain are all up to date to work with the new
libbu++. The program chain may undergo heavy changes still, or be removed
entirely, but we need it for congo and squirrelmud, so here it is for a while
longer.
The TafWriter isn't much closer, you still only get the groups in the output.
Diffstat (limited to 'src/programchain.cpp')
-rw-r--r-- | src/programchain.cpp | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/src/programchain.cpp b/src/programchain.cpp new file mode 100644 index 0000000..0bb7a77 --- /dev/null +++ b/src/programchain.cpp | |||
@@ -0,0 +1,97 @@ | |||
1 | #include <stdlib.h> | ||
2 | #include "bu/programchain.h" | ||
3 | #include "bu/programlink.h" | ||
4 | |||
5 | using namespace Bu; | ||
6 | |||
7 | Bu::ProgramChain::ProgramChain() | ||
8 | { | ||
9 | } | ||
10 | |||
11 | Bu::ProgramChain::~ProgramChain() | ||
12 | { | ||
13 | } | ||
14 | |||
15 | bool Bu::ProgramChain::addLink( ProgramLink *pLink ) | ||
16 | { | ||
17 | if( pLink->init() == false ) | ||
18 | { | ||
19 | emergencyShutdown(); | ||
20 | return false; | ||
21 | } | ||
22 | |||
23 | lLink.append( pLink ); | ||
24 | |||
25 | pLink->setChain( this ); | ||
26 | |||
27 | return true; | ||
28 | } | ||
29 | |||
30 | ProgramLink *Bu::ProgramChain::getLink( const char *lpName ) | ||
31 | { | ||
32 | char a; | ||
33 | a = lpName[0]; | ||
34 | return NULL; | ||
35 | } | ||
36 | |||
37 | ProgramLink *Bu::ProgramChain::getBaseLink() | ||
38 | { | ||
39 | return NULL; | ||
40 | } | ||
41 | |||
42 | bool Bu::ProgramChain::execChainOnce() | ||
43 | { | ||
44 | for( Bu::List<Bu::ProgramLink *>::iterator i = lLink.begin(); | ||
45 | i != lLink.end(); i++ ) | ||
46 | { | ||
47 | if( (*i)->timeSlice() == false ) | ||
48 | { | ||
49 | emergencyShutdown(); | ||
50 | return false; | ||
51 | } | ||
52 | } | ||
53 | |||
54 | return true; | ||
55 | } | ||
56 | |||
57 | bool Bu::ProgramChain::enterChainLoop() | ||
58 | { | ||
59 | for(;;) | ||
60 | { | ||
61 | if( execChainOnce() == false ) | ||
62 | { | ||
63 | return false; | ||
64 | } | ||
65 | } | ||
66 | |||
67 | return true; | ||
68 | } | ||
69 | |||
70 | void Bu::ProgramChain::emergencyShutdown() | ||
71 | { | ||
72 | for( Bu::List<Bu::ProgramLink *>::iterator i = lLink.begin(); | ||
73 | i != lLink.end(); i++ ) | ||
74 | { | ||
75 | (*i)->deInit(); | ||
76 | delete *i; | ||
77 | } | ||
78 | lLink.clear(); | ||
79 | } | ||
80 | |||
81 | LinkMessage *Bu::ProgramChain::broadcastIRM( LinkMessage *pMsgOut, ProgramLink *pSender ) | ||
82 | { | ||
83 | for( Bu::List<Bu::ProgramLink *>::iterator i = lLink.begin(); | ||
84 | i != lLink.end(); i++ ) | ||
85 | { | ||
86 | LinkMessage *pMsg = (*i)->processIRM( pMsgOut ); | ||
87 | if( pMsg != NULL ) | ||
88 | { | ||
89 | delete pMsgOut; | ||
90 | return pMsg; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | delete pMsgOut; | ||
95 | return NULL; | ||
96 | } | ||
97 | |||