1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149 | /**
* MOAB, a Mesh-Oriented datABase, is a software component for creating,
* storing and accessing finite element mesh data.
*
* Copyright 2004 Sandia Corporation. Under the terms of Contract
* DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
* retains certain rights in this software.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*/
#ifdef WIN32
#ifdef _DEBUG
// turn off warnings that say they debugging identifier has been truncated
// this warning comes up when using some STL containers
#pragma warning( disable : 4786 )
#endif
#endif
#include "moab/Core.hpp"
#ifdef XPCOM_MB
#include "nsIGenericFactory.h"
// define constructor function for Core
NS_GENERIC_FACTORY_CONSTRUCTOR( moab::Core )<--- There is an unknown macro here somewhere. Configuration is required. If NS_GENERIC_FACTORY_CONSTRUCTOR is a macro then please configure it.
// support for nsIClassInfo
NS_DECL_CLASSINFO( moab::Core )
MB_EXPORT const char* MoabVersion();
MB_EXPORT void GetInterface( MBuuid& interface_requested, UnknownInterface** iface );
MB_EXPORT void DeInitialize();
MB_EXPORT void ReleaseInterface( UnknownInterface* iface );
static const nsModuleComponentInfo components[] = {
{ "MOAB Interface", CORE_CID, CORE_CONTRACTID, CoreConstructor, NULL /* NULL if you dont need one */,
NULL /* NULL if you dont need one */, NULL /* no factory destructor */, NS_CI_INTERFACE_GETTER_NAME( moab::Core ),
NULL /* no language helper */, &NS_CLASSINFO_NAME( moab::Core ), 0 } };
// implement NSGetModule()
NS_IMPL_NSGETMODULE( moab::Core, components );
#endif
#ifndef WIN32
#define MB_EXPORT extern "C"
#else
#define MB_EXPORT extern "C" __declspec( dllexport )
#endif
#include <list>
namespace moab
{
class ComponentFactory : public UnknownInterface
{
public:
ComponentFactory() {}
virtual ~ComponentFactory() {}
// returns the interface requested from an object
virtual int QueryInterface( const MBuuid&, UnknownInterface** );
// keep track of the objects this component factory creates
static std::list< UnknownInterface* > objects_in_use;
};
// the list that keeps track of all the interfaces generated by this server
std::list< UnknownInterface* > ComponentFactory::objects_in_use;
// this QueryInterface function is supposed to create an instance of the object
// that contains the interface requested
//
// note: the object is not the same as the interface, therefore
// we ask the object for the interface that was requested
//
int ComponentFactory::QueryInterface( const MBuuid& uuid, UnknownInterface** iface )
{
// this is an unknown interface that was requested
// if wanted, we could provide a default interface
// if IDD_MBUnknown is specified
if( uuid == IDD_MBUnknown ) return 0;
// IDD_MBVerde interface was requested
// create an Verde object and have it return the interface
// requested
else if( uuid == IDD_MBCore )
{
Core* mdb = new Core;
// if the object does not contain the interface requested, delete the object
if( !mdb->QueryInterface( uuid, iface ) )
{
delete mdb;
return 0;
}
return 1;
}
else
return 0;
}
// returns the interface version
MB_EXPORT const char* MoabVersion()<--- The function 'MoabVersion' is never used.
{
return MB_INTERFACE_VERSION;
}
// Initialize function is accessed by the MBClient when asking for interfaces
MB_EXPORT void GetInterface( MBuuid& interface_requested, UnknownInterface** iface )<--- Parameter 'interface_requested' can be declared with const<--- The function 'GetInterface' is never used.
{
// create an instance of our component factory
ComponentFactory server;
// ask the component factory to give us the interface we want
server.QueryInterface( interface_requested, iface );
// if the interface existed, put it on our list
if( iface && *iface ) ComponentFactory::objects_in_use.push_front( *iface );
}
// DeInitialize function is accessed by the MBClient when disconnecting from this library
// this will clean everything up prior to a disconnection
// from this library
MB_EXPORT void DeInitialize()<--- The function 'DeInitialize' is never used.
{
// delete all instances of objects
while( ComponentFactory::objects_in_use.size() )
{
UnknownInterface* iface = ComponentFactory::objects_in_use.front();
ComponentFactory::objects_in_use.pop_front();
if( iface ) delete iface;
}
}
// ReleaseInterface function is accessed by the MBClient when deleting an interface
// ReleaseInterface will delete this interface
MB_EXPORT void ReleaseInterface( UnknownInterface* iface )<--- The function 'ReleaseInterface' is never used.
{
if( !iface ) return;
// remove this object from our list and delete it
ComponentFactory::objects_in_use.remove( iface );
delete iface;
}
} // namespace moab
|