Guest User

New example of thrift problem

a guest
Feb 26th, 2014
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1.  
  2. template<typename T>
  3. void deleteProcessors(T &processor) {
  4.     for (typename T::iterator iter = processor.begin(); iter != processor.end(); ++iter) {
  5.         delete iter->second;
  6.     }
  7.     processor.clear();
  8. }
  9.  
  10. class taggerHandler : virtual public taggerIf {
  11. public:
  12.     taggerHandler() {
  13.         this->loadResources();
  14.     }
  15.  
  16.     void tagText(std::string& _return, const std::string& text, const std::string& language) {
  17.         //useful function
  18.     }
  19.  
  20.     void reload(std::string& _return, const std::string& parmeters) {
  21.         this->clearResources();
  22.         this->loadResources();
  23.     }
  24.     private:
  25.         void loadResources() {
  26.             //here config reading,  option declaring etc..
  27.             //maco just object from freeling library, that could allocate 100MB
  28.             string language = "en";
  29.             this->macoProcs[language] = shared_ptr<maco>(new maco());
  30.         }
  31.         void clearResources(){
  32.             //this way was before shared_ptr
  33.             //deleteProcessors(macoProcs);
  34.  
  35.             macoProcs.clear();
  36.         }
  37.         map<string, shared_ptr<maco> > macoProcs;
  38. };
Advertisement
Add Comment
Please, Sign In to add comment