NCBI C++ ToolKit
hookdatakey.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: hookdatakey.cpp 33815 2007-05-04 17:18:18Z kazimird $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Author: Eugene Vasilchenko
27 *
28 * File Description:
29 * Class for storing local hooks in CObjectIStream
30 */
31 
32 #include <ncbi_pch.hpp>
33 #include <corelib/ncbistd.hpp>
34 
36 #include <serial/impl/hookdata.hpp>
37 
38 #include <algorithm>
39 
41 
42 
43 /////////////////////////////////////////////////////////////////////////////
44 // CLocalHookSetBase
45 /////////////////////////////////////////////////////////////////////////////
46 
47 
49 {
50 }
51 
52 
54 {
55  Clear();
56 }
57 
58 
59 inline
60 CLocalHookSetBase::THooks::iterator
62 {
63  return lower_bound(m_Hooks.begin(), m_Hooks.end(), key, Compare());
64 }
65 
66 
67 inline
68 CLocalHookSetBase::THooks::const_iterator
70 {
71  return lower_bound(m_Hooks.begin(), m_Hooks.end(), key, Compare());
72 }
73 
74 
75 inline
76 bool CLocalHookSetBase::x_Found(THooks::const_iterator it,
77  const THookData* key) const
78 {
79  return it != m_Hooks.end() && it->first == key;
80 }
81 
82 
84 {
85  THooks::iterator it = x_Find(key);
86  _ASSERT(!x_Found(it, key));
87  m_Hooks.insert(it, TValue(key, CRef<CObject>(hook)));
88 }
89 
90 
92 {
93  THooks::iterator it = x_Find(key);
94  _ASSERT(x_Found(it, key));
95  m_Hooks.erase(it);
96 }
97 
98 
100 {
101  THooks::const_iterator it = x_Find(key);
102  return x_Found(it, key)? it->second.GetPointer(): 0;
103 }
104 
105 
107 {
108  ITERATE ( THooks, it, m_Hooks ) {
109  _ASSERT(it->first);
110  it->first->ForgetLocalHook(*this);
111  }
112  m_Hooks.clear();
113 }
114 
115 
const struct ncbi::grid::netcache::search::fields::KEY key
void ResetHook(THookData *key)
Definition: hookdatakey.cpp:91
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:776
vector< TValue > THooks
Definition: hookdatakey.hpp:66
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:101
const THook * GetHook(const THookData *key) const
Definition: hookdatakey.cpp:99
pair< THookData *, CRef< THook > > TValue
Definition: hookdatakey.hpp:65
sequence::ECompare Compare(const CSeq_loc &loc1, const CSeq_loc &loc2, CScope *scope)
Returns the sequence::ECompare containment relationship between CSeq_locs.
CObject –.
Definition: ncbiobj.hpp:180
bool x_Found(THooks::const_iterator it, const THookData *key) const
Definition: hookdatakey.cpp:76
#define _ASSERT
void SetHook(THookData *key, THook *hook)
Definition: hookdatakey.cpp:83
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:98
THooks::iterator x_Find(const THookData *key)
Definition: hookdatakey.cpp:61
Modified on Wed May 24 16:19:26 2017 by modify_doxy.py rev. 533848