1 /* Filename : UnkonwnInterface.h
2 * Creator : Clinton Stimpson
3 *
4 * Date : 10 Jan 2002
5 *
6 * Owner : Clinton Stimpson
7 *
8 * Description: Contains declarations for MBuuid which keeps
9 * track of different interfaces.
10 * Also contains the declaration for the base class
11 * UknownInterface from which all interfaces are
12 * derived from
13 */
14
15 #ifndef MOAB_UNKNOWN_INTERFACE_HPP
16 #define MOAB_UNKNOWN_INTERFACE_HPP
17
18 #include <memory.h>
19
20 namespace moab
21 {
22
23 //! struct that handles universally unique id's for the Mesh Database
24
25 // note: this MBuuid is compliant with the windows GUID.
26 // It is possible to do a memcpy() to copy the data from a MBuuid to a GUID
27 // if we want to support dll registration
28 struct MBuuid
29 {
30 //! default constructor that initializes to zero
31 MBuuid()
32 {
33 memset( this, 0, sizeof( MBuuid ) );
34 }
35 //! constructor that takes initialization arguments
36 MBuuid( unsigned l,
37 unsigned short w1,
38 unsigned short w2,
39 unsigned char b1,
40 unsigned char b2,
41 unsigned char b3,
42 unsigned char b4,
43 unsigned char b5,
44 unsigned char b6,
45 unsigned char b7,
46 unsigned char b8 )
47 {
48 data1 = l;
49 data2 = w1;
50 data3 = w2;
51 data4[0] = b1;
52 data4[1] = b2;
53 data4[2] = b3;
54 data4[3] = b4;
55 data4[4] = b5;
56 data4[5] = b6;
57 data4[6] = b7;
58 data4[7] = b8;
59 }
60 //! copy constructor
61 MBuuid( const MBuuid& mdbuuid )
62 {
63 memcpy( this, &mdbuuid, sizeof( MBuuid ) );
64 }
65 //! sets this uuid equal to another one
66 MBuuid& operator=( const MBuuid& orig )
67 {
68 memcpy( this, &orig, sizeof( MBuuid ) );
69 return *this;
70 }
71 //! returns whether two uuid's are equal
72 bool operator==( const MBuuid& orig ) const
73 {
74 return !memcmp( this, &orig, sizeof( MBuuid ) );
75 }
76 //! returns whether two uuid's are not equal
77 bool operator!=( const MBuuid& orig ) const
78 {
79 return !( *this == orig );
80 }
81
82 //! uuid data storage
83 unsigned data1;
84 unsigned short data2;
85 unsigned short data3;
86 unsigned char data4[8];
87 };
88
89 //! uuid for an unknown interface
90 //! this can be used to either return a default interface
91 //! or a NULL interface
92 static const MBuuid IDD_MBUnknown =
93 MBuuid( 0xf4f6605e, 0x2a7e, 0x4760, 0xbb, 0x06, 0xb9, 0xed, 0x27, 0xe9, 0x4a, 0xec );
94
95 //! base class for all interface classes
96 class UnknownInterface
97 {
98 public:
99 virtual int QueryInterface( const MBuuid&, UnknownInterface** ) = 0;
100 virtual ~UnknownInterface() {}
101 };
102
103 } // namespace moab
104
105 #endif // MOAB_UNKNOWN_INTERFACE_HPP