2010-06-10 11:11:11 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2014-06-30 08:39:45 -07:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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
|
|
|
{
|
2014-06-30 15:11:53 -07:00
|
|
|
~GenericFactory() {}
|
|
|
|
|
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
|
|
|
|
2013-07-18 19:31:26 -07:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2010-06-10 11:11:11 -07:00
|
|
|
NS_DECL_NSIFACTORY
|
|
|
|
|
2014-06-26 18:35:39 -07:00
|
|
|
GenericFactory(ConstructorProcPtr aCtor)
|
|
|
|
: mCtor(aCtor)
|
2010-06-10 11:11:11 -07:00
|
|
|
{
|
|
|
|
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
|