MsgTripWire Class Reference

#include <MsgTripWire.h>

List of all members.

Public Member Functions

 MsgTripWire ()
 ~MsgTripWire ()
void SetTripWire (int recordSet, int node=0, int call=0, Msg::LogLevel_t level=0)
void StartRecordSet ()
void StartNode ()
void StartCall ()
bool IsActive () const
bool SuppressMessage () const
Msg::LogLevel_t GetLogLevel () const
std::string GetMessagePrefix () const
 ......................................................................
void Print (std::ostream &os) const

Static Public Member Functions

static MsgTripWireInstance ()

Private Member Functions

void Activated () const
 Dummy function called as trip wire is activated.
void CheckTripWire ()

Private Attributes

bool fIsActive
 True if tripwire has been set and triggered.
bool fIsEnabled
 True if tripwire has been set.
Msg::LogLevel_t fLogLevel
 Log level set once trip wire has been triggered.
int fCurrentRecordSet
int fCurrentNode
 Current node counter (reset every record set).
int fCurrentCall
 Current call counter (reset every node).
int fTripRecordSet
 Tripwire record set.
int fTripNode
 Tripwire call.
int fTripCall
 Tripwire node.

Static Private Attributes

static MsgTripWire fgTheTripWire
 The singleton instance.

Detailed Description

Definition at line 19 of file MsgTripWire.h.


Constructor & Destructor Documentation

MsgTripWire::MsgTripWire (  ) 

Definition at line 24 of file MsgTripWire.cxx.

References CheckTripWire(), fIsEnabled, fLogLevel, fTripCall, fTripNode, and fTripRecordSet.

00024                          :
00025   fIsActive(false),
00026   fIsEnabled(false),
00027   fCurrentRecordSet(0),
00028   fCurrentNode(0),
00029   fCurrentCall(0),
00030   fTripRecordSet(999999999),
00031   fTripNode(0)
00032 {
00033 
00034   // Check for environmental setting - this allows trip wire to be activated
00035   // from instantiation, long before any script gets run.
00036   const char* env = getenv("ENV_MSG_TRIP_WIRE");
00037   if ( env ) {
00038     fIsEnabled = true;
00039     std::istringstream is(env);
00040     is >> fTripRecordSet  >> fTripNode >> fTripCall >> fLogLevel;
00041     fIsEnabled = true;
00042     this->CheckTripWire();
00043   }
00044 }

MsgTripWire::~MsgTripWire (  ) 

Definition at line 48 of file MsgTripWire.cxx.

00049 {
00050 }


Member Function Documentation

void MsgTripWire::Activated (  )  const [private]

Dummy function called as trip wire is activated.

Definition at line 54 of file MsgTripWire.cxx.

References fCurrentCall, fCurrentNode, and fCurrentRecordSet.

Referenced by CheckTripWire().

00054                                   {
00055 
00056   std::cout << "Debug: Trip Wire activated."  
00057             << " RecordSet: " << fCurrentRecordSet
00058             << " Node: "  << fCurrentNode
00059             << " Call: "  << fCurrentCall << std::endl;
00060 }

void MsgTripWire::CheckTripWire (  )  [private]

Definition at line 64 of file MsgTripWire.cxx.

References Activated(), fCurrentCall, fCurrentNode, fCurrentRecordSet, fIsActive, fIsEnabled, fTripCall, fTripNode, and fTripRecordSet.

Referenced by MsgTripWire(), SetTripWire(), and StartCall().

00064                                 {
00065 
00066   //  Has trip-wire record set just occurred?
00067   if (    fCurrentCall  == fTripCall 
00068        && fCurrentNode  == fTripNode
00069        && fCurrentCall  == fTripCall ) this->Activated();
00070 
00071   //  Has the trip-wire record set been passed?
00072   if ( fCurrentRecordSet < fTripRecordSet ) return;
00073   if ( fCurrentRecordSet > fTripRecordSet ) {
00074     fIsActive = fIsEnabled;
00075     return;
00076   }
00077   if ( fCurrentNode < fTripNode ) return;
00078   if ( fCurrentNode > fTripNode ) {
00079     fIsActive = fIsEnabled;
00080     return;
00081   }
00082   if ( fCurrentCall >= fTripCall ) fIsActive = fIsEnabled;
00083 
00084 }

Msg::LogLevel_t MsgTripWire::GetLogLevel (  )  const [inline]

Definition at line 59 of file MsgTripWire.h.

References fLogLevel.

00059 { return fLogLevel; }

std::string MsgTripWire::GetMessagePrefix (  )  const

......................................................................

Definition at line 88 of file MsgTripWire.cxx.

References fCurrentCall, fCurrentNode, fCurrentRecordSet, and fIsActive.

Referenced by MsgStream::operator()().

00089 {
00090 //======================================================================
00091 // Purpose: Assemble a message prefix.
00092 //======================================================================
00093 
00094   if ( ! fIsActive ) return "";
00095   std::ostringstream os;
00096   os << fCurrentRecordSet << ":" << fCurrentNode << ":" << fCurrentCall << ":";
00097   return os.str();
00098 
00099 }

