/******************************************************************* * * DESCRIPTION: class ParallelRoot * * AUTHOR: Alejandro Troccoli * Revised By: Qi (Jacky) Liu * * EMAIL: mailto://atroccol@dc.uba.ar * mailto://liuqi@sce.carleton.ca * * DATE: 11/01/2001 * Revision Date: Sept. 6, 2005 *******************************************************************/ #ifndef __ROOT_H #define __ROOT_H #include "JackyDebugStream.h" /** include files **/ #include //Template list #ifndef JACKY_REVISION #include "event.h" //class event #include "eventlist.h" #endif #ifdef JACKY_REVISION #include "port.h" // InfluenceList ( list ) #endif #include "prootmodel.h" #include "pprocess.h" // class Processor #include "pRootState.h" // class ParallelRootState #include "pprocadm.h" // ParallelProcessorAdmin::rootId /** forward declarations **/ class Coupled ; class ParallelMainSimulator ; class Port ; class VTime ; class ParallelRoot : public ParallelProcessor { public: static ParallelRoot &Instance(); //Functions that are required by Warped void initialize(); ParallelRoot &rootInitialize(); ParallelRoot &rootSimulate(); ParallelRoot &rootStop(); #ifndef JACKY_REVISION //following functions are commented out ========================= /*Jacky Note: ** The ParallelRoot will NOT hold external events, and will NOT receive ** (D) msgs from NCs. It will NOT stop the simulation as well. */ ParallelRoot &addExternalEvent( const VTime &, const Port &, const Real & ) ; ParallelRoot &stopTime( const VTime & ) ; const VTime &stopTime() const ; const EventList &events() const ; ParallelProcessor &receive( const DoneMessage &); #endif //end JACKY_REVISION ============================================================== //this function receives (Y) msg from the NCs to output simulation results //to the environment ParallelProcessor &receive( const BasicOutputMessage * ); const string description() const ; BasicState* allocateState(); bool createOutput; int outputIndex; private: friend class ParallelProcessorAdmin ; ParallelRoot( RootModel*) ; // Default constructor #ifdef JACKY_REVISION //add variable and function here ================================= //Note: this variable is moved into the ParallelRootState, Oct. 19, 2005 //InfluenceList topOutputPorts; //function to retrieve the topOutputPorts defined in the state, Oct. 19, 2005 InfluenceList &getTopOutputPorts() const; //function to find out to which ports on the TOP model we need to deliver //an (Y) msg. i.e. output infomation to the environment ParallelRoot &findTopOutputPorts(const Port&); #ifdef JACKY_DEBUG //------------------------------------------------------------ //print out the output ports on the TOP model found for debugging purpose void showTopOutputPorts(ostream& out); #endif //end JACKY_DEBUG -------------------------------------------------------- #endif //end JACKY_REVISION ============================================================= #ifndef JACKY_REVISION // Following variables & functions are commented out ============ /*Jacky Note: ** The ParallelRoot will NOT hold the topMasterId. It will only send (I) msg ** to all the NCs */ //State shortcuts void sendMsgType ( ParallelRootState::nextMsgType msgType); ParallelRootState::nextMsgType sendMsgType (); //Event List Management shortcuts EventList::iterator currentEvent(); void eventsBegin(); void eventsMoveNext(); bool endOfEvents(); VTime timeStop ; EventList externalEvents; ProcId topMasterId; #endif //end JACKY_REVISION ============================================================= }; // class Root inline const string ParallelRoot::description() const { return "ParallelRoot" ; } inline BasicState* ParallelRoot::allocateState() { return new ParallelRootState; } /******************************************************************* * Function Name: findTopOutputPorts() * Description: function to retrieve the topOutputPorts defined in the state * Oct. 19, 2005 ********************************************************************/ inline InfluenceList& ParallelRoot::getTopOutputPorts() const { return ((ParallelRootState *)state->current)->topOutputPorts; } #ifndef JACKY_REVISION // The following functions are commented out ========================= inline const EventList &ParallelRoot::events() const { return externalEvents ; } inline ParallelRoot &ParallelRoot::stopTime( const VTime &t ) { timeStop = t ; return *this ; } inline const VTime &ParallelRoot::stopTime() const { return timeStop ; } /******************************************************************* * Function Name: currentEvent * Description: retrieve the current event iterator from the Root State ********************************************************************/ inline EventList::iterator ParallelRoot::currentEvent(){ return ((ParallelRootState *)state->current)->eventsCursor; } /******************************************************************* * Function Name: eventBegin * Description: move the current event iterator to the first event ********************************************************************/ inline void ParallelRoot::eventsBegin() { (((ParallelRootState *)state->current)->eventsCursor) = externalEvents.begin(); } /******************************************************************* * Function Name: nextEvent * Description: move the current event iterator to the next event ********************************************************************/ inline void ParallelRoot::eventsMoveNext() { ((ParallelRootState *)state->current)->eventsCursor++; } /******************************************************************* * Function Name: endOfEvents * Description: returns true if the last external events has been processed ********************************************************************/ inline bool ParallelRoot::endOfEvents() { return ((((ParallelRootState *)state->current)->eventsCursor) == externalEvents.end()); } /******************************************************************* * Function Name: State Shortcuts * Description: ********************************************************************/ inline void ParallelRoot::sendMsgType ( ParallelRootState::nextMsgType msgType) { ((ParallelRootState *)state->current)->next = msgType; } inline ParallelRootState::nextMsgType ParallelRoot::sendMsgType () { return ((ParallelRootState *)state->current)->next; } #endif //JACKY_REVISION ============================================================== #endif //__ROOT_H