INET Framework for OMNeT++/OMNEST
inet::OperationalBase Class Referenceabstract

#include <OperationalBase.h>

Inheritance diagram for inet::OperationalBase:
inet::ILifecycle inet::ApplicationBase inet::LayeredProtocolBase inet::PhysicalLayerBase inet::PIMBase inet::UDPBasicApp inet::UDPBasicBurst inet::UDPEchoApp inet::UDPSink inet::UDPVideoStreamCli inet::UDPVideoStreamSvr inet::MACProtocolBase inet::NetworkProtocolBase inet::TransportProtocolBase inet::physicallayer::Radio inet::PIMDM inet::PIMSM

Public Member Functions

 OperationalBase ()
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void handleMessageWhenDown (cMessage *msg)
 
virtual void handleMessageWhenUp (cMessage *msg)=0
 
virtual bool handleOperationStage (LifecycleOperation *operation, int stage, IDoneCallback *doneCallback) override
 Perform one stage of a lifecycle operation. More...
 
virtual bool handleNodeStart (IDoneCallback *doneCallback)
 
virtual bool handleNodeShutdown (IDoneCallback *doneCallback)
 
virtual void handleNodeCrash ()
 
virtual bool isInitializeStage (int stage)=0
 
virtual bool isNodeStartStage (int stage)=0
 
virtual bool isNodeShutdownStage (int stage)=0
 
virtual void setOperational (bool isOperational)
 

Protected Attributes

bool isOperational
 
simtime_t lastChange
 

Constructor & Destructor Documentation

inet::OperationalBase::OperationalBase ( )
27  :
28  isOperational(false)
29 {
30 }
bool isOperational
Definition: OperationalBase.h:28

Member Function Documentation

void inet::OperationalBase::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
43 {
44  if (isOperational)
45  handleMessageWhenUp(message);
46  else
47  handleMessageWhenDown(message);
48 }
bool isOperational
Definition: OperationalBase.h:28
virtual void handleMessageWhenUp(cMessage *msg)=0
virtual void handleMessageWhenDown(cMessage *msg)
Definition: OperationalBase.cc:50
void inet::OperationalBase::handleMessageWhenDown ( cMessage *  msg)
protectedvirtual

Reimplemented in inet::physicallayer::Radio.

Referenced by handleMessage(), and inet::physicallayer::Radio::handleMessageWhenDown().

51 {
52  if (message->isSelfMessage())
53  throw cRuntimeError("Self message '%s' received when %s is down", message->getName(), getComponentType()->getName());
54  else if (simTime() == lastChange)
55  EV_WARN << getComponentType()->getName() << " is down, dropping '" << message->getName() << "' message\n";
56  else
57  throw cRuntimeError("Message '%s' received when %s is down", message->getName(), getComponentType()->getName());
58  delete message;
59 }
simtime_t lastChange
Definition: OperationalBase.h:29
virtual void inet::OperationalBase::handleMessageWhenUp ( cMessage *  msg)
protectedpure virtual
bool inet::OperationalBase::handleOperationStage ( LifecycleOperation operation,
int  stage,
IDoneCallback doneCallback 
)
overrideprotectedvirtual

Perform one stage of a lifecycle operation.

Processing may be done entirely within this method, or may be a longer process that involves nonzero simulation time or several events, and is triggered by this method call.

Return value: true = "done"; false = "not yet done, will invoke doneCallback when done"

Implements inet::ILifecycle.

62 {
63  Enter_Method_Silent();
64  if (dynamic_cast<NodeStartOperation *>(operation)) {
65  if (isNodeStartStage(stage)) {
66  setOperational(true);
67  return handleNodeStart(doneCallback);
68  }
69  }
70  else if (dynamic_cast<NodeShutdownOperation *>(operation)) {
71  if (isNodeShutdownStage(stage)) {
72  bool done = handleNodeShutdown(doneCallback);
73  setOperational(false);
74  return done;
75  }
76  }
77  else if (dynamic_cast<NodeCrashOperation *>(operation)) {
78  if (stage == NodeCrashOperation::STAGE_CRASH) {
80  setOperational(false);
81  return true;
82  }
83  }
84  return true;
85 }
virtual void handleNodeCrash()
Definition: OperationalBase.cc:97
virtual bool handleNodeShutdown(IDoneCallback *doneCallback)
Definition: OperationalBase.cc:92
virtual void setOperational(bool isOperational)
Definition: OperationalBase.cc:101
virtual bool handleNodeStart(IDoneCallback *doneCallback)
Definition: OperationalBase.cc:87
virtual bool isNodeShutdownStage(int stage)=0
virtual bool isNodeStartStage(int stage)=0
Definition: NodeOperations.h:127
void inet::OperationalBase::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented in inet::PIMDM, inet::PIMSM, inet::PIMBase, inet::physicallayer::Radio, inet::CsmaCaMac, inet::Flood, inet::LMacLayer, inet::CSMA, inet::IdealMac, inet::UDPBasicBurst, inet::UDPVideoStreamSvr, inet::BMacLayer, inet::ieee80211::Ieee80211Mac, inet::WiseRoute, inet::ProbabilisticBroadcast, inet::UDPBasicApp, inet::UDPSink, inet::UDPVideoStreamCli, inet::MACProtocolBase, inet::physicallayer::Ieee80211Radio, inet::UDPEchoApp, inet::NetworkProtocolBase, and inet::AdaptiveProbabilisticBroadcast.

Referenced by inet::NetworkProtocolBase::initialize(), inet::UDPEchoApp::initialize(), inet::MACProtocolBase::initialize(), inet::UDPVideoStreamCli::initialize(), inet::UDPSink::initialize(), inet::UDPBasicApp::initialize(), inet::UDPVideoStreamSvr::initialize(), inet::UDPBasicBurst::initialize(), inet::physicallayer::Radio::initialize(), and inet::PIMBase::initialize().

33 {
34  if (isInitializeStage(stage)) {
35  NodeStatus *nodeStatus = dynamic_cast<NodeStatus *>(findContainingNode(this)->getSubmodule("status"));
36  setOperational(!nodeStatus || nodeStatus->getState() == NodeStatus::UP);
37  if (isOperational)
38  handleNodeStart(nullptr);
39  }
40 }
bool isOperational
Definition: OperationalBase.h:28
virtual void setOperational(bool isOperational)
Definition: OperationalBase.cc:101
cModule * findContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:56
virtual bool handleNodeStart(IDoneCallback *doneCallback)
Definition: OperationalBase.cc:87
virtual bool isInitializeStage(int stage)=0
Definition: NodeStatus.h:40
virtual bool inet::OperationalBase::isInitializeStage ( int  stage)
protectedpure virtual
virtual bool inet::OperationalBase::isNodeShutdownStage ( int  stage)
protectedpure virtual
virtual bool inet::OperationalBase::isNodeStartStage ( int  stage)
protectedpure virtual
virtual int inet::OperationalBase::numInitStages ( ) const
inlineoverrideprotectedvirtual
void inet::OperationalBase::setOperational ( bool  isOperational)
protectedvirtual

Referenced by handleOperationStage(), and initialize().

102 {
104  lastChange = simTime();
105 }
bool isOperational
Definition: OperationalBase.h:28
simtime_t lastChange
Definition: OperationalBase.h:29

Member Data Documentation

bool inet::OperationalBase::isOperational
protected
simtime_t inet::OperationalBase::lastChange
protected

The documentation for this class was generated from the following files: