| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

ContextRange Class Reference

Delimits and identifies the allowed "context" values associated with the associated DBI returned information. More...

#include <ContextRange.h>

Collaboration diagram for ContextRange:

[legend]
List of all members.

Public Member Functions

 ContextRange ()
 ContextRange (const int siteMask, const int simMask, const TimeStamp &tstart, const TimeStamp &tend)
virtual ~ContextRange ()
std::string AsString (const char *option="") const
bool IsCompatible (const Context &cx) const
bool IsCompatible (const Context *cx) const
int GetSiteMask () const
int GetSimMask () const
TimeStamp GetTimeStart () const
TimeStamp GetTimeEnd () const
void TrimTo (const ContextRange &other)
 Trim this range to the intersection (ie.
void SetTimeStart (const TimeStamp &tstart)
void SetTimeEnd (const TimeStamp &tend)
void SetSiteMask (const int siteMask)
void SetSimMask (const int simMask)

Protected Attributes

int mSiteMask
 Which sites.
int mSimMask
TimeStamp mTimeStart
 or's of data/mc conditions
TimeStamp mTimeEnd

Friends

bool operator== (const ContextRange &lhs, const ContextRange &rhs)
bool operator!= (const ContextRange &lhs, const ContextRange &rhs)
bool operator< (const ContextRange &lhs, const ContextRange &rhs)
bool operator<= (const ContextRange &lhs, const ContextRange &rhs)
bool operator> (const ContextRange &lhs, const ContextRange &rhs)
bool operator>= (const ContextRange &lhs, const ContextRange &rhs)

Detailed Description

Delimits and identifies the allowed "context" values associated with the associated DBI returned information.

Author:
(last to touch it)
Author
tagg
Version:
Revision
1.1
Date:
Date
2007/05/09 20:49:35
Contact: R. Hatcher

Created on: 2000.05.03

Add comparison operators according to start time to build ContextRange indexed map. If you have another need for a more meaningful comparison, go ahead and change it. 2010/03/01 Zhe Wang

Definition at line 34 of file ContextRange.h.


Constructor & Destructor Documentation

ContextRange::ContextRange (  ) 

Definition at line 22 of file ContextRange.cc.

00023     : mSiteMask(0)
00024     , mSimMask(0)
00025     , mTimeStart(0,0)
00026     , mTimeEnd(0,0)
00027 {
00028     // Default constructor
00029 }

ContextRange::ContextRange ( const int  siteMask,
const int  simMask,
const TimeStamp tstart,
const TimeStamp tend 
)

Definition at line 32 of file ContextRange.cc.

00036     : mSiteMask(siteMask), mSimMask(simMask), 
00037       mTimeStart(tstart), mTimeEnd(tend)
00038 {
00039     // normal constructor
00040 }

ContextRange::~ContextRange (  )  [virtual]

Definition at line 43 of file ContextRange.cc.

00044 {
00045     // delete all the owned sub-objects
00046 
00047 }


Member Function Documentation

std::string ContextRange::AsString ( const char *  option = ""  )  const

Definition at line 50 of file ContextRange.cc.

00051 {
00052     // Return the ContextRange as a string
00053     //
00054     // Result is a pointer to a statically allocated string.
00055     // User should copy this into their own buffer before calling
00056     // this method again.
00057     //
00058     // option "a": give site/simflag masks as alpha chars
00059     // option "c": compact (single line)
00060     // option "s": drop nsec part of times
00061 
00062     std::string opt = option;
00063     std::transform(opt.begin(),opt.end(),opt.begin(),::tolower);
00064 
00065     bool opt_a = (opt.find("a") != std::string::npos);
00066     bool opt_c = (opt.find("c") != std::string::npos);
00067     bool opt_s = (opt.find("s") != std::string::npos);
00068 
00069     static std::string out;
00070     out="|";
00071 
00072     if (opt_a) 
00073         out += Site::StringFromMask(mSiteMask);
00074     else {
00075         out += "site ";
00076         char buffer[1024] = {0};
00077         snprintf(buffer,1024,"%#4.4x",mSiteMask);
00078         out += buffer;
00079     }
00080 
00081     out += "|";
00082    
00083     if (opt_a) 
00084         out += SimFlag::StringFromMask(mSimMask);
00085     else {
00086         out += "sim ";
00087         char buffer[1024] = {0};
00088         snprintf(buffer,1024,"%#4.4x",mSiteMask);
00089         out += buffer;
00090     }
00091 
00092     // TimeStamp::AsString returns pointer to statically allocated string
00093     // one needs to copy this before calling it again in same function call
00094     static char timeopt[4] = "c  ";
00095     timeopt[0] = (opt_s ? 's' : 'c');
00096     if(opt_c)    out += "|";
00097     else         out += "\n\t";
00098 
00099     out += mTimeStart.AsString(timeopt);
00100 
00101     if(opt_c)    out += "|";
00102     else         out += "\n\t";
00103 
00104     out += mTimeEnd.AsString(timeopt);
00105    
00106     return out;
00107 }

bool ContextRange::IsCompatible ( const Context cx  )  const

Definition at line 110 of file ContextRange.cc.

00111 {
00112     // compare Context with this ContextRange to see if the
00113     // the tagged set is compatible
00114 
00115     int site     = (int)cx.GetSite();
00116     int simflag  = (int)cx.GetSimFlag();
00117 
00118     // account for case where both Context and ContextRange
00119     // are using "kUnknown" which has no bits set
00120     if ( ! (site & mSiteMask) &&
00121          (site      != Site::kUnknown || 
00122           mSiteMask != Site::kUnknown    ) ) return false;
00123     if ( ! (simflag  & mSimMask) &&
00124          (simflag  != SimFlag::kUnknown || 
00125           mSimMask != SimFlag::kUnknown   ) ) return false;
00126 
00127     // the start time is taken as inclusive, but the end time is exclusive
00128 
00129     if ( cx.GetTimeStamp() <  mTimeStart ) return false;
00130     if ( cx.GetTimeStamp() >= mTimeEnd   ) return false;
00131 
00132     return true;
00133 }

bool ContextRange::IsCompatible ( const Context cx  )  const

Definition at line 136 of file ContextRange.cc.

00137 {
00138     // compare Context with this ContextRange to see if the
00139     // the tagged set is compatible
00140     assert(cx);
00141     return IsCompatible(*cx);
00142 }

int ContextRange::GetSiteMask (  )  const [inline]

Definition at line 48 of file ContextRange.h.

00048 { return mSiteMask; }

int ContextRange::GetSimMask (  )  const [inline]

Definition at line 49 of file ContextRange.h.

00049 { return mSimMask; }

TimeStamp ContextRange::GetTimeStart (  )  const [inline]

Definition at line 50 of file ContextRange.h.

00050 { return mTimeStart; }

TimeStamp ContextRange::GetTimeEnd (  )  const [inline]

Definition at line 51 of file ContextRange.h.

00051 { return mTimeEnd; }

void ContextRange::TrimTo ( const ContextRange other  ) 

Trim this range to the intersection (ie.

more restricted) limits of it's initial value and that of the argument

Definition at line 146 of file ContextRange.cc.

00147 {
00148     // Trim this range to the intersection (ie. more restricted)
00149     // limits of it's initial value and that of the argument
00150 
00151     mSiteMask &= cx.mSiteMask;
00152     mSimMask      &= cx.mSimMask;
00153     if (mTimeStart < cx.mTimeStart) mTimeStart = cx.mTimeStart;
00154     if (mTimeEnd   > cx.mTimeEnd  ) mTimeEnd   = cx.mTimeEnd;
00155 }

void ContextRange::SetTimeStart ( const TimeStamp tstart  )  [inline]

Definition at line 57 of file ContextRange.h.

00057 { mTimeStart = tstart; }

void ContextRange::SetTimeEnd ( const TimeStamp tend  )  [inline]

Definition at line 58 of file ContextRange.h.

00058 { mTimeEnd = tend; }

void ContextRange::SetSiteMask ( const int  siteMask  )  [inline]

Definition at line 59 of file ContextRange.h.

00059 { mSiteMask = siteMask ; }  

void ContextRange::SetSimMask ( const int  simMask  )  [inline]

Definition at line 60 of file ContextRange.h.

00060 { mSimMask = simMask ; }  


Friends And Related Function Documentation

bool operator== ( const ContextRange lhs,
const ContextRange rhs 
) [friend]

Definition at line 158 of file ContextRange.cc.

00159 { return lhs.mTimeStart  == rhs.mTimeStart; }

bool operator!= ( const ContextRange lhs,
const ContextRange rhs 
) [friend]

Definition at line 161 of file ContextRange.cc.

00162 { return lhs.mTimeStart  != rhs.mTimeStart; }

bool operator< ( const ContextRange lhs,
const ContextRange rhs 
) [friend]

Definition at line 164 of file ContextRange.cc.

00165 { return lhs.mTimeStart  < rhs.mTimeStart; }

bool operator<= ( const ContextRange lhs,
const ContextRange rhs 
) [friend]

Definition at line 167 of file ContextRange.cc.

00168 { return lhs.mTimeStart  < rhs.mTimeStart; }

bool operator> ( const ContextRange lhs,
const ContextRange rhs 
) [friend]

Definition at line 170 of file ContextRange.cc.

00171 { return lhs.mTimeStart  > rhs.mTimeStart; }

bool operator>= ( const ContextRange lhs,
const ContextRange rhs 
) [friend]

Definition at line 173 of file ContextRange.cc.

00174 { return lhs.mTimeStart  > rhs.mTimeStart; }


Member Data Documentation

int ContextRange::mSiteMask [protected]

Which sites.

Definition at line 70 of file ContextRange.h.

int ContextRange::mSimMask [protected]

Definition at line 71 of file ContextRange.h.

TimeStamp ContextRange::mTimeStart [protected]

or's of data/mc conditions

Definition at line 72 of file ContextRange.h.

TimeStamp ContextRange::mTimeEnd [protected]

Definition at line 73 of file ContextRange.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:15:31 2011 for Context by doxygen 1.4.7