Util.cpp
Go to the documentation of this file.
1 // **********************************************************************
2 //
3 // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
4 //
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
7 //
8 // **********************************************************************
9 
10 #include <IceStorm/Util.h>
12 #include <IceStorm/Instance.h>
13 
14 using namespace IceStorm;
15 using namespace std;
16 
17 namespace IceStormInternal
18 {
20 }
21 
22 string
24 {
25  //
26  // Work out the topic name. If the category is empty then we're in
27  // backwards compatibility mode and the name is just
28  // identity.name. Otherwise identity.name is topic.<topicname>.
29  //
30  if (id.category.empty())
31  {
32  return id.name;
33  }
34 
35  assert(id.name.length() > 6 && id.name.compare(0, 6, "topic.") == 0);
36  return id.name.substr(6);
37 }
38 
40 IceStormInternal::nameToIdentity(const InstancePtr& instance, const string& name)
41 {
42  // Identity is instanceName>/topic.<topicname>
43  Ice::Identity id;
44  id.category = instance->instanceName();
45  id.name = "topic." + name;
46 
47  return id;
48 }
49 
50 string
51 IceStormInternal::describeEndpoints(const Ice::ObjectPrx& proxy)
52 {
53  ostringstream os;
54  if (proxy)
55  {
56  Ice::EndpointSeq endpoints = proxy->ice_getEndpoints();
57  for (Ice::EndpointSeq::const_iterator i = endpoints.begin(); i != endpoints.end(); ++i)
58  {
59  if (i != endpoints.begin())
60  {
61  os << ", ";
62  }
63  os << "\"" << (*i)->toString() << "\"";
64  }
65  }
66  else
67  {
68  os << "subscriber proxy is null";
69  }
70  return os.str();
71 }
72 
73 int
74 IceStormInternal::compareSubscriberRecordKey(const MDB_val* v1, const MDB_val* v2)
75 {
76  SubscriberRecordKey k1, k2;
79  if (k1 < k2)
80  {
81  return -1;
82  }
83  else if (k1 == k2)
84  {
85  return 0;
86  }
87  else
88  {
89  return 1;
90  }
91 }
92 
95 {
97  lluMap.get(txn, lluDbKey, llu);
98  llu.iteration++;
99  lluMap.put(txn, lluDbKey, llu);
100  return llu;
101 }
IceStorm
Definition: DBTypes.ice:22
IceDB::ReadWriteTxn
Definition: IceDB.h:206
IceStorm::SubscriberRecordKey
The key for persistent subscribers, or topics.
Definition: SubscriberRecord.h:149
IceStormInternal::dbContext
IceDB::IceContext dbContext
Definition: Util.cpp:19
IceStormElection::LogUpdate
A struct used for marking the last log update.
Definition: LLURecord.h:100
Util.h
IceDB::Dbi::put
void put(const ReadWriteTxn &txn, const K &key, const D &data, unsigned int flags=0)
Definition: IceDB.h:273
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:523
IceStormElection::LogUpdate::iteration
::Ice::Long iteration
Definition: LLURecord.h:103
IceStormInternal::compareSubscriberRecordKey
int compareSubscriberRecordKey(const MDB_val *v1, const MDB_val *v2)
Definition: Util.cpp:74
IceStorm::lluDbKey
const std::string lluDbKey
Definition: Util.h:31
armarx::read
void read(auto &eigen, auto *table)
Definition: FTSensorCalibrationGuiWidgetController.cpp:462
IceDB::IceContext
Definition: IceDB.h:499
IceDB::Dbi< std::string, IceStormElection::LogUpdate, IceDB::IceContext, Ice::OutputStream >
IceStormInternal::describeEndpoints
std::string describeEndpoints(const Ice::ObjectPrx &)
Definition: Util.cpp:51
IceStormInternal::nameToIdentity
Ice::Identity nameToIdentity(const IceStorm::InstancePtr &, const std::string &)
IceDB::Dbi::get
bool get(const Txn &txn, const K &key, D &data) const
Definition: IceDB.h:256
IceStormInternal::getIncrementedLLU
IceStormElection::LogUpdate getIncrementedLLU(const IceDB::ReadWriteTxn &, IceStorm::LLUMap &)
Definition: Util.cpp:94
SubscriberRecord.h
IceStormInternal::identityToTopicName
std::string identityToTopicName(const Ice::Identity &)
Definition: Util.cpp:23
std
Definition: Application.h:66
IceStormInternal
Definition: Instance.cpp:27
IceUtil::Handle
Definition: forward_declarations.h:29
Instance.h