[ndnSIM] Setting a custom policy for Content Store
Alex Afanasyev
aa at CS.UCLA.EDU
Tue Nov 15 22:27:11 PST 2016
Try replacing
myContentStore.setPolicy(policy);
with
myContentStore.setPolicy(std::move(policy));
> On Nov 16, 2016, at 3:10 PM, John Baugh <jpbaugh at umich.edu> wrote:
>
> Alex,
>
> Actually, as soon as I sent the last e-mail, I noticed that Policy didn't have a default/no-arg ctor defined, so I went in and modified it to use one. I gave JPBPolicy a no-arg constructor, but used a passthrough to the base class (Policy) constructor with the constant string. I *think* I have that part correct.
>
> However, I still am getting the "use of deleted function" error related to unique_ptr.
>
>
> Updated Errors:
> https://drive.google.com/open?id=1Ni2wc7mSecJR-1KseA_1k4oDKoXuJJrGNtwXl6sHnrA <https://drive.google.com/open?id=1Ni2wc7mSecJR-1KseA_1k4oDKoXuJJrGNtwXl6sHnrA>
>
> Updated jpb-policy-test.cpp:
> https://drive.google.com/open?id=0By9ufeKqmJYYOThERVMtOVo2STA <https://drive.google.com/open?id=0By9ufeKqmJYYOThERVMtOVo2STA>
>
> Updated JPBPolicy.hpp:
> https://drive.google.com/open?id=0By9ufeKqmJYYV183emczZ01kM28 <https://drive.google.com/open?id=0By9ufeKqmJYYV183emczZ01kM28>
>
>
> I neglected to include my Policy class last time. And yes, I suppose using separate compilation (.hpp and .cpp file for the JPBPolicy class) would be better, but I'm trying to take it one step at a time! :)
>
> I think some of this might be some misunderstandings with some of the new C++ 11 and 14 features / smart pointer stuff.
>
> Also, do I need the = delete for the copy constructor and = operator? I was reading in a few areas where that helped with the error I'm receiving, but I don't know if those are necessary.
Not really. These are already prohibited by the base class. You can delete them in your class as well, but nothing really changes.
--
Alex
>
> Thank you all so much,
>
> John
>
>
> On Wed, Nov 16, 2016 at 12:38 AM, Alex Afanasyev <aa at cs.ucla.edu <mailto:aa at cs.ucla.edu>> wrote:
> Hi John,
>
> You have a small issue in your implementation of JPBPolicy. If you haven't, you need to define the default constructor and in the default constructor use ``Policy::Policy(const std::string&)`` to initialize the base class. You can see the example in other policies:
>
> LruPolicy::LruPolicy()
> : Policy(POLICY_NAME)
> {
> }
>
> The reason is that each policy has to have a name, which is enforced by the deleted default constructor of the base class.
>
> --
> Alex
>
>> On Nov 16, 2016, at 1:44 PM, John Baugh <jpbaugh at umich.edu <mailto:jpbaugh at umich.edu>> wrote:
>>
>> Greetings all,
>>
>> See the error(s) I'm getting below from my Google Drive:
>> https://drive.google.com/open?id=1Ni2wc7mSecJR-1KseA_1k4oDKoXuJJrGNtwXl6sHnrA <https://drive.google.com/open?id=1Ni2wc7mSecJR-1KseA_1k4oDKoXuJJrGNtwXl6sHnrA>
>>
>> Here's the code:
>> https://drive.google.com/open?id=0By9ufeKqmJYYOThERVMtOVo2STA <https://drive.google.com/open?id=0By9ufeKqmJYYOThERVMtOVo2STA>
>>
>> Thanks,
>>
>> John
>>
>> On Mon, Nov 14, 2016 at 3:02 AM, Alex Afanasyev <aa at cs.ucla.edu <mailto:aa at cs.ucla.edu>> wrote:
>> Hi John,
>>
>> Can you post the exact error you're getting (if it is too long, you can use pastebin.com <http://pastebin.com/>). If you also can share the snippet that reproduces the problem, it would be much faster to debug the issue and suggest the solution.
>>
>> --
>> Alex
>>
>>> On Nov 14, 2016, at 3:53 PM, John Baugh <jpbaugh at umich.edu <mailto:jpbaugh at umich.edu>> wrote:
>>>
>>> I am trying code like so:
>>>
>>> unique_ptr<nfd::cs::Policy> policy(new JPBPolicy());
>>>
>>> myContentStore.setPolicy(policy);
>>>
>>> I'm getting tons of errors. It doesn't like any of the conversions I'm trying to perform... It may be a misunderstanding of some of the techniques used with managed/smart pointers in terms of polymorphic references, but something's not working.
>>>
>>> I want to create a subclass of Policy in order to override functions such as doAfterInsert(iterator i);
>>>
>>> In my derived class (subclass), I did provide a body for all the pure virtual methods from the documentation of Policy.
>>>
>>> But I think the problem is the conversion. Is there some way to do this with say, static_cast ?
>>>
>>> Thanks,
>>>
>>> John
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20161116/a2d92205/attachment.html>
More information about the ndnSIM
mailing list