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

Go to the SVN repository for this file.

1 /* $Id: hookdata.cpp 45767 2010-05-17 13:55:18Z gouriano $
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 information in CTypeInfo
30 */
31 
32 #include <ncbi_pch.hpp>
33 #include <corelib/ncbistd.hpp>
34 
35 #include <serial/impl/hookdata.hpp>
36 #include <serial/impl/objstack.hpp>
37 
39 
40 
41 /////////////////////////////////////////////////////////////////////////////
42 // CHookDataBase
43 /////////////////////////////////////////////////////////////////////////////
44 
45 
47 {
48 }
49 
50 
52 {
53  _ASSERT(m_HookCount.Get() == 0);
54 }
55 
56 
58 {
59  _ASSERT(hook);
61  key.SetHook(this, hook);
62  m_HookCount.Add(1);
64  _ASSERT(!Empty());
65 }
66 
67 
69 {
70  _ASSERT(!Empty());
72  key.ResetHook(this);
73  m_HookCount.Add(-1);
75 }
76 
77 
79 {
80  _ASSERT(!Empty());
82  _ASSERT(key.GetHook(this) != 0);
83  m_HookCount.Add(-1);
85 }
86 
87 
89 {
90  _ASSERT(hook);
92  m_GlobalHook.Reset(hook);
93  m_HookCount.Add(1);
94  _ASSERT(m_HookCount.Get() > 0);
95  _ASSERT(!Empty());
96 }
97 
98 
100 {
101  _ASSERT(!Empty());
103  _ASSERT(m_HookCount.Get() > 0);
104  m_GlobalHook.Reset();
105  m_HookCount.Add(-1);
106 }
107 
108 void CHookDataBase::SetPathHook(CObjectStack* stk, const string& path, THook* hook)
109 {
110  if (m_PathHooks.SetHook(stk, path, hook)) {
111  m_HookCount.Add(hook ? 1 : -1);
112  }
113 }
114 
115 void CHookDataBase::ResetPathHook(CObjectStack* stk, const string& path)
116 {
117  if (m_PathHooks.SetHook(stk, path, 0)) {
118  m_HookCount.Add(-1);
119  }
120 }
121 
122 
CObject –.
Definition: ncbiobj.hpp:180
Include a standard set of the NCBI C++ Toolkit most basic headers.
TValue Add(int delta) THROWS_NONE
Atomically add value (=delta), and return new counter value.
Definition: ncbicntr.hpp:278
TValue Get(void) const THROWS_NONE
Get atomic counter value.
Definition: ncbicntr.hpp:168
#define _DEBUG_ARG(arg)
Definition: ncbidbg.hpp:134
void ForgetLocalHook(TLocalHooks &key)
Definition: hookdata.cpp:78
void ResetPathHook(CObjectStack *stk, const string &path)
Definition: hookdata.cpp:115
void SetPathHook(CObjectStack *stk, const string &path, THook *hook)
Definition: hookdata.cpp:108
bool Empty(void) const
Definition: hookdata.hpp:66
CPathHook m_PathHooks
Definition: hookdata.hpp:102
void SetLocalHook(TLocalHooks &key, THook *hook)
Definition: hookdata.cpp:57
~CHookDataBase(void)
Definition: hookdata.cpp:51
CHookDataBase(void)
Definition: hookdata.cpp:46
CAtomicCounter_WithAutoInit m_HookCount
Definition: hookdata.hpp:103
void ResetLocalHook(TLocalHooks &key)
Definition: hookdata.cpp:68
void ResetGlobalHook(void)
Definition: hookdata.cpp:99
CRef< THook > m_GlobalHook
Definition: hookdata.hpp:101
void SetGlobalHook(THook *hook)
Definition: hookdata.cpp:88
bool SetHook(CObjectStack *stk, const string &path, CObject *hook)
Definition: pathhook.cpp:58
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
size_t TNCBIAtomicValue
Define platform specific atomic-operations macros/values.
const struct ncbi::grid::netcache::search::fields::KEY key
#define _ASSERT
Modified on Fri Sep 20 14:57:26 2024 by modify_doxy.py rev. 669887