"Fossies" - the Fresh Open Source Software Archive

Member "fimex-1.4.1/include/fimex/TimeSpec.h" (30 Oct 2019, 3364 Bytes) of package /linux/privat/fimex-1.4.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "TimeSpec.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Fimex, TimeSpec.h
    3  *
    4  * (C) Copyright 2008, met.no
    5  *
    6  * Project Info:  https://wiki.met.no/fimex/start
    7  *
    8  * This library is free software; you can redistribute it and/or modify it
    9  * under the terms of the GNU Lesser General Public License as published by
   10  * the Free Software Foundation; either version 2.1 of the License, or
   11  * (at your option) any later version.
   12  *
   13  * This library is distributed in the hope that it will be useful, but
   14  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   15  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
   16  * License for more details.
   17  *
   18  * You should have received a copy of the GNU Lesser General Public
   19  * License along with this library; if not, write to the Free Software
   20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
   21  * USA.
   22  *
   23  *  Created on: Dec 11, 2008
   24  *      Author: Heiko Klein
   25  */
   26 
   27 #ifndef TIMESPEC_H_
   28 #define TIMESPEC_H_
   29 
   30 #include "fimex/TimeUnit.h"
   31 #include <vector>
   32 #include <string>
   33 
   34 namespace MetNoFimex
   35 {
   36 
   37 /**
   38  * @headerfile fimex/TimeSpec.h
   39  */
   40 /**
   41  * This class can be used to describe a list of times in an efficient textual way.
   42  *
   43  * Unless otherwise mentioned, i.e. with <em>bounds</em> a value v(time)
   44  * describes the time at exactly that instance. All times are UTC.
   45  *
   46  *
   47  * - TIMESTAMP format: YYYY-MM-DD HH:MM:SS
   48  * - TIMESTAMPS: comma-separated list of values with possible ... extension, ... meaning continuation of the difference of the previous two values
   49  * - UNIT: see <a href="http://www.unidata.ucar.edu/software/udunits/">udunit</a>, default: second
   50  * - VALUE: float-number
   51  * - VALUES: comma-separated list of values with possible ... extension, ... meaning continuation of the difference of the previous two values
   52  *         0 is the first time in the original time-axis, x is the last time-value in the original time-axis
   53  *
   54  * A TimeSpec consists of at least of timestamps or values:
   55  *
   56  * - timespec := (TIMESTAMPS | VALUES[;relativeUnit=UNIT])[;unit=UNIT]
   57  *
   58  * relativeUnit will reset the relative value 0 to the first value larger
   59  * than t0 (original start time)
   60  * with t0 =  i * (v1-v0)* unit with i being a integer.
   61  *
   62  * @subsubsection secTimeSpecEx1 Example: absolute times, every 4th hour
   63  *
   64  * @code
   65  * timespec = 2000-01-01 00:00:00,2000-01-01 00:04:00,...,2010-01-01 00:00:00
   66  * @endcode
   67  *
   68  * All times outside the original time-axis will be discarded.
   69  *
   70  * @subsubsection secTimeSpecEx2 Example: relative time, each 3rd hour starting at 00 o'clock, one extrapolation
   71  *
   72  * @code
   73  * timespec = -3,0,3,...,x,x+3;relativeUnit=hours since 2000-01-01 00:00:00;unit=hours since 2000-01-01 00:00:00;
   74  * @endcode
   75  */
   76 class TimeSpec
   77 {
   78 public:
   79     /**
   80      * Define a timeSpec
   81      * @param timeSpec string representation as explained above
   82      * @param startTime time to start in case of a relativeStart timeSpec
   83      * @param endTime time to end in case of a relativeStart timeSpec
   84      */
   85     TimeSpec(const std::string& timeSpec, const FimexTime& startTime, const FimexTime& endTime);
   86     virtual ~TimeSpec() {};
   87     const std::vector<FimexTime>& getTimeSteps() const {return timeSteps;}
   88     const std::string& getUnitString() const {return outputUnit;}
   89 
   90 private:
   91     std::string outputUnit;
   92     std::vector<FimexTime> timeSteps;
   93 };
   94 
   95 } /* MetNoFimex */
   96 
   97 #endif /* TIMESPEC_H_ */