Reland bug 121341.
[wine-gecko.git] / xpcom / sample / nsSampleModule.cpp
blobb405a57eb986430c64f103dcd587d941702548cb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Suresh Duddu <dp@netscape.com>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
38 #include "nsIGenericFactory.h"
39 #include "nsIClassInfoImpl.h"
41 #include "nsSample.h"
43 ////////////////////////////////////////////////////////////////////////
44 // NOTE this file supercedes nsSampleFactory.cpp. nsSampleFactory has
45 // extensive comments, but it has been CVS removed to reduce clutter
46 // in this sample. It's available to the interested via CVS history:
47 // cvs up nsSampleFactory.cpp -r 1.10
48 ////////////////////////////////////////////////////////////////////////
50 ////////////////////////////////////////////////////////////////////////
51 // With the below sample, you can define an implementation glue
52 // that talks with xpcom for creation of component nsSampleImpl
53 // that implement the interface nsISample. This can be extended for
54 // any number of components.
55 ////////////////////////////////////////////////////////////////////////
57 ////////////////////////////////////////////////////////////////////////
58 // Define the contructor function for the object nsSampleImpl
60 // What this does is defines a function nsSampleImplConstructor which we
61 // will specific in the nsModuleComponentInfo table. This function will
62 // be used by the generic factory to create an instance of nsSampleImpl.
64 // NOTE: This creates an instance of nsSampleImpl by using the default
65 // constructor nsSampleImpl::nsSampleImpl()
67 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSampleImpl)
69 ////////////////////////////////////////////////////////////////////////
70 // Define a table of CIDs implemented by this module along with other
71 // information like the function to create an instance, contractid, and
72 // class name.
74 // The Registration and Unregistration proc are optional in the structure.
76 static NS_METHOD nsSampleRegistrationProc(nsIComponentManager *aCompMgr,
77 nsIFile *aPath,
78 const char *registryLocation,
79 const char *componentType,
80 const nsModuleComponentInfo *info)
82 // Do any registration specific activity like adding yourself to a
83 // category. The Generic Module will take care of registering your
84 // component with xpcom. You don't need to do that. Only any component
85 // specific additional activity needs to be done here.
87 // This functions is optional. If you don't need it, don't add it to the structure.
89 return NS_OK;
92 static NS_METHOD nsSampleUnregistrationProc(nsIComponentManager *aCompMgr,
93 nsIFile *aPath,
94 const char *registryLocation,
95 const nsModuleComponentInfo *info)
97 // Undo any component specific registration like adding yourself to a
98 // category here. The Generic Module will take care of unregistering your
99 // component from xpcom. You don't need to do that. Only any component
100 // specific additional activity needs to be done here.
102 // This functions is optional. If you don't need it, don't add it to the structure.
104 // Return value is not used from this function.
105 return NS_OK;
108 // For each class that wishes to support nsIClassInfo, add a line like this
109 NS_DECL_CLASSINFO(nsSampleImpl)
111 static const nsModuleComponentInfo components[] =
113 { "Sample Component", NS_SAMPLE_CID, NS_SAMPLE_CONTRACTID, nsSampleImplConstructor,
114 nsSampleRegistrationProc /* NULL if you don't need one */,
115 nsSampleUnregistrationProc /* NULL if you don't need one */,
116 NULL /* no factory destructor */,
117 NS_CI_INTERFACE_GETTER_NAME(nsSampleImpl),
118 NULL /* no language helper */,
119 &NS_CLASSINFO_NAME(nsSampleImpl)
123 ////////////////////////////////////////////////////////////////////////
124 // Implement the NSGetModule() exported function for your module
125 // and the entire implementation of the module object.
127 // NOTE: If you want to use the module shutdown to release any
128 // module specific resources, use the macro
129 // NS_IMPL_NSGETMODULE_WITH_DTOR() instead of the vanilla
130 // NS_IMPL_NSGETMODULE()
132 NS_IMPL_NSGETMODULE(nsSampleModule, components)