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 
25 #include <MemoryX/interface/core/MongoDBRefBase.h>
26 
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 :
46  public MongoDBRefBase
47  {
48  public:
49  /**
50  * Construct an empty MongoDBRef
51  *
52  */
53  MongoDBRef();
54 
55  /**
56  * Construct a MongoDBRef
57  *
58  * @param dbName mongo database name
59  * @param docId document ID
60  *
61  */
62  MongoDBRef(const ::std::string& dbName, const ::std::string& docId);
63  ~MongoDBRef() override;
64 
65  // inherited from VariantDataClass
66  public:
67  Ice::ObjectPtr ice_clone() const override
68  {
69  return this->clone();
70  }
71  armarx::VariantDataClassPtr clone(const Ice::Current& c = Ice::emptyCurrent) const override
72  {
73  return new MongoDBRef(*this);
74  }
75  std::string output(const Ice::Current& c = Ice::emptyCurrent) const override
76  {
77  std::stringstream s;
78  s << dbName << ":" << docId;
79  return s.str();
80  }
81  armarx::VariantTypeId getType(const Ice::Current& c = Ice::emptyCurrent) const override
82  {
84  }
85  bool validate(const Ice::Current& c = Ice::emptyCurrent) override
86  {
87  return true;
88  }
89 
90  /**
91  * @brief Write this DBRef into serializer.
92  *
93  *
94  */
95  void serialize(const armarx::ObjectSerializerBasePtr& serializer, const ::Ice::Current& c = Ice::emptyCurrent) const override;
96 
97  /**
98  * @brief Read DBRef from serializer.
99  *
100  */
101  void deserialize(const armarx::ObjectSerializerBasePtr& serializer, const ::Ice::Current& c = Ice::emptyCurrent) override;
102  };
104 
105 }
106 
memoryx::MongoDBRef::getType
armarx::VariantTypeId getType(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: MongoDBRef.h:81
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:71
memoryx::MongoDBRef::deserialize
void deserialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &c=Ice::emptyCurrent) override
Read DBRef from serializer.
Definition: MongoDBRef.cpp:47
AbstractObjectSerializer.h
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
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:75
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:160
armarx::VariantTypeId
Ice::Int VariantTypeId
Definition: Variant.h:44
memoryx::MongoDBRef::validate
bool validate(const Ice::Current &c=Ice::emptyCurrent) override
Definition: MongoDBRef.h:85
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:38
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:751