aboutsummaryrefslogtreecommitdiff
path: root/src/programchain.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-06-25 21:15:55 +0000
committerMike Buland <eichlan@xagasoft.com>2007-06-25 21:15:55 +0000
commit3f26c19b0b7a9fa73c58189788972ea43b72f014 (patch)
tree8f34928a267fb35becdf939d21187a526f235869 /src/programchain.cpp
parent2b0fa89df615cb4789668014475ae64d99e773b5 (diff)
downloadlibbu++-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.cpp97
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
5using namespace Bu;
6
7Bu::ProgramChain::ProgramChain()
8{
9}
10
11Bu::ProgramChain::~ProgramChain()
12{
13}
14
15bool 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
30ProgramLink *Bu::ProgramChain::getLink( const char *lpName )
31{
32 char a;
33 a = lpName[0];
34 return NULL;
35}
36
37ProgramLink *Bu::ProgramChain::getBaseLink()
38{
39 return NULL;
40}
41
42bool 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
57bool Bu::ProgramChain::enterChainLoop()
58{
59 for(;;)
60 {
61 if( execChainOnce() == false )
62 {
63 return false;
64 }
65 }
66
67 return true;
68}
69
70void 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
81LinkMessage *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