How to specify when giving a generic parameter that it should implement some specific creation method? as LIST[G -> create make end]
doesn't work :-(
In my particular case,
* SMA_INVERTER_MANAGER_CSV
has inherited from CONSUMPTION_SECTOR_MODBUS_DEVICE_CSV
a list of devices as devices: LINKED_SET[G]
as G -> MEASURING_POINT_MODBUS_DEVICE create make_from_file_path end
.
I'd like the SMA_INVERTER_MANAGER_CSV
class to be able into devices: LINKED_SET[G]
to be able to have either JANITZA_DEVICE, SUNSPEC_DEVICE, ABB_DEVICE, etc. Giving the generic parameter as MEASURING_POINT_MODBUS_DEVICE seems to come out of a sense, but how do I specify that I'd like the creation method to be make_from_file_path
Hope the description is sufficient to understand, refactoring I think this question is linked -> explicit creation type not conforming to type of target
The only workaround for the moment I found working for the moment is
class
SMA_INVERTER_MANAGER_CSV
inherit
CONSUMPTION_SECTOR_MODBUS_DEVICE_CSV[SUNSPEC_DEVICE]
create
make
end
but I'd like it to be
class
SMA_INVERTER_MANAGER_CSV
inherit
CONSUMPTION_SECTOR_MODBUS_DEVICE_CSV[MEASURING_POINT_MODBUS_DEVICE]
create
make
end
which would generate a conformance problem because MEASURING_POINT_MODBUS_DEVICE
generic parameter doesn't specify make_from_file_path
as creation procedure as its deferred
There is more than a conformance problem. MEASURING_POINT_MODBUS_DEVICE
is deferred. Therefore, it cannot be used as an actual parameter for CONSUMPTION_SECTOR_MODBUS_DEVICE_CSV
. If it were allowed, how would CONSUMPTION_SECTOR_MODBUS_DEVICE_CSV
create an instance of a deferred class?
One possible solution — supplying an effective class — is mentioned in the question. Another solution is to add a formal generic parameter to SMA_INVERTER_MANAGER_CSV
with the corresponding constraint and to use it for the actual generic of CONSUMPTION_SECTOR_MODBUS_DEVICE_CSV
.