00001
00021 #include "libnebular.hpp"
00022
00023 #ifndef NEBULAR_PLUGIN_HPP_
00024 #define NEBULAR_PLUGIN_HPP_
00025
00029
00030 namespace libnebular{
00036 void setDefault(
00037 PicturePropContainer &p,
00038 const String &key,
00039 const String &value
00040 );
00041
00048 class ThrowableError: public Error{
00049 public:
00050 ThrowableError(const std::string& msg = "");
00051 };
00052
00053 #if __GNUC__
00054
00055
00056
00057
00058
00059 #define LIBNEBULAR_ERROR(x) libnebular::ThrowableError( \
00060 std::string() + \
00061 "In function \"" + __PRETTY_FUNCTION__ + \
00062 "\", file \"" + __FILE__ + \
00063 "\" at line " + lexicalCastToStdString(__LINE__) + \
00064 ": \n" + x \
00065 )
00066 #else
00067 #error Please redefine LIBNEBULAR_ERROR macro to use your analogue of GCC "__PRETTY_FUNCTION__"
00068 #endif
00069
00075 class Log{
00076 private:
00077 struct Impl_;
00078
00079 friend class LogListener;
00080
00081 public:
00083 static void warning(const std::string &message);
00085 static void info(const std::string &message);
00086
00091 template <typename T> static const String getWrongValueMsg(
00092 const String &key,
00093 const T &value,
00094 const String &shouldBe,
00095 const String &where,
00096 const String &wrongnessType
00097 );
00098
00099 Log();
00100 ~Log();
00101 };
00102
00106 class NumberedStrings{
00107 private:
00108 Integer numStrings;
00109 const String *table;
00110 public:
00113 NumberedStrings(Integer newNumStrings, const String *newTable);
00114 ~NumberedStrings();
00115
00116 Integer stringToIndex(const String &string) const;
00117 const String indexToString(Integer number) const;
00118 };
00119
00120
00121 class PictureHandler;
00122
00129 class PicHandlerMgr{
00130 private:
00132 PicHandlerMgr(const PicHandlerMgr &);
00134 PicHandlerMgr &operator=(const PicHandlerMgr &);
00135
00136 protected:
00140 static void determineFileExt(Picture &);
00142 static bool haveContentMagic(Picture &pictureFile, const Blob &magicData, Integer magicFileOffset);
00143
00144 PicHandlerMgr();
00145
00146 public:
00147
00148 virtual ~PicHandlerMgr();
00149
00155
00156
00157
00158
00159 bool virtual isHandleableByFileExt(Picture &pictureFile) const = 0;
00163 bool virtual isHandleableByContentMagic(Picture &pictureFile) const = 0;
00167 bool virtual isWriteable(Picture &picture) const = 0;
00169
00170 boost::shared_ptr<PictureHandler> virtual createPictureHandler() const = 0;
00171 };
00172
00179 class PictureHandler{
00180 protected:
00182 boost::shared_ptr<Picture> pic;
00183
00185 PictureHandler(const PictureHandler &);
00187 PictureHandler &operator=(const PictureHandler&);
00188 public:
00189
00196 void virtual setPicture(Picture &newPic) = 0;
00197
00198 PictureHandler();
00199 virtual ~PictureHandler();
00200
00201 void virtual readFileInfo() = 0;
00202 void virtual readBm() = 0;
00203 void virtual write() = 0;
00204 };
00205
00212 class PluginIterator: public std::iterator<
00213 std::forward_iterator_tag,
00214 PicHandlerMgr
00215 >{
00216 private:
00217 typedef PluginIteratorImpl_ Impl_;
00218 friend class PluginIteratorImpl_;
00219 boost::shared_ptr<Impl_> pimpl_;
00220
00221 friend PluginIterator pluginBegin();
00222 friend PluginIterator pluginEnd();
00223 public:
00224
00225 PluginIterator();
00226 ~PluginIterator();
00227 PluginIterator(const PluginIterator &);
00228 PluginIterator &operator=(const PluginIterator &);
00229
00230 PluginIterator& operator++();
00231 PluginIterator operator++(int);
00232
00233 bool operator!=(const PluginIterator &) const;
00234 bool operator==(const PluginIterator &) const;
00235
00236 value_type &operator*();
00237 value_type *operator->();
00238 };
00239 PluginIterator pluginBegin();
00240 PluginIterator pluginEnd();
00241
00242 #if HAVE_LOKI_FUNCTOR_H
00243 #if HAVE_CSETJMP
00244
00252 class RawCExceptionLongJmp{
00253 private:
00254 jmp_buf aJmpBuf;
00255 Loki::Functor< void > cleanupCode;
00256 boost::shared_ptr<std::exception> anException;
00257 bool isEnabled;
00258 Loki::Functor< void, LOKI_TYPELIST_1(boost::shared_ptr<const std::exception>) > currExactThrow;
00259 template <typename CurrException> static void exactThrow(boost::shared_ptr<const std::exception>);
00260
00261 public:
00263 RawCExceptionLongJmp(
00264 Loki::Functor< void > newCleanupCode =
00265 Loki::Functor< void >()
00266 );
00267 ~RawCExceptionLongJmp();
00268
00271 template <typename Return> Return run(Loki::Functor<Return> code);
00272
00275 template <typename CurrException> void doThrow(const CurrException &newException);
00276 };
00277
00278 #endif // HAVE_CSETJMP
00279 #endif // HAVE_LOKI_FUNCTOR_H
00280
00281 }
00282
00283
00284 #include "libnebular-plugin.templates.hpp"
00285
00286 #endif // NEBULAR_PLUGIN_HPP_