home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv7.zip / VACPP / IBMCPP / smarts / DTS / MAIN.CPP next >
Text File  |  1995-06-02  |  1KB  |  68 lines

  1. %PROLOG%
  2.  
  3. #include <stdio.h>
  4. #include "animal.hh"
  5. #include "cat.hh"
  6.  
  7. /*
  8.  * Statically load the DLLs that implement the Animal
  9.  * base class and the Cat derived class.
  10.  * The Dog class DLL will be dynamically loaded using one of the
  11.  * SOM Class Manager APIs.
  12.  */
  13.  
  14. void Annoy(Animal*);
  15. void countThem();
  16.  
  17. int main()
  18. {
  19.    Animal animal1;
  20.    Cat      cat1("Snookums");
  21.  
  22.    countThem();
  23.  
  24.    // Set buffering off for standard out stream 
  25.    setbuf (stdout, NULL);
  26.  
  27.    Annoy(&animal1);
  28.    Annoy(&cat1);
  29.  
  30.    /*
  31.     * Load DOG.DLL and find the dynamic class object representing
  32.     * the Dog class.  It's SOM name is SOMDog.
  33.     */
  34.    SOMClass *c = SOMClassMgrObject->somFindClsInFile(
  35.            somIdFromString("SOMDog"), 0, 0, "DOG");
  36.  
  37.  
  38.    /*
  39.     * Check that the previous call succeeded and that the class
  40.     * we found is descended from Animal.
  41.     */
  42.    if(c && c->somDescendedFrom(Animal::__ClassObject))
  43.    {
  44.       // Create an instance of the dynamically loaded class.
  45.       Animal *ap = (Animal*) c->somNew();
  46.  
  47.       countThem();
  48.       Annoy(ap);
  49.  
  50.       delete ap;
  51.       countThem();
  52.    }
  53.    return 0;
  54. }
  55.  
  56. void Annoy(Animal *ap)
  57. {
  58.    printf("Now let us vex mightily a %s named %s\n",
  59.        ap->somGetClassName(), ap->name);
  60.    ap->reactTo(Animal::vex_mightily);
  61.    printf("\n");
  62. }
  63.  
  64. void countThem()
  65. {
  66.    printf("%d Animals.\n", Animal::numberOfAnimals);
  67. }
  68.