2010-06-10 18:11:11 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2004-05-18 06:18:15 +00:00
|
|
|
|
2010-06-10 18:11:11 +00:00
|
|
|
#ifndef mozilla_GenericFactory_h
|
|
|
|
#define mozilla_GenericFactory_h
|
2004-05-18 06:18:15 +00:00
|
|
|
|
2011-11-21 06:21:16 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
|
2010-06-10 18:11:11 +00:00
|
|
|
#include "mozilla/Module.h"
|
2004-05-18 06:18:15 +00:00
|
|
|
|
2010-06-10 18:11:11 +00:00
|
|
|
namespace mozilla {
|
2004-05-18 06:18:15 +00:00
|
|
|
|
2010-06-10 18:11:11 +00:00
|
|
|
/**
|
|
|
|
* A generic factory which uses a constructor function to create instances.
|
2010-06-24 20:36:27 +00:00
|
|
|
* This class is intended for use by the component manager and the generic
|
|
|
|
* module.
|
2010-06-10 18:11:11 +00:00
|
|
|
*/
|
2011-11-21 06:21:16 +00:00
|
|
|
class GenericFactory MOZ_FINAL : public nsIFactory
|
2010-06-10 18:11:11 +00:00
|
|
|
{
|
|
|
|
public:
|
2010-06-21 16:46:26 +00:00
|
|
|
typedef Module::ConstructorProcPtr ConstructorProcPtr;
|
2004-05-18 06:18:15 +00:00
|
|
|
|
2010-06-10 18:11:11 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIFACTORY
|
|
|
|
|
2010-06-21 16:46:26 +00:00
|
|
|
GenericFactory(ConstructorProcPtr ctor)
|
2010-06-10 18:11:11 +00:00
|
|
|
: mCtor(ctor)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mCtor, "GenericFactory with no constructor");
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2010-06-21 16:46:26 +00:00
|
|
|
ConstructorProcPtr mCtor;
|
2010-06-10 18:11:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_GenericFactory_h
|