Re: [Evolution-hackers] [Camel] How can I get a reference to the store class from another class?



> > > > Something like:
> > > > 
> > > >    CAMEL_SERVICE_CLASS(parent_class)->connect(service, ex);
> > > > 
> > > > from within the transport connect() method?
> > > > 
> > > yup. you could do it. Should be no problem. Guess its a clean way to do
> > > it.
> > 
> > Partha, what are you saying here?
> > 
> > parent_class.connect() will only call the super-class method.
> > 
> > Transport doesn't derive from Store, they both derive from Service.
> > 
> > So if you want to share the connect() implementation from both classes,
> > then it must be implemented in a sharable manner, and not separately.
> 
> I just noticed this recently added wiki entry:
> 
> http://go-evolution.org/Camel.Transport#Example:_Sending_a_message
> 
> where camel_service_connect() is used. It looks very much like
> camel_service_connect() is using the inherited Camel store connect()
> method:

No, that's wrong.

CamelStore INHERITS the CamelService.connect() method.  That is where
it's defined.  Service doesn't inherit anything from camel store, not
can it obivously.

In somethng like java syntax:

class Service {
  public void connect();
...
};

class Store:Service {
 ...
};

class Transport:Service {
 ...
}

class SMTP:Transport {

  public void connect() {
    super.connect();
    do whatever;
  }
}

The store and transport are TWO _completely separate_ object classes.

> ############## snip ###############
> 	trans = (CamelTransport *)camel_session_get_service(session, "smtp://localhost/", ex);
> 	if (camel_exception_is_set(ex))
> 		return;
> 	camel_service_connect(trans, ex);
> 	if (camel_exception_is_set(ex))
> 		goto noconnect;
> ############## snip ###############
> 
> and from camel-service.c:
> 
> 	ret = CSERV_CLASS (service)->connect (service, ex);
> 
> Can the camel_service_connect() method be used from the transport class
> to invoke the provider specific Camel store connect() method or am I
> totally off here once again?

You can do whatever you want.

I mean its like having the cat.eat() method call the mouse.eat() method.
They're both animals, but they're not the same class or even the same
common branch.  There's nothing stopping cat from looking up mouse and
then making it eat ... but they're not the same object nor can they ever
be.

 Michael







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]