/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Protected Attributes | Friends
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:
Collaboration graph
[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.

    : mSiteMask(0)
    , mSimMask(0)
    , mTimeStart(0,0)
    , mTimeEnd(0,0)
{
    // Default constructor
}
ContextRange::ContextRange ( const int  siteMask,
const int  simMask,
const TimeStamp tstart,
const TimeStamp tend 
)

Definition at line 32 of file ContextRange.cc.

    : mSiteMask(siteMask), mSimMask(simMask), 
      mTimeStart(tstart), mTimeEnd(tend)
{
    // normal constructor
}
ContextRange::~ContextRange ( ) [virtual]

Definition at line 43 of file ContextRange.cc.

{
    // delete all the owned sub-objects

}

Member Function Documentation

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

Definition at line 50 of file ContextRange.cc.

{
    // Return the ContextRange as a string
    //
    // Result is a pointer to a statically allocated string.
    // User should copy this into their own buffer before calling
    // this method again.
    //
    // option "a": give site/simflag masks as alpha chars
    // option "c": compact (single line)
    // option "s": drop nsec part of times

    std::string opt = option;
    std::transform(opt.begin(),opt.end(),opt.begin(),::tolower);

    bool opt_a = (opt.find("a") != std::string::npos);
    bool opt_c = (opt.find("c") != std::string::npos);
    bool opt_s = (opt.find("s") != std::string::npos);

    static std::string out;
    out="|";

    if (opt_a) 
        out += Site::StringFromMask(mSiteMask);
    else {
        out += "site ";
        char buffer[1024] = {0};
        snprintf(buffer,1024,"%#4.4x",mSiteMask);
        out += buffer;
    }

    out += "|";
   
    if (opt_a) 
        out += SimFlag::StringFromMask(mSimMask);
    else {
        out += "sim ";
        char buffer[1024] = {0};
        snprintf(buffer,1024,"%#4.4x",mSiteMask);
        out += buffer;
    }

    // TimeStamp::AsString returns pointer to statically allocated string
    // one needs to copy this before calling it again in same function call
    static char timeopt[4] = "c  ";
    timeopt[0] = (opt_s ? 's' : 'c');
    if(opt_c)    out += "|";
    else         out += "\n\t";

    out += mTimeStart.AsString(timeopt);

    if(opt_c)    out += "|";
    else         out += "\n\t";

    out += mTimeEnd.AsString(timeopt);
   
    return out;
}
bool ContextRange::IsCompatible ( const Context cx) const

Definition at line 110 of file ContextRange.cc.

{
    // compare Context with this ContextRange to see if the
    // the tagged set is compatible

    int site     = (int)cx.GetSite();
    int simflag  = (int)cx.GetSimFlag();

    // account for case where both Context and ContextRange
    // are using "kUnknown" which has no bits set
    if ( ! (site & mSiteMask) &&
         (site      != Site::kUnknown || 
          mSiteMask != Site::kUnknown    ) ) return false;
    if ( ! (simflag  & mSimMask) &&
         (simflag  != SimFlag::kUnknown || 
          mSimMask != SimFlag::kUnknown   ) ) return false;

    // the start time is taken as inclusive, but the end time is exclusive

    if ( cx.GetTimeStamp() <  mTimeStart ) return false;
    if ( cx.GetTimeStamp() >= mTimeEnd   ) return false;

    return true;
}
bool ContextRange::IsCompatible ( const Context cx) const

Definition at line 136 of file ContextRange.cc.

{
    // compare Context with this ContextRange to see if the
    // the tagged set is compatible
    assert(cx);
    return IsCompatible(*cx);
}
int ContextRange::GetSiteMask ( ) const [inline]

Definition at line 48 of file ContextRange.h.

{ return mSiteMask; }
int ContextRange::GetSimMask ( ) const [inline]

Definition at line 49 of file ContextRange.h.

{ return mSimMask; }
TimeStamp ContextRange::GetTimeStart ( ) const [inline]

Definition at line 50 of file ContextRange.h.

{ return mTimeStart; }
TimeStamp ContextRange::GetTimeEnd ( ) const [inline]

Definition at line 51 of file ContextRange.h.

{ 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.

{
    // Trim this range to the intersection (ie. more restricted)
    // limits of it's initial value and that of the argument

    mSiteMask &= cx.mSiteMask;
    mSimMask      &= cx.mSimMask;
    if (mTimeStart < cx.mTimeStart) mTimeStart = cx.mTimeStart;
    if (mTimeEnd   > cx.mTimeEnd  ) mTimeEnd   = cx.mTimeEnd;
}
void ContextRange::SetTimeStart ( const TimeStamp tstart) [inline]

Definition at line 57 of file ContextRange.h.

{ mTimeStart = tstart; }
void ContextRange::SetTimeEnd ( const TimeStamp tend) [inline]

Definition at line 58 of file ContextRange.h.

{ mTimeEnd = tend; }
void ContextRange::SetSiteMask ( const int  siteMask) [inline]

Definition at line 59 of file ContextRange.h.

{ mSiteMask = siteMask ; }  
void ContextRange::SetSimMask ( const int  simMask) [inline]

Definition at line 60 of file ContextRange.h.

{ mSimMask = simMask ; }  

Friends And Related Function Documentation

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

Definition at line 158 of file ContextRange.cc.

{ return lhs.mTimeStart  == rhs.mTimeStart; }
bool operator!= ( const ContextRange lhs,
const ContextRange rhs 
) [friend]

Definition at line 161 of file ContextRange.cc.

{ return lhs.mTimeStart  != rhs.mTimeStart; }
bool operator< ( const ContextRange lhs,
const ContextRange rhs 
) [friend]

Definition at line 164 of file ContextRange.cc.

{ return lhs.mTimeStart  < rhs.mTimeStart; }
bool operator<= ( const ContextRange lhs,
const ContextRange rhs 
) [friend]

Definition at line 167 of file ContextRange.cc.

{ return lhs.mTimeStart  < rhs.mTimeStart; }
bool operator> ( const ContextRange lhs,
const ContextRange rhs 
) [friend]

Definition at line 170 of file ContextRange.cc.

{ return lhs.mTimeStart  > rhs.mTimeStart; }
bool operator>= ( const ContextRange lhs,
const ContextRange rhs 
) [friend]

Definition at line 173 of file ContextRange.cc.

{ 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.

or's of data/mc conditions

Definition at line 72 of file ContextRange.h.

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 Fri May 16 2014 09:56:40 for Context by doxygen 1.7.4