Because SOMClass is the root class for all metaclasses, M_Dog is derived from SOMClass. This is reflected in the Parent and Include sections in the class definition file for the M_Dog class. The only method that M_Dog defines is CreateADog, that is, the constructor that creates an instance of the dog class, as shown in the following sample code:

/*
 * This file was generated by the SOM compiler and Emitter Framework.
 * Generated using:  SOM Emitter emitctm: 2.38
 */

#ifndef SOM_Module_dogmeta_Source
#define SOM_Module_dogmeta_Source
#endif

#define M_Dog_Class_Source
#define Dog_Class_Source

#include "dogmeta.ih"

/*
 * Create an instance of the Dog class and return a pointer to it
 */

SOM_Scope Dog*  SOMLINK CreateADog(M_Dog *somSelf)
{
  Dog   *aNewDog;
  aNewDog = _somNew(somSelf);

  /* M_DogData *somThis = M_DogGetData(somSelf); */
  M_DogMethodDebug("M_Dog","CreateADog");

  /* Return statement to be customized */
  return(aNewDog);
}

/*
 * Display characteristics for this dog.
 * Show the breed and make the dog speak.
 */

SOM_Scope void  SOMLINK display(Dog *somSelf)
{
  DogData *somThis = DogGetData(somSelf);
  DogMethodDebug("Dog","display");

  /* Note there are two underscores before the get_breed below */
  printf("\nMy breed is %s.\n", __get_breed(somSelf));
  printf("I say:\n");
  /* Prefix method name with either an underscore or somThis */
  _bark(somSelf);
}

/*
 * Have the dog bark
 */

SOM_Scope void  SOMLINK bark(Dog *somSelf)
{
  DogData *somThis = DogGetData(somSelf);
  DogMethodDebug("Dog","bark");
  printf("Unknown dog noise\n");   /* Speak! */
}


[Back] [Next]