2010-06-10 18:11:11 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2014-06-30 15:39:45 +00:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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
|
|
|
*/
|
2015-03-21 16:28:04 +00:00
|
|
|
class GenericFactory final : public nsIFactory
|
2010-06-10 18:11:11 +00:00
|
|
|
{
|
2014-06-30 22:11:53 +00:00
|
|
|
~GenericFactory() {}
|
|
|
|
|
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
|
|
|
|
2013-07-19 02:31:26 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2010-06-10 18:11:11 +00:00
|
|
|
NS_DECL_NSIFACTORY
|
|
|
|
|
2014-07-30 00:43:56 +00:00
|
|
|
explicit GenericFactory(ConstructorProcPtr aCtor)
|
2014-06-27 01:35:39 +00:00
|
|
|
: mCtor(aCtor)
|
2010-06-10 18:11:11 +00:00
|
|
|
{
|
|
|
|
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
|