InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
VersionID.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Robin Briggs
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //
23 // Purpose of Interface:
24 // Specifies version numbers for file format conversion.
25 //
26 //========================================================================================
27 
28 #ifndef __VersionID__
29 #define __VersionID__
30 
31 // ----- Interfaces -----
32 
33 #include "IPMStream.h"
34 
35 // ----- ID.h files -----
36 
37 #include "FormatID.h"
38 
39 
40 class VersionID : public FormatID
41 {
42 public:
43  typedef base_type data_type;
44 
45  VersionID() :
46  FormatID(),
47  fPluginID(kInvalidPlugin)
48  {}
49  VersionID(PluginID plugInID, const FormatID &format) :
50  FormatID(format),
51  fPluginID(plugInID)
52  {}
53  VersionID(PluginID plugInID, int32 majorNumber, int32 minorNumber) :
54  FormatID(majorNumber, minorNumber),
55  fPluginID(plugInID)
56  {}
58  : FormatID()
59  {if (s->IsReading()) ReadWrite(s);}
60 
61  PluginID GetPluginID() const
62  { return fPluginID; }
63  void SetPluginID(PluginID id)
64  {fPluginID = id;}
65 
66  void SetFormat(const FormatID &format)
67  {SetMajorVersion(format.GetMajorVersion()); SetMinorVersion(format.GetMinorVersion());}
68 
69  bool16 PluginMatches(const VersionID& other) const
70  {return (fPluginID == other.fPluginID) || (fPluginID == kInvalidPlugin) || (other.fPluginID == kInvalidPlugin);}
71 
72  bool16 operator <(const VersionID& other) const
73  {return PluginMatches(other) ? (((FormatID)*this) < (FormatID)other) : (fPluginID < other.fPluginID);}
74  bool16 operator >(const VersionID& other) const
75  {return PluginMatches(other) ? (((FormatID)*this) > (FormatID)other) : (fPluginID > other.fPluginID);}
76  bool16 operator ==(const VersionID& other) const
77  {return PluginMatches(other) ? (((FormatID)*this) == (FormatID)other) : (fPluginID == other.fPluginID);}
78  bool16 operator !=(const VersionID& other) const
79  {return !(*this == other);}
80  bool16 operator <=(const VersionID& other) const
81  {return !(*this > other);}
82  bool16 operator >=(const VersionID& other) const
83  {return !(*this < other);}
84 
85  void ReadWrite(IPMStream *s)
86  {FormatID::ReadWrite(s);
87  s->XferInt32((int32 &)fPluginID);}
88 
89 private:
90  PluginID fPluginID;
91 };
92 
93 #endif // __VersionID__
94