Bug #3941
closedGenericLinkService is impossible to inherit from
100%
Description
GenericLinkService has virtual inheritance from GenericLinkServiceCounters.
GenericLinkServiceCounters constructor takes GenericLinkService::m_reassembler as argument.
When a subclass inherits from GenericLinkService, the most derived class's constructor must directly invoke GenericLinkServiceCounters constructor.
However, it cannot do so because GenericLinkService::m_reassembler is private.
      
      Updated by Junxiao Shi almost 9 years ago
      
    
    https://gerrit.named-data.net/3649 introduces a temporary workaround that GenericLinkServiceCounters inheritance is no longer virtual.
This improves the situation so that GenericLinkService can be inherited from, but the subclass would not be able to use a different Counters type.
This workaround should be reverted when this issue is resolved.
      
      Updated by Junxiao Shi almost 9 years ago
      
    
    - Assignee set to Eric Newberry
 - Estimated time set to 0.50 h
 
This issue is assigned to Eric who authored the GenericLinkServiceCounters constructor in nfd:commit:4c3e6b89a17c34d642d04fd5b37df447a939b9a6.
      
      Updated by Eric Newberry almost 9 years ago
      
    
    I will start work on this issue after #3931 is merged, as it also modifies GenericLinkService.
      
      Updated by Eric Newberry over 8 years ago
      
    
    - Status changed from New to In Progress
 
      
      Updated by Eric Newberry over 8 years ago
      
    
    - Status changed from In Progress to Code review
 - % Done changed from 0 to 100
 
      
      Updated by Junxiao Shi over 8 years ago
      
    
    https://gerrit.named-data.net/3817 makes GenericLinkService::m_reassembler protected, so that GenericLinkService can be inherited from. However, this still requires every subclass to be aware of this and to call GenericLinkServiceCounters constructor directly. Moreover, if the same pattern is used, every new parameter of GenericLinkServiceCounters constructor would trigger a widespread change.
Is it possible to avoid this constructor parameter, so that subclass doesn't need to do anything?
I'm thinking about:
LpReassemblerprovides its counters inLpReassemblerCountersclass.GenericLinkServiceCountersinherits fromLpReassemblerCounters.LpReassemblerconstructor takesLpReassemblerCounters¶meter.
      
      Updated by Davide Pesavento over 8 years ago
      
    
    Junxiao Shi wrote:
https://gerrit.named-data.net/3817 makes
GenericLinkService::m_reassemblerprotected, so thatGenericLinkServicecan be inherited from. However, this still requires every subclass to be aware of this and to callGenericLinkServiceCountersconstructor directly. Moreover, if the same pattern is used, every new parameter ofGenericLinkServiceCountersconstructor would trigger a widespread change.
I also dislike that solution.
LpReassemblerprovides its counters inLpReassemblerCountersclass.GenericLinkServiceCountersinherits fromLpReassemblerCounters.LpReassemblerconstructor takesLpReassemblerCounters¶meter.
I don't see how that would help... LpReassemblerCounters constructor would still require a const LpReassembler& parameter, no?
      
      Updated by Davide Pesavento over 8 years ago
      
    
    - Start date deleted (
02/01/2017) 
In any case, I would suggest not spending any more time on this issue, at least until we have a better way to export those additional counters. Right now only the "basic" counters are made available to management clients, the rest are practically dead code. And adding support for additional counters is a very tedious process and doesn't scale that well, as it involves adding a new TLV type and changes to both the library and NFD's FaceManager, for each new type of counter.
      
      Updated by Junxiao Shi over 8 years ago
      
    
    I don't see how that would help...
LpReassemblerCountersconstructor would still require aconst LpReassembler¶meter, no?
No.
LpReassemblerconstructor takesLpReassemblerCounters¶meter.
The counter variable is in LpReassemblerCounters, and LpReassembler stores a reference to LpReassemblerCounters. SizeCounter cannot be used, but LpReassembler has to manually increment and decrement the counter like ++m_counters.nReassembling when appropriate.
      
      Updated by Davide Pesavento over 8 years ago
      
    
    Junxiao Shi wrote:
The counter variable is in
LpReassemblerCounters, andLpReassemblerstores a reference toLpReassemblerCounters.SizeCountercannot be used, butLpReassemblerhas to manually increment and decrement the counter like++m_counters.nReassemblingwhen appropriate.
Well, this changes everything. In particular, the critical change is to stop using SizeCounter, that's what solves the constructor issue, not the changes in note-7.
I don't like this solution either though, it feels more like a workaround than a proper solution.
How about:
SizeCounteris changed to observe aconst T*instead of aconst T&SizeCounterremoves its constructor parameter, or defaults it tonullptr, so that it can be default constructed, and in addition it gains asetObservedObject(const T*)member function- Either 
GenericLinkServiceorLpReassemblerconstructor callssetObservedObjecton thenReassemblingcounter 
      
      Updated by Junxiao Shi over 8 years ago
      
    
    - Status changed from Code review to Closed