SPL Function Model

The function model file is structured as a sequence of one or more functionSet elements. The functionSet element represents the set of native functions declared within or included from a C++ header file.

Header File Name
Contains the name of the header file that declares the C++ functions or includes other header files that declare them.
CPP Namespace Name (Optional)
The second (optional) element is named cppNamespacename, which gives the C++ namespace for the functions. If the cppNamespacename element is not present, the SPL namespace, with "." converted to "::" is used.
Functions
A sequence of one or more function elements, each representing a native function signature in SPL format.
Description
A description of the function
Prototype
The prototype of the native function. Native function prototypes are declared with SPL syntax, which is described in the IBMStreams Processing Language Specification.
CPP Name (Optional)
Specifies the C++ name of the function. If not present, the SPL function name is used.
Dependencies (Optional)
A sequence of one or more library elements, each representing a library dependency. The library element format is exactly the same as the one used for operator models.
Description (Optional)
A description of the library
Managed Library
Specifies the details of the individual library artifacts. The paths can contain environment variables embedded between @ signs (for example: @FOO_FFT_HOME@/lib), which will be fully resolved by the SPL compiler at compile time.
lib (Optional)
Specifies a name to be passed to C++ compiler's -l argument (such as fft which will be translated into -lfft when passed to the linker)
libPath (Optional)
Specifies a path to be passed to C++ compiler's -L argument.
includePath (Optional)
Specifies a path to be passed to C++ compiler's -I argument.
command (Optional)
A path to a program that will be executed to retrieve includePath, libPath, and lib information. If the path to the program is relative, it is assumed to be rooted at the directory of the operator model. The program is executed three times, each time with a different argument, namely lib, libPath, and includePath. The standard output from these executions will be read and each line (trimmed of white spaces) will be added to one of the lib, libPath, and includePath elements, depending on the type of the execution. A line that begins with # will be ignored. Relative paths are assumed to be rooted at the directory where the operator model XML document resides.

Example

  <functionModel 
   xmlns="http://www.ibm.com/xmlns/prod/streams/spl/function" 
   xmlns:cmn="http://www.ibm.com/xmlns/prod/streams/spl/common" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xsi:schemaLocation="http://www.ibm.com/xmlns/prod/streams/spl/function functionModel.xsd"> 
  <functionSet> 
    <!-- header file to include from within C++ code --> 
    <headerFileName>Sample.h</headerFileName> 
    <!-- functions lists the SPL prototypes of the functions implemented in this library --> 
    <functions> 
      <!-- use of CDATA allows easy use of < in the prototypyes --> 
      <function>
        <description>Increment all list elements by a given amount</description>
        <prototype cppName="increment_by"><![CDATA[ void incrementBy(mutable list<int32> l, int32 incr) ]]></prototype>
      </function>
      <function>
        <description>Join two lists</description>
        <prototype><![CDATA[ list<int32> joinLists(list<int32> a, list<int32> b) ]]></prototype>
      </function>
    </functions> 
    <dependencies> 
      <!-- This library can have several dependencies. We only use one here --> 
      <library> 
        <!-- A description for this library --> 
        <cmn:description>Sample-Functions</cmn:description> 
        <cmn:managedLibrary> 
          <!-- the name of the library for linking. Will be used as -lSample --> 
          <cmn:lib>Sample</cmn:lib> 
          <!-- Where to find the library. Relative to the current directory. 
               Will be used as -L<dir>/lib --> 
          <cmn:libPath>lib</cmn:libPath> 
          <!-- Where to find the include file. Relative to the current directory. 
               Will be used as -I<dir> --> 
          <cmn:includePath>./</cmn:includePath> 
        </cmn:managedLibrary> 
      </library> 
    </dependencies> 
  </functionSet> 
</functionModel>