STL-related And Other Template Utilities
[CORELIB]

Collaboration diagram for STL-related And Other Template Utilities:


Classes

class  CMask
 CMask --. More...
class  CMaskFileName
 CMaskFileName --. More...
class  CSignal
 CSignal --. More...
struct  p_equal_to< T >
 Check for equality of objects pointed to by pointer. More...
struct  PPtrLess< T >
 Compare objects pointed to by (smart) pointer. More...
struct  pair_equal_to< Pair >
 Check whether a pair's second element matches a given value. More...
struct  CNameGetter< Value >
 Get name attribute for Value object. More...
class  CBestChoiceTracker< T, F >
 Tracks the best score (lowest value). More...
class  CRequestRateControlException
 CRequestRateControlException --. More...
class  CRequestRateControl
 CRequestRateControl --. More...
class  CMaskRegexp
 CMaskRegexp --. More...

Typedefs

typedef int CSignal::TSignalMask
 Binary OR of "ESignal".

Functions

static void CSignal::TrapSignals (TSignalMask signals)
 Sets interrupt signal handling.
static TSignalMask CSignal::Reset (void)
 Reset the list of handled signal.
static bool CSignal::IsSignaled (TSignalMask signals=eSignal_Any)
 Check that any of specified signals is received.
static TSignalMask CSignal::GetSignals (void)
 Get signals state.
static bool CSignal::Raise (ESignal signal)
 Sends a signal to the current process.
template<class X>
X * NotNull (X *object)
 Check for not null value (after C malloc, strdup etc.).
template<class Key, class Element>
Element GetMapElement (const map< Key, Element > &m, const Key &key, const Element &def=0)
 Get map element (pointer) or NULL if absent.
template<class Key, class Element>
void SetMapElement (map< Key, Element * > &m, const Key &key, Element *data)
 Set map element -- if data is null, erase the existing key.
template<class Key, class Element>
bool InsertMapElement (map< Key, Element * > &m, const Key &key, Element *data)
 Insert map element.
template<class Key>
string GetMapString (const map< Key, string > &m, const Key &key)
 Get string map element or "" if absent.
template<class Key>
void SetMapString (map< Key, string > &m, const Key &key, const string &data)
 Set string map element -- if data is null erase the existing key.
template<class Cnt>
void DeleteElements (Cnt &cnt)
 Delete all elements from a container of pointers (list, vector, set, multiset); clear the container afterwards.
template<class Key, class Element>
void DeleteElements (map< Key, Element * > &m)
 Delete all elements from map containing pointers; clear container afterwards.
template<class Key, class Element>
void DeleteElements (multimap< Key, Element * > &m)
 Delete all elements from multimap containing pointers; clear container afterwards.
template<class Result, class Source, class ToKey>
Result & AutoMap (auto_ptr< Result > &cache, const Source &source, const ToKey &toKey)
 Retrieve the result from the result cache - if cache is empty, insert into cache from the supplied source.
template<typename C, typename F>
C::value_type FindBestChoice (const C &container, F score_func)
 Find the best choice (lowest score) for values in a container.
template<class Iterator>
END_NCBI_SCOPE BEGIN_STD_SCOPE
bool 
is_sorted (Iterator iter1, Iterator iter2)
 is_sorted is provided by some implementations of the STL and may be included in future releases of all standard-conforming implementations This is provided here for future compatibility
template<class Iterator, class Predicate>
bool is_sorted (Iterator iter1, Iterator iter2, Predicate pred)
bool CRequestRateControl::Approve (EThrottleAction action=eDefault)
 Approve a request.
CTimeSpan CRequestRateControl::ApproveTime (void)
 Get a time span in which request can be approved.
 CRequestRateControl::CRequestRateControl (unsigned int num_requests_allowed, CTimeSpan per_period=CTimeSpan(1, 0), CTimeSpan min_time_between_requests=CTimeSpan(0, 0), EThrottleAction throttle_action=eDefault, EThrottleMode throttle_mode=eContinuous)
 Constructor.
void CRequestRateControl::Reset (unsigned int num_requests_allowed, CTimeSpan per_period=CTimeSpan(1, 0), CTimeSpan min_time_between_requests=CTimeSpan(0, 0), EThrottleAction throttle_action=eDefault, EThrottleMode throttle_mode=eContinuous)
 Set new restriction for throttling mechanism.
bool CRequestRateControl::x_Approve (EThrottleAction action, CTimeSpan *sleeptime)
static void CRequestRateControl::Sleep (CTimeSpan sleep_time)
 Sleep for CTimeSpan.
void CRequestRateControl::x_CleanTimeLine (TTime now)
 Remove from the list of approved requests all expared items.
virtual const char * CRequestRateControlException::GetErrCodeString (void) const
 Translate from the error code value to its string representation.


Typedef Documentation

typedef int CSignal::TSignalMask [inherited]
 

Binary OR of "ESignal".

Definition at line 84 of file ncbi_signal.hpp.


Function Documentation

bool CRequestRateControl::Approve EThrottleAction  action = eDefault  )  [inline, inherited]
 

Approve a request.

Throttle action used by this function call. If passed argument equal to eDefault that use throttle action was set in the constructor.

Returns:
Return TRUE if everything meet to established requirements. Return FALSE if some requirements are not passed, or throw exception if throttle action was set to eException.
See also:
Reset, ApproveTime

Definition at line 236 of file request_control.hpp.

References CRequestRateControl::x_Approve().

Referenced by CGridThreadContext::IsJobCanceled(), CRequestRateControl::Lock(), and CGridThreadContext::PutProgressMessage().

CTimeSpan CRequestRateControl::ApproveTime void   )  [inline, inherited]
 

Get a time span in which request can be approved.

You should call this method until it returns zero time span, otherwise you should sleep (using Sleep() method) for indicated time.

Returns:
Returns time to wait until actual request, zero if can proceed immediately. If you use this method with absolute limitation (no time period and no minimum between requests) and the limitation is exhausted it will throw an exception.
See also:
Reset, Approve

Definition at line 242 of file request_control.hpp.

References CRequestRateControl::eSleep, and CRequestRateControl::x_Approve().

template<class Result, class Source, class ToKey>
Result& AutoMap auto_ptr< Result > &  cache,
const Source &  source,
const ToKey &  toKey
[inline]
 

Retrieve the result from the result cache - if cache is empty, insert into cache from the supplied source.

Definition at line 197 of file ncbiutil.hpp.

References auto_ptr< X >::get(), and auto_ptr< X >::reset().

CRequestRateControl::CRequestRateControl unsigned int  num_requests_allowed,
CTimeSpan  per_period = CTimeSpan(1, 0),
CTimeSpan  min_time_between_requests = CTimeSpan(0, 0),
EThrottleAction  throttle_action = eDefault,
EThrottleMode  throttle_mode = eContinuous
[inherited]
 

Constructor.

Construct class object. Run Reset() method.

See also:
Reset, EThrottleAction, EThrottleMode

Definition at line 47 of file request_control.cpp.

References CRequestRateControl::Reset().

template<class Key, class Element>
void DeleteElements multimap< Key, Element * > &  m  )  [inline]
 

Delete all elements from multimap containing pointers; clear container afterwards.

Definition at line 183 of file ncbiutil.hpp.

References multimap_checker< std::multimap< Key, T, Compare > >::begin(), and multimap_checker< std::multimap< Key, T, Compare > >::end().

template<class Key, class Element>
void DeleteElements map< Key, Element * > &  m  )  [inline]
 

Delete all elements from map containing pointers; clear container afterwards.

Definition at line 171 of file ncbiutil.hpp.

References map_checker< std::map< Key, T, Compare > >::begin(), and map_checker< std::map< Key, T, Compare > >::end().

template<class Cnt>
void DeleteElements Cnt &  cnt  )  [inline]
 

Delete all elements from a container of pointers (list, vector, set, multiset); clear the container afterwards.

Definition at line 160 of file ncbiutil.hpp.

Referenced by CNcbiResource::~CNcbiResource().

template<typename C, typename F>
C::value_type FindBestChoice const C &  container,
score_func
[inline]
 

Find the best choice (lowest score) for values in a container.

Container and scoring functions are specified as template parameters.

Definition at line 264 of file ncbiutil.hpp.

References CBestChoiceTracker< T, F >::GetBestChoice(), and ITERATE.

