2010-06-10 22:11:11 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2014-06-30 19:39:45 +04:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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 10:18:15 +04:00
|
|
|
|
2010-06-10 22:11:11 +04:00
|
|
|
#ifndef mozilla_GenericFactory_h
|
|
|
|
#define mozilla_GenericFactory_h
|
2004-05-18 10:18:15 +04:00
|
|
|
|
2011-11-21 10:21:16 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
|
2010-06-10 22:11:11 +04:00
|
|
|
#include "mozilla/Module.h"
|
2004-05-18 10:18:15 +04:00
|
|
|
|
2010-06-10 22:11:11 +04:00
|
|
|
namespace mozilla {
|
2004-05-18 10:18:15 +04:00
|
|
|
|
2010-06-10 22:11:11 +04:00
|
|
|
/**
|
|
|
|
* A generic factory which uses a constructor function to create instances.
|
2010-06-25 00:36:27 +04:00
|
|
|
* This class is intended for use by the component manager and the generic
|
|
|
|
* module.
|
2010-06-10 22:11:11 +04:00
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
class GenericFactory final : public nsIFactory {
|
2014-07-01 02:11:53 +04:00
|
|
|
~GenericFactory() {}
|
|
|
|
|
2010-06-10 22:11:11 +04:00
|
|
|
public:
|
2010-06-21 20:46:26 +04:00
|
|
|
typedef Module::ConstructorProcPtr ConstructorProcPtr;
|
2004-05-18 10:18:15 +04:00
|
|
|
|
2013-07-19 06:31:26 +04:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2010-06-10 22:11:11 +04:00
|
|
|
NS_DECL_NSIFACTORY
|
|
|
|
|
2014-07-30 04:43:56 +04:00
|
|
|
explicit GenericFactory(ConstructorProcPtr aCtor) : mCtor(aCtor) {
|
2010-06-10 22:11:11 +04:00
|
|
|
NS_ASSERTION(mCtor, "GenericFactory with no constructor");
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2010-06-21 20:46:26 +04:00
|
|
|
ConstructorProcPtr mCtor;
|
2010-06-10 22:11:11 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_GenericFactory_h
|