Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost StateChart and Template parameters
From: Etienne Philip Pretorius (icewolfhunter_at_[hidden])
Date: 2009-07-25 14:10:23


Igor R wrote:
>> class prolog
>> : public Entity ///<-----needs argument here but compains the
>> 'prolog' is NOT a template
>>
>
> You should either make a decision about Entity template argument here,
> or make the above state (and all the FMS) a template.
>
> [...]
>
>> virtual void parse(
>> T begin,
>> T end
>> ) {
>> };
>>
>
> What is "T" here? Again, probably you meant to make all the FSM templated?
>
Hello Igor.

Short version : parse(T begin,T end) should iterators from
asio::streambuf or any other Biderection iterators.

Long version:
Well all that I wanted was to have parse(T begin,T end) available on all
states.

        class entity {
        public:
            virtual boost::regex& regex() const = 0;
            template<typename T>
            virtual void parse(T,T) = 0;
        };

I am not allowed to use 'template' on virtual methods (compiler error)
so I moved the template parameter to be applied to the whole class:

    template<typename T>
        class entity {
        public:
            virtual boost::regex& regex() const = 0;
            virtual void parse(T,T) = 0;
        };

But then I needed to pass a template parameter to class prolog because
it is derived from class entity and therefore it needs to tell entity
what type entity needs to be.
And then when I needed to instantiate prolog the document class needed
chainging also.

Any Advice?
Should I just make the whole thing a template?
If I do so will there be a copy of the static data for each instantiated
type?

Etienne


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net