Alida-C++ 0.5

dataio/ioManager.cc

Go to the documentation of this file.
00001 /*
00002  * This file is part of Alida-C++ library for
00003  *
00004  * Automatic Logging of Process Information in Data Analysis.
00005  *
00006  * Copyright (C) 2012 - @YEAR@
00007  *
00008  * This program is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 3 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020  *
00021  * Fore more information on Alida, visit
00022  *
00023  *    http://www.informatik.uni-halle.de/alida/
00024  *
00025  */
00026 
00027 /*
00028  * Most recent change(s):
00029  *
00030  * $Rev: 41 $
00031  * $Date: 2012-02-19 13:29:35 +0100 (So, 19 Feb 2012) $
00032  * $Author: moeller $
00033  *
00034  */
00035 
00036 #include <math.h>
00037 #include <stdio.h>
00038 #include <fstream>
00039 #include <string>
00040 #include <iostream>
00041 #include <dlfcn.h>
00042 
00043 /* 
00044  *  This file (matrix.cc) is included by matrix.h !!!!
00045  */
00046 
00047 #include "ioManager.h"
00048 
00049 /* #]  : */
00050 
00051 using namespace std;
00052 
00053 using namespace Alida;
00054 
00055 Provider* Alida::IOManager::registerProvider(string type, Provider *p)
00056 {
00057     if (this->registrationTable == NULL)
00058         this->registrationTable = new map<string, Provider*>();
00059     cout << "[IOManager] Registering provider for type " << type << endl;
00060     (*registrationTable)[type] = p;
00061     map<string, Provider*>::iterator it;
00062     return p;
00063 }
00064 
00065 void Alida::IOManager::printRegistrationTable()
00066 {
00067     cout << "Registered providers:" << endl;
00068     map<string, Provider*>::iterator it;
00069     for (it = this->registrationTable->begin(); it != this->registrationTable->end(); ++it)
00070         cout << "Index: " << it->first << endl;
00071 }
00072 
00073 //std::map<std::string, std::string> *IOManager::provider = NULL;
00074 //
00075 //void IOManager::init()
00076 //{
00077   // std::cout << "Registering float provider... " << std::endl;
00078   // std::string classname = "floatProvider";
00079   // std::cout << classname << std::endl;
00080   // char toLoad[128];
00081   // sprintf(toLoad,"./lib%s.so",classname.c_str());
00082   // void *hndl = dlopen(toLoad, RTLD_NOW);
00083   // if(hndl == NULL){
00084   //   std::cerr << dlerror() << std::endl;
00085   //   return;
00086   // }
00087   // typedef void (*hello_t)();
00088   // hello_t read = (hello_t)dlsym(hndl, "init");
00089   // read();
00090 
00091   // std::cout << "Registering string provider... " << std::endl;
00092   // classname = "stringProvider";
00093   // std::cout << classname << std::endl;
00094   // sprintf(toLoad,"./lib%s.so",classname.c_str());
00095   // hndl = dlopen(toLoad, RTLD_NOW);
00096   // if(hndl == NULL){
00097   //   std::cerr << dlerror() << std::endl;
00098   //   return;
00099   // }
00100   // read = (hello_t)dlsym(hndl, "init");
00101   // read();
00102 //}
00103 //
00104 //void IOManager::registerProvider(std::string type, std::string classname)
00105 //{
00106 //  std::cout << "Registering... " << type << " , " << classname << std::endl;
00107 //  if (IOManager::provider == NULL)
00108 //    IOManager::provider = new std::map<std::string, std::string>();
00109 //  (*IOManager::provider)[type] = classname;
00110 //  std::cout << "Done!" << std::endl;
00111 //}
00112 //
00113 //void* IOManager::readObject(std::string input, std::string type)
00114 //{
00115 //  std::cout << "Reading object of type " << type << " from input " << input << "... " << std::endl;
00116 //  std::string classname = (*IOManager::provider)[type];
00117 //  std::cout << "Library: " <<  classname << std::endl;
00118 //  char toLoad[128];
00119 //  sprintf(toLoad,"./lib%s.so",classname.c_str());
00120 //  std::cout << toLoad << std::endl;
00121 //  void *hndl = dlopen(toLoad, RTLD_NOW);
00122 //  if(hndl == NULL){
00123 //    std::cerr << dlerror() << std::endl;
00124 //    return NULL;
00125 //  }
00126 //  typedef void* (*hello_t)(std::string, std::string, void* &);
00127 //  hello_t read = (hello_t)dlsym(hndl, "maker");
00128 //  void* module;
00129 //  read(input,type,module);
00130 //  return module;
00131 //}
00132 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines