NCBI C++ ToolKit
Classes | Typedefs | Enumerations | Enumerator | Functions
STL-related And Other Template Utilities
CORELIB
+ Collaboration diagram for STL-related And Other Template Utilities:

Classes

class  CConnTest
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".

Enumerations

enum  CSignal::ESignal {
  CSignal::eSignal_HUP = (1<<1), CSignal::eSignal_INT = (1<<2), CSignal::eSignal_QUIT = (1<<3), CSignal::eSignal_ILL = (1<<4),
  CSignal::eSignal_FPE = (1<<5), CSignal::eSignal_ABRT = (1<<6), CSignal::eSignal_SEGV = (1<<7), CSignal::eSignal_PIPE = (1<<8),
  CSignal::eSignal_TERM = (1<<9), CSignal::eSignal_USR1 = (1<<10), CSignal::eSignal_USR2 = (1<<11), CSignal::eSignal_Any = 0xfffffff
}

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 TSignalMask CSignal::ClearSignals (TSignalMask signals=eSignal_Any)
 Clear 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 >
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

Binary OR of "ESignal".

Definition at line 84 of file ncbi_signal.hpp.


Enumeration Type Documentation

Enumerator:
eSignal_HUP 

Hangup.

eSignal_INT 

Interrupt.

eSignal_QUIT 

Quit.

eSignal_ILL 

Illegal instruction.

eSignal_FPE 

Floating-point exception.

eSignal_ABRT 

Abort.

eSignal_SEGV 

Segmentation violation.

eSignal_PIPE 

Broken pipe.

eSignal_TERM 

Termination.

eSignal_USR1 

User defined signal 1.

eSignal_USR2 

User defined signal 2.

eSignal_Any 

Any/all signal(s) from the list above.

Definition at line 69 of file ncbi_signal.hpp.


Function Documentation

Approve a request.

Parameters:
actionThrottle 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 239 of file request_control.hpp.

References CRequestRateControl::x_Approve().

Referenced by CDiagContext::ApproveMessage(), SWorkerNodeJobContextImpl::GetShutdownLevel(), and SWorkerNodeJobContextImpl::PutProgressMessage().

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 245 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 195 of file ncbiutil.hpp.

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

static TSignalMask CSignal::ClearSignals ( TSignalMask  signals = eSignal_Any) [static]

Clear signals state.

Returns:
Current signal state after clearing. Each bit represent some caught signal.
See also:
TrapSignals, GetSignals, IsSignaled
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.

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 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 158 of file ncbiutil.hpp.

Referenced by CNcbiResource::~CNcbiResource().

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 169 of file ncbiutil.hpp.

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

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 181 of file ncbiutil.hpp.

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

