ARTSAT API  2.7.1
 全て クラス ファイル 関数 変数 型定義 列挙型 列挙型の値 マクロ定義 ページ
ofxSATTimeDiff.h
説明を見る。
1 /*
2 ** ARTSAT Project
3 **
4 ** Original Copyright (C) 2011 - 2012 HORIGUCHI Junshi.
5 ** http://iridium.jp/
6 ** zap00365@nifty.com
7 ** Portions Copyright (C) <year> <author>
8 ** <website>
9 ** <e-mail>
10 ** Version openFrameworks
11 ** Website http://artsat.jp/
12 ** E-mail info@artsat.jp
13 **
14 ** This source code is for Xcode.
15 ** Xcode 4.2 (LLVM compiler 3.0)
16 **
17 ** ofxSATTimeDiff.h
18 **
19 ** ------------------------------------------------------------------------
20 **
21 ** THE SOURCE CODE AND THE BINARY OF ARTSAT API IS DISTRIBUTED UNDER THE MIT LICENSE WRITTEN BELOW.
22 ** THE LICENSE OF ANY DATA GOTTEN THROUGH ARTSAT API FOLLOWS PROVIDED LICENSE ON EACH SATELLITE.
23 **
24 ** ARTSAT API のソースコードとバイナリは下記に示す MIT ライセンスの元で配布されます。
25 ** ARTSAT API を通して取得できるデータのライセンスに関してはデータの提供元となる各衛星の定めるライセンスに準じます。
26 **
27 ** The MIT License (MIT)
28 **
29 ** Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
30 ** associated documentation files (the "Software"), to deal in the Software without restriction,
31 ** including without limitation the rights to use, copy, modify, merge, publish, distribute,
32 ** sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
33 ** furnished to do so, subject to the following conditions:
34 ** The above copyright notice and this permission notice shall be included in all copies or
35 ** substantial portions of the Software.
36 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 ** BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
38 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
39 ** WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40 ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 **
42 ** 以下に定める条件に従い、本ソフトウェアおよび関連文書のファイル(以下「ソフトウェア」)の複製を
43 ** 取得するすべての人に対し、ソフトウェアを無制限に扱うことを無償で許可します。
44 ** これには、ソフトウェアの複製を使用、複写、変更、結合、掲載、頒布、サブライセンス、および、または販売する権利、
45 ** およびソフトウェアを提供する相手に同じことを許可する権利も無制限に含まれます。
46 ** 上記の著作権表示および本許諾表示を、ソフトウェアのすべての複製または重要な部分に記載するものとします。
47 ** ソフトウェアは「現状のまま」で、明示であるか暗黙であるかを問わず、何らの保証もなく提供されます。
48 ** ここでいう保証とは、商品性、特定の目的への適合性、および権利非侵害についての保証も含みますが、それに限定されるものではありません。
49 ** 作者または著作権者は、契約行為、不法行為、またはそれ以外であろうと、ソフトウェアに起因または関連し、
50 ** あるいはソフトウェアの使用またはその他の扱いによって生じる一切の請求、損害、その他の義務について何らの責任も負わないものとします。
51 */
52 
53 #ifndef __OFX_SATTIMEDIFF_H
54 #define __OFX_SATTIMEDIFF_H
55 
61 #include "ofxSATType.h"
62 #include <time.h>
63 
65 
70  private:
71  time_t _second;
72 
73  public:
78  explicit ofxSATTimeDiff (void);
84  ofxSATTimeDiff (ofxSATTimeDiff const& param);
94  explicit ofxSATTimeDiff (int day, int hour, int minute, int second);
103  explicit ofxSATTimeDiff (int hour, int minute, int second);
111  explicit ofxSATTimeDiff (int minute, int second);
117  explicit ofxSATTimeDiff (time_t second);
121  ~ofxSATTimeDiff (void);
145  ofxSATTimeDiff& operator*= (int param);
151  ofxSATTimeDiff& operator/= (int param);
157  ofxSATTimeDiff& operator%= (int param);
162  ofxSATTimeDiff operator+ (void) const;
167  ofxSATTimeDiff operator- (void) const;
173  ofxSATTimeDiff& set (ofxSATTimeDiff const& param);
183  ofxSATTimeDiff& set (int day, int hour, int minute, int second);
201  void get (int* day, int* hour, int* minute, int* second) const;
210  ofxSATTimeDiff& set (int hour, int minute, int second);
225  void get (int* hour, int* minute, int* second) const;
233  ofxSATTimeDiff& set (int minute, int second);
245  void get (int* minute, int* second) const;
251  ofxSATTimeDiff& set (time_t second);
257  ofxSATTimeDiff& add (ofxSATTimeDiff const& param);
263  ofxSATTimeDiff& sub (ofxSATTimeDiff const& param);
269  ofxSATTimeDiff& mul (int param);
275  ofxSATTimeDiff& div (int param);
281  ofxSATTimeDiff& mod (int param);
286  ofxSATTimeDiff& neg (void);
294  bool equals (ofxSATTimeDiff const& param) const;
303  int compare (ofxSATTimeDiff const& param) const;
308  time_t asTime_t (void) const;
313  static ofxSATTimeDiff localTimeOffset (void);
314 };
315 
322 extern ofxSATTimeDiff operator+ (ofxSATTimeDiff const& x, ofxSATTimeDiff const& y);
329 extern ofxSATTimeDiff operator- (ofxSATTimeDiff const& x, ofxSATTimeDiff const& y);
336 extern ofxSATTimeDiff operator* (ofxSATTimeDiff const& x, int y);
343 extern ofxSATTimeDiff operator/ (ofxSATTimeDiff const& x, int y);
350 extern ofxSATTimeDiff operator% (ofxSATTimeDiff const& x, int y);
359 extern bool operator== (ofxSATTimeDiff const& x, ofxSATTimeDiff const& y);
368 extern bool operator!= (ofxSATTimeDiff const& x, ofxSATTimeDiff const& y);
377 extern bool operator< (ofxSATTimeDiff const& x, ofxSATTimeDiff const& y);
386 extern bool operator<= (ofxSATTimeDiff const& x, ofxSATTimeDiff const& y);
395 extern bool operator> (ofxSATTimeDiff const& x, ofxSATTimeDiff const& y);
404 extern bool operator>= (ofxSATTimeDiff const& x, ofxSATTimeDiff const& y);
405 
406 /*public */inline ofxSATTimeDiff::ofxSATTimeDiff(void)
407 {
408 }
409 
410 /*public */inline ofxSATTimeDiff::ofxSATTimeDiff(ofxSATTimeDiff const& param)
411 {
412  set(param);
413 }
414 
415 /*public */inline ofxSATTimeDiff::ofxSATTimeDiff(int day, int hour, int minute, int second)
416 {
417  set(day, hour, minute, second);
418 }
419 
420 /*public */inline ofxSATTimeDiff::ofxSATTimeDiff(int hour, int minute, int second)
421 {
422  set(hour, minute, second);
423 }
424 
425 /*public */inline ofxSATTimeDiff::ofxSATTimeDiff(int minute, int second)
426 {
427  set(minute, second);
428 }
429 
430 /*public */inline ofxSATTimeDiff::ofxSATTimeDiff(time_t second)
431 {
432  set(second);
433 }
434 
435 /*public */inline ofxSATTimeDiff::~ofxSATTimeDiff(void)
436 {
437 }
438 
440 {
441  return set(param);
442 }
443 
445 {
446  return add(param);
447 }
448 
450 {
451  return sub(param);
452 }
453 
454 /*public */inline ofxSATTimeDiff& ofxSATTimeDiff::operator*=(int param)
455 {
456  return mul(param);
457 }
458 
459 /*public */inline ofxSATTimeDiff& ofxSATTimeDiff::operator/=(int param)
460 {
461  return div(param);
462 }
463 
464 /*public */inline ofxSATTimeDiff& ofxSATTimeDiff::operator%=(int param)
465 {
466  return mod(param);
467 }
468 
469 /*public */inline ofxSATTimeDiff ofxSATTimeDiff::operator+(void) const
470 {
471  return ofxSATTimeDiff(+_second);
472 }
473 
474 /*public */inline ofxSATTimeDiff ofxSATTimeDiff::operator-(void) const
475 {
476  return ofxSATTimeDiff(-_second);
477 }
478 
479 /*public */inline ofxSATTimeDiff& ofxSATTimeDiff::set(ofxSATTimeDiff const& param)
480 {
481  _second = param._second;
482  return *this;
483 }
484 
485 /*public */inline ofxSATTimeDiff& ofxSATTimeDiff::set(time_t second)
486 {
487  _second = second;
488  return *this;
489 }
490 
491 /*public */inline ofxSATTimeDiff& ofxSATTimeDiff::add(ofxSATTimeDiff const& param)
492 {
493  _second += param._second;
494  return *this;
495 }
496 
497 /*public */inline ofxSATTimeDiff& ofxSATTimeDiff::sub(ofxSATTimeDiff const& param)
498 {
499  _second -= param._second;
500  return *this;
501 }
502 
503 /*public */inline ofxSATTimeDiff& ofxSATTimeDiff::mul(int param)
504 {
505  _second *= param;
506  return *this;
507 }
508 
509 /*public */inline ofxSATTimeDiff& ofxSATTimeDiff::div(int param)
510 {
511  _second /= param;
512  return *this;
513 }
514 
515 /*public */inline ofxSATTimeDiff& ofxSATTimeDiff::mod(int param)
516 {
517  _second %= param;
518  return *this;
519 }
520 
521 /*public */inline ofxSATTimeDiff& ofxSATTimeDiff::neg(void)
522 {
523  _second = -_second;
524  return *this;
525 }
526 
527 /*public */inline bool ofxSATTimeDiff::equals(ofxSATTimeDiff const& param) const
528 {
529  return (_second == param._second);
530 }
531 
532 /*public */inline time_t ofxSATTimeDiff::asTime_t(void) const
533 {
534  return _second;
535 }
536 
538 {
539  return ofxSATTimeDiff(x).operator+=(y);
540 }
541 
543 {
544  return ofxSATTimeDiff(x).operator-=(y);
545 }
546 
547 inline ofxSATTimeDiff operator*(ofxSATTimeDiff const& x, int y)
548 {
549  return ofxSATTimeDiff(x).operator*=(y);
550 }
551 
552 inline ofxSATTimeDiff operator/(ofxSATTimeDiff const& x, int y)
553 {
554  return ofxSATTimeDiff(x).operator/=(y);
555 }
556 
557 inline ofxSATTimeDiff operator%(ofxSATTimeDiff const& x, int y)
558 {
559  return ofxSATTimeDiff(x).operator%=(y);
560 }
561 
562 inline bool operator==(ofxSATTimeDiff const& x, ofxSATTimeDiff const& y)
563 {
564  return x.equals(y);
565 }
566 
567 inline bool operator!=(ofxSATTimeDiff const& x, ofxSATTimeDiff const& y)
568 {
569  return !x.equals(y);
570 }
571 
572 inline bool operator<(ofxSATTimeDiff const& x, ofxSATTimeDiff const& y)
573 {
574  return (x.compare(y) < 0);
575 }
576 
577 inline bool operator<=(ofxSATTimeDiff const& x, ofxSATTimeDiff const& y)
578 {
579  return (x.compare(y) <= 0);
580 }
581 
582 inline bool operator>(ofxSATTimeDiff const& x, ofxSATTimeDiff const& y)
583 {
584  return (x.compare(y) > 0);
585 }
586 
587 inline bool operator>=(ofxSATTimeDiff const& x, ofxSATTimeDiff const& y)
588 {
589  return (x.compare(y) >= 0);
590 }
591 
592 #endif