home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / vista_1 / !Manual_manual_channel < prev    next >
Encoding:
Text File  |  1996-01-04  |  2.8 KB  |  77 lines

  1. <html>
  2. <title>Communications</title>
  3. <h1>Communications</h1>
  4.  
  5.  
  6. Vista contains a simple communication stack called a 'Channel'.  This allows the
  7. task to communicate with other tasks using the WIMP Messaging protocols.  
  8. <p>
  9. The idea of a Channel is that it is an object which can send and receive messages.
  10. It registers interest in receiving certain messages (identified by the action code)
  11. with a Task and will be called when a message of the appropriate type arrives.  If
  12. the message is in response to one sent earlier by the channel then it will be asked
  13. if it is willing to accept the message by reference to the 'your_ref' field.
  14. <p>
  15. At present, only channels talking to the WIMP are implemented, but this may be extended
  16. in future.
  17. <p>
  18. The Channel class is defined as:
  19. <pre>
  20.  
  21. class Channel : virtual public DeferredDelete
  22.    {
  23.    public:
  24.       Channel(Task *task, char *name) ;
  25.       virtual ~Channel() ;
  26.       virtual void receive (int action, int task, int my_ref, int your_ref, int data_length, void *data) ;   // receive a message
  27.       virtual int accept (int your_ref) = 0 ;   // accept a message?
  28.       char *name ;
  29.    protected:
  30.       Task *task ;
  31.    } ;
  32.  
  33. </pre>
  34. The Channel is connected to a Task.  When a message arrives at the task, it
  35. asks each Channel connected to it if it is willing to accept the message (using
  36. the accept() function).  If the channel accepts the message (by returning
  37. non-zero from accept()), the task notifies the channel of the message by 
  38. calling the 'receive()' function.
  39. <p>
  40. An example channel is supplied as part of Vista.  This implements the
  41. standard WIMP 'datasave' protocol for loading and saving files.  It is 
  42. derived from the Channel class and is defined as:
  43. <pre>
  44.  
  45. class DataSave : public Channel
  46.    {
  47.    public:
  48.       struct saveackdata
  49.          {
  50.          int window ;
  51.          int icon ;
  52.          int x ;
  53.          int y ;
  54.          int est_size ;
  55.          int filetype ;
  56.          char pathname[1] ;
  57.          } ;
  58.       DataSave(Task *task) ;
  59.       virtual ~DataSave() ;
  60.       virtual void receive (int action, int task, int my_ref, int your_ref, int data_length, void *data) = 0 ;   // receive a message
  61.       int accept (int your_ref) ;   // accept a message?
  62.       virtual void save (int window, int icon, int x, int y, char *leaf) ;
  63.       virtual void save (char *path) ;
  64.       void datasave (int window, int icon, int x, int y, int est_size, int filetype, char *leaf) ;
  65.       void datasaveack (int my_ref, saveackdata *data, char *path) ;
  66.       void dataload (int task, int my_ref, int your_ref, int data_length, void *data) ;
  67.       void dataloadack (int task, int my_ref, int your_ref, int data_length, void *data) ;
  68.    protected:
  69.       int my_ref ;
  70.    } ;
  71.  
  72. </pre>
  73.  
  74. The details of the operation of this class are left as an exercise for the
  75. reader (did I hear you say 'copout'?).
  76.  
  77.