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

Go to the SVN repository for this file.

1 #ifndef CONN___NETCACHE_PARAMS__HPP
2 #define CONN___NETCACHE_PARAMS__HPP
3 
4 /* $Id: netcache_params.hpp 69195 2015-10-08 15:54:01Z 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  * NetCache API parameters (declarations).
33  *
34  */
35 
36 /// @file netcache_params.hpp
37 /// NetCache client parameters.
38 ///
39 
41 
43 
44 
45 /** @addtogroup NetCacheClient
46  *
47  * @{
48  */
49 
51 {
52 public:
54  eDP_TTL = 1 << 0,
55  eDP_CachingMode = 1 << 1,
56  eDP_MirroringMode = 1 << 2,
57  eDP_ServerCheck = 1 << 3,
58  eDP_ServerCheckHint = 1 << 4,
59  eDP_Password = 1 << 5,
60  eDP_ServerToUse = 1 << 6,
61  eDP_ServerLastUsedPtr = 1 << 7,
62  eDP_MaxBlobAge = 1 << 8,
63  eDP_ActualBlobAgePtr = 1 << 9,
64  eDP_UseCompoundID = 1 << 10,
65  eDP_TryAllServers = 1 << 11,
66  eDP_CacheName = 1 << 12,
67  };
68  typedef unsigned TDefinedParameters;
69 
70  // EVoid is only to avoid having a default constructor.
72  m_DefinedParameters(
73  eDP_TTL |
74  eDP_CachingMode |
75  eDP_MirroringMode |
76  eDP_Password |
77  eDP_UseCompoundID),
78  m_Defaults(NULL),
79  m_TTL(0),
80  m_CachingMode(CNetCacheAPI::eCaching_Disable),
81  m_MirroringMode(CNetCacheAPI::eIfKeyMirrored),
82  m_ServerCheck(eDefault),
83  m_ServerCheckHint(true),
84  m_ServerLastUsedPtr(NULL),
85  m_MaxBlobAge(0),
86  m_ActualBlobAgePtr(NULL),
87  m_UseCompoundID(false),
88  m_TryAllServers(false)
89  {
90  }
91 
93 
94  void LoadNamedParameters(const CNamedParameterList* optional);
95 
96  void SetTTL(unsigned blob_ttl);
97 
99  {
100  m_DefinedParameters |= eDP_CachingMode;
101  m_CachingMode = caching_mode;
102  }
103 
105  {
106  m_DefinedParameters |= eDP_MirroringMode;
107  m_MirroringMode = mirroring_mode;
108  }
109 
110  void SetMirroringMode(const string& mirroring_mode);
111 
112  void SetServerCheck(ESwitch server_check)
113  {
114  m_DefinedParameters |= eDP_ServerCheck;
115  m_ServerCheck = server_check;
116  }
117 
118  void SetServerCheck(const string& server_check);
119 
120  void SetServerCheckHint(bool server_check_hint)
121  {
122  m_DefinedParameters |= eDP_ServerCheckHint;
123  m_ServerCheckHint = server_check_hint;
124  }
125 
126  void SetServerCheckHint(const string& server_check_hint);
127 
128  void SetPassword(const string& password);
129 
131  {
132  m_DefinedParameters |= eDP_ServerToUse;
133  m_ServerToUse = server_to_use;
134  }
135 
136  void SetServerLastUsedPtr(CNetServer* server_last_used_ptr)
137  {
138  m_DefinedParameters |= eDP_ServerLastUsedPtr;
139  m_ServerLastUsedPtr = server_last_used_ptr;
140  }
141 
142  void SetMaxBlobAge(unsigned max_age)
143  {
144  m_DefinedParameters |= eDP_MaxBlobAge;
145  m_MaxBlobAge = max_age;
146  }
147 
148  void SetActualBlobAgePtr(unsigned* actual_age_ptr)
149  {
150  m_DefinedParameters |= eDP_ActualBlobAgePtr;
151  m_ActualBlobAgePtr = actual_age_ptr;
152  }
153 
154  void SetUseCompoundID(bool use_compound_id)
155  {
156  m_DefinedParameters |= eDP_UseCompoundID;
157  m_UseCompoundID = use_compound_id;
158  }
159 
160  void SetTryAllServers(bool try_all_servers)
161  {
162  m_DefinedParameters |= eDP_TryAllServers;
163  m_TryAllServers = try_all_servers;
164  }
165 
166  void SetCacheName(const string& cache_name)
167  {
168  m_DefinedParameters |= eDP_CacheName;
169  m_CacheName = cache_name;
170  }
171 
172  unsigned GetTTL() const;
173  CNetCacheAPI::ECachingMode GetCachingMode() const;
174  CNetCacheAPI::EMirroringMode GetMirroringMode() const;
175  bool GetServerCheck(ESwitch* server_check) const;
176  bool GetServerCheckHint(bool* server_check_hint) const;
177  std::string GetPassword() const;
178  CNetServer GetServerToUse() const;
179  CNetServer* GetServerLastUsedPtr() const;
180  unsigned GetMaxBlobAge() const;
181  unsigned* GetActualBlobAgePtr() const;
182  bool GetUseCompoundID() const;
183  bool GetTryAllServers() const;
184  string GetCacheName() const;
185 
186  static bool StringToBool(const string& bool_str,
187  bool default_value = false);
188 
189 private:
192 
193  unsigned m_TTL;
201  unsigned m_MaxBlobAge;
205  string m_CacheName;
206 };
207 
208 /* @} */
209 
210 
212 
213 #endif /* CONN___NETCACHE_PARAMS__HPP */
Client API for NetCache server.
#define true
Definition: bool.h:35
#define false
Definition: bool.h:36
string
Definition: cgiapp.hpp:687
#define NULL
Definition: ncbistd.hpp:225
void SetUseCompoundID(bool use_compound_id)
ECachingMode
Allows to define caching behavior on a per-call basis.
void SetCacheName(const string &cache_name)
void SetActualBlobAgePtr(unsigned *actual_age_ptr)
void SetServerCheck(ESwitch server_check)
EMirroringMode
Mirroring modes.
void SetMirroringMode(CNetCacheAPI::EMirroringMode mirroring_mode)
void SetServerLastUsedPtr(CNetServer *server_last_used_ptr)
TDefinedParameters m_DefinedParameters
void SetMaxBlobAge(unsigned max_age)
CNetCacheAPI::ECachingMode m_CachingMode
void SetServerToUse(CNetServer::TInstance server_to_use)
CNetServer * m_ServerLastUsedPtr
CNetCacheAPI::EMirroringMode m_MirroringMode
void SetTryAllServers(bool try_all_servers)
const CNetCacheAPIParameters * m_Defaults
void SetServerCheckHint(bool server_check_hint)
void SetCachingMode(CNetCacheAPI::ECachingMode caching_mode)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
enum ENcbiSwitch ESwitch
Aux.
#define NCBI_XCONNECT_EXPORT
NetCache client specs.
EVoid
To create a void (uninitialized) component instance.
Modified on Fri Jun 14 16:49:58 2024 by modify_doxy.py rev. 669887