PLearn 0.1
Public Member Functions
PLearn::PythonEmbedder Class Reference

Include this file when you want to embed the Python interpreter. More...

#include <PythonEmbedder.h>

List of all members.

Public Member Functions

 PythonEmbedder ()
 ~PythonEmbedder ()

Detailed Description

Include this file when you want to embed the Python interpreter.

It ensures that Py_Initialize and Py_Finalize are called only once in the entire program. NOTE that it does not include the Python.h header file for you; you must still include those files yourself.

Create one such object that is called early enough in your Python-using code (e.g. a build function before any Python calls are made) ::

static PythonEmbedder python;

Definition at line 63 of file PythonEmbedder.h.


Constructor & Destructor Documentation

PLearn::PythonEmbedder::PythonEmbedder ( )

Definition at line 54 of file PythonEmbedder.cc.

References PLearn::endl(), and PLearn::num_python_instances.

{
    if (num_python_instances == 0) {
        MODULE_LOG << "Py_Initialize() called" << endl;
        Py_Initialize();
    }

    num_python_instances++;
}

Here is the call graph for this function:

PLearn::PythonEmbedder::~PythonEmbedder ( )

Definition at line 64 of file PythonEmbedder.cc.

References PLearn::endl(), and PLearn::num_python_instances.

{
    if (num_python_instances > 0) {
        --num_python_instances;
        if (num_python_instances == 0)
            MODULE_LOG << "Py_Finalize() called" << endl;
            Py_Finalize();
    }
}

Here is the call graph for this function:


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines