OOF2: The Manual
Name
oof2-extension-setup — Generate the infrastructure of the code for an OOF2 extension.
Synopsis
oof2-extension-setup [args]
Required Arguments
-t templatename,--template=templatename-
The name of the template to use. It must be one of
names listed by the
-lor--listoptions. -m name,--module=name- The name of the Python module. This is the name by which the extension can be imported into OOF2.
-c name,--classname=name-
The name of the C++ class defined by the
Property.
Optional Arguments
-l,--list- Print the names of all available templates, and exit. No output files will be generated.
-s number,--sequence=number-
One of the pieces of a
Property's definition is its path, which define where it sits in thePropertyhierarchy and where it appears in the Materials Page. If there is more than onePropertyat the same level of the hierarchy, they are listed in order of their sequence numbers. Larger numbers are listed later. -f,--force- Normally oof2-extension-setup will not overwrite existing files. This option forces it to overwrite them.
Description
oof2-extension-setup is a program
that helps writing certain kinds of OOF2 extensions. It is
installed in the same location as OOF2 when OOF2 is built
with OOF2_DEV_INSTALL set to
ON.
To use oof2-extension-setup, in a terminal window cd to the directory where you want the extension source code to reside, and type
oof2-extension-setup
followed by the arguments described above. A new directory will be created with the given module name. The contents of the directory will be:
-
A copy of the
READMEfile from theEXTENSION_TEMPLATESdirectory in the OOF2 source. It's worth a read, even though some of the information is redundant with what's on this page. -
The
CMakeLists.txtfile that CMake uses to build the extension. You may want to change the version number in this file. If you have rebuilt OOF2 with new versions of Python or swig after running oof2-extension-setup, you should change the version numbers in the file as well. -
An
__init__.pyfile that imports the actual extension script when the module is imported by OOF2. You can combine multiple extensions in one module by adding lines to this file. -
An empty
builddirectory. You can cd to here to run ccmake to build and install the extension. You can also ignore or delete this directory and build the extension elsewhere if you like. See Section 7.3. -
A
sourcedirectory. Edit the files in this directory to implement the details of yourProperty. They are:-
CMakeLists.txt: This file contains a call to swig_sources. If you add new C++ files or need to link to additional libraries (other than the OOF2 libraries) they will need to be added to this file. -
A C++ header file, a C++ source file, and a swig file with names determined by the
--moduleargument. The file suffixes are “.h” for the header, “.C” for the C++ source, and “.swg” for swig. These files contain comments indicating how they should be edited. See Chapter 8 for more information. -
A Python file named by the
--moduleargument, with a “.spy” suffix.[66] Swig reads this file and embeds it directly into the output Python script. It also will need to be edited.
-
[66] The odd suffix makes it clear that this file is not directly loaded by Python. It contains code that belongs in the module's Python file but is not generated by swig.



