[#BloombergLP-bdlma-Factory] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlma.adoc[bdlma]::Factory :relfileprefix: ../../ :mrdocs: This `class` provides a protocol (or pure interface) for a thread‐safe object creator and deleter. It extends the `Deleter` protocol with the addition of a `createObject` method. == Synopsis Declared in `<bdlma_factory.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class TYPE> class Factory : public xref:BloombergLP/bdlma/Deleter.adoc[Deleter<TYPE>] ---- == Base Classes [cols="1,4"] |=== | Name| Description | `xref:BloombergLP/bdlma/Deleter.adoc[Deleter<TYPE>]` | Provide a protocol (or pure interface) for a thread‐safe object deleter. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlma/Factory/2destructor.adoc[`~Factory`] [.small]#[destructor]# [.small]#[virtual]# | Destroy this object factory. | xref:BloombergLP/bdlma/Factory/createObject.adoc[`createObject`] [.small]#[virtual]# | Create an instance of the specified `TYPE` using default arguments. Return the address of the newly‐created object on success, and 0 otherwise. The instance must be destroyed using the `deleteObject` method of this object factory. | xref:BloombergLP/bdlma/Factory/deleteObject.adoc[`deleteObject`] [.small]#[virtual]# | Destroy the specified `instance` based on its static type and return its memory footprint to the appropriate memory manager. The behavior is undefined unless `instance` was obtained from a call to `createObject` on this object factory and has not yet been deleted. |=== == Derived Classes [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlcc/ObjectPool.adoc[`ObjectPool`] | This class provides a thread‐safe pool of reusable objects. It also implements the `bdlma::Factory` protocol: "creating" objects gets them from the pool and "deleting" objects returns them to the pool. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#