From 3f26c19b0b7a9fa73c58189788972ea43b72f014 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 25 Jun 2007 21:15:55 +0000 Subject: 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. --- src/programchain.cpp | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 src/programchain.cpp (limited to 'src/programchain.cpp') 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 @@ +#include +#include "bu/programchain.h" +#include "bu/programlink.h" + +using namespace Bu; + +Bu::ProgramChain::ProgramChain() +{ +} + +Bu::ProgramChain::~ProgramChain() +{ +} + +bool Bu::ProgramChain::addLink( ProgramLink *pLink ) +{ + if( pLink->init() == false ) + { + emergencyShutdown(); + return false; + } + + lLink.append( pLink ); + + pLink->setChain( this ); + + return true; +} + +ProgramLink *Bu::ProgramChain::getLink( const char *lpName ) +{ + char a; + a = lpName[0]; + return NULL; +} + +ProgramLink *Bu::ProgramChain::getBaseLink() +{ + return NULL; +} + +bool Bu::ProgramChain::execChainOnce() +{ + for( Bu::List::iterator i = lLink.begin(); + i != lLink.end(); i++ ) + { + if( (*i)->timeSlice() == false ) + { + emergencyShutdown(); + return false; + } + } + + return true; +} + +bool Bu::ProgramChain::enterChainLoop() +{ + for(;;) + { + if( execChainOnce() == false ) + { + return false; + } + } + + return true; +} + +void Bu::ProgramChain::emergencyShutdown() +{ + for( Bu::List::iterator i = lLink.begin(); + i != lLink.end(); i++ ) + { + (*i)->deInit(); + delete *i; + } + lLink.clear(); +} + +LinkMessage *Bu::ProgramChain::broadcastIRM( LinkMessage *pMsgOut, ProgramLink *pSender ) +{ + for( Bu::List::iterator i = lLink.begin(); + i != lLink.end(); i++ ) + { + LinkMessage *pMsg = (*i)->processIRM( pMsgOut ); + if( pMsg != NULL ) + { + delete pMsgOut; + return pMsg; + } + } + + delete pMsgOut; + return NULL; +} + -- cgit v1.2.3