rippled
NodeObject.cpp
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #include <ripple/nodestore/NodeObject.h>
21 #include <memory>
22 
23 namespace ripple {
24 
25 //------------------------------------------------------------------------------
26 
28  NodeObjectType type,
29  Blob&& data,
30  uint256 const& hash,
32  : mType(type), mHash(hash), mData(std::move(data))
33 {
34 }
35 
38 {
39  return std::make_shared<NodeObject>(
40  type, std::move(data), hash, PrivateAccess());
41 }
42 
45 {
46  return mType;
47 }
48 
49 uint256 const&
51 {
52  return mHash;
53 }
54 
55 Blob const&
57 {
58  return mData;
59 }
60 
61 } // namespace ripple
std::shared_ptr< NodeObject >
std::vector< unsigned char >
ripple::NodeObjectType
NodeObjectType
The types of node objects.
Definition: NodeObject.h:32
ripple::NodeObject::createObject
static std::shared_ptr< NodeObject > createObject(NodeObjectType type, Blob &&data, uint256 const &hash)
Create an object from fields.
Definition: NodeObject.cpp:37
ripple::NodeObject::mHash
const uint256 mHash
Definition: NodeObject.h:99
ripple::NodeObject::mData
const Blob mData
Definition: NodeObject.h:100
ripple::NodeObject::getData
Blob const & getData() const
Returns the underlying data.
Definition: NodeObject.cpp:56
ripple::NodeObject::getType
NodeObjectType getType() const
Returns the type of this object.
Definition: NodeObject.cpp:44
ripple::base_uint< 256 >
memory
ripple::NodeObject::mType
const NodeObjectType mType
Definition: NodeObject.h:98
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
std
STL namespace.
ripple::NodeObject::getHash
uint256 const & getHash() const
Returns the hash of the data.
Definition: NodeObject.cpp:50
ripple::NodeObject::NodeObject
NodeObject(NodeObjectType type, Blob &&data, uint256 const &hash, PrivateAccess)
Definition: NodeObject.cpp:27
ripple::NodeObject::PrivateAccess
Definition: NodeObject.h:58