Alida-C++ 0.1

operator/ALDOperator.cc

Go to the documentation of this file.
00001 /*
00002  * This file is part of Alida-C++ library for
00003  *
00004  * Advanced Library for Integrated Development of Data Analysis Applications.
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: 102 $
00031  * $Date: 2012-03-12 10:30:51 +0100 (Mo, 12 Mrz 2012) $
00032  * $Author: posch $
00033  *
00034  */
00035 
00036 #include <math.h>
00037 #include <stdio.h>
00038 
00039 #include <fstream>
00040 #include <iostream>
00041 #include <string>
00042 
00043 #include "operator/ALDOperator.h"
00044 
00045 using namespace std;
00046 
00047 using namespace Alida;
00048 
00056 void ALDOperator::runOp() throw (ALDException)
00057 {
00058   cout << endl << "Entering runOp()..." << endl << endl;
00059 
00060   this->validate();
00061   this->operate();
00062 
00063   cout << endl << "...leaving runOp()!" << endl;
00064 }
00065 
00066 /*
00067  *  The generic part of this validation checks that each required parameter
00068  *  and input is set to a non-null value.
00069  *  The custom part of validation is operator depended and implemented
00070  * via the method <code>validateCustom</code>.
00071  *  An Exception is thrown if either validation fails.
00072 */
00073 void ALDOperator::validate() throw (ALDException)
00074 {
00075     map<string, ALDOpParameterDescriptor*> params = this->getParameters();
00076     map<string, ALDOpParameterDescriptor*>::const_iterator it;
00077     for (it = params.begin(); it != params.end(); ++it) {
00078         if ( (it->second->direction == PARAMETER_IN ||
00079               it->second->direction == PARAMETER_INOUT ) &&
00080              it->second->value == NULL) {
00081         throw ALDException( "ALDOperator", "validate",  it->second->name + " is required, but NULL");
00082         } 
00083     } 
00084 
00085     validateCustom();
00086 }
00087 
00091 std::map<std::string, ALDOpParameterDescriptor*>& ALDOperator::getParameters()
00092 {
00093   return this->parameters;
00094 }
00095 
00100 void* ALDOperator::getParameter(std::string name)
00101 {
00102   return this->parameters[name]->value;
00103 }
00104 
00109 void ALDOperator::setParameter(std::string name, void* val)
00110 {
00111   this->parameters[name]->value = val;
00112 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines