OOF2: The Manual

Name

IndexP — Generic wrapper for index objects

Synopses

C++ Synopsis

#include "engine/fieldindex.h"
class IndexP {
  IndexP(FieldIndex* index);
  IndexP(const IndexP& other);
  IndexP(IndexP&& other);
  int integer() const;
  bool in_plane() const;
  operator const FieldIndex&() const;
  operator const FieldIndex*() const;
}

Source Files

  • SRC/engine/fieldindex.h: C++ header
  • SRC/engine/fieldindex.C: C++ source code
  • SRC/engine/fieldindex.swg: SWIG source code
  • SRC/engine/fieldindex.spy: Python code included in the SWIG output

Description

IndexP is a wrapper for the various FieldIndex classes, which are used to refer to components of various kinds of Fields, Fluxes, Equations, and OutputVals. The wrapper is a light-weight object that allows a FieldIndex to be used in a generic fashion, while at the same time handling allocation and deallocation of the FieldIndex object.

All of the public FieldIndex methods are available in IndexP, so an IndexP can be treated just like a FieldIndex. An IndexP can be implicitly converted to a const FieldIndex* or const FieldIndex&, so any C++ function expecting a FieldIndex argument can also operate on an IndexP.

Note that IndexP does not do reference counting. It's not a smart pointer class. It's main purpose is to deallocate the FieldIndex pointer that it holds and to access the FieldIndex virtual functions.

[Note] Note

In Python there is no need for the IndexP class. Whenever a FieldIndex object is returned from a C++ function to Python, it is converted into an object of the appropriate derived class, and Python's garbage collection ensures that the FieldIndex is destroyed when necessary.

Methods

IndexP(FieldIndex *index)

The IndexP constructor has a single argument, which must be a pointer to a newly constructed instance of a FieldIndex subclass. The IndexP takes over ownership of the FieldIndex and will delete it when necessary.

IndexP(const IndexP& other)

The copy constructor creates a new IndexP wrapping a pointer to a copy of the underlying FieldIndex object.

IndexP(const IndexP&& other)

The move constructor creates a new IndexP that takes ownership of the old IndexP's FieldIndex pointer. The FieldIndex will be deleted when the new IndexP is destroyed. The old IndexP is invalidated.

int integer() const()

See FieldIndex::integer().

bool in_plane() const

See FieldIndex::in_plane().

operator const FieldIndex&() const and operator const FieldIndex*() const

These operators convert an IndexP to a const FieldIndex reference or pointer, allowing it to be passed to functions expecting a FieldIndex argument.