Teamcenter C++ API Reference  2312
Namespaces | Macros | Functions
NewOperator.hxx File Reference
#include <cstddef>
#include <unidefs.h>
#include <mach_datatypes.h>
#include <base_utils/libbase_utils_exports.h>
#include <base_utils/libbase_utils_undef.h>

Go to the source code of this file.

Namespaces

namespace  Teamcenter
 A convenient C++ class to manage a list of tag_t. This convenient class is derived from TagList class which is only available for internal developers.
 
namespace  Teamcenter::NewOperator
 

Macros

#define TC_SM_MEMORY_CLASS_NEW_DELETE_OPERATOR_DECLARATIONS
 
#define TC_SM_MEMORY_CLASS_NEW_DELETE_OPERATOR_IMPLEMENTATIONS(CLASSNAME)
 
#define TC_SM_MEMORY_CLASS_NEW_DELETE_OPERATORS_INLINED
 

Functions

void * Teamcenter::NewOperator::alloc (std::size_t size)
 
void * Teamcenter::NewOperator::arrayalloc (std::size_t size)
 
void Teamcenter::NewOperator::arraydealloc (void *p, std::size_t size)
 
void * Teamcenter::NewOperator::askRsrctrkPool ()
 
MACH_uint64_t Teamcenter::NewOperator::askUnloadablePoolSize ()
 
void Teamcenter::NewOperator::dealloc (void *p, std::size_t size)
 
void Teamcenter::NewOperator::init ()
 
bool Teamcenter::NewOperator::isCurrentAreaUnloadable ()
 
void Teamcenter::NewOperator::setCurrentArea (const bool isUnloadable)
 
void Teamcenter::NewOperator::setResourceTracking (bool onOrOff)
 

Detailed Description

This file contains the declarations for the non-member functions in the Teamcenter::NewOperator namespace in module libbase_utils, which can be used for overloading new operators

See Also
http://en.wikipedia.org/wiki/Placement_syntax When overloading new operators you should overload all new operators, in particular the placement new operators used by std containers. C++ function name lookups start in the current scope (e.g. your class) and look for the desired name (e.g. operator new). If no instances of the name are found, it moves outward to the next enclosing scope and repeats. Once it finds a scope containing at least one instance of the name, it stops looking and works only with the matches it has found, which means that further outer scopes (e.g. the global scope) are not considered and any functions (like the placement new operators) in them are hidden. Instead, the compiler looks at all the instances of the name it has found, selects a function using overload resolution, and finally checks access rules to determine whether the selected function can be called. The outer scopes are ignored even if
  1. none of the overloads found has a compatible signature, meaning that none of them could possibly be the right one
  2. the signature-compatible function that's selected isn't accessible. That's why name hiding works the way it does in C++.

Most Teamcenter classes are already using these SM memory new() operators by virtue of subclassing from Teamcenter::Object or inClass objects If you are sure your class isn't already using these SM memory new() operators you can add them to your class by using the macros

  1. TC_SM_MEMORY_CLASS_NEW_DELETE_OPERATOR_DECLARATIONS -> .hxx
  2. TC_SM_MEMORY_CLASS_NEW_DELETE_OPERATOR_IMPLEMENTATIONS(CLASSNAME) -> .cxx

Definition in file NewOperator.hxx.

Macro Definition Documentation

#define TC_SM_MEMORY_CLASS_NEW_DELETE_OPERATOR_DECLARATIONS
Value:
static void * operator new( std::size_t size ); \
static void * operator new[]( std::size_t size ); \
static void operator delete( void * p, std::size_t size ); \
static void operator delete[]( void * p, std::size_t size ); \
static void operator delete( void * p ); \
static void operator delete[]( void * p ); \
\
static void * operator new( std::size_t, void * p ); \
static void * operator new[]( std::size_t, void * p ); \
static void operator delete( void *, void * ); \
static void operator delete[]( void *, void * );

Definition at line 45 of file NewOperator.hxx.

#define TC_SM_MEMORY_CLASS_NEW_DELETE_OPERATOR_IMPLEMENTATIONS (   CLASSNAME)
Value:
void * CLASSNAME::operator new( std::size_t size ) { return Teamcenter::NewOperator::alloc( size ); } \
void * CLASSNAME::operator new[]( std::size_t size ) { return Teamcenter::NewOperator::arrayalloc( size ); } \
void CLASSNAME::operator delete( void * p, std::size_t size ) { Teamcenter::NewOperator::dealloc( p, size ); } \
void CLASSNAME::operator delete[]( void * p, std::size_t size ) { Teamcenter::NewOperator::arraydealloc( p, size ); } \
void CLASSNAME::operator delete( void * p ) { Teamcenter::NewOperator::dealloc( p, 0 ); } \
void CLASSNAME::operator delete[]( void * p ) { Teamcenter::NewOperator::arraydealloc( p, 0 ); } \
\
void * CLASSNAME::operator new( std::size_t, void * p ) { return p; } \
void * CLASSNAME::operator new[]( std::size_t, void * p ) { return p; } \
void CLASSNAME::operator delete( void *, void * ) {} \
void CLASSNAME::operator delete[]( void *, void * ) {}

Definition at line 59 of file NewOperator.hxx.

#define TC_SM_MEMORY_CLASS_NEW_DELETE_OPERATORS_INLINED
Value:
static void * operator new( std::size_t size ) { return Teamcenter::NewOperator::alloc( size ); } \
static void * operator new[]( std::size_t size ) { return Teamcenter::NewOperator::arrayalloc( size ); } \
static void operator delete( void * p, std::size_t size ) { Teamcenter::NewOperator::dealloc( p, size ); } \
static void operator delete[]( void * p, std::size_t size ) { Teamcenter::NewOperator::arraydealloc( p, size ); } \
static void operator delete( void * p ) { Teamcenter::NewOperator::dealloc( p, 0 ); } \
static void operator delete[]( void * p ) { Teamcenter::NewOperator::arraydealloc( p, 0 ); } \
\
static void * operator new( std::size_t, void * p ) { return p; } \
static void * operator new[]( std::size_t, void * p ) { return p; } \
static void operator delete( void *, void * ) {} \
static void operator delete[]( void *, void * ) {}

Definition at line 76 of file NewOperator.hxx.