Alida-C++ 0.5

dataio/ioManagerCmdline.cc

Go to the documentation of this file.
00001 #include <math.h>
00002 #include <stdio.h>
00003 #include <fstream>
00004 #include <string>
00005 #include <iostream>
00006 #include <dlfcn.h>
00007 
00008 #include "dataio/ioManagerCmdline.h"
00009 #include "dataio/provider/cmdline/providerCmdline.h"
00010 
00011 using namespace std;
00012 
00013 using namespace Alida;
00014 
00015 void* Alida::_IOManagerCmdline::readData(string input, string type)
00016 {
00017     cout << "Reading " << type << "-data from string " << input << endl;
00018     ProviderCmdline* provObjCmd;
00019     if (this->registrationTable == NULL)
00020         cout << "Table is null" << endl;
00021     if (this->registrationTable->find(type) == this->registrationTable->end()) {
00022         cerr << "Generate provider - no prototype found!" << endl;
00023         return NULL;
00024     }
00025     Provider* provObj = (*(this->registrationTable))[type];
00026     provObjCmd = dynamic_cast<ProviderCmdline*>(provObj);
00027     if (provObjCmd == NULL)
00028         cout << "Object is null!" << endl;
00029     return provObjCmd->parseInput(input, type);
00030 }
00031 
00032 string Alida::_IOManagerCmdline::writeData(string input,string type,void *data)
00033 {
00034     ProviderCmdline* provObjCmd;
00035     if (this->registrationTable == NULL)
00036         cout << "Table is null" << endl;
00037     if (this->registrationTable->find(type) == this->registrationTable->end()) {
00038         cerr << "Generate provider - no prototype found!" << endl;
00039         return string();
00040     }
00041     Provider* provObj = (*(this->registrationTable))[type];
00042     provObjCmd = dynamic_cast<ProviderCmdline*>(provObj);
00043     if (provObjCmd == NULL)
00044         cout << "Object is null!" << endl;
00045     return provObjCmd->writeOutput(input, type, data);
00046 }
00047 
00048 //std::map<std::string, std::string> *IOManager::provider = NULL;
00049 //
00050 //void IOManager::init()
00051 //{
00052   // std::cout << "Registering float provider... " << std::endl;
00053   // std::string classname = "floatProvider";
00054   // std::cout << classname << std::endl;
00055   // char toLoad[128];
00056   // sprintf(toLoad,"./lib%s.so",classname.c_str());
00057   // void *hndl = dlopen(toLoad, RTLD_NOW);
00058   // if(hndl == NULL){
00059   //   std::cerr << dlerror() << std::endl;
00060   //   return;
00061   // }
00062   // typedef void (*hello_t)();
00063   // hello_t read = (hello_t)dlsym(hndl, "init");
00064   // read();
00065 
00066   // std::cout << "Registering string provider... " << std::endl;
00067   // classname = "stringProvider";
00068   // std::cout << classname << std::endl;
00069   // sprintf(toLoad,"./lib%s.so",classname.c_str());
00070   // hndl = dlopen(toLoad, RTLD_NOW);
00071   // if(hndl == NULL){
00072   //   std::cerr << dlerror() << std::endl;
00073   //   return;
00074   // }
00075   // read = (hello_t)dlsym(hndl, "init");
00076   // read();
00077 //}
00078 //
00079 //void IOManager::registerProvider(std::string type, std::string classname)
00080 //{
00081 //  std::cout << "Registering... " << type << " , " << classname << std::endl;
00082 //  if (IOManager::provider == NULL)
00083 //    IOManager::provider = new std::map<std::string, std::string>();
00084 //  (*IOManager::provider)[type] = classname;
00085 //  std::cout << "Done!" << std::endl;
00086 //}
00087 //
00088 //void* IOManager::readObject(std::string input, std::string type)
00089 //{
00090 //  std::cout << "Reading object of type " << type << " from input " << input << "... " << std::endl;
00091 //  std::string classname = (*IOManager::provider)[type];
00092 //  std::cout << "Library: " <<  classname << std::endl;
00093 //  char toLoad[128];
00094 //  sprintf(toLoad,"./lib%s.so",classname.c_str());
00095 //  std::cout << toLoad << std::endl;
00096 //  void *hndl = dlopen(toLoad, RTLD_NOW);
00097 //  if(hndl == NULL){
00098 //    std::cerr << dlerror() << std::endl;
00099 //    return NULL;
00100 //  }
00101 //  typedef void* (*hello_t)(std::string, std::string, void* &);
00102 //  hello_t read = (hello_t)dlsym(hndl, "maker");
00103 //  void* module;
00104 //  read(input,type,module);
00105 //  return module;
00106 //}
00107 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines