Project

General

Profile

Task #3349

Change the ownership model of Pib and its related entities

Added by Yingdi Yu about 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Security
Target version:
Start date:
11/20/2015
Due date:
% Done:

100%

Estimated time:

Description

Current Pib Implementation simply creates an instance whenever returning an identity (similarly, an identity creates an instance when returning a key). As a result, multiple instances may corresponds the same identity or key. Changing the status of one instance may not affect the other instances.

A desired solution could be to create only one instance for an identity (or key) and give the shared pointer (const) to others, const reference could be another option, but it may have some problem in initialization.

Therefore, we plan to change the ownership as, each identity is maintained in the PIB's IdentityContainer, which provides shared pointer to the identity instance as handle for others. Similar for key and KeyContainer.

History

#1 Updated by Yingdi Yu about 3 years ago

  • Category set to Security

#2 Updated by Junxiao Shi about 3 years ago

each identity is maintained in the PIB's IdentityContainer, which provides shared pointer to the identity instance as handle for others

It's unnecessary to expose shared_ptr in public API.

Instead:

class Identity // copyable
{
public:
  explicit operator bool() const; ///< valid (not deleted)
  bool operator!() const; ///< deleted

  const Name& getName() const; ///< identity name

  // (other getters)

private:
  weak_ptr<detail::IdentityImpl> m_impl;
};

namespace detail {
class IdentityImpl;
} // namespace detail

class IdentityContainer : noncopyable
{
public:
  Identity getIdentity(..) const;

private:
  std::container<shared_ptr<detail::IdentityImpl>> m_container;
};

#3 Updated by Yingdi Yu about 3 years ago

I think you are right, weak_pointer is a better approach. actually shared_ptr does not address the issue completely. I will use weak_ptr in implementation.

#4 Updated by Yingdi Yu about 3 years ago

  • Status changed from New to Code review

#5 Updated by Alex Afanasyev about 3 years ago

  • Target version set to v0.5

#6 Updated by Yingdi Yu over 2 years ago

  • Status changed from Code review to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF