diff options
Diffstat (limited to 'src/programchain.cpp')
-rw-r--r-- | src/programchain.cpp | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/src/programchain.cpp b/src/programchain.cpp index 6120d58..0bb7a77 100644 --- a/src/programchain.cpp +++ b/src/programchain.cpp | |||
@@ -1,17 +1,18 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include "programchain.h" | 2 | #include "bu/programchain.h" |
3 | #include "bu/programlink.h" | ||
3 | 4 | ||
4 | ProgramChain::ProgramChain() : | 5 | using namespace Bu; |
5 | xLog( MultiLog::getInstance() ) | 6 | |
7 | Bu::ProgramChain::ProgramChain() | ||
6 | { | 8 | { |
7 | xLog.LineLog( MultiLog::LStatus, "Program Chain Initialized." ); | ||
8 | } | 9 | } |
9 | 10 | ||
10 | ProgramChain::~ProgramChain() | 11 | Bu::ProgramChain::~ProgramChain() |
11 | { | 12 | { |
12 | } | 13 | } |
13 | 14 | ||
14 | bool ProgramChain::addLink( ProgramLink *pLink ) | 15 | bool Bu::ProgramChain::addLink( ProgramLink *pLink ) |
15 | { | 16 | { |
16 | if( pLink->init() == false ) | 17 | if( pLink->init() == false ) |
17 | { | 18 | { |
@@ -26,26 +27,25 @@ bool ProgramChain::addLink( ProgramLink *pLink ) | |||
26 | return true; | 27 | return true; |
27 | } | 28 | } |
28 | 29 | ||
29 | ProgramLink *ProgramChain::getLink( const char *lpName ) | 30 | ProgramLink *Bu::ProgramChain::getLink( const char *lpName ) |
30 | { | 31 | { |
31 | char a; | 32 | char a; |
32 | a = lpName[0]; | 33 | a = lpName[0]; |
33 | return NULL; | 34 | return NULL; |
34 | } | 35 | } |
35 | 36 | ||
36 | ProgramLink *ProgramChain::getBaseLink() | 37 | ProgramLink *Bu::ProgramChain::getBaseLink() |
37 | { | 38 | { |
38 | return NULL; | 39 | return NULL; |
39 | } | 40 | } |
40 | 41 | ||
41 | bool ProgramChain::execChainOnce() | 42 | bool Bu::ProgramChain::execChainOnce() |
42 | { | 43 | { |
43 | int nLen = lLink.getSize(); | 44 | for( Bu::List<Bu::ProgramLink *>::iterator i = lLink.begin(); |
44 | for( int j = 0; j < nLen; j++ ) | 45 | i != lLink.end(); i++ ) |
45 | { | 46 | { |
46 | if( ((ProgramLink *)lLink[j])->timeSlice() == false ) | 47 | if( (*i)->timeSlice() == false ) |
47 | { | 48 | { |
48 | xLog.LineLog( MultiLog::LInfo, "Shutting down due to signal from link #%d", j ); | ||
49 | emergencyShutdown(); | 49 | emergencyShutdown(); |
50 | return false; | 50 | return false; |
51 | } | 51 | } |
@@ -54,7 +54,7 @@ bool ProgramChain::execChainOnce() | |||
54 | return true; | 54 | return true; |
55 | } | 55 | } |
56 | 56 | ||
57 | bool ProgramChain::enterChainLoop() | 57 | bool Bu::ProgramChain::enterChainLoop() |
58 | { | 58 | { |
59 | for(;;) | 59 | for(;;) |
60 | { | 60 | { |
@@ -67,23 +67,23 @@ bool ProgramChain::enterChainLoop() | |||
67 | return true; | 67 | return true; |
68 | } | 68 | } |
69 | 69 | ||
70 | void ProgramChain::emergencyShutdown() | 70 | void Bu::ProgramChain::emergencyShutdown() |
71 | { | 71 | { |
72 | int nLen = lLink.getSize(); | 72 | for( Bu::List<Bu::ProgramLink *>::iterator i = lLink.begin(); |
73 | for( int j = 0; j < nLen; j++ ) | 73 | i != lLink.end(); i++ ) |
74 | { | 74 | { |
75 | ((ProgramLink *)lLink[j])->deInit(); | 75 | (*i)->deInit(); |
76 | delete (ProgramLink *)lLink[j]; | 76 | delete *i; |
77 | } | 77 | } |
78 | lLink.empty(); | 78 | lLink.clear(); |
79 | } | 79 | } |
80 | 80 | ||
81 | LinkMessage *ProgramChain::broadcastIRM( LinkMessage *pMsgOut, ProgramLink *pSender ) | 81 | LinkMessage *Bu::ProgramChain::broadcastIRM( LinkMessage *pMsgOut, ProgramLink *pSender ) |
82 | { | 82 | { |
83 | int nLen = lLink.getSize(); | 83 | for( Bu::List<Bu::ProgramLink *>::iterator i = lLink.begin(); |
84 | for( int j = 0; j < nLen; j++ ) | 84 | i != lLink.end(); i++ ) |
85 | { | 85 | { |
86 | LinkMessage *pMsg = ((ProgramLink *)lLink[j])->processIRM( pMsgOut ); | 86 | LinkMessage *pMsg = (*i)->processIRM( pMsgOut ); |
87 | if( pMsg != NULL ) | 87 | if( pMsg != NULL ) |
88 | { | 88 | { |
89 | delete pMsgOut; | 89 | delete pMsgOut; |
@@ -94,3 +94,4 @@ LinkMessage *ProgramChain::broadcastIRM( LinkMessage *pMsgOut, ProgramLink *pSen | |||
94 | delete pMsgOut; | 94 | delete pMsgOut; |
95 | return NULL; | 95 | return NULL; |
96 | } | 96 | } |
97 | |||