См. документацию.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef STANZA_H_
00009 #define STANZA_H_
00010 #include "Node.h"
00011 #include <sstream>
00012 using namespace std;
00013
00014 #define FROM "from"
00015 #define TO "to"
00016 #define ID "id"
00017
00018 static int curid=0;
00019 static pthread_mutex_t mutexID1 = PTHREAD_MUTEX_INITIALIZER;
00020
00021 class Stanza: public Node {
00022
00023
00024 public:
00025 virtual ~Stanza();
00026 Stanza(string name, map <string, string> &attrs, Node* parent);
00027 Stanza(string name, Node* parent,string from="", string to="", string id="");
00028 void setID(string id){setAttribute("id",id);}
00029 void setFrom(string from){return setAttribute(FROM,from);};
00030 void setTo(string to){return setAttribute(TO,to);};
00031 string getFrom(){return getAttribute(FROM);};
00032 string getID(){return getAttribute(ID);}
00033 string getTo(){return getAttribute(TO);};
00034 static string generateID(){
00035 stringstream res;
00036 pthread_mutex_lock(&mutexID1);
00037 curid++;
00038 res<<"id_"<<curid;
00039 pthread_mutex_unlock(&mutexID1);
00040 return res.str();
00041 }
00042 Stanza(const Node &basedNode);
00043 };
00044
00045 #endif