ffead.server.doc
ComponentHandler.h
1 /*
2  Copyright 2009-2012, Sumeet Chhetri
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 /*
17  * ComponentHandler.h
18  *
19  * Created on: Mar 26, 2010
20  * Author: sumeet
21  */
22 
23 #ifndef COMPONENTHANDLER_H_
24 #define COMPONENTHANDLER_H_
25 #include "string"
26 #include "Reflector.h"
27 #include "Component.h"
28 #include "Server.h"
29 #include "XmlParser.h"
30 #include "Reflector.h"
31 #include "fstream"
32 #include "Serialize.h"
33 #include "Thread.h"
34 #include "map"
35 #include "Logger.h"
36 #include "Constants.h"
37 
38 #define BACKLOG1 500
39 #define MAXBUFLEN1 1024
40 using namespace std;
41 class ComponentHandlerException: public exception
42 {
43  public:
44  ComponentHandlerException(string message,string &ret){message="<return:exception>"+message+"</return:exception>";ret=message;}
45  virtual ~ComponentHandlerException() throw(){}
46  string getMessage() const{return message;};
47  private:
48  string message;
49 };
51  Logger logger;
52  static void* service(void* arg);
53  Server server;
54  bool running;
55  map<string,string> components;
56  static void initComponent();
57  static void init();
59  virtual ~ComponentHandler();
60 public:
61  static bool registerComponent(string);
62  static bool unregisterComponent(string);
63  static void trigger(string);
64  static void stop();
65  Server getServer(){return this->server;}
66  void setServer(Server server){this->server = server;}
67 };
68 
69 #endif /* COMPONENTHANDLER_H_ */