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

Go to the SVN repository for this file.

1 #ifndef CONNECT_SERVICES__NET_OBJECT_HPP
2 #define CONNECT_SERVICES__NET_OBJECT_HPP
3 
4 /* $Id: netcomponent.hpp 76647 2017-02-23 18:35:51Z sadyrovr $
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  * Authors: Dmitry Kazimirov
30  *
31  * File Description:
32  *
33  */
34 
35 #include <connect/connect_export.h>
36 
37 #include <corelib/ncbiobj.hpp>
38 #include <corelib/ncbicntr.hpp>
39 
41 
42 ///////////////////////////////////////////////////////////////////////////
43 //
44 
45 /// To create a void (uninitialized) component instance
46 enum EVoid {
47  eVoid ///< To create a void (uninitialized) instance of a component
48 };
49 
50 template <class S>
52 {
53 public:
54  void Lock(const S* object) const
55  {
56  CObjectCounterLocker::Lock(reinterpret_cast<const CObject*>(object));
57  }
58 
59  void Relock(const S* object) const
60  {
61  CObjectCounterLocker::Relock(reinterpret_cast<const CObject*>(object));
62  }
63 
64  void Unlock(const S* object) const
65  {
66  CObjectCounterLocker::Unlock(reinterpret_cast<const CObject*>(object));
67  }
68 
69  void UnlockRelease(const S* object) const
70  {
72  reinterpret_cast<const CObject*>(object));
73  }
74 
75  void TransferLock(const S* object,
76  const CNetComponentCounterLocker& old_locker) const
77  {
79  reinterpret_cast<const CObject*>(object), old_locker);
80  }
81 };
82 
83 template <class S>
85 
86 template <class S> inline S& operator--( CNetRef<S>& r, int) { return r.GetObject(); }
87 template <class S> inline const S& operator--(const CNetRef<S>& r, int) { return r.GetObject(); }
88 
89 #define NCBI_NET_COMPONENT_DEF(Class, Impl) \
90  protected: \
91  CNetRef<Impl> m_Impl; \
92  public: \
93  typedef Impl* TInstance; \
94  Class(EVoid) {} \
95  Class(Impl* impl) : m_Impl(impl) {} \
96  Class& operator =(Impl* impl) { m_Impl = impl; return *this; } \
97  operator Impl*() { return m_Impl.GetPointer(); } \
98  operator const Impl*() const { return m_Impl.GetPointer(); } \
99  Impl& operator --(int) { return m_Impl.GetObject(); } \
100  const Impl& operator --(int) const { return m_Impl.GetObject(); } \
101  Impl* operator ->() { return m_Impl.GetPointer(); } \
102  const Impl* operator ->() const { return m_Impl.GetPointer(); }
103 
104 #define NCBI_NET_COMPONENT_IMPL(component) \
105  NCBI_NET_COMPONENT_DEF(C##component, S##component##Impl)
106 
107 #define NCBI_NET_COMPONENT(component) \
108  NCBI_NET_COMPONENT_IMPL(component) \
109  C##component() {}
110 
112 
113 #endif // CONNECT_SERVICES__SERVER_CONN_HPP
void TransferLock(const S *object, const CNetComponentCounterLocker &old_locker) const
void Relock(const S *object) const
void Lock(const S *object) const
void Unlock(const S *object) const
void UnlockRelease(const S *object) const
CObject –.
Definition: ncbiobj.hpp:180
CRef –.
Definition: ncbiobj.hpp:618
void TransferLock(const CObject *object, const CObjectCounterLocker &old_locker) const
Definition: ncbiobj.cpp:1179
void Relock(const CObject *object) const
Definition: ncbiobj.cpp:1152
void UnlockRelease(const CObject *object) const
Definition: ncbiobj.cpp:1167
void Unlock(const CObject *object) const
Definition: ncbiobj.cpp:1158
void Lock(const CObject *object) const
Definition: ncbiobj.cpp:1143
#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 S(x, n)
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
S & operator--(CNetRef< S > &r, int)
EVoid
To create a void (uninitialized) component instance.
@ eVoid
To create a void (uninitialized) instance of a component.
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
Modified on Wed Apr 17 13:08:30 2024 by modify_doxy.py rev. 669887