pyinherit - two object servers that implement a type of implementation/interface inheritance(Delegation).

1. To start the parent server type:
	HelloParent.py &

2. To start the child server type:

3. To run the client type:

Note: remember to place double quotes around the binding_handle.

The client should print "Hello Stanford DL project!", "my hello!!", and exit. The servers will continue to wait and process new hello messages.


The Code


HelloObject.isl


INTERFACE HelloObject;

TYPE Hello = OBJECT OPTIONAL
	METHODS
		hello () : ilu.CString
	END;

TYPE MyHello = OBJECT OPTIONAL
	SUPERTYPES
		Hello
	END

	METHODS
		myhello() : ilu.CString
	END;

HelloParent.py


#!/usr/local/bin/python
#

# 
# HelloParent.py
#
#   This is the parent object to HelloChild.py.  It implements the
#   Hello root class and the method 'hello'.
#
#   This program displays its SBH.  You will need to give this string
#   as input to HelloChild.py.
#

import os, socket, sys, ilu, HelloObject__skel

class Hello(HelloObject__skel.Hello):
    def hello(self):
	return "Hello Stanford DL Project!";

def main(argv):
  server = ilu.CreateServer(None, None, None);

  mach = Hello()
  print mach.IluSBH()

  ilu.RunMainLoop()

main(sys.argv)


HelloChild.py


#!/usr/local/bin/python
#

# 
# HelloChild.py
#
#   This is the child object to HelloParent.py.  It implements the
#   MyHello child class and the method 'myhello'.  It passes the
#   method 'hello' up to its parent class instance.
#
#   The first parameter to this program is the SBH of the parent object
#   server instance.  First start of the parent instance, copy the SBH
#   that is displayed, and run this server with that string as the first
#   parameter.
#
#   This program displays its SBH.  You will need to give this string
#   as input to the client program HelloClient.py.
#

import os, socket, sys, ilu
import HelloObject, HelloObject__skel

#
# define the MyHello child class
#
class MyHello(HelloObject__skel.MyHello):
  # set the parent reference up.
  def __init__(self, pParent):
    self.fParent = pParent

  # call the parent method
  def hello(self):
    return self.fParent.hello()
  
  # define the myhello method
  def myhello(self):
    return "my hello!!"

def main(argc, argv):
  if(argc != 2):
    print "usage: HelloChild.py "
    sys.exit(1)

  parent_sbh = sys.argv[1]
  parent = ilu.ObjectOfSBH(HelloObject.Hello, parent_sbh)

  server = ilu.CreateServer(None, None, None);

  mach = MyHello(parent)
  print mach.IluSBH()

  ilu.RunMainLoop()

main(len(sys.argv), sys.argv)


HelloClient.py


#!/usr/local/bin/python
#

# 
# HelloClient.py
#
#   This is the client object to HelloChild.py.  It will first create the
#   surrogate of MyHello, call the hello method, and then try to call
#   the myhello method on it.
#
#   The first parameter to this program is the SBH of the child server object
#   server instance.  First start of the child server instance, copy the SBH
#   that is displayed, and run this client with that string as the first
#   parameter.
#

import os, sys, ilu, HelloObject

if(len(sys.argv) != 2):
  print "usage: HelloClient.py "
  sys.exit(1)

sbh = sys.argv[1]

# try to create an object of type MyHello
HelloObjectInstance = ilu.ObjectOfSBH(HelloObject.MyHello, sbh)

# try to call the hello method on MyHello
print HelloObjectInstance.hello()

# try to call the myhello method on MyHello
try:
  print HelloObjectInstance.myhello()
except:
  print "myHello() not supported!"




Imakefile


NormalObjectRule()
DependTarget()

InterfaceTarget(HelloObject.isl)

#ifdef ADD_PYTHON_LANGUAGE

ILUPythonTarget(HelloObject.py HelloObject__skel.py, HelloObject.isl)
all:: HelloObject.py HelloObject__skel.py

#endif