---
name: "ACE_Singleton_Strategy"
section: "3"
platform: "linux"
package: "libace-doc"
version: "5.0.7-4"
release: "Debian 2.2 (Potato)"
platforms: ["linux"]
url: "https://new.carta.tech/ACE_Singleton_Strategy"
---

# ACE\_Singleton\_Strategy(3)

Defines the interface for specifying a creation strategy for a SVC\_HANDLER that always returns the same SVC\_HANDLER (i.e., it's a Singleton).

## NAME

ACE\_Singleton\_Strategy -  Defines the interface for specifying a creation strategy for a SVC\_HANDLER that always returns the same SVC\_HANDLER (i.e., it's a Singleton).

## SYNOPSIS

```
#include <ace/ACE_Strategies_T.h>
template<class SVC_HANDLER>
class ACE_Singleton_Strategy :
  public ACE_Creation_Strategy<SVC_HANDLER>
{
  public:
    ACE_Singleton_Strategy (
        SVC_HANDLER * = 0,
        ACE_Thread_Manager * = 0
        );
    int open (SVC_HANDLER *, ACE_Thread_Manager * = 0);
    virtual ~ACE_Singleton_Strategy (void);
    virtual int make_svc_handler (SVC_HANDLER *&);
    void dump (void) const;
    ACE_ALLOC_HOOK_DECLARE;
  protected:
    SVC_HANDLER *svc_handler_;
    int delete_svc_handler_;
};
```

## DESCRIPTION

Note that this class takes over the ownership of the SVC\_HANDLER passed into it as a parameter and it becomes responsible for deleting this object.

## Initialization and termination methods.

```
ACE_Singleton_Strategy (SVC_HANDLER * = 0, ACE_Thread_Manager * = 0);
```

```
int open (SVC_HANDLER *, ACE_Thread_Manager * = 0);
```

```
virtual ~ACE_Singleton_Strategy (void);
```

## Factory method.

```
virtual int make_svc_handler (SVC_HANDLER *&);
```

Create a Singleton SVC\_HANDLER by always returning the same SVC\_HANDLER.  Returns -1 on failure, else 0.

```
void dump (void) const;
```

Dump the state of an object.

```
ACE_ALLOC_HOOK_DECLARE;
```

Declare the dynamic allocation hooks.

## AUTHOR

Doug Schmidt

## LIBRARY

ace
