Next: Write the Functions
Up: Define the Pike Level
Previous: Without CMOD
  Contents
Using CMOD when writing the module makes it a little easier to define
the Pike level interface. What needs to be done is in abstract:
- -
- Add classes using a PIKECLASS ...... statement. Everything
that belongs to that class is then placed in between its curly
brackets.
- -
- Use PIKEFUN ...(...)... to add a method to a class. Place it
somewhere in between the curly brackets of the PIKECLASS statement
of the class that the method is supposed to belong to.
- -
- Use CVAR ... to add a private object variable. Place the
variable declaration in the class that it is supposed to belong to.
Note that even though we use CMOD, the functions pike_module_init() and pike_module_exit() need to exist. They can be kept empty though.
As we can see CMOD is very convenient since the design can easily
be translated to an implementation. If we for instance have a UML
design model the mapping from the most basic UML components to CMOD is
straight forward. As it can be seen in figure 5.2, UML components in this particular
case have intuitive CMOD equivalents, so the translation is easy.
Figure:
A class modeled with UML and its CMOD correspondence
|
|
Next: Write the Functions
Up: Define the Pike Level
Previous: Without CMOD
  Contents
2003-03-04