Configurator
Public Member Functions | List of all members
data_structures.Function Class Reference

One Function of a module. More...

Inheritance diagram for data_structures.Function:
data_structures.Node

Public Member Functions

def __init__
 Function constructor.
 
def __format__
 Format self using fmt string.
 
def cpp_header_write
 Write the C++ method declaration for self to out_stream.
 
def cpp_local_source_write
 Write local C++ RPC code for self to out_stream.
 
def cpp_slave_write
 Write C++ code for RPC request handing for self to out_stream
 
def cpp_remote_source_write
 Write remote side RPC code for self to out_stream.
 
def python_write
 Output Python RPC code for self to out_stream
 
- Public Member Functions inherited from data_structures.Node
def __init__
 Node Constructor
 
def parent_index_find
 Recursively find parent of self starting from root_node.
 
def show
 Method print self indented by indent.
 
def sub_node_append
 Append sub_node to the children sub nodes of self.
 
def xml_write
 Method writes self to out_stream indented by indent.
 

Detailed Description

One Function of a module.

A module can have one or more functions that can be invoked via a remote procedure call. A function has zero, one, or more parameters and zero, one, or more results. This shows up in the XML files as:

   <Function Name="..." Number="..." Brief="...">
     <Description>
       *Description goes here*
     </Description>
     <Parameter Name="..." Type="..." Brief="..." />
     ...
     <Result Name="..." Type="..." Brief="..." />
     ...
   </Function> 

Constructor & Destructor Documentation

def data_structures.Function.__init__ (   self,
  function_element,
  style 
)

Function constructor.

Parameters
selfFunction object to initialize
function_elementElement containing XML to extract from
styleStyle object that specifies how to format generate code.

This method extacts information about a remote procedure call function from function_element and stuffs it into self.

Member Function Documentation

def data_structures.Function.__format__ (   self,
  fmt 
)

Format self using fmt string.

Parameters
selfFunction to use for formatting.
fmtstr that specifies the format to use
Returns
str Formatted string is returned

Format self using fmt to control formatting and return the formatted string. The allowed formatting strings are:

  • 'r' returns just the routine name in the appropriate style
  • 'S' returns C/C++ output signature.
  • 'Sxxx' returns the C/C++ output signature with 'xxx' spliced in before the routine name. This is used to splice a class name in front of the routine name. For example, 'SClass_Name::' will return "Class_name::{routine_name}(...)".
  • 's' returns a simplified signature that has just the a routine name, parameter name and result names in the form "routine_name(parameter_names, ...) => result_names, ...
def data_structures.Function.cpp_header_write (   self,
  module,
  out_stream 
)

Write the C++ method declaration for self to out_stream.

Parameters
selfFunction object to use for information
moduleModule (Currently unused)
out_streamFile output stream to output to

This routine will output a chunk of C++ code to out_stream that corresponds to method declaration in C++ class definition: The code looks roughly as follows:

   // BRIEF
   RT1 FUNCTION(PT1 PN1,...,PTn PNn,RT2 RN2,...,RTn RNn);

where

  • FUNCTION is the function name
  • BRIEF is the 1 line comment brief
  • PNi is the i'th Parameter Name
  • PTi is the i'th Parameter Type
  • RNi is the i'th Result Name
  • RTi is the i'th Result Type
def data_structures.Function.cpp_local_source_write (   self,
  module,
  out_stream 
)

Write local C++ RPC code for self to out_stream.

Parameters
selfFunction to use for parameters and return results
moduleModule to use for module name and the like.
out_streamFile to write everything out to.

This method will output the local remote procedure call C++ code for function out to *out_stream. The code looks basically like this:

   // FUNCTION: BRIEF
   RT1 MODULE::FUNCTION(PT1 PN1,...,PTn PNn, RT2 *RN2,...,RTn *RNn) {
     RT1 RN1;
     ...
     RTn RNn;
     //////// Edit begins here: {FUNCTION_NAME}
     //////// Edit ends here: {FUNCTION_NAME}
     return RN1;
   }

where

  • FUNCTION is the function name
  • BRIEF is the 1 line comment brief
  • MODULE is the module name
  • PNi is the i'th Parameter Name
  • PTi is the i'th Parameter Type
  • RNi is the i'th Result Name
  • RTi is the i'th Result Type
def data_structures.Function.cpp_remote_source_write (   self,
  module,
  out_stream 
)

Write remote side RPC code for self to out_stream.

Parameters
selfFunction to output RPC code for
moduleModule to use for module name
out_streamFile to output code to

The routine will look something like:

// NAME: BRIEF RT1 MODULE::FUNCTION(PT1 PN1,...,PTn PNn,RT2 *RN2,...,RTn *RNn) { Maker_Bus_Module::command_begin(NUMBER); Maker_Bus_Module::PT1_put(P1); ... Maker_Bus_Module::PTn_put(Pn); RT1 R1 = Maker_Bus_Module::RT1_get(); *RN2 = Maker_Bus_Module::RT2_get(); ... *RNn = Maker_Bus_Module::RTn_get(); Maker_Bus_Module::command_end(); return RN1; }

where

  • NUMBER is the RPC number
  • FUNCTION_NAME is the function name
  • BRIEF is the 1 line comment brief
  • PNi is the i'th Parameter Name
  • PTi is the i'th Parameter Type
  • RNi is the i'th Result Name
  • RTi is the i'th Result Type
def data_structures.Function.cpp_slave_write (   self,
  module_name,
  out_stream 
)

Write C++ code for RPC request handing for self to out_stream

Parameters
selfFunction to process
module_namestr Module name to use
out_streamFile to write output to

This method will output self to out_stream as a case clause as part of a switch statement. The basic format of the code that is generated looks as follows:

   case NUMBER: {
     // FUNCTION_NAME: BRIEF
     PN1 = maker_bus->PT1_get();
     ...
     PNn = maker_bus->PTn_get();
     RT1 RN1;
     ...
     RTn RNn;
     if (execute_mode) {
       RN1 = FUNCTION_NAME(PN1,...PNn,&RN2,...,&RNn);
       maker_bus->RT2_put(RN2);
       ...
       maker_bus->RTn_put(RNn);
       break;
     }
   }

where

  • NUMBER is the RPC number
  • FUNCTION_NAME is the function name
  • BRIEF is the 1 line comment brief
  • PNi is the i'th Parameter Name
  • PTi is the i'th Parameter Type
  • RNi is the i'th Result Name
  • RTi is the i'th Result Type
def data_structures.Function.python_write (   self,
  out_stream 
)

Output Python RPC code for self to out_stream

Parameters
selfFunction to output Python code for
out_streamFile to output Python code to

This routine will output remote procedure call code for self to out_stream. The code looks as follows:

   def FUNCTION(self, PN1, ..., PNn):
       # BRIEF
       self.request_begin(NUMBER)
       self.request_PT1_put(PN1)
       ...
       self.request_PTn_put(PNn)
       self.request_end()
       RN1 = self.request_RT1_get()
       ...
       RNn = self.request_RTn_get()
       return RN1, ..., RNn

where:

  • FUNCTION is the function name
  • BRIEF is the 1 line comment brief
  • PNi is the i'th Parameter Name
  • PTi is the i'th Parameter Type
  • RNi is the i'th Result Name
  • RTi is the i'th Result Type

The documentation for this class was generated from the following file: