MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ByteSerializable.h
Go to the documentation of this file.
1 /* -*- mode:C++ -*-
2  ByteSerializable.h Interface for objects that print and read themselves
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 BYTESERIALIZABLE_H
28 #define BYTESERIALIZABLE_H
29 
30 #include "itype.h"
31 #include "Fail.h"
32 #include "Format.h"
33 #include "ByteSink.h"
34 #include "ByteSource.h"
35 #include <stdarg.h> /* For ... */
36 
37 namespace MFM
38 {
46  {
47  public:
48 
49  enum Result
50  {
51  UNSUPPORTED = -1,
52  FAILURE = 0,
53  SUCCESS = 1
54  };
65  virtual Result ReadFrom(ByteSource & byteSource, s32 argument = 0) = 0;
66  /*
67  {
68  return UNSUPPORTED;
69  }
70  */
71 
81  virtual Result PrintTo(ByteSink & byteSink, s32 argument = 0) = 0;
82  /*
83  {
84  return UNSUPPORTED;
85  }*/
86 
87  virtual ~ByteSerializable()
88  { }
89  };
90 
92  {
93  virtual Result ReadFrom(ByteSource & byteSource, s32 argument = 0)
94  {
95  return SUCCESS;
96  }
97 
98  virtual Result PrintTo(ByteSink & byteSink, s32 argument = 0)
99  {
100  return SUCCESS;
101  }
102  };
103 
104  extern NullByteSerializable NullSerializable;
105 
106 }
107 
108 #endif /* BYTESERIALIZABLE_H */
Definition: ByteSerializable.h:91
virtual Result ReadFrom(ByteSource &byteSource, s32 argument=0)=0
Definition: ByteSource.h:44
Definition: ByteSink.h:47
virtual Result PrintTo(ByteSink &byteSink, s32 argument=0)=0
Definition: ByteSerializable.h:45