---
name: "ACE_Managed_Object"
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_Managed_Object"
---

# ACE\_Managed\_Object(3)

Wrapper for interface to allocate an object managed by the ACE\_Object\_Manager.

## NAME

ACE\_Managed\_Object -  Wrapper for interface to allocate an object managed by the ACE\_Object\_Manager.

## SYNOPSIS

```
#include <ace/Managed_Object.h>
template<class TYPE>
class ACE_Managed_Object
{
  public:
    inline static TYPE *get_preallocated_object (
        ACE_Object_Manager::Preallocated_Object id
        );
    inline return &((ACE_Cleanup_Adapter<TYPE> *);
    inline static TYPE *get_preallocated_array (
        ACE_Object_Manager::Preallocated_Array id
        );
    inline return &((ACE_Cleanup_Adapter<TYPE> *);
  private:
    inline ACE_UNIMPLEMENTED_FUNC (ACE_Managed_Object (void));
        friend class this_prevents_compiler_warning_about_only_private_constructors;

};
```

## DESCRIPTION

This template class wraps an interface that is used to allocate and access an object that is managed by the ACE\_Object\_Manager.  Because static template member functions are not supported by some compilers, it is a separate (template) class.

This interface is typically used to replace a static object with one that is dynamically allocated.  It helps to avoid problems with order of static object construction/destruction.  Managed objects won't be allocated until needed, but should be allocated when first needed.  And they are destroyed in the reverse order of construction.

get\_preallocated\_object accesses a "preallocated" object, i.e., one that is identified by a value in the ACE\_Object\_Manager:: Preallocated\_Object enum.  These objects are used internally by the ACE library.

Hooks are provided for the application to preallocate objects via the same mechanism. ACE\_APPLICATION\_PREALLOCATED\_OBJECT\_DECLARATIONS can be used to define enum values; ACE\_APPLICATION\_PREALLOCATED\_OBJECT\_DEFINITIONS can be used to define the corresponding objects.  The format of the ACE internal library definitions should be followed.  And similarly, ACE\_APPLICATION\_PREALLOCATED\_ARRAY\_DECLARATIONS and ACE\_APPLICATION\_PREALLOCATED\_ARRAY\_DEFINITIONS can be used to preallocate arrays.

By default, preallocation uses dynamic allocation.  The preallocated objects and arrays are allocated off the heap in the ACE\_Object\_Manager constructor.  To statically place the preallocated objects in program global data instead of on the heap, #define ACE\_HAS\_STATIC\_PREALLOCATION prior to building the ACE library.

## PUBLIC MEMBERS

```
inline static TYPE *get_preallocated_object (
    ACE_Object_Manager::Preallocated_Object id
    );
```

The preallocated objects are in a separate, "read-only" array so that this function doesn't need a lock.  Also, because it is intended \_only\_ for use with hard-code values, it performs no range checking on "id".

```
inline return &((ACE_Cleanup_Adapter<TYPE> *);
```

Get the preallocated object identified by "id".  Returns a pointer to the object.  Beware: no error indication is provided, because it can \_only\_ be used for accessing preallocated objects. Note: the function definition is inlined here so that it compiles on AIX 4.1 w/xlC v. 3.01.

```
inline static TYPE *get_preallocated_array (
    ACE_Object_Manager::Preallocated_Array id
    );
```

The preallocated array are in a separate, "read-only" array so that this function doesn't need a lock.  Also, because it is intended \_only\_ for use with hard-code values, it performs no range checking on "id".

```
inline return &((ACE_Cleanup_Adapter<TYPE> *);
```

Get the preallocated array identified by "id".  Returns a pointer to the array.  Beware: no error indication is provided, because it can \_only\_ be used for accessing preallocated arrays. Note: the function definition is inlined here so that it compiles on AIX 4.1 w/xlC v. 3.01.

## PRIVATE MEMBERS

```
inline ACE_UNIMPLEMENTED_FUNC (ACE_Managed_Object (void));
```

```
    friend class this_prevents_compiler_warning_about_only_private_constructors;

```

## AUTHORS

David L. Levine

## LIBRARY

ace
