home *** CD-ROM | disk | FTP | other *** search
- <html>
- <title>Communications</title>
- <h1>Communications</h1>
-
-
- Vista contains a simple communication stack called a 'Channel'. This allows the
- task to communicate with other tasks using the WIMP Messaging protocols.
- <p>
- The idea of a Channel is that it is an object which can send and receive messages.
- It registers interest in receiving certain messages (identified by the action code)
- with a Task and will be called when a message of the appropriate type arrives. If
- the message is in response to one sent earlier by the channel then it will be asked
- if it is willing to accept the message by reference to the 'your_ref' field.
- <p>
- At present, only channels talking to the WIMP are implemented, but this may be extended
- in future.
- <p>
- The Channel class is defined as:
- <pre>
-
- class Channel : virtual public DeferredDelete
- {
- public:
- Channel(Task *task, char *name) ;
- virtual ~Channel() ;
- virtual void receive (int action, int task, int my_ref, int your_ref, int data_length, void *data) ; // receive a message
- virtual int accept (int your_ref) = 0 ; // accept a message?
- char *name ;
- protected:
- Task *task ;
- } ;
-
- </pre>
- The Channel is connected to a Task. When a message arrives at the task, it
- asks each Channel connected to it if it is willing to accept the message (using
- the accept() function). If the channel accepts the message (by returning
- non-zero from accept()), the task notifies the channel of the message by
- calling the 'receive()' function.
- <p>
- An example channel is supplied as part of Vista. This implements the
- standard WIMP 'datasave' protocol for loading and saving files. It is
- derived from the Channel class and is defined as:
- <pre>
-
- class DataSave : public Channel
- {
- public:
- struct saveackdata
- {
- int window ;
- int icon ;
- int x ;
- int y ;
- int est_size ;
- int filetype ;
- char pathname[1] ;
- } ;
- DataSave(Task *task) ;
- virtual ~DataSave() ;
- virtual void receive (int action, int task, int my_ref, int your_ref, int data_length, void *data) = 0 ; // receive a message
- int accept (int your_ref) ; // accept a message?
- virtual void save (int window, int icon, int x, int y, char *leaf) ;
- virtual void save (char *path) ;
- void datasave (int window, int icon, int x, int y, int est_size, int filetype, char *leaf) ;
- void datasaveack (int my_ref, saveackdata *data, char *path) ;
- void dataload (int task, int my_ref, int your_ref, int data_length, void *data) ;
- void dataloadack (int task, int my_ref, int your_ref, int data_length, void *data) ;
- protected:
- int my_ref ;
- } ;
-
- </pre>
-
- The details of the operation of this class are left as an exercise for the
- reader (did I hear you say 'copout'?).
-
-