Bug #3941
closedGenericLinkService is impossible to inherit from
Added by Junxiao Shi almost 8 years ago. Updated over 7 years ago.
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 8 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 8 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 8 years ago
I will start work on this issue after #3931 is merged, as it also modifies GenericLinkService.
Updated by Eric Newberry over 7 years ago
- Status changed from New to In Progress
Updated by Eric Newberry over 7 years ago
- Status changed from In Progress to Code review
- % Done changed from 0 to 100
Updated by Junxiao Shi over 7 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:
LpReassembler
provides its counters inLpReassemblerCounters
class.GenericLinkServiceCounters
inherits fromLpReassemblerCounters
.LpReassembler
constructor takesLpReassemblerCounters&
parameter.
Updated by Davide Pesavento over 7 years ago
Junxiao Shi wrote:
https://gerrit.named-data.net/3817 makes
GenericLinkService::m_reassembler
protected, so thatGenericLinkService
can be inherited from. However, this still requires every subclass to be aware of this and to callGenericLinkServiceCounters
constructor directly. Moreover, if the same pattern is used, every new parameter ofGenericLinkServiceCounters
constructor would trigger a widespread change.
I also dislike that solution.
LpReassembler
provides its counters inLpReassemblerCounters
class.GenericLinkServiceCounters
inherits fromLpReassemblerCounters
.LpReassembler
constructor takesLpReassemblerCounters&
parameter.
I don't see how that would help... LpReassemblerCounters
constructor would still require a const LpReassembler&
parameter, no?
Updated by Davide Pesavento over 7 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 7 years ago
I don't see how that would help...
LpReassemblerCounters
constructor would still require aconst LpReassembler&
parameter, no?
No.
LpReassembler
constructor takesLpReassemblerCounters&
parameter.
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 7 years ago
Junxiao Shi wrote:
The counter variable is in
LpReassemblerCounters
, andLpReassembler
stores a reference toLpReassemblerCounters
.SizeCounter
cannot be used, butLpReassembler
has to manually increment and decrement the counter like++m_counters.nReassembling
when 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:
SizeCounter
is changed to observe aconst T*
instead of aconst T&
SizeCounter
removes 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
GenericLinkService
orLpReassembler
constructor callssetObservedObject
on thenReassembling
counter
Updated by Junxiao Shi over 7 years ago
- Status changed from Code review to Closed