System::Object class
Object class
Base class that enables using methods available for System.Object class in C#. All non-trivial classes used with translated environment should inherit it.
class Object
Methods
Method | Description |
---|---|
virtual Equals(ptr) | Compares objects using C# Object.Equals semantics. |
static Equals(T1 const&, T2 const&) | Compares reference type objects in C# style. |
static Equals(T1 const&, T2 const&) | Compares value type objects in C# style. |
static Equals(float const&, float const&) | Emulates C#-style floating point comparison where two NaNs are considered equal even though according to IEC 60559:1989 NaN is not equal to any value, including NaN. |
static Equals(double const&, double const&) | Emulates C#-style floating point comparison where two NaNs are considered equal even though according to IEC 60559:1989 NaN is not equal to any value, including NaN. |
virtual FastCast(const Details::FastRttiBase&, void **) const | For internal purposes only. |
GetCounter() | Gets reference counter data structure associated with the object. |
virtual GetHashCode() const | Analog of C# Object.GetHashCode() method. Enables hashing of custom objects. |
virtual GetType() const | Gets actual type of object. Analog of C# System.Object.GetType() call. |
virtual Is(const TypeInfo&) const | Check if object represents an instance of type described by targetType. Analog of C# ‘is’ operator. |
Lock() | Implements C# lock() statement locking. Call directly or use LockContext sentry object. |
virtual MemberwiseClone() const | Analog of C# Object.MemberwiseClone() method. Enables cloning custom types. |
Object() | Creates object. Initializes all internal data structures. |
Object(Object const&) | Copy constructor. Doesn’t copy anything, really, just initializes new object and enables copy constructing subclasses. |
operator=(Object const&) | Assignment operator. Doesn’t copy anything, really, just initializes new object and enables copy constructing subclasses. |
static ReferenceEquals(ptr const&, ptr const&) | Compares objects by reference. |
static ReferenceEquals(T const&, T const&) | Compares objects by reference. |
static ReferenceEquals(T const&, std::nullptr_t) | Reference-compares value type object with nullptr. |
ReferenceEquals(String const&, std::nullptr_t) | Specialization of Object::ReferenceEquals for case of string and nullptr. |
ReferenceEquals(String const&, String const&) | Specialization of Object::ReferenceEquals for case of strings. |
RemovedSharedRefs(int) | Decreases shared reference count by specified value. |
virtual SetTemplateWeakPtr(uint32_t) | Set n’th template argument a weak pointer (rather than shared). Allows switching pointers in containers to weak mode. |
SharedCount() const | Gets current value of shared reference counter. |
SharedRefAdded() | Increments shared reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector. |
SharedRefRemovedSafe() | Decrements and returns shared reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector. |
virtual ToString() const | Analog of C# Object.ToString() method. Enables converting custom objects to string. |
static Type() | Implements C# typeof(System.Object) construct. |
Unlock() | Implements C# lock() statement unlocking. Call directly or use LockContext sentry object. |
WeakRefAdded() | Increments weak reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector. |
WeakRefRemoved() | Decrements weak reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector. |
virtual ~Object() | Destroys object. Frees all internal data structures. |
Typedefs
Typedef | Description |
---|---|
ptr | Alias for smart pointer type. |
Remarks
Alongside with methods available in C# System.Object class, it also enables support for some concepts specific for translated code environment. This includes reference counting used by smart pointer classes (System::SmartPtr, System::WeakPtr, System::DynamicWeakPtr) and other services related to memory management, debug, etc.
Each Object has two reference counters: shared reference counter and weak reference counter. Weak reference counter is always stored in detached data structure rather than in Object itself which allows weak pointers overlive referenced object. Smart reference counter is stored either in object itself or in same detached structure, depending on ENABLE_EXTERNAL_REFCOUNT macro state. By default, it is enabled in debug builds and disabled in release builds. If smart pointer counter is stored in object itself, detached data structure is created only if weak pointers to object exist. Otherwise, it is created alongside with object itself.
All smart pointers use these two reference counters and contribute to same and only ownership group.
If Object subclass is created on stack, no smart pointers to it may be created, otherwise there is a stack deletion issue.
This type can be allocated either in stack as value type or in heap using System::MakeObject() function. Once the object is allocated, never mix up these two usecases: having SmartPtr pointers onto stack-allocated objects is strictly prohibited.
See Also
- Namespace System
- Library Aspose.TeX for C++