vtkPVPythonModule.h 2.94 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkPVPythonModule.h

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
/*-------------------------------------------------------------------------
  Copyright 2009 Sandia Corporation.
  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
  the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------*/

// .NAME vtkPVPythonModule - Stores code and option for python modules
//
// .SECTION Description
//
// vtkPVPythonModule is a simple class that stores some Python source code that
// makes up a Python module as well as some state variables about the module
// (such as its name).
//

#ifndef __vtkPVPythonModule_h
#define __vtkPVPythonModule_h

#include "vtkObject.h"

class VTK_EXPORT vtkPVPythonModule : public vtkObject
{
public:
38
  vtkTypeMacro(vtkPVPythonModule, vtkObject);
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
  static vtkPVPythonModule *New();
  virtual void PrintSelf(ostream &os, vtkIndent indent);

  // Description:
  // Set/get the full Python source for this module.
  vtkGetStringMacro(Source);
  vtkSetStringMacro(Source);

  // Description:
  // Set/get the full name for this module (e.g. package.subpackage.module).
  vtkGetStringMacro(FullName);
  vtkSetStringMacro(FullName);

  // Description:
  // Set/get a flag indicating whether this module is actually a package (which
  // can have submodules).
  vtkGetMacro(IsPackage, int);
  vtkSetMacro(IsPackage, int);
  vtkBooleanMacro(IsPackage, int);

  // Description:
  // Register the Python module.  Once registered, the module can be retrieved
  // with GetModule and HaveModule.  Python interpreters can query these
  // global methods in a custom import mechanism.
  static void RegisterModule(vtkPVPythonModule *module);

  // Description:
  // Return the registered Python module with the given full module name.  If
  // no such module has been registered, this returns NULL.
  static vtkPVPythonModule *GetModule(const char *fullname);

  // Description:
  // Returns 1 if a Python module with the given full name has been registered,
  // 0 otherwise.
  static int HasModule(const char *fullname) {
    return (vtkPVPythonModule::GetModule(fullname) != NULL);
  }

protected:
  vtkPVPythonModule();
  ~vtkPVPythonModule();

  char *Source;
  char *FullName;
  int   IsPackage;

private:
  vtkPVPythonModule(const vtkPVPythonModule &); // Not implemented
  void operator=(const vtkPVPythonModule &);    // Not implemented
};

#endif //__vtkPVPythonModule_h