Referenced by CAutoDefFakePromoterClause::CAutoDefFakePromoterClause(), ChangeSeqId(), Convert_Bioseq_Seq_id(), Convert_Seq_entry_Seq_id(), Convert_Seq_entry_Seq_loc(), Convert_SeqSubmit_Seq_id(), CFastaExtractor::Extract(), CAccessionExtractor::Extract(), CBioseq::GetLabel(), GetSequenceLengthAndId(), CSeq_id::GetStringDescr(), CRmOutReader::MakeFeature(), s_ConvertBioseqs2TSeqLocVector(), s_ExtractQueryIdsFromBioseqSet(), s_FindBestChoiceForDbsource(), s_GetIdUrl(), s_GetSeqIdListString(), s_SetIntervals(), CAliToSeq_align::StringToSeq_id(), CSeqDBIsam::TryToSimplifyAccession(), CSeq_id::WriteAsFasta(), CId1FetchApp::WriteQualityScores(), CBlastFormat::x_CreateSubjectBioseq(), CRemoteBlast::x_ExtractQueryIds(), CDisplaySeqalign::x_FillSeqid(), CDBSourceItem::x_GatherInfo(), CAlnGraphic::x_GetAlnInfo(), and CAutoDef::x_GetFeatureClauses().

const char * CRequestRateControlException::GetErrCodeString void   )  const [virtual, inherited]
 

Translate from the error code value to its string representation.

Reimplemented from CCoreException.

Definition at line 280 of file request_control.cpp.

References CRequestRateControlException::eMinTimeBetweenRequests, CRequestRateControlException::eNumRequestsMax, CRequestRateControlException::eNumRequestsPerPeriod, CCoreException::GetErrCode(), and CException::GetErrCodeString().

template<class Key, class Element>
Element GetMapElement const map< Key, Element > &  m,
const Key &  key,
const Element def = 0
[inline]
 

Get map element (pointer) or NULL if absent.

Definition at line 109 of file ncbiutil.hpp.

References map_checker< std::map< Key, T, Compare > >::end(), and map_checker< std::map< Key, T, Compare > >::find().

template<class Key>
string GetMapString const map< Key, string > &  m,
const Key &  key
[inline]
 

Get string map element or "" if absent.

Definition at line 138 of file ncbiutil.hpp.

References map_checker< std::map< Key, T, Compare > >::end(), and map_checker< std::map< Key, T, Compare > >::find().

static TSignalMask CSignal::GetSignals void   )  [static, inherited]
 

Get signals state.

Returns:
Current signal state. Each bit represent some caught signal.
See also:
TrapSignals

template<class Key, class Element>
bool InsertMapElement map< Key, Element * > &  m,
const Key &  key,
Element data
[inline]
 

Insert map element.

Definition at line 130 of file ncbiutil.hpp.

References map_checker< std::map< Key, T, Compare > >::insert().

template<class Iterator, class Predicate>
bool is_sorted Iterator  iter1,
Iterator  iter2,
Predicate  pred
 

Definition at line 301 of file ncbiutil.hpp.

template<class Iterator>
END_NCBI_SCOPE BEGIN_STD_SCOPE bool is_sorted Iterator  iter1,
Iterator  iter2
 

is_sorted is provided by some implementations of the STL and may be included in future releases of all standard-conforming implementations This is provided here for future compatibility

Definition at line 288 of file ncbiutil.hpp.

Referenced by CCleanup_imp::BasicCleanup().

static bool CSignal::IsSignaled TSignalMask  signals = eSignal_Any  )  [static, inherited]
 

Check that any of specified signals is received.

Parameters:
signals The set of signals to check.
Returns:
TRUE if any of specified signals is set, FALSE otherwise.
See also:
TrapSignals

template<class X>
X* NotNull X *  object  )  [inline]
 

Check for not null value (after C malloc, strdup etc.).

Definition at line 99 of file ncbiutil.hpp.

References kEmptyStr, and NCBI_THROW.

Referenced by CCharPtrFunctions< T >::Assign(), CPrimitiveTypeInfoCharPtr< T >::SetValueChar(), and CPrimitiveTypeInfoCharPtr< T >::SetValueString().

static bool CSignal::Raise ESignal  signal  )  [static, inherited]
 

Sends a signal to the current process.

Parameters:
signal Signal to send to the current process.
Returns:
TRUE on success, FALSE otherwise. Return FALSE also if the signal is not supported on current platform.

void CRequestRateControl::Reset unsigned int  num_requests_allowed,
CTimeSpan  per_period = CTimeSpan(1, 0),
CTimeSpan  min_time_between_requests = CTimeSpan(0, 0),
EThrottleAction  throttle_action = eDefault,
EThrottleMode  throttle_mode = eContinuous
[inherited]
 

Set new restriction for throttling mechanism.

Zero values for time spans 'per_period' or 'min_time_between_requests' means no rate restriction for that throttling mechanism, respectively.

