egami
C++ Image Processing program
/homes/esi30/DCS339/coursework/src/utils.hpp
Go to the documentation of this file.
00001 
00006 #ifndef UTILS_HPP_INCLUDED
00007 #define UTILS_HPP_INCLUDED
00008 
00009 #include <stdexcept>
00010 #include <type_traits>
00011 
00012 extern const char *cmake_install_prefix;
00013 
00014 void register_processings();
00015 
00016 template<class T>
00017 struct Singleton{
00018     Singleton() {
00019         if(!std::is_base_of<Singleton<T>, T>::value)
00020             throw std::runtime_error("Instanciation of a type inheriting from Singleton without itself as template parameter");
00021         static bool first=true;
00022         if(!first || (first=!first))
00023             throw std::runtime_error("Trying to construct more than one singleton");
00024     }
00025 };
00026 
00027 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends