template class Poco::MetaSingleton

Overview

A SingletonMetaObject disables the create() method and instead offers an instance() method to access the single instance of its class. Moreā€¦

#include <MetaObject.h>

template <
    class C,
    class B
    >
class MetaSingleton: public Poco::AbstractMetaObject
{
public:
    // construction

    MetaSingleton(const char* name);

    // methods

    virtual
    B*
    create() const;

    virtual
    bool
    canCreate() const;

    virtual
    B&
    instance() const;

    virtual
    bool
    isAutoDelete(B* pObject) const;
};

Inherited Members

public:
    // methods

    const char*
    name() const;

    virtual
    B*
    create() const = 0;

    virtual
    B&
    instance() const = 0;

    virtual
    bool
    canCreate() const = 0;

    virtual
    void
    destroy(B* pObject) const;

    B*
    autoDelete(B* pObject) const;

    virtual
    bool
    isAutoDelete(B* pObject) const;

Detailed Documentation

A SingletonMetaObject disables the create() method and instead offers an instance() method to access the single instance of its class.

Methods

virtual
B*
create() const

Create a new instance of a class.

Cannot be used for singletons.

virtual
bool
canCreate() const

Returns true iff the create method can be used to create instances of the class.

Returns false if the class is a singleton.

virtual
B&
instance() const

Returns a reference to the only instance of the class.

Used for singletons only.

virtual
bool
isAutoDelete(B* pObject) const

Returns true if the object is owned by meta object.

Overloaded in MetaSingleton - returns true if the class is a singleton.