1 #ifndef GENBANK_STANDALONE_RESULT_HPP
2 #define GENBANK_STANDALONE_RESULT_HPP
3 
4 /*  $Id: standalone_result.hpp 440717 2014-07-16 16:13:07Z vasilche $
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 *   Class for storing results of reader's request and thread synchronization
33 *
34 * ===========================================================================
35 */
36 
37 #include <objtools/data_loaders/genbank/impl/request_result.hpp>
38 #include <objtools/data_loaders/genbank/impl/dispatcher.hpp>
39 
40 
41 BEGIN_NCBI_SCOPE
42 BEGIN_SCOPE(objects)
43 
44 
45 class CStandaloneRequestResult :
46     public CReaderRequestResult
47 {
48 public:
49     CStandaloneRequestResult(const CSeq_id_Handle& requested_id);
50     virtual ~CStandaloneRequestResult(void);
51 
52     virtual CTSE_LoadLock GetTSE_LoadLock(const TKeyBlob& blob_id);
53     virtual CTSE_LoadLock GetTSE_LoadLockIfLoaded(const TKeyBlob& blob_id);
54 
55     virtual operator CInitMutexPool&(void);
56 
57 
58     virtual TConn GetConn(void);
59     virtual void ReleaseConn(void);
60 
61     void ReleaseTSE_LoadLocks();
62 
63     CInitMutexPool    m_MutexPool;
64 
65     CRef<CDataSource> m_DataSource;
66 
67 };
68 
69 
70 /////////////////////////////////////////////////////////////////////////////
71 // CStandaloneRequestResult
72 /////////////////////////////////////////////////////////////////////////////
73 
74 
75 inline
76 CStandaloneRequestResult::
CStandaloneRequestResult(const CSeq_id_Handle & requested_id)77 CStandaloneRequestResult(const CSeq_id_Handle& requested_id)
78     : CReaderRequestResult(requested_id,
79                            *new CReadDispatcher(),
80                            *new CGBInfoManager(100))
81 {
82 }
83 
84 
85 inline
~CStandaloneRequestResult(void)86 CStandaloneRequestResult::~CStandaloneRequestResult(void)
87 {
88 }
89 
90 
91 inline
92 CTSE_LoadLock
GetTSE_LoadLock(const CBlob_id & blob_id)93 CStandaloneRequestResult::GetTSE_LoadLock(const CBlob_id& blob_id)
94 {
95     if ( !m_DataSource ) {
96         m_DataSource = new CDataSource;
97     }
98     CDataLoader::TBlobId key(new CBlob_id(blob_id));
99     return m_DataSource->GetTSE_LoadLock(key);
100 }
101 
102 
103 inline
104 CTSE_LoadLock
GetTSE_LoadLockIfLoaded(const CBlob_id & blob_id)105 CStandaloneRequestResult::GetTSE_LoadLockIfLoaded(const CBlob_id& blob_id)
106 {
107     if ( !m_DataSource ) {
108         m_DataSource = new CDataSource;
109     }
110     CDataLoader::TBlobId key(new CBlob_id(blob_id));
111     return m_DataSource->GetTSE_LoadLockIfLoaded(key);
112 }
113 
114 
115 inline
operator CInitMutexPool&(void)116 CStandaloneRequestResult::operator CInitMutexPool&(void)
117 {
118     return m_MutexPool;
119 }
120 
121 
122 inline
GetConn(void)123 CStandaloneRequestResult::TConn CStandaloneRequestResult::GetConn(void)
124 {
125     return 0;
126 }
127 
128 
129 inline
ReleaseConn(void)130 void CStandaloneRequestResult::ReleaseConn(void)
131 {
132 }
133 
134 
135 END_SCOPE(objects)
136 END_NCBI_SCOPE
137 
138 
139 #endif
140