main.cpp

См. документацию.
00001 #include "main.h"
00002 //#include "RmDirs.h"
00003 
00004 //Указатель такого типа обрабатывает вызовы всех станз, модуль сам должен их заполнить в список и после прихода станзы
00005 //вызывается каждый раз последовательно до тех пор пока не будет возвращено значение true
00006 static unsigned int modid=0;
00007 static map<unsigned int,moduleStruct> modules;
00008 
00009 bool /*extern*/ moduleFunc(void* stanza, funcSendData *sendd, funcGetData *getd) {
00010     return false;
00011 };
00012 
00013 unsigned int /*extern*/ registerModule(Server* protocol, ServerConfig* sc, BinaryProtocol* bp) {
00014     unsigned int mid = ++modid;
00015     moduleStruct ms;
00016     cout << "Register module FILEOPERATION" << endl;
00017     ms.rd = new ReadDirectory(*protocol, sc);
00018     ms.ga = new GetAttributes(*protocol, sc);
00019     ms.of = new OpenFiles(*protocol, sc);
00020     ms.rf = new ReadFiles(*protocol, sc, bp);
00021     ms.wf= new WriteFiles(*protocol,sc,bp);
00022     ms.rlf= new ReleaseFiles(*protocol,sc);
00023 
00024     ms.cm=new ChmodFile(*protocol,sc);
00025     ms.ul=new UnlinkFiles(*protocol,sc);
00026     ms.lf=new LinkFiles(*protocol,sc);
00027     ms.rmd=new RmDirs(*protocol,sc);
00028     ms.md=new MkDirs(*protocol,sc);
00029     modules.insert(make_pair(mid,ms));
00030     return mid;
00031 }
00032 
00033 void /*extern*/ unregisterModule(unsigned int mid) {    
00034     map<unsigned int,moduleStruct>::iterator it=modules.find(mid);
00035     if(it!=modules.end()){
00036         cout<<"Удаление данных модуля id:"<<mid<<endl;
00037         moduleStruct ms=it->second;
00038         cout<<"1 шаг уд"<<endl;
00039         modules.erase(it);
00040         cout<<"2 шаг уд"<<endl;
00041         delete ms.rd;        
00042         cout<<"3 шаг уд"<<endl;
00043         delete ms.ga;
00044         cout<<"4 шаг уд"<<endl;
00045         delete ms.of;
00046         cout<<"5 шаг уд"<<endl;
00047         delete ms.rf;
00048         cout<<"6 шаг уд"<<endl;
00049         delete ms.wf;
00050         cout<<"7 шаг уд"<<endl;
00051         delete ms.rlf;
00052         delete ms.cm;
00053         delete ms.ul;
00054         delete ms.lf;
00055         delete ms.rmd;
00056         delete ms.md;
00057     }
00058 }