00001 #include
00002 #include
00003
00004
00005 #include
00006
00007 #include
00008 using std::string;
00009
00010
00011 #include "../proto/Img2Value.pb.h"
00012
00013 #ifdef WITH_RADOS
00014 namespace librados {class Rados; class IoCtx;};
00015 #endif
00016
00032 class Img2 {
00034 const string _root;
00035
00036 memcached_st* _memcached;
00037
00038 #ifdef WITH_RADOS
00039 librados::Rados* _rados;
00040 librados::IoCtx* _ctx;
00041 #endif
00042
00044 void pingMagick (const string& path, img2::Img2Value& info);
00045
00047 void pingMagic (const string& path, img2::Img2Value& info);
00048
00051 void cephPut (const string key, const string value);
00054 const string cephGet (const string key);
00056 bool cephDelete (const string key);
00057
00059 void restore();
00060
00061 string memcachedGet (const string key) const;
00062 bool memcachedSet (const string key, const string val, int ttl = -1);
00063
00064 Img2 (string root);
00065
00066 friend int main (int, char**);
00067 public:
00068 virtual ~Img2();
00069
00071 static Img2* getInstance();
00072
00076 string hi();
00077
00092 void storeFile (string fileId, string path, string oDb, string oTable, string oIdField, string oId);
00093
00098 string getUrl (string fileId, string humanReadableName);
00099
00109 string getScaleUrlV0 (string fileId, int maxWidth, int maxHeight, string humanReadableName);
00110
00130 string getScaleUrlV1 (string fileId, int maxWidth, int maxHeight,
00131 string watermarkName, string watermarkPath, string humanReadableName);
00132
00140 void deleteFile (string fileId, string* _id);
00141
00151 bool optionalHaveFile (string fileId);
00152 };