ffead.server.doc
Reflector.cpp
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 #include "Reflector.h"
17 
18 Reflector::Reflector()
19 {
20 
21 }
22 
23 Reflector::~Reflector()
24 {
25 
26 }
27 void Reflector::cleanUp()
28 {
29  for (int var=0;var<(int)objectT.size();var++)
30  {
31  if(objectT.at(var)=="string" || objectT.at(var)=="int" || objectT.at(var)=="long"
32  || objectT.at(var)=="double" || objectT.at(var)=="float" || objectT.at(var)=="bool"
33  || objectT.at(var)=="char")
34  delete objects.at(var);
35  else
36  {
37  destroy(objects.at(var),objectT.at(var));
38  }
39  }
40 }
41 
42 ClassInfo Reflector::getClassInfo(string className)
43 {
44  ClassInfo info;
45  string libName = Constants::INTER_LIB_FILE;
46  void *dlib = dlopen(libName.c_str(), RTLD_NOW);
47  if(dlib == NULL)
48  {
49  cerr << dlerror() << endl;
50  exit(-1);
51  }
52  string methodname = "getReflectionCIFor"+className;
53  void *mkr = dlsym(dlib, methodname.c_str());
54  typedef ClassInfo (*RfPtr) ();
55  RfPtr f = (RfPtr)mkr;
56  if(f!=NULL)
57  return f();
58  else
59  return info;
60 }
61