Hello Luigi,
1) The last lines I wrote in yesterday's
mail was:
"Of course, STRATEGY must have
a fixed interface, but our implementation can maintain its "inheritance"
hierarchy. I think the Observer would benefit of an analogous template
class also."
That isn't true, since if I subclass
ObservableStrategy, any interface of STRATEGY is OK, as long as the
subclass can adapt the interface of "ObservableStrategy" to what the STRATEGY
needs, everything is OK. Sorry, about that.
2) How do you implement persistence?
We makes use of the OO database VERSANT. So our persistent classes, such
as our Instruments, inherit from the VERSANT class PObject, in order to
make them persistent. Then there are some other stuff to make it work,
like schema compilation. I our case the same arguments to create an "ObservableStrategy"
template class, applies for persistence too.
For example:
.hh/.h file:
template<class INSTR_IMPL, class OBSERVER_IMPL, class OBSERVABLE_IMPL>
class InstrumentStrategy : public ObserverStrategy<OBSERVER_IMPL>,
public ObservableStrategy<OBSERVABLE_IMPL>
{
public:
InstrumentStrategy(const INSTR_IMPL& instrument_impl,
const OBSERVER_IMPL& observer_impl,
const OBSERVABLE_IMPL& observable_impl,
const std:string &isinCode="",
const std::string &descriptions="")
.....
private:
INSTR_IMPL& _impl;
}
This would offer complete freedom with
regard to the local implementations. The strategy's merely works as adapaters.
Would appreciate very much your comments
about it. It's valuable indeed!
Bye Johan