2007-08-14 08:14:21 +02:00
|
|
|
/*
|
|
|
|
|
APPCONFIG.hpp - for global initialization and configuration
|
|
|
|
|
|
|
|
|
|
Copyright (C) CinelerraCV
|
|
|
|
|
2007, Christian Thaeter <ct@pipapo.org>
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
2007-08-17 00:36:07 +02:00
|
|
|
/** @file appconfig.hpp
|
|
|
|
|
** This header is special, as it causes global system initialisation
|
|
|
|
|
** to happen. On inclusion, it places static initialisation code,
|
|
|
|
|
** which on first run will create the Appconfig singleton instance.
|
|
|
|
|
** Additionally, the inclusion, configuration and initialisation
|
|
|
|
|
** of the NoBug library is handled here. Global <i>definitions</i>
|
|
|
|
|
** for NoBug are placed into the corresponding translation unit
|
|
|
|
|
** appconfig.cpp"
|
|
|
|
|
**
|
|
|
|
|
** @see nobugcfg.h
|
|
|
|
|
*/
|
|
|
|
|
|
2007-08-14 08:14:21 +02:00
|
|
|
|
|
|
|
|
#ifndef CINELERRA_APPCONFIG_H
|
|
|
|
|
#define CINELERRA_APPCONFIG_H
|
|
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
2007-08-17 00:36:07 +02:00
|
|
|
#include "nobugcfg.h"
|
|
|
|
|
|
2007-08-14 08:14:21 +02:00
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
using std::auto_ptr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace cinelerra
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Singleton to hold inevitable global flags and constants
|
2007-08-17 00:36:07 +02:00
|
|
|
* and for performing early (static) global initialization tasks.
|
2007-08-14 08:14:21 +02:00
|
|
|
*/
|
|
|
|
|
class Appconfig
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
/** holds the single instance and triggers initialization */
|
2007-08-17 00:36:07 +02:00
|
|
|
static Appconfig* theApp_;
|
2007-08-14 08:14:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/** perform initialization on first access.
|
|
|
|
|
* A call is placed in static initialization code
|
2007-08-17 00:36:07 +02:00
|
|
|
* included via cinelerra.h (see below),
|
|
|
|
|
* thus it will happen rather early.
|
2007-08-14 08:14:21 +02:00
|
|
|
*/
|
|
|
|
|
Appconfig () ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
static Appconfig& instance()
|
|
|
|
|
{
|
2007-08-17 00:36:07 +02:00
|
|
|
if (!theApp_) theApp_ = new Appconfig ();
|
2007-08-14 08:14:21 +02:00
|
|
|
return *theApp_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** access the configuation value for a given key.
|
2007-08-17 00:36:07 +02:00
|
|
|
* @return empty string for unknown keys, config value else
|
|
|
|
|
* @todo do we need such a facility?
|
2007-08-14 08:14:21 +02:00
|
|
|
*/
|
2007-08-17 00:36:07 +02:00
|
|
|
static const string & get (const string& key) throw();
|
2007-08-14 08:14:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
typedef std::map<string,string> Configmap;
|
|
|
|
|
typedef auto_ptr<Configmap> PConfig;
|
|
|
|
|
|
2007-08-17 00:36:07 +02:00
|
|
|
/** @TODO <b>the following is just placeholder code!</b>
|
2007-08-14 08:14:21 +02:00
|
|
|
* Appconfig <i>could</i> do such things if necessary.
|
|
|
|
|
*/
|
|
|
|
|
PConfig configParam_;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
|
{
|
2007-08-17 00:36:07 +02:00
|
|
|
/** "magic code" to cause early static initialization */
|
|
|
|
|
Appconfig& init (Appconfig::instance ());
|
2007-08-14 08:14:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace cinelerra
|
|
|
|
|
#endif
|