Asposecpplib
CsToCppPorter::MemoryManagement Class Reference

Defines a methods that changes the lifetime of objects. More...

Public Types

using ObjectsBag = System::Details::ObjectsBag
 Highly optimized container designed to extend objects lifetime. More...
 

Static Public Member Functions

template<typename T1 , typename T2 >
static T1 BindLifetime (const T1 &target, const T2 &owner)
 Creates a smart pointer using the aliasing constructor. Creates a pointer to the target object which controls lifetime of the owner object. This pointer's expiration is bound to expiration of the owner object, just like this of any other pointer that owns owner object. If converted to weak type, it is still consistent with other pointers to owner and does not expire while there is at least one shared pointer to owner object. Also, the returned pointer does not ensure that target object is alive, so some other means (e. g. shared pointer stored in the owner object) should do so.  . More...
 
template<typename T1 , typename T2 >
static std::enable_if<!std::is_reference< T1 >::value, T1 >::type BindLifetime (T1 &&target, const T2 &owner)
 Creates a smart pointer using the aliasing constructor. Creates a pointer to the target object which controls lifetime of the owner object. This pointer's expiration is bound to expiration of the owner object, just like this of any other pointer that owns owner object. If converted to weak type, it is still consistent with other pointers to owner and does not expire while there is at least one shared pointer to owner object. Also, the returned pointer does not ensure that target object is alive, so some other means (e. g. shared pointer stored in the owner object) should do so.  . More...
 
template<typename T , typename ... Objects>
static T ExtendLifetime (const T &target, const Objects &...objects)
 Creates a smart pointer using the aliasing constructor and moves target and objects pointers to the "proxy" objects holder. Creates a pointer to the target and extends the lifetime of all objects to the lifetime of this pointer. The resulting pointer guarantees all parameters to remain alive, even if it is the only pointer that keeps track of them. The resulting pointer effectively owns all objects passed to this method, however, it has its own expiration track. This means, that converting its own copy to weak type will expire it, even if all objects it tracks are still alive.  . More...
 

Detailed Description

Defines a methods that changes the lifetime of objects.

Member Typedef Documentation

◆ ObjectsBag

using CsToCppPorter::MemoryManagement::ObjectsBag = System::Details::ObjectsBag

Highly optimized container designed to extend objects lifetime.

Member Function Documentation

◆ BindLifetime() [1/2]

template<typename T1 , typename T2 >
static T1 CsToCppPorter::MemoryManagement::BindLifetime ( const T1 &  target,
const T2 &  owner 
)
inlinestatic

Creates a smart pointer using the aliasing constructor. Creates a pointer to the target object which controls lifetime of the owner object. This pointer's expiration is bound to expiration of the owner object, just like this of any other pointer that owns owner object. If converted to weak type, it is still consistent with other pointers to owner and does not expire while there is at least one shared pointer to owner object. Also, the returned pointer does not ensure that target object is alive, so some other means (e. g. shared pointer stored in the owner object) should do so.  .

Template Parameters
T1Type of smart pointer to the object that the new smart pointer will refer to.  
T2Type of smart pointer to an object whose ownership is shared with a new smart pointer.  
Parameters
targetSmart pointer to the object that the new smart pointer will refer to.  
ownerSmart pointer to an object whose ownership is shared with a new smart pointer.  
Returns
New smart pointer.

◆ BindLifetime() [2/2]

template<typename T1 , typename T2 >
static std::enable_if<!std::is_reference<T1>::value, T1>::type CsToCppPorter::MemoryManagement::BindLifetime ( T1 &&  target,
const T2 &  owner 
)
inlinestatic

Creates a smart pointer using the aliasing constructor. Creates a pointer to the target object which controls lifetime of the owner object. This pointer's expiration is bound to expiration of the owner object, just like this of any other pointer that owns owner object. If converted to weak type, it is still consistent with other pointers to owner and does not expire while there is at least one shared pointer to owner object. Also, the returned pointer does not ensure that target object is alive, so some other means (e. g. shared pointer stored in the owner object) should do so.  .

Template Parameters
T1Type of smart pointer to the object that the new smart pointer will refer to.  
T2Type of smart pointer to an object whose ownership is shared with a new smart pointer.  
Parameters
targetSmart pointer to the object that the new smart pointer will refer to.  
ownerSmart pointer to an object whose ownership is shared with a new smart pointer.  
Returns
New smart pointer.

◆ ExtendLifetime()

template<typename T , typename ... Objects>
static T CsToCppPorter::MemoryManagement::ExtendLifetime ( const T &  target,
const Objects &...  objects 
)
inlinestatic

Creates a smart pointer using the aliasing constructor and moves target and objects pointers to the "proxy" objects holder. Creates a pointer to the target and extends the lifetime of all objects to the lifetime of this pointer. The resulting pointer guarantees all parameters to remain alive, even if it is the only pointer that keeps track of them. The resulting pointer effectively owns all objects passed to this method, however, it has its own expiration track. This means, that converting its own copy to weak type will expire it, even if all objects it tracks are still alive.  .

Template Parameters
TType of the object that the new smart pointer will refer to.  
ObjectsTypes of the objects whose ownership is shared with a new smart pointer.  
Parameters
targetSmart pointer to the object that the new smart pointer will refer to.  
objectsSmart pointers to the objects whose ownership is shared with a new smart pointer.  
Returns
New smart pointer.