Parameters:
num_requests_allowed Maximum number of allowed requests per 'per_period'. Can be kNoLimit for unlimited number of requests (throttler is disabled, Approve() always returns TRUE).
per_period Time span in which only 'num_requests_allowed' requests can be approved.
min_time_between_requests Minimum time between two succesful consecutive requests.
throttle_action Set throttle action by default. The eDefault means eSleep here.
throttle_mode Set throttle action by default. The eDefault means eSleep here. For backward compatibility, use eContinuous mode by default.
See also:
Approve, ApproveTime

Definition at line 59 of file request_control.cpp.

References CRequestRateControl::eDefault, CRequestRateControl::eSleep, CTimeSpan::GetAsDouble(), CRequestRateControl::m_LastApproved, CRequestRateControl::m_MinTimeBetweenRequests, CRequestRateControl::m_Mode, CRequestRateControl::m_NumRequests, CRequestRateControl::m_NumRequestsAllowed, CRequestRateControl::m_PerPeriod, CRequestRateControl::m_StopWatch, CRequestRateControl::m_ThrottleAction, CRequestRateControl::m_TimeLine, and CStopWatch::Restart().

Referenced by CGridThreadContext::CloseStreams(), and CRequestRateControl::CRequestRateControl().

static TSignalMask CSignal::Reset void   )  [static, inherited]
 

Reset the list of handled signal.

Default signal handlers will be used for all handled signals (SIG_DFL).

Returns:
List of handled signals before reset.
See also:
TrapSignals, GetSignals

template<class Key, class Element>
void SetMapElement map< Key, Element * > &  m,
const Key &  key,
Element data
[inline]
 

Set map element -- if data is null, erase the existing key.

Definition at line 120 of file ncbiutil.hpp.

References map_checker< std::map< Key, T, Compare > >::erase().

template<class Key>
void SetMapString map< Key, string > &  m,
const Key &  key,
const string &  data
[inline]
 

Set string map element -- if data is null erase the existing key.

Definition at line 148 of file ncbiutil.hpp.

References map_checker< std::map< Key, T, Compare > >::erase().

void CRequestRateControl::Sleep CTimeSpan  sleep_time  )  [static, inherited]
 

Sleep for CTimeSpan.

Parameters:
sleep_time For how long to sleep. If it's impossible to sleep to that long in millisecond range, rounds up sleep time to the whole seconds.

Definition at line 229 of file request_control.cpp.

References CTimeSpan::GetCompleteSeconds(), CTimeSpan::GetNanoSecondsAfterSecond(), kMicroSecondsPerSecond, SleepMicroSec(), and SleepSec().

static void CSignal::TrapSignals TSignalMask  signals  )  [static, inherited]
 

Sets interrupt signal handling.

Install default signal handler for all specified signal types. Use IsSignaled/GetSignals to check in your code to check that some signal was caught. Consecutive calls add signals to list of handled signals.

See also:
IsSignaled, GetSignals, Reset
Parameters:
signals The set of signals to check.

bool CRequestRateControl::x_Approve EThrottleAction  action,
CTimeSpan sleeptime
[private, inherited]
 

Definition at line 85 of file request_control.cpp.

References CRequestRateControl::eDefault, CRequestRateControl::eDiscrete, CRequestRateControl::eErrCode, CRequestRateControl::eException, CStopWatch::Elapsed(), CRequestRateControl::eSleep, CRequestRateControl::kNoLimit, CRequestRateControl::m_LastApproved, CRequestRateControl::m_MinTimeBetweenRequests, CRequestRateControl::m_Mode, CRequestRateControl::m_NumRequests, CRequestRateControl::m_NumRequestsAllowed, CRequestRateControl::m_PerPeriod, CRequestRateControl::m_StopWatch, CRequestRateControl::m_ThrottleAction, CRequestRateControl::m_TimeLine, and NCBI_THROW.

Referenced by CRequestRateControl::Approve(), and CRequestRateControl::ApproveTime().

void CRequestRateControl::x_CleanTimeLine TTime  now  )  [private, inherited]
 

Remove from the list of approved requests all expared items.

Definition at line 248 of file request_control.cpp.

References CRequestRateControl::eContinuous, CRequestRateControl::eDiscrete, CRequestRateControl::m_LastApproved, CRequestRateControl::m_Mode, CRequestRateControl::m_NumRequests, CRequestRateControl::m_PerPeriod, and CRequestRateControl::m_TimeLine.


Generated on Mon Dec 7 16:01:43 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Mon Dec 07 16:24:35 2009 by modify_doxy.py rev. 173732