Anaphe Home Page Reference Documentation

Main Page     Namespaces     Classes     Source Code    

FunctionFactory.cpp

Go to the documentation of this file.
00001  /**********************************************************************
00002   *                                                                    *
00003   * Copyright (c) 2002 Jakub MOSCICKI, CERN/IT                       *
00004   *                   <Jakub.MOSCICKI@cern.ch>                       *
00005   *                                                                    *
00006   * This library is free software; you can redistribute it and/or      *
00007   * modify it under the terms of the GNU Lesser General Public         *
00008   * License as published by the Free Software Foundation; either       *
00009   * version 2.1 of the License, or (at your option) any later version. *
00010   *                                                                    *
00011   * This library is distributed in the hope that it will be useful,    *
00012   * but WITHOUT ANY WARRANTY; without even the implied warranty of     *
00013   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   *
00014   * Lesser General Public License for more details.                    *
00015   *                                                                    *
00016   * You should have received a copy of the GNU Lesser General Public   *
00017   * License along with this library (see file COPYING); if not, write  *
00018   * to the Free Software Foundation, Inc., 59 Temple Place, Suite      *
00019   * 330, Boston, MA 02111-1307 USA, or contact the author at           *
00020   *  <Jakub.MOSCICKI@cern.ch>                                        *
00021   **********************************************************************/
00022 
00023 // Implementation file for class FunctionFactory 
00024 // 
00025 // Created by: Jakub MOSCICKI at Tue Jan 15 13:05:55 2002
00026 // 
00027 // Last update: Tue Jan 15 13:05:55 2002
00028 // 
00029 
00030 
00031 #include "FunctionFactory.h" 
00032 
00033 #include "AIDA_FML/IFitter_impl.h"
00034 
00035 #include "Function.h"
00036 #include "FitFunction.h"
00037 
00038 #include <memory>
00039 
00040 FunctionFactory::FunctionFactory() 
00041 {
00042 }
00043 
00044 FunctionFactory::~FunctionFactory() 
00045 {
00046 }
00047 
00048 FunctionFactory::FunctionFactory(const FunctionFactory &) 
00049 {
00050 }
00051 
00052 FunctionFactory & FunctionFactory::operator = (const FunctionFactory &rhs) 
00053 {
00054    if (this == &rhs) return *this;  // time saving self-test
00055 
00056    return *this;
00057 }
00058 
00059 IFunction * FunctionFactory::create(const std::string & name, 
00060                                     const std::string & label, 
00061                                     const std::string & type, 
00062                                     const std::vector<double> & parameterValues, 
00063                                     const std::string & parameterNames)
00064 {
00065 
00066   std::auto_ptr<Anaphe::IModelFunction> newmodel(FML::newModelFunction(type));
00067 
00068   if(!newmodel.get()) return 0;
00069 
00070 // change ownership of newmodel
00071   std::auto_ptr<Function_impl_owner> newfun(new Function_impl_owner(label,newmodel)); 
00072 
00073   if(!newfun.get()) return 0;
00074 
00075   newfun->setParameterValues(parameterValues);
00076 
00077   return newfun.release();  
00078 }
00079 
00080 IFunction * FunctionFactory::createScripted(const std::string & name, 
00081                                             const std::string & label, 
00082                                             const std::string & script)
00083 {
00084   cerr << "FunctionFactory: createScripted not implemented" << endl;
00085   return 0;
00086 }
00087 
00088 IFitFunction * FunctionFactory::createFit(const std::string & name, 
00089                                           const std::string & label, 
00090                                           const std::string & type,
00091                                           const std::string & options)
00092 {
00093   std::auto_ptr<FitFunction> fitfun(new FitFunction(label, type,options));
00094 
00095   if(!fitfun.get()) return 0;
00096   else
00097     return fitfun.release(); // release pointer to caller
00098 }
00099 


Anaphe documentation generated by Doxygen (www.doxygen.org)