32 Pib::Pib(
const std::string& scheme,
const std::string& location, shared_ptr<PibImpl> impl)
34 , m_location(location)
35 , m_isDefaultIdentityLoaded(false)
37 , m_impl(std::move(impl))
39 BOOST_ASSERT(m_impl !=
nullptr);
42 Pib::~Pib() =
default;
45 Pib::getPibLocator()
const
47 return m_scheme +
":" + m_location;
51 Pib::setTpmLocator(
const std::string& tpmLocator)
53 if (tpmLocator == m_impl->getTpmLocator()) {
57 m_impl->setTpmLocator(tpmLocator);
61 Pib::getTpmLocator()
const
63 std::string tpmLocator = m_impl->getTpmLocator();
64 if (tpmLocator.empty()) {
73 m_impl->clearIdentities();
74 m_impl->setTpmLocator(
"");
75 m_isDefaultIdentityLoaded =
false;
80 Pib::addIdentity(
const Name& identity)
82 BOOST_ASSERT(m_identities.isConsistent());
84 return m_identities.add(identity);
88 Pib::removeIdentity(
const Name& identity)
90 BOOST_ASSERT(m_identities.isConsistent());
92 if (m_isDefaultIdentityLoaded && m_defaultIdentity.getName() == identity) {
93 m_isDefaultIdentityLoaded =
false;
96 m_identities.remove(identity);
100 Pib::getIdentity(
const Name& identity)
const
102 BOOST_ASSERT(m_identities.isConsistent());
104 return m_identities.get(identity);
108 Pib::getIdentities()
const
110 BOOST_ASSERT(m_identities.isConsistent());
116 Pib::setDefaultIdentity(
const Name& identityName)
118 BOOST_ASSERT(m_identities.isConsistent());
120 m_defaultIdentity = m_identities.add(identityName);
121 m_isDefaultIdentityLoaded =
true;
122 NDN_LOG_DEBUG(
"Default identity is set to " << identityName);
124 m_impl->setDefaultIdentity(identityName);
125 return m_defaultIdentity;
129 Pib::getDefaultIdentity()
const
131 BOOST_ASSERT(m_identities.isConsistent());
133 if (!m_isDefaultIdentityLoaded) {
134 m_defaultIdentity = m_identities.get(m_impl->getDefaultIdentity());
135 m_isDefaultIdentityLoaded =
true;
136 NDN_LOG_DEBUG(
"Default identity is " << m_defaultIdentity.getName());
139 BOOST_ASSERT(m_impl->getDefaultIdentity() == m_defaultIdentity.getName());
141 return m_defaultIdentity;
Represents an absolute name.
Container of identities of a Pib.
A frontend handle of an Identity.
represents a semantic error
#define NDN_LOG_DEBUG(expression)
Log at DEBUG level.
#define NDN_LOG_INIT(name)
Define a non-member log module.