Published Objects Usage

内容表

关于

A published object is declared in a header file using the MAXON_DECLARATION attribute. It can be accessed and used in any source code file that includes this header file.

用法

The following functions are automatically generated for the published object class:

  • GetId() :返回 maxon::Id of the published object class.
  • GetInstance() : Returns a reference to the published object class instance. The returned type is maxon::Declaration.
  • IsInitialized() : Returns true if the published object is initialized.
  • GetReference() : Returns a reference to the published object.

A reference can also be obtained by using the function call operator "()".

// This example checks if the given published object is initialized. // If so a reference to that published object is accessed.

// check if the published object "Carbon" is initialized if ( MAXON_UNLIKELY (Carbon.IsInitialized() == false )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION , "\"Carbon\" not initialized" _s);

// get reference to published object "Carbon" const SimpleAtom& carbon = Carbon();

DiagnosticOutput ( "Atom: @, @, @" , carbon._protonCnt, carbon._neutronCnt, carbon._electronCnt);

延伸阅读

MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
DiagnosticOutput
#define DiagnosticOutput(formatString,...)
定义: debugdiagnostics.h:166
MAXON_UNLIKELY
#define MAXON_UNLIKELY(X)
定义: compilerdetection.h:482

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1