Kinetic C/C++ Client
Main Page
Classes
Files
File List
All
Classes
Functions
Variables
Pages
include
kinetic
incoming_value.h
1
/*
2
* kinetic-cpp-client
3
* Copyright (C) 2014 Seagate Technology.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
*
19
*/
20
21
#ifndef KINETIC_CPP_CLIENT_INCOMING_VALUE_H_
22
#define KINETIC_CPP_CLIENT_INCOMING_VALUE_H_
23
24
#include <string>
25
26
#include "common.h"
27
28
namespace
kinetic
{
29
30
/*
31
* IncomingValueInterface represents a byte-array value arriving in a PUT
32
* request. This can take the form of either a string in memory or a socket
33
* file descriptor from which we can read a specified number of bytes.
34
*/
35
class
IncomingValueInterface
{
36
public
:
37
virtual
~
IncomingValueInterface
() {}
38
39
virtual
size_t
size() = 0;
40
41
/*
42
* TransferToFile transfers the contents of the value to a file represented
43
* by the given file descriptor. As soon as this method has been called,
44
* the object should be considered defunct and all further calls to
45
* TransferToFile and ToString will fail.
46
*/
47
virtual
bool
TransferToFile(
int
fd) = 0;
48
49
/*
50
* ToString copies the value to the string pointed to by the result
51
* parameter.
52
*/
53
virtual
bool
ToString(std::string *result) = 0;
54
55
/*
56
* Consume does whatever is necessary to consume the resources underlying
57
* the value. In the SpliceableValue implementation this consists of
58
* reading the appropriate bytes from the socket and throwing them away.
59
* After this method has been called, the object should be considered
60
* defunct and all further calls to TransferToFile and ToString will fail.
61
*/
62
virtual
void
Consume() = 0;
63
};
64
65
/*
66
* IncomingStringValue represents a value stored internally as a plain string.
67
* It's preferable to use SpliceableValue whenever possible because of its
68
* performance benefits.
69
*/
70
class
IncomingStringValue
:
public
IncomingValueInterface
{
71
public
:
72
explicit
IncomingStringValue
(
const
std::string &s);
73
size_t
size();
74
bool
TransferToFile(
int
fd);
75
bool
ToString(std::string *result);
76
void
Consume();
77
78
private
:
79
const
std::string s_;
80
bool
defunct_;
81
DISALLOW_COPY_AND_ASSIGN(
IncomingStringValue
);
82
};
83
84
class
IncomingValueFactoryInterface
{
85
public
:
86
virtual
~
IncomingValueFactoryInterface
() {}
87
virtual
IncomingValueInterface
*NewValue(
int
fd,
size_t
n) = 0;
88
};
89
90
}
// namespace kinetic
91
92
#endif // KINETIC_CPP_CLIENT_INCOMING_VALUE_H_
kinetic::IncomingStringValue
Definition:
incoming_value.h:70
kinetic::IncomingValueFactoryInterface
Definition:
incoming_value.h:84
kinetic::IncomingValueInterface
Definition:
incoming_value.h:35
kinetic
Definition:
blocking_smoketest.cc:26
Generated on Mon Mar 30 2015 08:24:47 for Kinetic C/C++ Client by
1.8.8