/* This file is part of SECONDO. Copyright (C) 2011, University in Hagen, Department of Computer Science, Database Systems for New Applications. SECONDO is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. SECONDO is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SECONDO; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef RASTER2_ATPERIODS_H #define RASTER2_ATPERIODS_H #include #include #include "../msbool.h" #include "../msreal.h" #include "../msint.h" #include "../msstring.h" #include "Algebras/Temporal/TemporalAlgebra.h" namespace raster2 { extern ValueMapping atperiodsFuns[]; ListExpr atperiodsTypeMap(ListExpr args); int atperiodsSelectFun(ListExpr args); template int atperiodsFun (Word* args, Word& result, int message, Word& local, Supplier s) { typename Helper::implementation_type* pImplementationType = static_cast(args[0].addr); temporalalgebra::Periods* periods = static_cast(args[1].addr); result = qp->ResultStorage(s); typename Helper::implementation_type* pResult = static_cast(result.addr); if((pImplementationType != 0) && pImplementationType->isDefined() && periods->IsDefined()) { if(pResult != 0) { typename Helper::implementation_type* patperiodsResult = pImplementationType->atperiods(*periods); if(patperiodsResult != 0) { swap(*pResult, *patperiodsResult); delete patperiodsResult; } } } else { pResult->setDefined(false); } return 0; } struct atperiodsInfo : OperatorInfo { atperiodsInfo() { name = "atperiods"; signature = msbool::BasicType() + " atperiods " + temporalalgebra::Periods::BasicType() + "-> " + msbool::BasicType(); appendSignature(msreal::BasicType() + " atperiods " + temporalalgebra::Periods::BasicType() + "-> " + msreal::BasicType()); appendSignature(msint::BasicType() + " atperiods " + temporalalgebra::Periods::BasicType() + "-> " + msint::BasicType()); appendSignature(msstring::BasicType() + " atperiods " + temporalalgebra::Periods::BasicType() + "-> " + msstring::BasicType()); syntax = "atperiods(_)"; meaning = "restricts values to periods"; } }; } #endif /* #define RASTER2_ATPERIODS_H */