-
首页
-
C4D R23.110 C++ SDK
System Class Reference
系统
#include <system.h>
详细描述
应用程序
wide system functions. Do not use any of those functions directly. Implement this interface to link against the kernel library.
静态公共成员函数
|
static
MAXON_METHOD
void
|
_ConsoleOutput
(const
Char
*s, const
SourceLocation
&loc)
|
static
MAXON_METHOD
OUTPUT
|
GetConsoleOutputType
()
|
static
MAXON_METHOD
void *
|
Alloc
(
Int
size, const
SourceLocation
&location)
|
static
MAXON_METHOD
void *
|
AllocClear
(
Int
size, const
SourceLocation
&location)
|
static
MAXON_METHOD
void *
|
Realloc
(void *data,
Int
size, const
SourceLocation
&location)
|
static
MAXON_METHOD
void
|
Free
(const void *data)
|
template<typename T >
|
static
MAXON_FUNCTION
void
|
FreeWithDestructor
(T *object, void(*destructor)(T *))
|
static
MAXON_METHOD
Int
|
GetAllocSize
(void *data)
|
static
MAXON_METHOD
Int
|
MemoryDiagnostics
(
MEMORYDIAGNOSTICSMODE
mode=
MEMORYDIAGNOSTICSMODE::VERBOSE
,
Int
*totalAllocation=nullptr,
Int
*freePhysicalMemoryEstimate=nullptr)
|
static
MAXON_METHOD
Bool
|
MemoryAddObserver
(
MEMORYOBSERVERMODE
模式,
Delegate
< void()> &&observer)
|
static
MAXON_METHOD
void
|
SetMemoryAllocationThreshold
(
UInt
warnMemoryAllocationThreshold)
|
static
MAXON_METHOD
Float64
|
GetCustomTimer
()
|
static
MAXON_METHOD
Int
|
GetConfigurationCount
()
|
static
MAXON_METHOD
Bool
|
GetConfiguration
(
Int
index, ConfigInit &config)
|
static
MAXON_METHOD
Bool
|
ConfigurationRegister
(const ConfigInit &config)
|
static
MAXON_METHOD
Char
*
|
GetCriticalLog
(
Int
index,
Int
*count)
|
static
MAXON_METHOD
Int
|
GetDefinitionCount
(EntityBase::TYPE type)
|
static const
MAXON_METHOD
InterfaceReference *
|
GetVirtualInterfaceReference
(const
Id
&idWithoutHash)
|
static
MAXON_METHOD
EntityDefinition *
|
FindDefinition
(EntityBase::TYPE type, const
Id
&eid)
|
static
MAXON_METHOD
void *
|
SetDebugErrorObserver
(
Delegate
< void(const
ErrorInterface
*)> &&observer)
|
static
MAXON_METHOD
void
|
ResetDebugErrorObserver
(void *observer)
|
static const
MAXON_METHOD
Error *
|
SetCurrentError
(const Error &error)
|
static const
MAXON_METHOD
Error *
|
SetCurrentError
(Error &&error)
|
static const
MAXON_METHOD
Error *
|
GetLastError
()
|
static
MAXON_METHOD
void
|
SetDebugError
(const Error *preallocated, const Error &error)
|
static const
MAXON_METHOD
ErrorInterface
*
|
GetDebugError
(const Error *preallocated)
|
static
MAXON_METHOD
Result
< const
Id
* >
|
PrivateGetInternedId
(const
Id
&value)
|
static
MAXON_METHOD
void
|
PrivateFreeInternedId
(const
Id
*ptr)
|
static
StrongReferenceCounter
&
|
GetReferenceCounter
(const void *object)
|
static const
MAXON_METHOD
Block
< const Binary *const > &
|
GetBinaries
()
|
static
MAXON_METHOD
void
|
PrivateShowSynchronizedHashMapDiagnostics
(
Int
size,
Int
capacity, const
Char
*signature)
|
static const
MAXON_METHOD
Char
*
|
GetPreferencesPathSuffix
()
|
static
MAXON_METHOD
Id
|
GetApplicationId
()
|
static
MAXON_METHOD
void
|
SetApplicationType
(const
Char
*dna)
|
Member Enumeration Documentation
◆
MEMORYDIAGNOSTICSMODE
Enumerator
|
ESTIMATEONLY
|
Just return current total allocation estimate.
|
QUIET
|
Just return allocation numbers.
|
VERBOSE
|
Additional details will be sent to the console.
|
LEAKGRAPH
|
Create a memory leak graph (circular references).
|
PRIVATE_OFF
|
|
PRIVATE_ON
|
|
◆
MEMORYOBSERVERMODE
Enumerator
|
LOWMEM_CLEANUP
|
The observer should free resources/caches and then the allocator will retry.
|
LOWMEM_FAILURE
|
An allocation failed (even retry didn't change that).
|
WARNMEM_LIMIT
|
The allocations exceed a user specified amount of memory.
|
◆
SPECIALBEHAVIOR
Enumerator
|
NONE
|
|
OMIT_HELP
|
If set "-help" will not start help mode of the underlying base system, whereas "help" will. This is legacy behavior for C4D.
|
DONTWARN_MISSINGARGUMENTS
|
If set there will be no output in the console if an argument is passed but not defined in the code.
|
成员函数文档编制
◆
MAXON_INTERFACE_NONVIRTUAL()
◆
MAXON_ENUM_LIST_CLASS()
[1/2]
◆
MAXON_ENUM_LIST_CLASS()
[2/2]
◆
MAXON_ENUM_FLAGS_CLASS()
◆
_ConsoleOutput()
Prints debug information into the console window.
-
参数
-
[in]
|
s
|
Char* to print out.
|
◆
GetConsoleOutputType()
Retrieves which types of output shall be supported.
-
返回
-
Diagnostic, warning and/or critical output.
◆
Alloc()
Allocates a memory block, does not clear memory (similar to malloc). The memory is not cleared, it may contain a certain byte pattern in debug mode.
-
参数
-
[in]
|
size
|
Block
size in bytes (values < 0 will return nullptr).
|
[in]
|
location
|
MemoryAllocationStructure (filled out by a define).
|
-
返回
-
Memory block address or nullptr.
◆
AllocClear()
Allocates a memory block and clears it (similar to calloc).
-
参数
-
[in]
|
size
|
Block
size in bytes (values < 0 will return nullptr).
|
[in]
|
location
|
MemoryAllocationStructure (filled out by a define).
|
-
返回
-
Memory block address or nullptr.
◆
Realloc()
Resizes a memory block (similar to realloc). The additional memory is not cleared, it may contain a certain byte pattern in debug mode.
-
参数
-
[in]
|
data
|
Current memory block (can be nullptr).
|
[in]
|
size
|
New block size in bytes (values < 0 will return nullptr).
|
[in]
|
location
|
MemoryAllocationStructure (filled out by a define).
|
-
返回
-
Memory block address or nullptr if resize is not possible (p is still valid in this case).
◆
Free()
Frees a memory block (free).
-
参数
-
[in]
|
data
|
Memory block address (can be nullptr).
|
◆
FreeWithDestructor()
static
MAXON_FUNCTION
void FreeWithDestructor
|
(
|
T *
|
object
,
|
|
|
void(*)(T *)
|
destructor
|
|
)
|
|
|
|
static
|
◆
GetAllocSize()
Returns the size of a memory block.
-
参数
-
[in]
|
data
|
Memory block address (can be nullptr, but otherwise must be valid).
|
-
返回
-
Size of the allocated block in bytes.
◆
MemoryDiagnostics()
Returns information about memory usage and optionally prints details to the console.
-
参数
-
[in]
|
mode
|
See MEMORYDIAGNOSTICSMODE.
|
[out]
|
totalAllocation
|
Used to return the total amount of memory allocated including blocks being cached, used for management and so on. This might be considerably bigger than what was allocated by the application.
|
[out]
|
freePhysicalMemoryEstimate
|
Used to return a very rough estimate of the free physical memory (if any).
|
-
返回
-
Memory allocated by the application in bytes.
◆
MemoryAddObserver()
Adds an observer for low memory situations. The observer will be active until shutdown.
-
参数
-
[in]
|
mode
|
See MEMORYOBSERVERMODE.
|
[in]
|
observer
|
Observer.
|
-
返回
-
True on success.
◆
SetMemoryAllocationThreshold()
static
MAXON_METHOD
void SetMemoryAllocationThreshold
|
(
|
UInt
|
warnMemoryAllocationThreshold
|
)
|
|
|
static
|
Sets the threshold value when observers of mode
MEMORYOBSERVERMODE::WARNMEM_LIMIT
will be executed. Calling the function again overwrites the older value.
-
参数
-
[in]
|
warnMemoryAllocationThreshold
|
The value when the observer will be executed.
|
◆
GetCustomTimer()
Returns the current system time which is being used by the Timer class.
-
返回
-
Seconds
of the system time.
◆
GetConfigurationCount()
Returns the number of configuration values registered with ConfigurationRegister
-
返回
-
Number of configuration values.
◆
GetConfiguration()
Gets the configuration value by a given index.
-
参数
-
-
返回
-
True on success or false if the index is out of range.
◆
ConfigurationRegister()
Registers a configuration value
ConfigValues
with the main application.
-
参数
-
[in]
|
config
|
The configuration value and related data (default, limits etc.).
|
-
返回
-
Success of the registration.
◆
GetCriticalLog()
Reads information from the critical log (which is automatically stored in memory). It contains messages that were generated calling
CriticalOutput()
. THREADSAFE.
-
参数
-
[in]
|
index
|
Index to the log, starting at zero. If the return value is nullptr then no more log entries exist.
|
[out]
|
count
|
Pointer to a value that will receive the number of log entries or nullptr.
|
-
返回
-
C-Style string containing the critical message or nullptr if no log entry exists for this index.
◆
GetDefinitionCount()
Returns the total number of definitions for the given entity type. This is used for statistics about the complexity of the whole application.
-
参数
-
[in]
|
type
|
Entity type. Use EntityBase::TYPE::COUNT for the total number of methods of all (virtual and non-virtual) interfaces.
|
-
返回
-
Number of definitions of the given type.
◆
GetVirtualInterfaceReference()
static const
MAXON_METHOD
InterfaceReference* GetVirtualInterfaceReference
|
(
|
const
Id
&
|
idWithoutHash
|
)
|
|
|
static
|
Returns the virtual references of a given class.
-
参数
-
[in]
|
idWithoutHash
|
Class
ID without hash.
|
-
返回
-
Found interface references
◆
FindDefinition()
static
MAXON_METHOD
EntityDefinition* FindDefinition
|
(
|
EntityBase::TYPE
|
type
,
|
|
|
const
Id
&
|
eid
|
|
)
|
|
|
|
static
|
Returns the definition of the given entity type.
-
参数
-
[in]
|
type
|
Entity type. Use EntityBase::TYPE::COUNT for the total number of methods of all (virtual and non-virtual) interfaces.
|
[in]
|
eid
|
Entity id.
|
-
返回
-
Found EntityDefinition or nullptr if no entity was found with the given name or type.
◆
SetDebugErrorObserver()
Sets a callback which shall be invoked when an error occurs. This should be used only for debugging purposes. For example, if you want to have a DebugStop on any error during a function call, you can write:
void
* callback =
System::SetDebugErrorObserver
([] (
const
ErrorInterface* error) {
DiagnosticOutput
(
"@"
, error);
DebugStop
(); });
SomeFunctionToDebug();
System::ResetDebugErrorObserver
(callback);
You could even make the
DebugStop()
depend on the type of the error by checking the type of the error parameter.
You should clear the error callback after the code to debug by calling ResetErrorCallback().
-
警告
-
This method is not thread-safe.
-
参数
-
[in]
|
observer
|
Observer for errors.
|
-
返回
-
Pointer to the installed observer or nullptr on failure.
◆
ResetDebugErrorObserver()
static
MAXON_METHOD
void ResetDebugErrorObserver
|
(
|
void *
|
observer
|
)
|
|
|
static
|
Resets a previously set error callback.
-
警告
-
This method is not thread-safe.
-
另请参阅
-
SetErrorCallback
-
参数
-
[in]
|
observer
|
The observer to remove.
|
◆
SetCurrentError()
[1/2]
static const
MAXON_METHOD
Error* SetCurrentError
|
(
|
const Error &
|
error
|
)
|
|
|
static
|
◆
SetCurrentError()
[2/2]
static const
MAXON_METHOD
Error* SetCurrentError
|
(
|
Error &&
|
error
|
)
|
|
|
static
|
◆
GetLastError()
◆
SetDebugError()
static
MAXON_METHOD
void SetDebugError
|
(
|
const Error *
|
preallocated
,
|
|
|
const Error &
|
error
|
|
)
|
|
|
|
static
|
◆
GetDebugError()
◆
PrivateGetInternedId()
-
返回
-
Nullptr indicates OutOfMemory.
◆
PrivateFreeInternedId()
◆
GetReferenceCounter()
Returns the reference counter for classes which do not implement custom AddReference/RemoveReference methods.
◆
GetBinaries()
◆
PrivateShowSynchronizedHashMapDiagnostics()
static
MAXON_METHOD
void PrivateShowSynchronizedHashMapDiagnostics
|
(
|
Int
|
size
,
|
|
|
Int
|
capacity
,
|
|
|
const
Char
*
|
signature
|
|
)
|
|
|
|
static
|
◆
GetPreferencesPathSuffix()
◆
GetApplicationId()
Returns the kind of application. Common definitions can be found in
APPLICATIONID
.
◆
SetApplicationType()
◆
FreeWithDestructorI()
-
参数
-
[in]
|
object
|
Object/memory block address (guaranteed not to be nullptr).
|
[in]
|
destruct
|
Object destructor (guaranteed not to be nullptr).
|
#define DebugStop(...)
定义:
debugdiagnostics.h:228
#define DiagnosticOutput(formatString,...)
定义:
debugdiagnostics.h:166
static MAXON_METHOD void ResetDebugErrorObserver(void *observer)
static MAXON_METHOD void * SetDebugErrorObserver(Delegate< void(const ErrorInterface *)> &&observer)