template<typename C , typename F >
C::value_type FindBestChoice ( const C &  container,
F  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 262 of file ncbiutil.hpp.

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

Referenced by CSourceModParser::ApplyAllMods(), CAutoDefFakePromoterClause::CAutoDefFakePromoterClause(), ChangeSeqId(), COligoSpecificityTemplate::COligoSpecificityTemplate(), Convert_Bioseq_Seq_id(), Convert_Seq_entry_Seq_id(), Convert_Seq_entry_Seq_loc(), Convert_SeqSubmit_Seq_id(), CBlastDBExtractor::ExtractAccession(), CBlastDBExtractor::ExtractFasta(), CBlastDBExtractor::ExtractLinksInteger(), CBlastDBExtractor::ExtractMembershipInteger(), CBlastDBExtractor::ExtractSeqId(), CAlignFormatUtil::GetBdlLinkoutInfo(), GetBestBioseqLabel(), CShowBlastDefline::GetBioseqHandleDeflineAndId(), CAlignFormatUtil::GetDisplayIds(), CAlignFormatUtil::GetFullLinkoutUrl(), CBioseq::GetLabel(), CAlignFormatUtil::GetLinkoutUrl(), CBioseq::GetNonLocalId(), CShowBlastDefline::GetSeqIdListString(), GetSequenceLengthAndId(), CSeq_id::GetStringDescr(), MakeFullLengthLocation(), CFastaReader::ParseDefLine(), CGlimmerReader::Read(), CFastaIdsResolver::ResolveSeqId(), CSplignApp::Run(), s_AddOtherRelatedInfoLinks(), s_ConvertBioseqs2TSeqLocVector(), s_ConvertSubjects2TSeqLocVector(), s_DeflineCompare(), s_ExtractQueryIdsFromBioseqSet(), s_FindBestChoiceForDbsource(), s_FixBioseqDeltas(), s_GetBestIDForURL(), s_GetIdLabel(), s_GetSeqIdListString(), s_SeqAlignToXMLHit(), s_SetIntervals(), s_UseFastaReaderDeflines(), SeqDB_SimplifyAccession(), CSearch< LEGACY, NHITS >::SetResult(), CAliToSeq_align::StringToSeq_id(), CSeq_id::WriteAsFasta(), CId1FetchApp::WriteQualityScores(), CBlastFormat::x_CreateSubjectBioseq(), CDisplaySeqalign::x_DisplaySequenceIDForQueryAnchored(), CRemoteBlast::x_ExtractQueryIds(), CBlastFastaInputSource::x_FastaToSeqLoc(), CShowBlastDefline::x_FillDeflineAndId(), CDisplaySeqalign::x_FillSeqid(), CDBSourceItem::x_GatherInfo(), CAlnGraphic::x_GetAlnInfo(), CDisplaySeqalign::x_GetDumpgnlLink(), CAutoDef::x_GetFeatureClauses(), x_GetId(), CDisplaySeqalign::x_PrintDefLine(), CFastaReader::x_ReadSegSet(), COligoSpecificityCheck::x_SavePrimerInfo(), CBlastDBExtractor::x_SetGi2AccMap(), CBlastDBExtractor::x_SetGi2SeqIdMap(), and CSeqFetchApp::xWriteSequence().

const char * CRequestRateControlException::GetErrCodeString ( void  ) const [virtual]
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 107 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 136 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]

Get signals state.

Returns:
Current signal state. Each bit represent some caught signal.
See also:
TrapSignals, ClearSignals, IsSignaled
template<class Key , class Element >
bool InsertMapElement ( map< Key, Element * > &  m,
const Key &  key,
Element data 
) [inline]

Insert map element.

Definition at line 128 of file ncbiutil.hpp.

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

template<class Iterator >
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 286 of file ncbiutil.hpp.

Referenced by CRawScoreVector< Key, Score >::operator+=(), and CRawScoreVector< Key, Score >::Set().

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

Definition at line 299 of file ncbiutil.hpp.

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

Check that any of specified signals is received.

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

Referenced by CNgAligner::x_Align_Impl(), CAsn2FlatApp::x_CreateCancelBenchmarkCallback(), and CInstancedAligner::x_RunAligner().

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

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

Definition at line 97 of file ncbiutil.hpp.

References kEmptyStr, and NCBI_THROW.

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

static bool CSignal::Raise ( ESignal  signal) [static]

Sends a signal to the current process.

Parameters:
signalSignal to send to the current process.
Returns:
TRUE on success, FALSE otherwise. Return FALSE also if the signal is not supported on current platform.
static TSignalMask CSignal::Reset ( void  ) [static]

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

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

Parameters:
num_requests_allowedMaximum number of allowed requests per 'per_period'. Can be kNoLimit for unlimited number of requests (throttler is disabled, Approve() always returns TRUE).
per_periodTime span in which only 'num_requests_allowed' requests can be approved.
min_time_between_requestsMinimum time between two succesful consecutive requests.
throttle_actionSet throttle action by default. The eDefault means eSleep here.
throttle_modeSet 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 CWorkerNodeJobContext::CloseStreams(), CRequestRateControl::CRequestRateControl(), CDiagContext::ResetLogRates(), CDiagContext::SetLogRate_Limit(), and CDiagContext::SetLogRate_Period().

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 118 of file ncbiutil.hpp.

References data, and 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 146 of file ncbiutil.hpp.

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

void CRequestRateControl::Sleep ( CTimeSpan  sleep_time) [static]

Sleep for CTimeSpan.

Parameters:
sleep_timeFor 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().

Referenced by CRequestRateControl::x_Approve().

static void CSignal::TrapSignals ( TSignalMask  signals) [static]

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:
signalsThe set of signals to check.

Referenced by CAsn2FlatApp::Run().

bool CRequestRateControl::x_Approve ( EThrottleAction  action,
CTimeSpan sleeptime 
) [private]
Modified on Sun Dec 21 10:33:49 2014 by modify_doxy.py rev. 426318