Loading...
Searching...
No Matches
casacore::AppStateSource Class Reference
casa package (libcasa_casa) » System_module

Allow configuration of casacore without environment variables. More...

`#include <AppState.h>`

## Static Public Member Functions

static void | initialize (AppState *init)
static AppState & | fetch ()

## Private Member Functions

| AppStateSource ()
| AppStateSource (AppStateSource const &)
void | operator= (AppStateSource const &)

## Static Private Attributes

static AppState * | user_state

## Detailed Description

Allow configuration of casacore without environment variables.

### Intended use:

Public interface

### Review Status

Date Reviewed:
  yyyy/mm/dd

### Synopsis

This class allows packages which use casacore to configure casacore behavior without reverting to environment variables. It is composed primarly of static functions. An external application configures casacore by calling the initialize(...) member function passing in a pointer to an object which is derived from the AppState base class. AppStateSource takes ownership of the provided pointer.

When casacore no longer depends on compilers whose standard is older than C++11, the raw pointers here should be changed to unique_ptrs. The std::unique_ptr constructor is a constexpr, and it does not throw exceptions.

### Example

class MyState: public casacore::AppState { public: MyState() { }

const std::list<std::string> &dataPath() const { static std::list<std::string> my_path; return my_path; }

bool initialized() const { return true; } };

MyState &get_my_state() { if (AppStateSource::fetch().initialized() == false) casacore::AppStateSource::initialize(new MyState); return dynamic_cast<MyState&>(AppStateSource::fetch()); }

int main(int argc, char *argv[]) { MyState &state = get_my_state(); ... return 0; }

Definition at line 131 of file AppState.h.

## Constructor & Destructor Documentation

## AppStateSource() [1/2]

casacore::AppStateSource::AppStateSource | ( |  | ) |

inline private

Definition at line 147 of file AppState.h.

Referenced by AppStateSource(), and operator=().

## AppStateSource() [2/2]

casacore::AppStateSource::AppStateSource | ( | AppStateSource const & |  | ) |

inline private

Definition at line 148 of file AppState.h.

References AppStateSource().

## Member Function Documentation

## fetch()

AppState & casacore::AppStateSource::fetch | ( |  | ) |

inline static

Definition at line 140 of file AppState.h.

References user_state.

## initialize()

void casacore::AppStateSource::initialize | ( | AppState * | init | ) |

inline static

Definition at line 134 of file AppState.h.

References casacore::init(), and user_state.

## operator=()

void casacore::AppStateSource::operator= | ( | AppStateSource const & |  | ) |

inline private

Definition at line 149 of file AppState.h.

References AppStateSource().

## Member Data Documentation

## user_state

AppState* casacore::AppStateSource::user_state

static private

Definition at line 146 of file AppState.h.

Referenced by fetch(), and initialize().

The documentation for this class was generated from the following file:

- casa/System/AppState.h