/*! \file piinit.h
 * \ingroup Core
 * \~\brief
 * \~english Library initialization
 * \~russian Инициализация библиотеки
*/
/*
	PIP - Platform Independent Primitives
	Initialization
	Ivan Pelipenko peri4ko@yandex.ru

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU Lesser General Public License as published by
	the Free Software Foundation, either version 3 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 Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef PIINIT_H
#define PIINIT_H

#include "pibase.h"

#ifndef MICRO_PIP

#include "piincludes.h"


class PIFile;
class PIStringList;


class PIP_EXPORT __PIInit_Initializer__ {
public:
	__PIInit_Initializer__();
	~__PIInit_Initializer__();
	static int count_;
	static PIInit * __instance__;
};

static __PIInit_Initializer__ __piinit_initializer__;


class PIP_EXPORT PIInit {
	friend class __PIInit_Initializer__;
	friend class PIFile;
public:
	~PIInit();

	//! \ingroup Core
	//! \~english Build options which PIP library was built
	//! \~russian Опции, с которыми был собран PIP
	enum BuildOption {
		boICU /*! \~english Unicode support by ICU \~russian Поддержка юникода через ICU */ = 0x01,
		boUSB /*! \~english USB support \~russian Поддержка USB */ = 0x02,
		boCrypt /*! \~english Crypt support \~russian Поддержка шифрования */ = 0x08,
		boIntrospection /*! \~english Introspection \~russian Интроспекция */ = 0x010,
		boFFTW /*! \~english FFTW3 support \~russian Поддержка FFTW3 */ = 0x40,
		boCompress /*! \~english Zlib compression support \~russian Поддержка сжатия Zlib */ = 0x80,
		boOpenCL /*! \~english OpenCL support \~russian Поддержка OpenCL */ = 0x100,
		boCloud /*! \~english PICloud transport support \~russian Поддержка облачного транспорта PICloud */ = 0x200,
	};
	static PIInit * instance() {return __PIInit_Initializer__::__instance__;}

	//! \ingroup Core
	//! \~english Returns if build option was enabled
	//! \~russian Возвращает была ли включена опция при сборке
	static bool isBuildOptionEnabled(BuildOption o);

	//! \ingroup Core
	//! \~english Returns build options as stringlist
	//! \~russian Возвращает опции сборки как список строк
	static PIStringList buildOptions();
private:
	explicit PIInit();
	void setFileCharset(const char *charset);
	bool fileExists(const PIString & p);
	PRIVATE_DECLARATION(PIP_EXPORT)
	char * file_charset;
};


#endif // MICRO_PIP
#endif // PIINIT_H
