Module "upnp.classes.upnpbase"

The base object for UPnP objects. This object provides hierarchy traversal and starting/stopping devices through eventhandlers

Copyright © 2012 Thijs Schreijer, LuaUPnP is licensed under GPLv3

Release: Version 0.1, LuaUPnP

Tables

upnpbase fields/properties Members of the upnpbase object.

Functions

upnpbase:clearlazyness () Clears all the lazy-elements set.
upnpbase:getaction (actionname) Gets an action from the owning service.
upnpbase:getdevice () Gets the owning device.
upnpbase:gethandle () Gets the handle of the owning rootdevice.
upnpbase:getroot () Gets the owning rootdevice.
upnpbase:getservice () Gets the owning service.
upnpbase:getstatevariable (varname) Gets a variable from the owning service.
upnpbase:initialize () Initializes the upnpbase object.
upnpbase:start () Startup handler.
upnpbase:stop () Shutdown handler.
upnpbase:subclass (tbl) Creates a descendant class in the table provided.
upnpbase:subclassof (super) Check whether the object is a subclass of another class
upnpbase:superclass () Returns the superclass of an object.


Tables

upnpbase fields/properties
Members of the upnpbase object.

Fields

  • classname: (string) the name of this class, basically the filename without the extension. Required to identify the type of class, but also to re-create a device from persistence. ????? check this!!
  • parent: (table/object) the parent object within the UPnP device hierarchy. Only a root device will not have a parent, but will have a field root set to true.

Functions

upnpbase:clearlazyness ()
Clears all the lazy-elements set. Applies to getaction(), getservice(), getdevice(), getroot(), gethandle() methods. Override in subclasses to clear tree-structure.
upnpbase:getaction (actionname)
Gets an action from the owning service. Can be called on a service, statevariable, action or argument.

Parameters:

  • actionname: name of the action sought (optional for arguments, will return owning action)

Return value:

the owning action for an argument, or the named action from the current objects owning service. Or nil if not found (or called on a device object)
upnpbase:getdevice ()
Gets the owning device.
upnpbase:gethandle ()
Gets the handle of the owning rootdevice.
upnpbase:getroot ()
Gets the owning rootdevice.
upnpbase:getservice ()
Gets the owning service.
upnpbase:getstatevariable (varname)
Gets a variable from the owning service. Can be called on a service, statevariable, action or argument.

Parameters:

  • varname: name of the statevariable sought

Return value:

the named statevariable from the current objects owning service. Or nil if not found (or called on a device object)
upnpbase:initialize ()
Initializes the upnpbase object. Will be called upon instantiation of an object, override this method to set default values for all properties.
upnpbase:start ()
Startup handler. Called for the event upnp.events.UPnPstarted (event through the Copas Timer eventer mechanism) This method will only be called on objects WITHOUT a parent (root devices). If an object has children, it should call the start() method on its children if required, they will not be called automatically.
upnpbase:stop ()
Shutdown handler. Called for the event upnp.events.UPnPstopping (event through the Copas Timer eventer mechanism) This method will only be called on objects WITHOUT a parent (root devices). If an object has children, it should call the stop() method on its children if required, they will not be called automatically.
upnpbase:subclass (tbl)
Creates a descendant class in the table provided.

Parameters:

  • tbl: table with properties to turn into a new object class

Return value:

object that represent a new class that provides the features defined by table and that inherits from the class called upon. Changes on the object returned by this function implies changes reflected on all its instances.
upnpbase:subclassof (super)
Check whether the object is a subclass of another class

Parameters:

  • super: the class to test against

Return value:

true if the object is a subclass of super
upnpbase:superclass ()
Returns the superclass of an object.

Return value:

the super-class of class or nil if class is not a class of the model or does not define a super class.

Valid XHTML 1.0!