from Service import Service
from PublicInterface import PublicInterface

class InterfaceCollection:
	def __init__(self,interfaces):
		assert type(interfaces) is list
		assert len(interfaces) > 0
		for i in interfaces: assert isinstance(i,PublicInterface)
		for i in interfaces: setattr(self,i.get_name(),i)
			# which means, for each interface, set an attribute for the interface in this class

class InterfaceServer(Service):
	"""The base class for all interface servers. Interface servers follow a Service pattern."""
	"""All passed interfaces are registered in the self.public_interfaces attribute.  Your particular interface server should map incoming method calls to members of the self.public_interfaces instance."""
	
	def __init__(self,config,interfaces):
		Service.__init__(self) # this does not expose any public interface
		self.public_interfaces = InterfaceCollection(interfaces)
		self.config = config
