| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/kernel/TeTimeInterval.h
Go to the documentation of this file.

    00001 /************************************************************************************
    00002 TerraLib - a library for developing GIS applications.
    00003 Copyright © 2001-2007 INPE and Tecgraf/PUC-Rio.
    00004
    00005 This code is part of the TerraLib library.
    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 You should have received a copy of the GNU Lesser General Public
    00012 License along with this library.
    00013
    00014 The authors reassure the license terms regarding the warranties.
    00015 They specifically disclaim any warranties, including, but not limited to,
    00016 the implied warranties of merchantability and fitness for a particular purpose.
    00017 The library provided hereunder is on an "as is" basis, and the authors have no
    00018 obligation to provide maintenance, support, updates, enhancements, or modifications.
    00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
    00020 indirect, special, incidental, or consequential damages arising out of the use
    00021 of this library and its documentation.
    00022 *************************************************************************************/
    00027 #ifndef  __TERRALIB_INTERNAL_TIMEINTERVAL_H
    00028 #define  __TERRALIB_INTERNAL_TIMEINTERVAL_H
    00029
    00030 #include "TeTime.h"
    00031
    00033 class TL_DLL TeTimeInterval
    00034 {
    00035 private:
    00036
    00037            TeTime  t1_;
    00038            TeTime  t2_;
    00039            TeChronon  intChronon_;
    00040
    00041            void adjustIntervaltoChronon ();
    00042
    00043 public:
    00044
    00046            void now(void) {t1_.now(); t2_.now();}
    00047
    00049            TeTimeInterval (void):           t1_(), t2_() {}
    00050
    00052            TeTimeInterval (TeTime& t1, TeTime& t2):    t1_(t1), t2_(t2) {}
    00053
    00055            TeTimeInterval(const TeTimeInterval& t): t1_(t.t1_), t2_(t.t2_) {}
    00056
    00058            TeTimeInterval(const std::string& t1, const std::string& t2, TeChronon chronon=TeSECOND, const std::string& mask="YYYYsMMsDDsHHsmmsSS", const std::string& dateS = "/", const std::string& timeS = ":", const std::string& indPM = "PM");
    00059
    00061            TeTimeInterval(const std::string& t1, TeChronon chronon=TeSECOND, const std::string& mask="YYYYsMMsDDsHHsmmsSS", int delta = 0, int numsteps = 1):
    00062                       t1_ (t1,  chronon, mask)
    00063            {
    00064                       t2_ = t1_ + (delta-1)*numsteps;
    00065                       adjustIntervaltoChronon();
    00066            }
    00067
    00069            TeChronon intervalChronon() { return  intChronon_; }
    00070
    00072            void intervalChronon(TeChronon c);
    00073
    00075            std::string getInitialTime()                           {return t1_.getTime();}
    00076
    00078            std::string getFinalTime()                             {return t2_.getTime();}
    00079
    00081            std::string getInitialDate(void)            {return t1_.getDate();}
    00082
    00084            std::string getFinalDate(void)              {return t2_.getDate();}
    00085
    00087            TeTime& getT1 (void) {return t1_;}
    00088
    00090            TeTime& getT2 (void) {return t2_;}
    00091
    00093            std::string getInitialDateTime (const std::string& mask="YYYYsMMsDDsHHsmmsSS", const std::string& dateS="/", const std::string& timeS=":", const std::string& indPM="PM", const std::string& indAM="AM") {return t1_.getDateTime(mask, dateS, timeS, indPM, indAM);}
    00094
    00096            std::string getFinalDateTime (const std::string& mask="YYYYsMMsDDsHHsmmsSS", const std::string& dateS="/", const std::string& timeS=":", const std::string& indPM="PM", const std::string& indAM="AM") {return t2_.getDateTime(mask, dateS, timeS, indPM, indAM);}
    00097
    00098
    00100
    00108            time_t setInitialTime (int y, int m, int d, int h = 0, int min = 0, int s = 0)
    00109            {return t1_.Set(y, m, d, h, min, s);}
    00110
    00111
    00113
    00121            time_t setFinalTime (int y, int m, int d, int h = 0, int min = 0, int s = 0)
    00122            {return t2_.Set(y, m, d, h, min, s);}
    00123
    00125            TeTimeInterval& operator=(const TeTimeInterval& t) {t1_ = t.t1_;  t2_ = t.t2_; intChronon_ = t.intChronon_; return (*this);}
    00126
    00128            bool operator==(const TeTimeInterval& other) const { return (this->t1_ == other.t1_ && this->t2_ == other.t2_); }
    00129
    00130            bool operator<(const TeTimeInterval& other) const { return (this->t1_ < other.t1_ && this->t2_ < other.t2_); }
    00131
    00133            int length ();
    00134
    00136
    00140            void shift (const std::string& t = "");
    00141
    00142
    00144            void shiftPlus (int delta);
    00145
    00147            void shiftMinus (int delta);
    00148
    00150            bool isValid()
    00151            { return (t1_.isValid() || t2_.isValid()); }
    00152
    00154            ~TeTimeInterval(void) { }
    00155
    00157            bool  during (TeTime& time);
    00158
    00160            bool  before (TeTime& time);
    00161
    00162 };
    00163
    00165 TL_DLL std::ostream& operator<<(std::ostream& os, TeTime& N);
    00166
    00167 #endif
    00168
    00169

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines