Alida-C++ 0.5

operator/aldOperatorManager.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: 34 $
00031  * $Date: 2012/03/06 20:50:22 $
00032  * $Author: posch $
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 #include "operator/aldOperatorManager.h"
00044 
00045 /* #]  : */
00046 
00047 using namespace std;
00048 
00049 using namespace Alida;
00050 
00051 Alida::_ALDOperatorManager::_ALDOperatorManager()
00052 {
00053     this->operatorHash = new map<string, ALDOperator*>();
00054 }
00055 
00056 ALDOperator*
00057 Alida::_ALDOperatorManager::registerOperator(string name, ALDOperator *op)
00058 {
00059     cout << "[OperatorManager] Registering operator " << name << endl;
00060     (*operatorHash)[name] = op;
00061     return op;
00062 }
00063 
00064 void Alida::_ALDOperatorManager::printOperatorHash()
00065 {
00066     cout << "Registered operators:" << endl;
00067     map<string, ALDOperator*>::iterator it;
00068     for (it = this->operatorHash->begin(); it != this->operatorHash->end(); ++it)
00069         cout << "Index: " << it->first << endl;
00070 }
00071 
00072 ALDOperator* Alida::_ALDOperatorManager::getOperator(string name)
00073 {
00074     return (*(this->operatorHash))[name];
00075 }
00076 
00077 //std::map<std::string, std::string> *IOManager::provider = NULL;
00078 //
00079 //void IOManager::init()
00080 //{
00081   // std::cout << "Registering float provider... " << std::endl;
00082   // std::string classname = "floatProvider";
00083   // std::cout << classname << std::endl;
00084   // char toLoad[128];
00085   // sprintf(toLoad,"./lib%s.so",classname.c_str());
00086   // void *hndl = dlopen(toLoad, RTLD_NOW);
00087   // if(hndl == NULL){
00088   //   std::cerr << dlerror() << std::endl;
00089   //   return;
00090   // }
00091   // typedef void (*hello_t)();
00092   // hello_t read = (hello_t)dlsym(hndl, "init");
00093   // read();
00094 
00095   // std::cout << "Registering string provider... " << std::endl;
00096   // classname = "stringProvider";
00097   // std::cout << classname << std::endl;
00098   // sprintf(toLoad,"./lib%s.so",classname.c_str());
00099   // hndl = dlopen(toLoad, RTLD_NOW);
00100   // if(hndl == NULL){
00101   //   std::cerr << dlerror() << std::endl;
00102   //   return;
00103   // }
00104   // read = (hello_t)dlsym(hndl, "init");
00105   // read();
00106 //}
00107 //
00108 //void IOManager::registerProvider(std::string type, std::string classname)
00109 //{
00110 //  std::cout << "Registering... " << type << " , " << classname << std::endl;
00111 //  if (IOManager::provider == NULL)
00112 //    IOManager::provider = new std::map<std::string, std::string>();
00113 //  (*IOManager::provider)[type] = classname;
00114 //  std::cout << "Done!" << std::endl;
00115 //}
00116 //
00117 //void* IOManager::readObject(std::string input, std::string type)
00118 //{
00119 //  std::cout << "Reading object of type " << type << " from input " << input << "... " << std::endl;
00120 //  std::string classname = (*IOManager::provider)[type];
00121 //  std::cout << "Library: " <<  classname << std::endl;
00122 //  char toLoad[128];
00123 //  sprintf(toLoad,"./lib%s.so",classname.c_str());
00124 //  std::cout << toLoad << std::endl;
00125 //  void *hndl = dlopen(toLoad, RTLD_NOW);
00126 //  if(hndl == NULL){
00127 //    std::cerr << dlerror() << std::endl;
00128 //    return NULL;
00129 //  }
00130 //  typedef void* (*hello_t)(std::string, std::string, void* &);
00131 //  hello_t read = (hello_t)dlsym(hndl, "maker");
00132 //  void* module;
00133 //  read(input,type,module);
00134 //  return module;
00135 //}
00136 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines