Project

General

Profile

Actions

Task #3349

closed

Change the ownership model of Pib and its related entities

Added by Yingdi Yu over 8 years ago. Updated almost 8 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.

Actions #1

Updated by Yingdi Yu over 8 years ago

  • Category set to Security
Actions #2

Updated by Junxiao Shi over 8 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;
};
Actions #3

Updated by Yingdi Yu over 8 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.

Actions #4

Updated by Yingdi Yu over 8 years ago

  • Status changed from New to Code review
Actions #5

Updated by Alex Afanasyev over 8 years ago

  • Target version set to v0.5
Actions #6

Updated by Yingdi Yu almost 8 years ago

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

Also available in: Atom PDF