Database.cpp
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::CommonStorage
17 * @author Alexey Kozlov ( kozlov at kit dot edu)
18 * @date 2013
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #include "Database.h"
24 
25 #include <IceUtil/UUID.h>
26 
27 using namespace memoryx;
28 
29 Database::Database(const CommonStorageInterfacePtr& dbConn, const std::string& dbName) :
30  dbConn(dbConn), dbName(dbName)
31 {
32  iceId.name = IceUtil::generateUUID();
33 }
34 
35 Database::~Database() = default;
36 
37 CollectionInterfacePrx
38 Database::requestCollection(const std::string& collName, const ::Ice::Current& c)
39 {
40  std::unique_lock lock(dbConnectionMutex);
41  return dbConn->requestCollection(getCollectionNS(collName), c);
42 }
43 
44 void
45 Database::releaseCollection(const ::memoryx::CollectionInterfacePrx& coll, const ::Ice::Current& c)
46 {
47  std::unique_lock lock(dbConnectionMutex);
48  return dbConn->releaseCollection(coll, c);
49 }
50 
51 void
52 Database::dropCollection(const ::std::string& collName, const ::Ice::Current& c)
53 {
54  std::unique_lock lock(dbConnectionMutex);
55  dbConn->dropCollection(getCollectionNS(collName), c);
56 }
57 
58 std::string
59 Database::getName(const ::Ice::Current&)
60 {
61  return dbName;
62 }
63 
66 {
67  return iceId;
68 }
69 
70 std::string
71 Database::getCollectionNS(std::string collName)
72 {
73  return dbName + "." + collName;
74 }
memoryx::Database::requestCollection
CollectionInterfacePrx requestCollection(const ::std::string &collName, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: Database.cpp:38
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
memoryx::Database::releaseCollection
void releaseCollection(const ::memoryx::CollectionInterfacePrx &coll, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: Database.cpp:45
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:570
memoryx::Database::getIceId
Ice::Identity getIceId() const
Definition: Database.cpp:65
memoryx::Database::Database
Database(const CommonStorageInterfacePtr &dbConn, const std::string &dbName)
Definition: Database.cpp:29
Database.h
memoryx::Database::dropCollection
void dropCollection(const ::std::string &collName, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: Database.cpp:52
memoryx::Database::~Database
~Database() override
memoryx::Database::getName
std::string getName(const ::Ice::Current &=Ice::emptyCurrent) override
Definition: Database.cpp:59