2010-06-10 11:11:11 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-10 11:11:11 -07:00
|
|
|
#ifndef mozilla_GenericFactory_h
|
|
|
|
#define mozilla_GenericFactory_h
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-11-20 22:21:16 -08:00
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
|
2010-06-10 11:11:11 -07:00
|
|
|
#include "mozilla/Module.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-10 11:11:11 -07:00
|
|
|
namespace mozilla {
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-10 11:11:11 -07:00
|
|
|
/**
|
|
|
|
* A generic factory which uses a constructor function to create instances.
|
2010-06-24 13:36:27 -07:00
|
|
|
* This class is intended for use by the component manager and the generic
|
|
|
|
* module.
|
2010-06-10 11:11:11 -07:00
|
|
|
*/
|
2011-11-20 22:21:16 -08:00
|
|
|
class GenericFactory MOZ_FINAL : public nsIFactory
|
2010-06-10 11:11:11 -07:00
|
|
|
{
|
|
|
|
public:
|
2010-06-21 09:46:26 -07:00
|
|
|
typedef Module::ConstructorProcPtr ConstructorProcPtr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-10 11:11:11 -07:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIFACTORY
|
|
|
|
|
2010-06-21 09:46:26 -07:00
|
|
|
GenericFactory(ConstructorProcPtr ctor)
|
2010-06-10 11:11:11 -07:00
|
|
|
: mCtor(ctor)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mCtor, "GenericFactory with no constructor");
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2010-06-21 09:46:26 -07:00
|
|
|
ConstructorProcPtr mCtor;
|
2010-06-10 11:11:11 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_GenericFactory_h
|