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

Go to the SVN repository for this file.

1 #ifndef CONNECT_SERVICES__NETSTORAGE_DIRECT_NC__HPP
2 #define CONNECT_SERVICES__NETSTORAGE_DIRECT_NC__HPP
3 
4 /* $Id: netstorage_direct_nc.hpp 76686 2017-02-27 16:44:59Z 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  * Author: Dmitry Kazimirov
30  *
31  * File Description:
32  * Direct access to NetCache servers through NetStorage API (declarations).
33  *
34  */
35 
36 #include "netstorage_rpc.hpp"
37 #include "netcache_rw.hpp"
38 
40 
42 {
43 private:
45  {
46  unique_ptr<CNetCacheReader> reader;
47 
48  ERW_Result Read(void* buf, size_t count, size_t* read) override;
49  ERW_Result PendingCount(size_t* count) override;
50  bool Eof() override;
51 
52  void Close() override;
53  void Abort() override;
54 
55  string GetLoc() const override { return m_BlobKey; }
56 
57  protected:
58  SIState(string& blob_key) : m_BlobKey(blob_key) {}
59 
60  private:
61  string& m_BlobKey;
62  };
63 
65  {
66  unique_ptr<IEmbeddedStreamWriter> writer;
67 
68  ERW_Result Write(const void* buf, size_t count, size_t* written) override;
69  ERW_Result Flush() override;
70 
71  void Close() override;
72  void Abort() override;
73 
74  string GetLoc() const override { return m_BlobKey; }
75 
76  protected:
77  SOState(string& blob_key) : m_BlobKey(blob_key) {}
78 
79  private:
80  string& m_BlobKey;
81  };
82 
83 public:
85  const string& blob_key) :
86  m_NetCacheAPI(netcache_api),
87  m_BlobKey(blob_key),
88  m_IState(fsm, m_BlobKey),
89  m_OState(fsm, m_BlobKey)
90  {
91  }
92 
93  ERW_Result Read(void* buf, size_t count, size_t* bytes_read) override;
94  ERW_Result PendingCount(size_t* count) override;
95 
96  ERW_Result Write(const void* buf, size_t count, size_t* bytes_written) override;
97  ERW_Result Flush() override;
98  void Close() override;
99  void Abort() override;
100 
101  string GetLoc() const override { return m_BlobKey; }
102  bool Eof() override;
103  Uint8 GetSize() override;
104  list<string> GetAttributeList() const override;
105  string GetAttribute(const string& attr_name) const override;
106  void SetAttribute(const string& attr_name, const string& attr_value) override;
107  CNetStorageObjectInfo GetInfo() override;
108  void SetExpiration(const CTimeout&) override;
109 
110  string FileTrack_Path() override;
112  bool Exists() override;
113  ENetStorageRemoveResult Remove() override;
114 
115  void StartWriting();
116 
117 private:
119  string m_BlobKey;
122 };
123 
125 
126 #endif /* CONNECT_SERVICES__NETSTORAGE_DIRECT_NC__HPP */
Client API for NetCache server.
Detailed information about a CNetStorage object.
Definition: netstorage.hpp:96
CTimeout – Timeout interval.
Definition: ncbitime.hpp:1693
static uch flags
unsigned TNetStorageFlags
Bitwise OR of ENetStorageFlags.
Definition: netstorage.hpp:147
function< void(CJsonNode)> TNetStorageProgressCb
Progress callback.
Definition: netstorage.hpp:348
ENetStorageRemoveResult
Result returned by Remove() methods.
Definition: netstorage.hpp:356
uint64_t Uint8
8-byte (64-bit) unsigned integer
Definition: ncbitype.h:105
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
ERW_Result
Result codes for I/O operations.
char * buf
NetCache client specs.
ERW_Result Read(void *buf, size_t count, size_t *read) override
Read as many as "count" bytes into a buffer pointed to by the "buf" argument.
ERW_Result PendingCount(size_t *count) override
Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that a...
unique_ptr< CNetCacheReader > reader
ERW_Result Flush() override
Flush pending data (if any) down to the output device.
unique_ptr< IEmbeddedStreamWriter > writer
ERW_Result Write(const void *buf, size_t count, size_t *written) override
Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device.
CNetStorageObjectInfo GetInfo() override
SNetStorageObjectState< SOState > m_OState
list< string > GetAttributeList() const override
ERW_Result Flush() override
Flush pending data (if any) down to the output device.
ERW_Result Read(void *buf, size_t count, size_t *bytes_read) override
Read as many as "count" bytes into a buffer pointed to by the "buf" argument.
ENetStorageRemoveResult Remove() override
string GetAttribute(const string &attr_name) const override
string Relocate(TNetStorageFlags flags, TNetStorageProgressCb cb) override
string GetLoc() const override
void SetExpiration(const CTimeout &) override
void SetAttribute(const string &attr_name, const string &attr_value) override
SNetStorageObjectState< SIState > m_IState
ERW_Result PendingCount(size_t *count) override
Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that a...
ERW_Result Write(const void *buf, size_t count, size_t *bytes_written) override
Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device.
SNetStorage_NetCacheBlob(SNetStorageObjectImpl &fsm, CNetCacheAPI::TInstance netcache_api, const string &blob_key)
Modified on Fri May 24 14:57:18 2024 by modify_doxy.py rev. 669887