MongoDBRef.h
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* ArmarX is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License version 2 as
6* published by the Free Software Foundation.
7*
8* ArmarX is distributed in the hope that it will be useful, but
9* WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details.
12*
13* You should have received a copy of the GNU General Public License
14* along with this program. If not, see <http://www.gnu.org/licenses/>.
15*
16* @package MemoryX::Core
17* @author Alexey Kozlov ( kozlov at kit dot edu)
18* @date Sep 23, 2012
19* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21*/
22
23#pragma once
24
27
28#include <MemoryX/interface/core/MongoDBRefBase.h>
29
30namespace armarx::VariantType
31{
32 const VariantTypeId MongoDBRef = Variant::addTypeName("::memoryx::MongoDBRefBase");
33}
34
35namespace memoryx
36{
37 /**
38 * @class MongoDBRef
39 * @brief Represents a cross-database reference to a document in MongoDB.
40 * @ingroup Core
41 *
42 * The MongoDBRef holds a pair of (database_name, document_id). It is currently used to store
43 * references to GridFS files in EntityAttribute.
44 */
45 class MongoDBRef : public MongoDBRefBase
46 {
47 public:
48 /**
49 * Construct an empty MongoDBRef
50 *
51 */
53
54 /**
55 * Construct a MongoDBRef
56 *
57 * @param dbName mongo database name
58 * @param docId document ID
59 *
60 */
61 MongoDBRef(const ::std::string& dbName, const ::std::string& docId);
62 ~MongoDBRef() override;
63
64 // inherited from VariantDataClass
65 public:
66 Ice::ObjectPtr
67 ice_clone() const override
68 {
69 return this->clone();
70 }
71
72 armarx::VariantDataClassPtr
73 clone(const Ice::Current& c = Ice::emptyCurrent) const override
74 {
75 return new MongoDBRef(*this);
76 }
77
78 std::string
79 output(const Ice::Current& c = Ice::emptyCurrent) const override
80 {
81 std::stringstream s;
82 s << dbName << ":" << docId;
83 return s.str();
84 }
85
87 getType(const Ice::Current& c = Ice::emptyCurrent) const override
88 {
90 }
91
92 bool
93 validate(const Ice::Current& c = Ice::emptyCurrent) override
94 {
95 return true;
96 }
97
98 /**
99 * @brief Write this DBRef into serializer.
100 *
101 *
102 */
103 void serialize(const armarx::ObjectSerializerBasePtr& serializer,
104 const ::Ice::Current& c = Ice::emptyCurrent) const override;
105
106 /**
107 * @brief Read DBRef from serializer.
108 *
109 */
110 void deserialize(const armarx::ObjectSerializerBasePtr& serializer,
111 const ::Ice::Current& c = Ice::emptyCurrent) override;
112 };
113
115
116} // namespace memoryx
constexpr T c
static VariantTypeId addTypeName(const std::string &typeName)
Register a new type for the use in a Variant.
Definition Variant.cpp:869
void deserialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &c=Ice::emptyCurrent) override
Read DBRef from serializer.
std::string output(const Ice::Current &c=Ice::emptyCurrent) const override
Definition MongoDBRef.h:79
MongoDBRef(const ::std::string &dbName, const ::std::string &docId)
Construct a MongoDBRef.
bool validate(const Ice::Current &c=Ice::emptyCurrent) override
Definition MongoDBRef.h:93
armarx::VariantDataClassPtr clone(const Ice::Current &c=Ice::emptyCurrent) const override
Definition MongoDBRef.h:73
~MongoDBRef() override
armarx::VariantTypeId getType(const Ice::Current &c=Ice::emptyCurrent) const override
Definition MongoDBRef.h:87
Ice::ObjectPtr ice_clone() const override
Definition MongoDBRef.h:67
MongoDBRef()
Construct an empty MongoDBRef.
void serialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &c=Ice::emptyCurrent) const override
Write this DBRef into serializer.
const VariantTypeId MongoDBRef
Definition MongoDBRef.h:32
Ice::Int VariantTypeId
Definition Variant.h:43
VirtualRobot headers.
IceInternal::Handle< MongoDBRef > MongoDBRefPtr
Definition MongoDBRef.h:114