static MsgTripWire& MsgTripWire::Instance (  )  [inline, static]

Definition at line 25 of file MsgTripWire.h.

References fgTheTripWire.

Referenced by JobCPath::Execute(), MsgService::Instance(), MsgStream::operator()(), and JobCPath::Run().

00025 { return fgTheTripWire; }

bool MsgTripWire::IsActive (  )  const [inline]

Definition at line 57 of file MsgTripWire.h.

References fIsActive.

Referenced by MsgStream::operator()().

00057 { return fIsActive; }

void MsgTripWire::Print ( std::ostream &  os  )  const

Definition at line 103 of file MsgTripWire.cxx.

References fCurrentCall, fCurrentNode, fCurrentRecordSet, fIsActive, fIsEnabled, fTripNode, and fTripRecordSet.

00104 {
00105 //======================================================================
00106 // Purpose:Print state
00107 //======================================================================
00108 
00109   os << "MsgTripWire: Enabled: " << fIsEnabled << " Active: " << fIsActive
00110      << " current state: " << fCurrentRecordSet << ":" << fCurrentNode << ":" << fCurrentCall
00111      << " tripwire " << fTripRecordSet << ":" << fTripNode << std::endl;
00112 
00113 }

void MsgTripWire::SetTripWire ( int  recordSet,
int  node = 0,
int  call = 0,
Msg::LogLevel_t  level = 0 
) [inline]

Definition at line 29 of file MsgTripWire.h.

References CheckTripWire(), fIsEnabled, fLogLevel, fTripCall, fTripNode, and fTripRecordSet.

00029                                                                                         {
00030     fIsEnabled = true;
00031     fTripRecordSet = recordSet;
00032     fTripNode  = node;
00033     fTripCall  = call;
00034     fLogLevel  = level;
00035     this->CheckTripWire();
00036   }

void MsgTripWire::StartCall (  )  [inline]

Definition at line 50 of file MsgTripWire.h.

References CheckTripWire(), and fCurrentCall.

Referenced by MsgStream::operator()(), and StartNode().

00050                    { 
00051     ++fCurrentCall;
00052     this->CheckTripWire();
00053   }

void MsgTripWire::StartNode (  )  [inline]

Definition at line 45 of file MsgTripWire.h.

References fCurrentCall, fCurrentNode, and StartCall().

Referenced by JobCPath::Execute(), and StartRecordSet().

00045                    { 
00046     ++fCurrentNode;
00047     fCurrentCall = 1;
00048     this->StartCall();
00049   }

void MsgTripWire::StartRecordSet (  )  [inline]

Definition at line 40 of file MsgTripWire.h.

References fCurrentNode, fCurrentRecordSet, and StartNode().

Referenced by JobCPath::Run().

00040                         { 
00041     ++fCurrentRecordSet;
00042     fCurrentNode = -1;
00043     this->StartNode();
00044   }

bool MsgTripWire::SuppressMessage (  )  const [inline]

Definition at line 58 of file MsgTripWire.h.

References fIsActive, and fIsEnabled.

Referenced by MsgStream::operator()().

00058 { return fIsEnabled && ! fIsActive; }


Member Data Documentation

Current call counter (reset every node).

Definition at line 80 of file MsgTripWire.h.

Referenced by Activated(), CheckTripWire(), GetMessagePrefix(), Print(), StartCall(), and StartNode().

Current node counter (reset every record set).

Definition at line 79 of file MsgTripWire.h.

Referenced by Activated(), CheckTripWire(), GetMessagePrefix(), Print(), StartNode(), and StartRecordSet().

Current record set counter (each call to a JobCInputModule reads a new record set).

Definition at line 77 of file MsgTripWire.h.

Referenced by Activated(), CheckTripWire(), GetMessagePrefix(), Print(), and StartRecordSet().

The singleton instance.

Definition at line 71 of file MsgTripWire.h.

Referenced by Instance().

bool MsgTripWire::fIsActive [private]

True if tripwire has been set and triggered.

Definition at line 73 of file MsgTripWire.h.

Referenced by CheckTripWire(), GetMessagePrefix(), IsActive(), Print(), and SuppressMessage().

bool MsgTripWire::fIsEnabled [private]

True if tripwire has been set.

Definition at line 74 of file MsgTripWire.h.

Referenced by CheckTripWire(), MsgTripWire(), Print(), SetTripWire(), and SuppressMessage().

Log level set once trip wire has been triggered.

Definition at line 76 of file MsgTripWire.h.

Referenced by GetLogLevel(), MsgTripWire(), and SetTripWire().

int MsgTripWire::fTripCall [private]

Tripwire node.

Definition at line 83 of file MsgTripWire.h.

Referenced by CheckTripWire(), MsgTripWire(), and SetTripWire().

int MsgTripWire::fTripNode [private]

Tripwire call.

Definition at line 82 of file MsgTripWire.h.

Referenced by CheckTripWire(), MsgTripWire(), Print(), and SetTripWire().

Tripwire record set.

Definition at line 81 of file MsgTripWire.h.

Referenced by CheckTripWire(), MsgTripWire(), Print(), and SetTripWire().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1