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

Go to the SVN repository for this file.

1 #ifndef HOOKDATAKEY__HPP
2 #define HOOKDATAKEY__HPP
3 
4 /* $Id: hookdatakey.hpp 44947 2010-03-01 15:45:11Z gouriano $
5 * ===========================================================================
6 *
7 * PUBLIC DOMAIN NOTICE
8 * National Center for Biotechnology Information
9 *
10 * This software/database is a "United States Government Work" under the
11 * terms of the United States Copyright Act. It was written as part of
12 * the author's official duties as a United States Government employee and
13 * thus cannot be copyrighted. This software/database is freely available
14 * to the public for use. The National Library of Medicine and the U.S.
15 * Government have not placed any restriction on its use or reproduction.
16 *
17 * Although all reasonable efforts have been taken to ensure the accuracy
18 * and reliability of the software and data, the NLM and the U.S.
19 * Government do not and cannot warrant the performance or results that
20 * may be obtained by using this software or data. The NLM and the U.S.
21 * Government disclaim all warranties, express or implied, including
22 * warranties of performance, merchantability or fitness for any particular
23 * purpose.
24 *
25 * Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * Author: Eugene Vasilchenko
30 *
31 * File Description:
32 * !!! PUT YOUR DESCRIPTION HERE !!!
33 */
34 
35 #include <corelib/ncbistd.hpp>
36 #include <corelib/ncbiobj.hpp>
37 
38 #include <vector>
39 
40 /** @addtogroup HookSupport
41  *
42  * @{
43  */
44 
45 
47 
48 class CHookDataBase;
49 
51 {
52 public:
54  typedef CObject THook;
55 
56  CLocalHookSetBase(void);
57  ~CLocalHookSetBase(void);
58 
59  void Clear(void);
60  bool IsEmpty(void) const
61  {
62  return m_Hooks.empty();
63  }
64 
65  typedef pair<THookData*, CRef<THook> > TValue;
66  typedef vector<TValue> THooks;
67 
68 protected:
69  void ResetHook(THookData* key);
70  void SetHook(THookData* key, THook* hook);
71  const THook* GetHook(const THookData* key) const;
72 
73 private:
76 
77  friend class CHookDataBase;
78 
79  struct Compare
80  {
81  bool operator()(const TValue& v1, const TValue& v2) const
82  {
83  return v1.first < v2.first;
84  }
85  bool operator()(const THookData* key, const TValue& value) const
86  {
87  return key < value.first;
88  }
89  bool operator()(const TValue& value, const THookData* key) const
90  {
91  return value.first < key;
92  }
93  };
94 
95  THooks::iterator x_Find(const THookData* key);
96  THooks::const_iterator x_Find(const THookData* key) const;
97  bool x_Found(THooks::const_iterator it, const THookData* key) const;
98 
100 };
101 
102 
103 template<class Hook>
105 {
107 public:
109  typedef Hook THook;
110 
111 protected:
112  friend class CHookDataBase;
113  void SetHook(THookData* key, THook* hook)
114  {
115  CParent::SetHook(key, hook);
116  }
118  {
119  return static_cast<THook*>(CParent::GetHook(key));
120  }
121 };
122 
124 
125 #endif /* HOOKDATAKEY__HPP */
126 
127 
128 /* @} */
CObject –.
Definition: ncbiobj.hpp:180
char value[7]
Definition: config.c:431
Include a standard set of the NCBI C++ Toolkit most basic headers.
const CVect2< U > & v2
Definition: globals.hpp:440
bool operator()(const TValue &value, const THookData *key) const
Definition: hookdatakey.hpp:89
bool IsEmpty(void) const
Definition: hookdatakey.hpp:60
void SetHook(THookData *key, THook *hook)
Definition: hookdatakey.cpp:83
pair< THookData *, CRef< THook > > TValue
Definition: hookdatakey.hpp:65
void SetHook(THookData *key, THook *hook)
bool operator()(const TValue &v1, const TValue &v2) const
Definition: hookdatakey.hpp:81
const THook * GetHook(const THookData *key) const
Definition: hookdatakey.cpp:99
CLocalHookSetBase CParent
vector< TValue > THooks
Definition: hookdatakey.hpp:66
CLocalHookSetBase(const CLocalHookSetBase &)
CLocalHookSetBase & operator=(const CLocalHookSetBase &)
CHookDataBase THookData
Definition: hookdatakey.hpp:53
bool operator()(const THookData *key, const TValue &value) const
Definition: hookdatakey.hpp:85
CParent::THookData THookData
THook * GetHook(THookData *key) const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_XSERIAL_EXPORT
Definition: ncbi_export.h:1435
const struct ncbi::grid::netcache::search::fields::KEY key
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Modified on Fri Feb 23 11:45:10 2024 by modify_doxy.py rev. 669887