00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifdef HAVE_CONFIG_H
00031 #include <config.h>
00032 #endif
00033
00034 #include "SILLYImageLoaderManager.h"
00035
00036 #ifndef SILLY_OPT_INLINE
00037 #define inline
00038 #include "SILLYImageLoaderManager.icpp"
00039 #undef inline
00040 #endif
00041 #include "SILLYImageLoader.h"
00042 #include "loaders/SILLYTGAImageLoader.h"
00043
00044 #ifdef SILLY_HAVE_JPG
00045 #include "loaders/SILLYJPGImageLoader.h"
00046 #endif
00047
00048 #ifdef SILLY_HAVE_PNG
00049 #include "loaders/SILLYPNGImageLoader.h"
00050 #endif
00051
00052
00053 namespace SILLY
00054 {
00055
00056
00057
00058 static size_t silly_init_counter = 0;
00059
00060 ImageLoaderManager* ImageLoaderManager::d_instance = 0;
00061
00062 ImageLoaderManager::ImageLoaderManager()
00063 {
00064 assert(d_instance == 0);
00065 d_instance = this;
00066 add(new TGAImageLoader);
00067 #ifdef SILLY_HAVE_JPG
00068 add(new JPGImageLoader);
00069 #endif
00070 #ifdef SILLY_HAVE_PNG
00071 add(new PNGImageLoader);
00072 #endif
00073
00074
00075 }
00076
00077 ImageLoaderManager::~ImageLoaderManager()
00078 {
00079 for(ImageLoaderList::iterator iter = d_loaders.begin() ; iter != d_loaders.end() ; ++iter)
00080 {
00081 delete (*iter);
00082 }
00083 d_instance = 0;
00084 }
00085
00086
00087 bool SILLYInit()
00088 {
00089 if (ImageLoaderManager::getSingletonPtr() == 0)
00090 {
00091 if (!new ImageLoaderManager)
00092 {
00093 return false;
00094 }
00095 }
00096 ++silly_init_counter;
00097 return true;
00098 }
00099
00100 void SILLYCleanup()
00101 {
00102 if (--silly_init_counter == 0)
00103 {
00104 delete ImageLoaderManager::getSingletonPtr();
00105 }
00106 }
00107
00108 }
00109
00110