Task #1299
closedEnforce Interest/Data is created with make_shared
0%
Description
Interest class and Data class are not fully functional if they are not created with boost::make_shared.
To enforce this requirement, their constructors should be marked private, and a static method should be provided to create shared_ptr<Interest> and shared_ptr<Data>:
class Interest
{
public:
  static shared_ptr<Interest>
  create(const Name& name);
private:
  explicit
  Interest(const Name& name);
};
  
      
      Updated by Alex Afanasyev over 11 years ago
      
    
    I can provide create methods, but I do not want to make create methods the only way to create Interests/Data.  While inside NFD, Interst/Data must be shared_ptr, this is not a general requirement for all ndn-cpp-dev based applications.
      
      Updated by Junxiao Shi over 11 years ago
      
    
    Doxygen comments should be added to indicates which operations are unsafe if Interest/Data isn’t created with create.
      
      Updated by Alex Afanasyev over 11 years ago
      
    
    They are unsafe only in certain context, not in general (I will add the comment)
      
      Updated by Alex Afanasyev over 11 years ago
      
    
    - Category set to Docs
 - Status changed from New to Code review
 - Target version set to v0.2
 
I have added the comment for each Interest/Data constructor
      
      Updated by Alex Afanasyev over 11 years ago
      
    
    - Status changed from Code review to Closed