1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5#ifndef __FASTSERIALIZABLE_OBJECT_H__
6#define __FASTSERIALIZABLE_OBJECT_H__
7
8#ifdef FEATURE_PERFTRACING
9
10class FastSerializer;
11
12class FastSerializableObject
13{
14
15public:
16
17 // Virtual destructor to ensure that derived class destructors get called.
18 virtual ~FastSerializableObject()
19 {
20 LIMITED_METHOD_CONTRACT;
21 }
22
23 // Serialize the object using the specified serializer.
24 virtual void FastSerialize(FastSerializer *pSerializer) = 0;
25
26 // Get the type name for the current object.
27 virtual const char* GetTypeName() = 0;
28
29 int GetObjectVersion() const
30 {
31 LIMITED_METHOD_CONTRACT;
32
33 return m_objectVersion;
34 }
35
36 int GetMinReaderVersion() const
37 {
38 LIMITED_METHOD_CONTRACT;
39
40 return m_minReaderVersion;
41 }
42
43protected:
44
45 void SetObjectVersion(int version)
46 {
47 LIMITED_METHOD_CONTRACT;
48
49 m_objectVersion = version;
50 }
51
52 void SetMinReaderVersion(int version)
53 {
54 LIMITED_METHOD_CONTRACT;
55
56 m_minReaderVersion = version;
57 }
58
59private:
60
61 int m_objectVersion = 1;
62 int m_minReaderVersion = 0;
63};
64
65#endif // FEATURE_PERFTRACING
66
67#endif // _FASTSERIALIZABLE_OBJECT_H__
68