home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / som / somk / c / animals / animals.idl < prev    next >
Encoding:
Text File  |  1996-01-24  |  4.4 KB  |  190 lines

  1. /*
  2.  *    %Z% %I% %W% %G% %U% [%H% %T%] (c)IBM Corp. 1993
  3.  */
  4. #include <somobj.idl>
  5. #include <somcls.idl>
  6.  
  7. module Animals {
  8.     
  9.     interface M_Animal;  // Forward reference needed for the metaclass.
  10.     
  11.     interface Animal : SOMObject
  12.     {
  13.       typedef sequence<Animal> AnimalInstances; 
  14.  
  15.       attribute string name;
  16.       // The name of the animal.
  17.  
  18.       attribute string sound;
  19.       // The kind of sound that an animal makes.
  20.  
  21.       readonly attribute string genus;
  22.       // The genus of animal.
  23.       // The "_get_" method for this attribute should be overridden 
  24.       // by derived classes.  The default version here just gives 
  25.       // "<unknown>" as the genus.
  26.  
  27.       readonly attribute string species;     
  28.       // The species of animal.
  29.       // The "_get" method for this attribute should be overridden 
  30.       // by derived classes.  The default version here just gives 
  31.       // "<unknown>" as the species.
  32.  
  33.       void talk();
  34.       // Ask the animal to talk.  Normally this just prints out the
  35.       // string corresponding to the sound attribute, but it can be 
  36.       // overridden to do something else.
  37.  
  38.       void display();
  39.       // Displays an animal.    Derived classes should override this to
  40.       // display new derived information, and then call their parent
  41.       // version. Note: this method makes use of talk() to describe what
  42.       // the animal says.
  43.  
  44. #ifdef __SOMIDL__
  45.       implementation {
  46.     releaseorder: _get_name, _set_name,
  47.               _get_sound, _set_sound,
  48.               _get_genus, 
  49.               _get_species,
  50.               talk, display;
  51.     
  52.     //# Class Modifiers
  53.     functionprefix = a_;
  54.     metaclass      = M_Animal;
  55.  
  56.     //# Internal Instance Variables (other than attributes)
  57.     long nsound;                   
  58.  
  59.     //# Attribute modifiers
  60.     name: noset;
  61.     sound: noset;
  62.     genus: nodata;
  63.     species: nodata;
  64.  
  65.     //# Method Modifiers
  66.     somFree: override;
  67.     somInit: override;
  68.     somUninit: override;
  69.     somDumpSelfInt: override;
  70.       };
  71. #endif /* __SOMIDL__ */
  72.     };
  73.  
  74.     interface M_Animal 
  75.     {
  76.       Animal newAnimal (in string name, in string sound);
  77.       // Create an instance of an Animal with a specific sound.
  78.  
  79.       attribute sequence<Animal> instances;
  80.       // All of the Animal instances that currently exist
  81.  
  82.       void addInstance (in Animal obj);
  83.       // Used to add an new instance to the instances sequence.
  84.  
  85.       void deleteInstance (in Animal obj);
  86.       // Used to remove an instance from the instances sequence.
  87.  
  88. #ifdef __SOMIDL__
  89.       implementation {
  90.     releaseorder: newAnimal, 
  91.               _get_instances, _set_instances,
  92.               addInstance, deleteInstance;
  93.     
  94.     //# Class Modifiers
  95.     functionprefix = ma_; 
  96.  
  97.     //# Method Modifiers
  98.     somNew: override;
  99.     somInit: override;
  100.     somUninit: override;
  101.       };
  102. #endif /* __SOMIDL__ */
  103.     };
  104.  
  105.     interface M_Dog;    // Forward reference needed for the metaclass.
  106.     
  107.     interface Dog : Animal
  108.     {
  109.       attribute string breed;
  110.       // The breed of this Dog.
  111.  
  112.       attribute string color;
  113.       // The color of this Dog.
  114.  
  115. #ifdef __SOMIDL__
  116.       implementation {
  117.     releaseorder: _get_breed, _set_breed,
  118.               _get_color, _set_color;
  119.     
  120.     //# Class Modifiers
  121.     metaclass = M_Dog;
  122.     functionprefix = d_; 
  123.  
  124.     //# Attribute Modifiers
  125.     breed: noset;
  126.     color: noset;
  127.     
  128.     //# Method Modifiers
  129.     _get_genus: override;
  130.     _get_species: override;
  131.     display: override;
  132.     somInit: override;
  133.     somUninit: override;
  134.     somDumpSelfInt: override;
  135.       };
  136. #endif /* __SOMIDL__ */
  137.     };
  138.  
  139.     interface M_Dog 
  140.     {
  141.       Dog newDog (in string name,
  142.           in string sound, 
  143.           in string breed, 
  144.           in string color);
  145.       // Create an instance of a Dog with a specific name, 
  146.       // sound, breed, & color.
  147.  
  148. #ifdef __SOMIDL__
  149.       implementation {
  150.     releaseorder: newDog;
  151.     
  152.     //# Class Modifiers
  153.     functionprefix = md_; 
  154.  
  155.     //# Internal Instance Variables
  156.     string classcolor;            
  157.  
  158.     //# Method Modifiers
  159.     somNew: override;
  160.       };
  161. #endif /* __SOMIDL__ */
  162.     };
  163.  
  164.     interface BigDog : Dog
  165.     {
  166. #ifdef __SOMIDL__
  167.       implementation {
  168.     //# Class Modifiers
  169.     functionprefix = bd_; 
  170.  
  171.     //# Method Modifiers
  172.     talk: override;
  173.       };
  174. #endif /* __SOMIDL__ */
  175.     };
  176.  
  177.     interface LittleDog : Dog
  178.     {
  179. #ifdef __SOMIDL__
  180.       implementation {
  181.     //# Class Modifiers
  182.     functionprefix = ld_; 
  183.  
  184.     //# Method Modifiers
  185.     talk: override;
  186.       };
  187. #endif /* __SOMIDL__ */
  188.     };
  189. };
  190.