MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DateTimeStamp.h
Go to the documentation of this file.
1 /* -*- mode:C++ -*-
2  DateTimeStamp.h A serializer for date/times
3  Copyright (C) 2014 The Regents of the University of New Mexico. All rights reserved.
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
27 #ifndef DATETIMESTAMP_H
28 #define DATETIMESTAMP_H
29 
30 #include <stdlib.h>
31 #include "ByteSerializable.h"
32 #include "itype.h"
33 #include "Utils.h"
34 
35 namespace MFM
36 {
38  u64 m_lastDateTime;
39  u32 m_sequence;
40  public:
41  DateTimeStamp() : m_lastDateTime(0), m_sequence(0) { }
42  void Reset() { m_lastDateTime = 0; }
43  virtual Result PrintTo(ByteSink & byteSink, s32 argument = 0)
44  {
45  m_lastDateTime = Utils::GetDateTimeNow();
46  byteSink.Print(m_lastDateTime);
47  if (argument == 0)
48  {
49  byteSink.Print("-");
50  byteSink.Print(m_sequence, Format::LEX32);
51  byteSink.Print(": ");
52  }
53  ++m_sequence;
54  return SUCCESS;
55  }
56 
57  virtual Result ReadFrom(ByteSource & byteSource, s32 argument = 0)
58  {
59  return UNSUPPORTED;
60  }
61 
62  };
63 }
64 
65 #endif /* DATETIMESTAMP_H */
Definition: DateTimeStamp.h:37
virtual Result ReadFrom(ByteSource &byteSource, s32 argument=0)
Definition: DateTimeStamp.h:57
Definition: ByteSource.h:44
Definition: Format.h:49
Definition: ByteSink.h:47
void Print(const char *str, s32 fieldWidth=-1, u8 padChar= ' ')
Definition: ByteSink.cpp:31
virtual Result PrintTo(ByteSink &byteSink, s32 argument=0)
Definition: DateTimeStamp.h:43
Definition: ByteSerializable.h:45