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 
30 namespace armarx::VariantType
31 {
32  const VariantTypeId MongoDBRef = Variant::addTypeName("::memoryx::MongoDBRefBase");
33 }
34 
35 namespace 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  */
52  MongoDBRef();
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:
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
memoryx::MongoDBRef::getType
armarx::VariantTypeId getType(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: MongoDBRef.h:87
memoryx::MongoDBRef::ice_clone
Ice::ObjectPtr ice_clone() const override
Definition: MongoDBRef.h:67
memoryx::MongoDBRef::clone
armarx::VariantDataClassPtr clone(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: MongoDBRef.h:73
memoryx::MongoDBRef::deserialize
void deserialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &c=Ice::emptyCurrent) override
Read DBRef from serializer.
Definition: MongoDBRef.cpp:48
AbstractObjectSerializer.h
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
memoryx::MongoDBRef
Represents a cross-database reference to a document in MongoDB.
Definition: MongoDBRef.h:45
memoryx::MongoDBRef::output
std::string output(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: MongoDBRef.h:79
IceInternal::Handle
Definition: forward_declarations.h:8
memoryx::MongoDBRef::~MongoDBRef
~MongoDBRef() override
armarx::VariantType::MongoDBRef
const VariantTypeId MongoDBRef
Definition: MongoDBRef.h:32
armarx::VariantType
Definition: ChannelRef.h:167
armarx::VariantTypeId
Ice::Int VariantTypeId
Definition: Variant.h:43
memoryx::MongoDBRef::validate
bool validate(const Ice::Current &c=Ice::emptyCurrent) override
Definition: MongoDBRef.h:93
memoryx::MongoDBRef::MongoDBRef
MongoDBRef()
Construct an empty MongoDBRef.
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
memoryx::MongoDBRef::serialize
void serialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &c=Ice::emptyCurrent) const override
Write this DBRef into serializer.
Definition: MongoDBRef.cpp:37
Variant.h
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx::Variant::addTypeName
static VariantTypeId addTypeName(const std::string &typeName)
Register a new type for the use in a Variant.
Definition: Variant.cpp:869