One Hat Cyber Team
Your IP :
216.73.216.115
Server IP :
194.44.31.54
Server :
Linux zen.imath.kiev.ua 4.18.0-553.77.1.el8_10.x86_64 #1 SMP Fri Oct 3 14:30:23 UTC 2025 x86_64
Server Software :
Apache/2.4.37 (Rocky Linux) OpenSSL/1.1.1k
PHP Version :
5.6.40
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
doc
/
qemu-kvm
/
devel
/
Edit File:
qom.html
<!DOCTYPE html> <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>The QEMU Object Model (QOM) — QEMU qemu-kvm-6.2.0-53.module+el8.10.0+2055+8eb7870b.4 documentation</title> <link rel="shortcut icon" href="../_static/qemu_32x32.png"/> <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="next" title="QEMU modules" href="modules.html" /> <link rel="prev" title="Modelling a clock tree in QEMU" href="clocks.html" /> <script src="../_static/js/modernizr.min.js"></script> </head> <body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search"> <a href="../index.html" class="icon icon-home"> QEMU <img src="../_static/qemu_128x128.png" class="logo" alt="Logo"/> </a> <div class="version"> 6.2.0 </div> <div role="search"> <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> </div> <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> <p class="caption"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../about/index.html">About QEMU</a></li> <li class="toctree-l1"><a class="reference internal" href="../system/index.html">System Emulation</a></li> <li class="toctree-l1"><a class="reference internal" href="../user/index.html">User Mode Emulation</a></li> <li class="toctree-l1"><a class="reference internal" href="../tools/index.html">Tools</a></li> <li class="toctree-l1"><a class="reference internal" href="../interop/index.html">System Emulation Management and Interoperability</a></li> <li class="toctree-l1"><a class="reference internal" href="../specs/index.html">System Emulation Guest Hardware Specifications</a></li> <li class="toctree-l1 current"><a class="reference internal" href="index.html">Developer Information</a><ul class="current"> <li class="toctree-l2"><a class="reference internal" href="code-of-conduct.html">Code of Conduct</a></li> <li class="toctree-l2"><a class="reference internal" href="conflict-resolution.html">Conflict Resolution Policy</a></li> <li class="toctree-l2"><a class="reference internal" href="build-system.html">The QEMU build system architecture</a></li> <li class="toctree-l2"><a class="reference internal" href="style.html">QEMU Coding Style</a></li> <li class="toctree-l2"><a class="reference internal" href="kconfig.html">QEMU and Kconfig</a></li> <li class="toctree-l2"><a class="reference internal" href="testing.html">Testing in QEMU</a></li> <li class="toctree-l2"><a class="reference internal" href="fuzzing.html">Fuzzing</a></li> <li class="toctree-l2"><a class="reference internal" href="control-flow-integrity.html">Control-Flow Integrity (CFI)</a></li> <li class="toctree-l2"><a class="reference internal" href="loads-stores.html">Load and Store APIs</a></li> <li class="toctree-l2"><a class="reference internal" href="memory.html">The memory API</a></li> <li class="toctree-l2"><a class="reference internal" href="migration.html">Migration</a></li> <li class="toctree-l2"><a class="reference internal" href="atomics.html">Atomic operations in QEMU</a></li> <li class="toctree-l2"><a class="reference internal" href="stable-process.html">QEMU and the stable process</a></li> <li class="toctree-l2"><a class="reference internal" href="ci.html">CI</a></li> <li class="toctree-l2"><a class="reference internal" href="qtest.html">QTest Device Emulation Testing Framework</a></li> <li class="toctree-l2"><a class="reference internal" href="decodetree.html">Decodetree Specification</a></li> <li class="toctree-l2"><a class="reference internal" href="secure-coding-practices.html">Secure Coding Practices</a></li> <li class="toctree-l2"><a class="reference internal" href="tcg.html">Translator Internals</a></li> <li class="toctree-l2"><a class="reference internal" href="tcg-icount.html">TCG Instruction Counting</a></li> <li class="toctree-l2"><a class="reference internal" href="tracing.html">Tracing</a></li> <li class="toctree-l2"><a class="reference internal" href="multi-thread-tcg.html">Multi-threaded TCG</a></li> <li class="toctree-l2"><a class="reference internal" href="tcg-plugins.html">QEMU TCG Plugins</a></li> <li class="toctree-l2"><a class="reference internal" href="bitops.html">Bitwise operations</a></li> <li class="toctree-l2"><a class="reference internal" href="ui.html">QEMU UI subsystem</a></li> <li class="toctree-l2"><a class="reference internal" href="reset.html">Reset in QEMU: the Resettable interface</a></li> <li class="toctree-l2"><a class="reference internal" href="s390-dasd-ipl.html">Booting from real channel-attached devices on s390x</a></li> <li class="toctree-l2"><a class="reference internal" href="clocks.html">Modelling a clock tree in QEMU</a></li> <li class="toctree-l2 current"><a class="current reference internal" href="#">The QEMU Object Model (QOM)</a><ul> <li class="toctree-l3"><a class="reference internal" href="#class-initialization">Class Initialization</a></li> <li class="toctree-l3"><a class="reference internal" href="#interfaces">Interfaces</a></li> <li class="toctree-l3"><a class="reference internal" href="#methods">Methods</a></li> <li class="toctree-l3"><a class="reference internal" href="#standard-type-declaration-and-definition-macros">Standard type declaration and definition macros</a><ul> <li class="toctree-l4"><a class="reference internal" href="#api-reference">API Reference</a></li> </ul> </li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="modules.html">QEMU modules</a></li> <li class="toctree-l2"><a class="reference internal" href="block-coroutine-wrapper.html">block-coroutine-wrapper</a></li> <li class="toctree-l2"><a class="reference internal" href="multi-process.html">Multi-process QEMU</a></li> <li class="toctree-l2"><a class="reference internal" href="ebpf_rss.html">eBPF RSS virtio-net support</a></li> <li class="toctree-l2"><a class="reference internal" href="vfio-migration.html">VFIO device Migration</a></li> <li class="toctree-l2"><a class="reference internal" href="qapi-code-gen.html">How to use the QAPI code generator</a></li> <li class="toctree-l2"><a class="reference internal" href="writing-monitor-commands.html">How to write monitor commands</a></li> <li class="toctree-l2"><a class="reference internal" href="trivial-patches.html">Trivial Patches</a></li> <li class="toctree-l2"><a class="reference internal" href="submitting-a-patch.html">Submitting a Patch</a></li> <li class="toctree-l2"><a class="reference internal" href="submitting-a-pull-request.html">Submitting a Pull Request</a></li> </ul> </li> </ul> </div> </div> </nav> <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> <nav class="wy-nav-top" aria-label="top navigation"> <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../index.html">QEMU</a> </nav> <div class="wy-nav-content"> <div class="rst-content"> <div role="navigation" aria-label="breadcrumbs navigation"> <ul class="wy-breadcrumbs"> <li><a href="../index.html">Docs</a> »</li> <li><a href="index.html">Developer Information</a> »</li> <li>The QEMU Object Model (QOM)</li> <li class="wy-breadcrumbs-aside"> <a href="https://gitlab.com/qemu-project/qemu/blob/master/docs/devel/qom.rst" class="fa fa-gitlab"> Edit on GitLab</a> </li> </ul> <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> <div class="section" id="the-qemu-object-model-qom"> <h1>The QEMU Object Model (QOM)<a class="headerlink" href="#the-qemu-object-model-qom" title="Permalink to this headline">¶</a></h1> <p>The QEMU Object Model provides a framework for registering user creatable types and instantiating objects from those types. QOM provides the following features:</p> <ul class="simple"> <li>System for dynamically registering types</li> <li>Support for single-inheritance of types</li> <li>Multiple inheritance of stateless interfaces</li> </ul> <div class="literal-block-wrapper docutils container" id="id1"> <div class="code-block-caption"><span class="caption-text">Creating a minimal type</span><a class="headerlink" href="#id1" title="Permalink to this code">¶</a></div> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#include</span> <span class="cpf">"qdev.h"</span><span class="cp"></span> <span class="cp">#define TYPE_MY_DEVICE "my-device"</span> <span class="c1">// No new virtual functions: we can reuse the typedef for the</span> <span class="c1">// superclass.</span> <span class="k">typedef</span> <span class="n">DeviceClass</span> <span class="n">MyDeviceClass</span><span class="p">;</span> <span class="k">typedef</span> <span class="k">struct</span> <span class="n">MyDevice</span> <span class="p">{</span> <span class="n">DeviceState</span> <span class="n">parent</span><span class="p">;</span> <span class="kt">int</span> <span class="n">reg0</span><span class="p">,</span> <span class="n">reg1</span><span class="p">,</span> <span class="n">reg2</span><span class="p">;</span> <span class="p">}</span> <span class="n">MyDevice</span><span class="p">;</span> <span class="k">static</span> <span class="k">const</span> <span class="n">TypeInfo</span> <span class="n">my_device_info</span> <span class="o">=</span> <span class="p">{</span> <span class="p">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">TYPE_MY_DEVICE</span><span class="p">,</span> <span class="p">.</span><span class="n">parent</span> <span class="o">=</span> <span class="n">TYPE_DEVICE</span><span class="p">,</span> <span class="p">.</span><span class="n">instance_size</span> <span class="o">=</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">MyDevice</span><span class="p">),</span> <span class="p">};</span> <span class="k">static</span> <span class="kt">void</span> <span class="nf">my_device_register_types</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="p">{</span> <span class="n">type_register_static</span><span class="p">(</span><span class="o">&</span><span class="n">my_device_info</span><span class="p">);</span> <span class="p">}</span> <span class="n">type_init</span><span class="p">(</span><span class="n">my_device_register_types</span><span class="p">)</span> </pre></div> </div> </div> <p>In the above example, we create a simple type that is described by #TypeInfo. #TypeInfo describes information about the type including what it inherits from, the instance and class size, and constructor/destructor hooks.</p> <p>Alternatively several static types could be registered using helper macro DEFINE_TYPES()</p> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">static</span> <span class="k">const</span> <span class="n">TypeInfo</span> <span class="n">device_types_info</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span> <span class="p">{</span> <span class="p">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">TYPE_MY_DEVICE_A</span><span class="p">,</span> <span class="p">.</span><span class="n">parent</span> <span class="o">=</span> <span class="n">TYPE_DEVICE</span><span class="p">,</span> <span class="p">.</span><span class="n">instance_size</span> <span class="o">=</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">MyDeviceA</span><span class="p">),</span> <span class="p">},</span> <span class="p">{</span> <span class="p">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">TYPE_MY_DEVICE_B</span><span class="p">,</span> <span class="p">.</span><span class="n">parent</span> <span class="o">=</span> <span class="n">TYPE_DEVICE</span><span class="p">,</span> <span class="p">.</span><span class="n">instance_size</span> <span class="o">=</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">MyDeviceB</span><span class="p">),</span> <span class="p">},</span> <span class="p">};</span> <span class="n">DEFINE_TYPES</span><span class="p">(</span><span class="n">device_types_info</span><span class="p">)</span> </pre></div> </div> <p>Every type has an #ObjectClass associated with it. #ObjectClass derivatives are instantiated dynamically but there is only ever one instance for any given type. The #ObjectClass typically holds a table of function pointers for the virtual methods implemented by this type.</p> <p>Using object_new(), a new #Object derivative will be instantiated. You can cast an #Object to a subclass (or base-class) type using object_dynamic_cast(). You typically want to define macro wrappers around OBJECT_CHECK() and OBJECT_CLASS_CHECK() to make it easier to convert to a specific type:</p> <div class="literal-block-wrapper docutils container" id="id2"> <div class="code-block-caption"><span class="caption-text">Typecasting macros</span><a class="headerlink" href="#id2" title="Permalink to this code">¶</a></div> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define MY_DEVICE_GET_CLASS(obj) \</span> <span class="cp"> OBJECT_GET_CLASS(MyDeviceClass, obj, TYPE_MY_DEVICE)</span> <span class="cp">#define MY_DEVICE_CLASS(klass) \</span> <span class="cp"> OBJECT_CLASS_CHECK(MyDeviceClass, klass, TYPE_MY_DEVICE)</span> <span class="cp">#define MY_DEVICE(obj) \</span> <span class="cp"> OBJECT_CHECK(MyDevice, obj, TYPE_MY_DEVICE)</span> </pre></div> </div> </div> <p>In case the ObjectClass implementation can be built as module a module_obj() line must be added to make sure qemu loads the module when the object is needed.</p> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">module_obj</span><span class="p">(</span><span class="n">TYPE_MY_DEVICE</span><span class="p">);</span> </pre></div> </div> <div class="section" id="class-initialization"> <h2>Class Initialization<a class="headerlink" href="#class-initialization" title="Permalink to this headline">¶</a></h2> <p>Before an object is initialized, the class for the object must be initialized. There is only one class object for all instance objects that is created lazily.</p> <p>Classes are initialized by first initializing any parent classes (if necessary). After the parent class object has initialized, it will be copied into the current class object and any additional storage in the class object is zero filled.</p> <p>The effect of this is that classes automatically inherit any virtual function pointers that the parent class has already initialized. All other fields will be zero filled.</p> <p>Once all of the parent classes have been initialized, #TypeInfo::class_init is called to let the class being instantiated provide default initialize for its virtual functions. Here is how the above example might be modified to introduce an overridden virtual function:</p> <div class="literal-block-wrapper docutils container" id="id3"> <div class="code-block-caption"><span class="caption-text">Overriding a virtual function</span><a class="headerlink" href="#id3" title="Permalink to this code">¶</a></div> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#include</span> <span class="cpf">"qdev.h"</span><span class="cp"></span> <span class="kt">void</span> <span class="nf">my_device_class_init</span><span class="p">(</span><span class="n">ObjectClass</span> <span class="o">*</span><span class="n">klass</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">class_data</span><span class="p">)</span> <span class="p">{</span> <span class="n">DeviceClass</span> <span class="o">*</span><span class="n">dc</span> <span class="o">=</span> <span class="n">DEVICE_CLASS</span><span class="p">(</span><span class="n">klass</span><span class="p">);</span> <span class="n">dc</span><span class="o">-></span><span class="n">reset</span> <span class="o">=</span> <span class="n">my_device_reset</span><span class="p">;</span> <span class="p">}</span> <span class="k">static</span> <span class="k">const</span> <span class="n">TypeInfo</span> <span class="n">my_device_info</span> <span class="o">=</span> <span class="p">{</span> <span class="p">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">TYPE_MY_DEVICE</span><span class="p">,</span> <span class="p">.</span><span class="n">parent</span> <span class="o">=</span> <span class="n">TYPE_DEVICE</span><span class="p">,</span> <span class="p">.</span><span class="n">instance_size</span> <span class="o">=</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">MyDevice</span><span class="p">),</span> <span class="p">.</span><span class="n">class_init</span> <span class="o">=</span> <span class="n">my_device_class_init</span><span class="p">,</span> <span class="p">};</span> </pre></div> </div> </div> <p>Introducing new virtual methods requires a class to define its own struct and to add a .class_size member to the #TypeInfo. Each method will also have a wrapper function to call it easily:</p> <div class="literal-block-wrapper docutils container" id="id4"> <div class="code-block-caption"><span class="caption-text">Defining an abstract class</span><a class="headerlink" href="#id4" title="Permalink to this code">¶</a></div> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#include</span> <span class="cpf">"qdev.h"</span><span class="cp"></span> <span class="k">typedef</span> <span class="k">struct</span> <span class="n">MyDeviceClass</span> <span class="p">{</span> <span class="n">DeviceClass</span> <span class="n">parent</span><span class="p">;</span> <span class="kt">void</span> <span class="p">(</span><span class="o">*</span><span class="n">frobnicate</span><span class="p">)</span> <span class="p">(</span><span class="n">MyDevice</span> <span class="o">*</span><span class="n">obj</span><span class="p">);</span> <span class="p">}</span> <span class="n">MyDeviceClass</span><span class="p">;</span> <span class="k">static</span> <span class="k">const</span> <span class="n">TypeInfo</span> <span class="n">my_device_info</span> <span class="o">=</span> <span class="p">{</span> <span class="p">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">TYPE_MY_DEVICE</span><span class="p">,</span> <span class="p">.</span><span class="n">parent</span> <span class="o">=</span> <span class="n">TYPE_DEVICE</span><span class="p">,</span> <span class="p">.</span><span class="n">instance_size</span> <span class="o">=</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">MyDevice</span><span class="p">),</span> <span class="p">.</span><span class="n">abstract</span> <span class="o">=</span> <span class="nb">true</span><span class="p">,</span> <span class="c1">// or set a default in my_device_class_init</span> <span class="p">.</span><span class="n">class_size</span> <span class="o">=</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">MyDeviceClass</span><span class="p">),</span> <span class="p">};</span> <span class="kt">void</span> <span class="nf">my_device_frobnicate</span><span class="p">(</span><span class="n">MyDevice</span> <span class="o">*</span><span class="n">obj</span><span class="p">)</span> <span class="p">{</span> <span class="n">MyDeviceClass</span> <span class="o">*</span><span class="n">klass</span> <span class="o">=</span> <span class="n">MY_DEVICE_GET_CLASS</span><span class="p">(</span><span class="n">obj</span><span class="p">);</span> <span class="n">klass</span><span class="o">-></span><span class="n">frobnicate</span><span class="p">(</span><span class="n">obj</span><span class="p">);</span> <span class="p">}</span> </pre></div> </div> </div> </div> <div class="section" id="interfaces"> <h2>Interfaces<a class="headerlink" href="#interfaces" title="Permalink to this headline">¶</a></h2> <p>Interfaces allow a limited form of multiple inheritance. Instances are similar to normal types except for the fact that are only defined by their classes and never carry any state. As a consequence, a pointer to an interface instance should always be of incomplete type in order to be sure it cannot be dereferenced. That is, you should define the ‘typedef struct SomethingIf SomethingIf’ so that you can pass around <code class="docutils literal notranslate"><span class="pre">SomethingIf</span> <span class="pre">*si</span></code> arguments, but not define a <code class="docutils literal notranslate"><span class="pre">struct</span> <span class="pre">SomethingIf</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">}</span></code>. The only things you can validly do with a <code class="docutils literal notranslate"><span class="pre">SomethingIf</span> <span class="pre">*</span></code> are to pass it as an argument to a method on its corresponding SomethingIfClass, or to dynamically cast it to an object that implements the interface.</p> </div> <div class="section" id="methods"> <h2>Methods<a class="headerlink" href="#methods" title="Permalink to this headline">¶</a></h2> <p>A <em>method</em> is a function within the namespace scope of a class. It usually operates on the object instance by passing it as a strongly-typed first argument. If it does not operate on an object instance, it is dubbed <em>class method</em>.</p> <p>Methods cannot be overloaded. That is, the #ObjectClass and method name uniquely identity the function to be called; the signature does not vary except for trailing varargs.</p> <p>Methods are always <em>virtual</em>. Overriding a method in #TypeInfo.class_init of a subclass leads to any user of the class obtained via OBJECT_GET_CLASS() accessing the overridden function. The original function is not automatically invoked. It is the responsibility of the overriding class to determine whether and when to invoke the method being overridden.</p> <p>To invoke the method being overridden, the preferred solution is to store the original value in the overriding class before overriding the method. This corresponds to <code class="docutils literal notranslate"><span class="pre">{super,base}.method(...)</span></code> in Java and C# respectively; this frees the overriding class from hardcoding its parent class, which someone might choose to change at some point.</p> <div class="literal-block-wrapper docutils container" id="id5"> <div class="code-block-caption"><span class="caption-text">Overriding a virtual method</span><a class="headerlink" href="#id5" title="Permalink to this code">¶</a></div> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="n">MyState</span> <span class="n">MyState</span><span class="p">;</span> <span class="k">typedef</span> <span class="nf">void</span> <span class="p">(</span><span class="o">*</span><span class="n">MyDoSomething</span><span class="p">)(</span><span class="n">MyState</span> <span class="o">*</span><span class="n">obj</span><span class="p">);</span> <span class="k">typedef</span> <span class="k">struct</span> <span class="n">MyClass</span> <span class="p">{</span> <span class="n">ObjectClass</span> <span class="n">parent_class</span><span class="p">;</span> <span class="n">MyDoSomething</span> <span class="n">do_something</span><span class="p">;</span> <span class="p">}</span> <span class="n">MyClass</span><span class="p">;</span> <span class="k">static</span> <span class="kt">void</span> <span class="nf">my_do_something</span><span class="p">(</span><span class="n">MyState</span> <span class="o">*</span><span class="n">obj</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// do something</span> <span class="p">}</span> <span class="k">static</span> <span class="kt">void</span> <span class="nf">my_class_init</span><span class="p">(</span><span class="n">ObjectClass</span> <span class="o">*</span><span class="n">oc</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">data</span><span class="p">)</span> <span class="p">{</span> <span class="n">MyClass</span> <span class="o">*</span><span class="n">mc</span> <span class="o">=</span> <span class="n">MY_CLASS</span><span class="p">(</span><span class="n">oc</span><span class="p">);</span> <span class="n">mc</span><span class="o">-></span><span class="n">do_something</span> <span class="o">=</span> <span class="n">my_do_something</span><span class="p">;</span> <span class="p">}</span> <span class="k">static</span> <span class="k">const</span> <span class="n">TypeInfo</span> <span class="n">my_type_info</span> <span class="o">=</span> <span class="p">{</span> <span class="p">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">TYPE_MY</span><span class="p">,</span> <span class="p">.</span><span class="n">parent</span> <span class="o">=</span> <span class="n">TYPE_OBJECT</span><span class="p">,</span> <span class="p">.</span><span class="n">instance_size</span> <span class="o">=</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">MyState</span><span class="p">),</span> <span class="p">.</span><span class="n">class_size</span> <span class="o">=</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">MyClass</span><span class="p">),</span> <span class="p">.</span><span class="n">class_init</span> <span class="o">=</span> <span class="n">my_class_init</span><span class="p">,</span> <span class="p">};</span> <span class="k">typedef</span> <span class="k">struct</span> <span class="n">DerivedClass</span> <span class="p">{</span> <span class="n">MyClass</span> <span class="n">parent_class</span><span class="p">;</span> <span class="n">MyDoSomething</span> <span class="n">parent_do_something</span><span class="p">;</span> <span class="p">}</span> <span class="n">DerivedClass</span><span class="p">;</span> <span class="k">static</span> <span class="kt">void</span> <span class="nf">derived_do_something</span><span class="p">(</span><span class="n">MyState</span> <span class="o">*</span><span class="n">obj</span><span class="p">)</span> <span class="p">{</span> <span class="n">DerivedClass</span> <span class="o">*</span><span class="n">dc</span> <span class="o">=</span> <span class="n">DERIVED_GET_CLASS</span><span class="p">(</span><span class="n">obj</span><span class="p">);</span> <span class="c1">// do something here</span> <span class="n">dc</span><span class="o">-></span><span class="n">parent_do_something</span><span class="p">(</span><span class="n">obj</span><span class="p">);</span> <span class="c1">// do something else here</span> <span class="p">}</span> <span class="k">static</span> <span class="kt">void</span> <span class="nf">derived_class_init</span><span class="p">(</span><span class="n">ObjectClass</span> <span class="o">*</span><span class="n">oc</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">data</span><span class="p">)</span> <span class="p">{</span> <span class="n">MyClass</span> <span class="o">*</span><span class="n">mc</span> <span class="o">=</span> <span class="n">MY_CLASS</span><span class="p">(</span><span class="n">oc</span><span class="p">);</span> <span class="n">DerivedClass</span> <span class="o">*</span><span class="n">dc</span> <span class="o">=</span> <span class="n">DERIVED_CLASS</span><span class="p">(</span><span class="n">oc</span><span class="p">);</span> <span class="n">dc</span><span class="o">-></span><span class="n">parent_do_something</span> <span class="o">=</span> <span class="n">mc</span><span class="o">-></span><span class="n">do_something</span><span class="p">;</span> <span class="n">mc</span><span class="o">-></span><span class="n">do_something</span> <span class="o">=</span> <span class="n">derived_do_something</span><span class="p">;</span> <span class="p">}</span> <span class="k">static</span> <span class="k">const</span> <span class="n">TypeInfo</span> <span class="n">derived_type_info</span> <span class="o">=</span> <span class="p">{</span> <span class="p">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">TYPE_DERIVED</span><span class="p">,</span> <span class="p">.</span><span class="n">parent</span> <span class="o">=</span> <span class="n">TYPE_MY</span><span class="p">,</span> <span class="p">.</span><span class="n">class_size</span> <span class="o">=</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">DerivedClass</span><span class="p">),</span> <span class="p">.</span><span class="n">class_init</span> <span class="o">=</span> <span class="n">derived_class_init</span><span class="p">,</span> <span class="p">};</span> </pre></div> </div> </div> <p>Alternatively, object_class_by_name() can be used to obtain the class and its non-overridden methods for a specific type. This would correspond to <code class="docutils literal notranslate"><span class="pre">MyClass::method(...)</span></code> in C++.</p> <p>The first example of such a QOM method was #CPUClass.reset, another example is #DeviceClass.realize.</p> </div> <div class="section" id="standard-type-declaration-and-definition-macros"> <h2>Standard type declaration and definition macros<a class="headerlink" href="#standard-type-declaration-and-definition-macros" title="Permalink to this headline">¶</a></h2> <p>A lot of the code outlined above follows a standard pattern and naming convention. To reduce the amount of boilerplate code that needs to be written for a new type there are two sets of macros to generate the common parts in a standard format.</p> <p>A type is declared using the OBJECT_DECLARE macro family. In types which do not require any virtual functions in the class, the OBJECT_DECLARE_SIMPLE_TYPE macro is suitable, and is commonly placed in the header file:</p> <div class="literal-block-wrapper docutils container" id="id6"> <div class="code-block-caption"><span class="caption-text">Declaring a simple type</span><a class="headerlink" href="#id6" title="Permalink to this code">¶</a></div> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">OBJECT_DECLARE_SIMPLE_TYPE</span><span class="p">(</span><span class="n">MyDevice</span><span class="p">,</span> <span class="n">my_device</span><span class="p">,</span> <span class="n">MY_DEVICE</span><span class="p">,</span> <span class="n">DEVICE</span><span class="p">)</span> </pre></div> </div> </div> <p>This is equivalent to the following:</p> <div class="literal-block-wrapper docutils container" id="id7"> <div class="code-block-caption"><span class="caption-text">Expansion from declaring a simple type</span><a class="headerlink" href="#id7" title="Permalink to this code">¶</a></div> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="n">MyDevice</span> <span class="n">MyDevice</span><span class="p">;</span> <span class="k">typedef</span> <span class="k">struct</span> <span class="n">MyDeviceClass</span> <span class="n">MyDeviceClass</span><span class="p">;</span> <span class="n">G_DEFINE_AUTOPTR_CLEANUP_FUNC</span><span class="p">(</span><span class="n">MyDeviceClass</span><span class="p">,</span> <span class="n">object_unref</span><span class="p">)</span> <span class="cp">#define MY_DEVICE_GET_CLASS(void *obj) \</span> <span class="cp"> OBJECT_GET_CLASS(MyDeviceClass, obj, TYPE_MY_DEVICE)</span> <span class="cp">#define MY_DEVICE_CLASS(void *klass) \</span> <span class="cp"> OBJECT_CLASS_CHECK(MyDeviceClass, klass, TYPE_MY_DEVICE)</span> <span class="cp">#define MY_DEVICE(void *obj)</span> <span class="n">OBJECT_CHECK</span><span class="p">(</span><span class="n">MyDevice</span><span class="p">,</span> <span class="n">obj</span><span class="p">,</span> <span class="n">TYPE_MY_DEVICE</span><span class="p">)</span> <span class="k">struct</span> <span class="n">MyDeviceClass</span> <span class="p">{</span> <span class="n">DeviceClass</span> <span class="n">parent_class</span><span class="p">;</span> <span class="p">};</span> </pre></div> </div> </div> <p>The ‘struct MyDevice’ needs to be declared separately. If the type requires virtual functions to be declared in the class struct, then the alternative OBJECT_DECLARE_TYPE() macro can be used. This does the same as OBJECT_DECLARE_SIMPLE_TYPE(), but without the ‘struct MyDeviceClass’ definition.</p> <p>To implement the type, the OBJECT_DEFINE macro family is available. In the simple case the OBJECT_DEFINE_TYPE macro is suitable:</p> <div class="literal-block-wrapper docutils container" id="id8"> <div class="code-block-caption"><span class="caption-text">Defining a simple type</span><a class="headerlink" href="#id8" title="Permalink to this code">¶</a></div> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">OBJECT_DEFINE_TYPE</span><span class="p">(</span><span class="n">MyDevice</span><span class="p">,</span> <span class="n">my_device</span><span class="p">,</span> <span class="n">MY_DEVICE</span><span class="p">,</span> <span class="n">DEVICE</span><span class="p">)</span> </pre></div> </div> </div> <p>This is equivalent to the following:</p> <div class="literal-block-wrapper docutils container" id="id9"> <div class="code-block-caption"><span class="caption-text">Expansion from defining a simple type</span><a class="headerlink" href="#id9" title="Permalink to this code">¶</a></div> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">static</span> <span class="kt">void</span> <span class="nf">my_device_finalize</span><span class="p">(</span><span class="n">Object</span> <span class="o">*</span><span class="n">obj</span><span class="p">);</span> <span class="k">static</span> <span class="kt">void</span> <span class="nf">my_device_class_init</span><span class="p">(</span><span class="n">ObjectClass</span> <span class="o">*</span><span class="n">oc</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">data</span><span class="p">);</span> <span class="k">static</span> <span class="kt">void</span> <span class="nf">my_device_init</span><span class="p">(</span><span class="n">Object</span> <span class="o">*</span><span class="n">obj</span><span class="p">);</span> <span class="k">static</span> <span class="k">const</span> <span class="n">TypeInfo</span> <span class="n">my_device_info</span> <span class="o">=</span> <span class="p">{</span> <span class="p">.</span><span class="n">parent</span> <span class="o">=</span> <span class="n">TYPE_DEVICE</span><span class="p">,</span> <span class="p">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">TYPE_MY_DEVICE</span><span class="p">,</span> <span class="p">.</span><span class="n">instance_size</span> <span class="o">=</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">MyDevice</span><span class="p">),</span> <span class="p">.</span><span class="n">instance_init</span> <span class="o">=</span> <span class="n">my_device_init</span><span class="p">,</span> <span class="p">.</span><span class="n">instance_finalize</span> <span class="o">=</span> <span class="n">my_device_finalize</span><span class="p">,</span> <span class="p">.</span><span class="n">class_size</span> <span class="o">=</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">MyDeviceClass</span><span class="p">),</span> <span class="p">.</span><span class="n">class_init</span> <span class="o">=</span> <span class="n">my_device_class_init</span><span class="p">,</span> <span class="p">};</span> <span class="k">static</span> <span class="kt">void</span> <span class="nf">my_device_register_types</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="p">{</span> <span class="n">type_register_static</span><span class="p">(</span><span class="o">&</span><span class="n">my_device_info</span><span class="p">);</span> <span class="p">}</span> <span class="n">type_init</span><span class="p">(</span><span class="n">my_device_register_types</span><span class="p">);</span> </pre></div> </div> </div> <p>This is sufficient to get the type registered with the type system, and the three standard methods now need to be implemented along with any other logic required for the type.</p> <p>If the type needs to implement one or more interfaces, then the OBJECT_DEFINE_TYPE_WITH_INTERFACES() macro can be used instead. This accepts an array of interface type names.</p> <div class="literal-block-wrapper docutils container" id="id10"> <div class="code-block-caption"><span class="caption-text">Defining a simple type implementing interfaces</span><a class="headerlink" href="#id10" title="Permalink to this code">¶</a></div> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">OBJECT_DEFINE_TYPE_WITH_INTERFACES</span><span class="p">(</span><span class="n">MyDevice</span><span class="p">,</span> <span class="n">my_device</span><span class="p">,</span> <span class="n">MY_DEVICE</span><span class="p">,</span> <span class="n">DEVICE</span><span class="p">,</span> <span class="p">{</span> <span class="n">TYPE_USER_CREATABLE</span> <span class="p">},</span> <span class="p">{</span> <span class="nb">NULL</span> <span class="p">})</span> </pre></div> </div> </div> <p>If the type is not intended to be instantiated, then then the OBJECT_DEFINE_ABSTRACT_TYPE() macro can be used instead:</p> <div class="literal-block-wrapper docutils container" id="id11"> <div class="code-block-caption"><span class="caption-text">Defining a simple abstract type</span><a class="headerlink" href="#id11" title="Permalink to this code">¶</a></div> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">OBJECT_DEFINE_ABSTRACT_TYPE</span><span class="p">(</span><span class="n">MyDevice</span><span class="p">,</span> <span class="n">my_device</span><span class="p">,</span> <span class="n">MY_DEVICE</span><span class="p">,</span> <span class="n">DEVICE</span><span class="p">)</span> </pre></div> </div> </div> <div class="section" id="api-reference"> <h3>API Reference<a class="headerlink" href="#api-reference" title="Permalink to this headline">¶</a></h3> <dl class="type"> <dt id="c.ObjectPropertyAccessor"> <code class="descname">ObjectPropertyAccessor</code><a class="headerlink" href="#c.ObjectPropertyAccessor" title="Permalink to this definition">¶</a></dt> <dd><p><strong>Typedef</strong>:</p> </dd></dl> <p><strong>Syntax</strong></p> <blockquote> <div><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">ObjectPropertyAccessor</span> <span class="pre">(Object</span> <span class="pre">*obj,</span> <span class="pre">Visitor</span> <span class="pre">*v,</span> <span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name,</span> <span class="pre">void</span> <span class="pre">*opaque,</span> <span class="pre">Error</span> <span class="pre">**errp)</span></code></div></blockquote> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object that owns the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Visitor</span> <span class="pre">*v</span></code></dt> <dd>the visitor that contains the property data</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">*opaque</span></code></dt> <dd>the object property opaque</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>a pointer to an Error that is filled if getting/setting fails.</dd> </dl> <p><strong>Description</strong></p> <p>Called when trying to get/set a property.</p> <dl class="type"> <dt id="c.ObjectPropertyResolve"> <code class="descname">ObjectPropertyResolve</code><a class="headerlink" href="#c.ObjectPropertyResolve" title="Permalink to this definition">¶</a></dt> <dd><p><strong>Typedef</strong>:</p> </dd></dl> <p><strong>Syntax</strong></p> <blockquote> <div><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*</span> <span class="pre">ObjectPropertyResolve</span> <span class="pre">(Object</span> <span class="pre">*obj,</span> <span class="pre">void</span> <span class="pre">*opaque,</span> <span class="pre">const</span> <span class="pre">char</span> <span class="pre">*part)</span></code></div></blockquote> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object that owns the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">*opaque</span></code></dt> <dd>the opaque registered with the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*part</span></code></dt> <dd>the name of the property</dd> </dl> <p><strong>Description</strong></p> <p>Resolves the <a class="reference internal" href="#c.Object" title="Object"><code class="xref c c-type docutils literal notranslate"><span class="pre">Object</span></code></a> corresponding to property <strong>part</strong>.</p> <p>The returned object can also be used as a starting point to resolve a relative path starting with “<strong>part</strong>”.</p> <p><strong>Return</strong></p> <p>If <strong>path</strong> is the path that led to <strong>obj</strong>, the function returns the <a class="reference internal" href="#c.Object" title="Object"><code class="xref c c-type docutils literal notranslate"><span class="pre">Object</span></code></a> corresponding to “<strong>path</strong>/<strong>part</strong>”. If “<strong>path</strong>/<strong>part</strong>” is not a valid object path, it returns <code class="xref c c-type docutils literal notranslate"><span class="pre">NULL</span></code>.</p> <dl class="type"> <dt id="c.ObjectPropertyRelease"> <code class="descname">ObjectPropertyRelease</code><a class="headerlink" href="#c.ObjectPropertyRelease" title="Permalink to this definition">¶</a></dt> <dd><p><strong>Typedef</strong>:</p> </dd></dl> <p><strong>Syntax</strong></p> <blockquote> <div><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">ObjectPropertyRelease</span> <span class="pre">(Object</span> <span class="pre">*obj,</span> <span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name,</span> <span class="pre">void</span> <span class="pre">*opaque)</span></code></div></blockquote> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object that owns the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">*opaque</span></code></dt> <dd>the opaque registered with the property</dd> </dl> <p><strong>Description</strong></p> <p>Called when a property is removed from a object.</p> <dl class="type"> <dt id="c.ObjectPropertyInit"> <code class="descname">ObjectPropertyInit</code><a class="headerlink" href="#c.ObjectPropertyInit" title="Permalink to this definition">¶</a></dt> <dd><p><strong>Typedef</strong>:</p> </dd></dl> <p><strong>Syntax</strong></p> <blockquote> <div><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">ObjectPropertyInit</span> <span class="pre">(Object</span> <span class="pre">*obj,</span> <span class="pre">ObjectProperty</span> <span class="pre">*prop)</span></code></div></blockquote> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object that owns the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">ObjectProperty</span> <span class="pre">*prop</span></code></dt> <dd>the property to set</dd> </dl> <p><strong>Description</strong></p> <p>Called when a property is initialized.</p> <dl class="type"> <dt id="c.ObjectUnparent"> <code class="descname">ObjectUnparent</code><a class="headerlink" href="#c.ObjectUnparent" title="Permalink to this definition">¶</a></dt> <dd><p><strong>Typedef</strong>:</p> </dd></dl> <p><strong>Syntax</strong></p> <blockquote> <div><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">ObjectUnparent</span> <span class="pre">(Object</span> <span class="pre">*obj)</span></code></div></blockquote> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object that is being removed from the composition tree</dd> </dl> <p><strong>Description</strong></p> <p>Called when an object is being removed from the QOM composition tree. The function should remove any backlinks from children objects to <strong>obj</strong>.</p> <dl class="type"> <dt id="c.ObjectFree"> <code class="descname">ObjectFree</code><a class="headerlink" href="#c.ObjectFree" title="Permalink to this definition">¶</a></dt> <dd><p><strong>Typedef</strong>:</p> </dd></dl> <p><strong>Syntax</strong></p> <blockquote> <div><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">ObjectFree</span> <span class="pre">(void</span> <span class="pre">*obj)</span></code></div></blockquote> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">*obj</span></code></dt> <dd>the object being freed</dd> </dl> <p><strong>Description</strong></p> <p>Called when an object’s last reference is removed.</p> <dl class="type"> <dt id="c.ObjectClass"> struct <code class="descname">ObjectClass</code><a class="headerlink" href="#c.ObjectClass" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Definition</strong></p> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">struct</span> <span class="n">ObjectClass</span> <span class="p">{</span> <span class="p">};</span> </pre></div> </div> <p><strong>Members</strong></p> <p><strong>Description</strong></p> <p>The base for all classes. The only thing that <a class="reference internal" href="#c.ObjectClass" title="ObjectClass"><code class="xref c c-type docutils literal notranslate"><span class="pre">ObjectClass</span></code></a> contains is an integer type handle.</p> <dl class="type"> <dt id="c.Object"> struct <code class="descname">Object</code><a class="headerlink" href="#c.Object" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Definition</strong></p> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">struct</span> <span class="n">Object</span> <span class="p">{</span> <span class="p">};</span> </pre></div> </div> <p><strong>Members</strong></p> <p><strong>Description</strong></p> <p>The base for all objects. The first member of this object is a pointer to a <a class="reference internal" href="#c.ObjectClass" title="ObjectClass"><code class="xref c c-type docutils literal notranslate"><span class="pre">ObjectClass</span></code></a>. Since C guarantees that the first member of a structure always begins at byte 0 of that structure, as long as any sub-object places its parent as the first member, we can cast directly to a <a class="reference internal" href="#c.Object" title="Object"><code class="xref c c-type docutils literal notranslate"><span class="pre">Object</span></code></a>.</p> <p>As a result, <a class="reference internal" href="#c.Object" title="Object"><code class="xref c c-type docutils literal notranslate"><span class="pre">Object</span></code></a> contains a reference to the objects type as its first member. This allows identification of the real type of the object at run time.</p> <dl class="function"> <dt id="c.DECLARE_INSTANCE_CHECKER"> <code class="descname">DECLARE_INSTANCE_CHECKER</code><span class="sig-paren">(</span>InstanceType, OBJ_NAME, TYPENAME<span class="sig-paren">)</span><a class="headerlink" href="#c.DECLARE_INSTANCE_CHECKER" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">InstanceType</span></code></dt> <dd>instance struct name</dd> <dt><code class="docutils literal notranslate"><span class="pre">OBJ_NAME</span></code></dt> <dd>the object name in uppercase with underscore separators</dd> <dt><code class="docutils literal notranslate"><span class="pre">TYPENAME</span></code></dt> <dd>type name</dd> </dl> <p><strong>Description</strong></p> <p>Direct usage of this macro should be avoided, and the complete OBJECT_DECLARE_TYPE macro is recommended instead.</p> <p>This macro will provide the instance type cast functions for a QOM type.</p> <dl class="function"> <dt id="c.DECLARE_CLASS_CHECKERS"> <code class="descname">DECLARE_CLASS_CHECKERS</code><span class="sig-paren">(</span>ClassType, OBJ_NAME, TYPENAME<span class="sig-paren">)</span><a class="headerlink" href="#c.DECLARE_CLASS_CHECKERS" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ClassType</span></code></dt> <dd>class struct name</dd> <dt><code class="docutils literal notranslate"><span class="pre">OBJ_NAME</span></code></dt> <dd>the object name in uppercase with underscore separators</dd> <dt><code class="docutils literal notranslate"><span class="pre">TYPENAME</span></code></dt> <dd>type name</dd> </dl> <p><strong>Description</strong></p> <p>Direct usage of this macro should be avoided, and the complete OBJECT_DECLARE_TYPE macro is recommended instead.</p> <p>This macro will provide the class type cast functions for a QOM type.</p> <dl class="function"> <dt id="c.DECLARE_OBJ_CHECKERS"> <code class="descname">DECLARE_OBJ_CHECKERS</code><span class="sig-paren">(</span>InstanceType, ClassType, OBJ_NAME, TYPENAME<span class="sig-paren">)</span><a class="headerlink" href="#c.DECLARE_OBJ_CHECKERS" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">InstanceType</span></code></dt> <dd>instance struct name</dd> <dt><code class="docutils literal notranslate"><span class="pre">ClassType</span></code></dt> <dd>class struct name</dd> <dt><code class="docutils literal notranslate"><span class="pre">OBJ_NAME</span></code></dt> <dd>the object name in uppercase with underscore separators</dd> <dt><code class="docutils literal notranslate"><span class="pre">TYPENAME</span></code></dt> <dd>type name</dd> </dl> <p><strong>Description</strong></p> <p>Direct usage of this macro should be avoided, and the complete OBJECT_DECLARE_TYPE macro is recommended instead.</p> <p>This macro will provide the three standard type cast functions for a QOM type.</p> <dl class="function"> <dt id="c.OBJECT_DECLARE_TYPE"> <code class="descname">OBJECT_DECLARE_TYPE</code><span class="sig-paren">(</span>InstanceType, ClassType, MODULE_OBJ_NAME<span class="sig-paren">)</span><a class="headerlink" href="#c.OBJECT_DECLARE_TYPE" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">InstanceType</span></code></dt> <dd>instance struct name</dd> <dt><code class="docutils literal notranslate"><span class="pre">ClassType</span></code></dt> <dd>class struct name</dd> <dt><code class="docutils literal notranslate"><span class="pre">MODULE_OBJ_NAME</span></code></dt> <dd>the object name in uppercase with underscore separators</dd> </dl> <p><strong>Description</strong></p> <p>This macro is typically used in a header file, and will:</p> <blockquote> <div><ul class="simple"> <li>create the typedefs for the object and class structs</li> <li>register the type for use with g_autoptr</li> <li>provide three standard type cast functions</li> </ul> </div></blockquote> <p>The object struct and class struct need to be declared manually.</p> <dl class="function"> <dt id="c.OBJECT_DECLARE_SIMPLE_TYPE"> <code class="descname">OBJECT_DECLARE_SIMPLE_TYPE</code><span class="sig-paren">(</span>InstanceType, MODULE_OBJ_NAME<span class="sig-paren">)</span><a class="headerlink" href="#c.OBJECT_DECLARE_SIMPLE_TYPE" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">InstanceType</span></code></dt> <dd>instance struct name</dd> <dt><code class="docutils literal notranslate"><span class="pre">MODULE_OBJ_NAME</span></code></dt> <dd>the object name in uppercase with underscore separators</dd> </dl> <p><strong>Description</strong></p> <p>This does the same as OBJECT_DECLARE_TYPE(), but with no class struct declared.</p> <p>This macro should be used unless the class struct needs to have virtual methods declared.</p> <dl class="function"> <dt id="c.OBJECT_DEFINE_TYPE_EXTENDED"> <code class="descname">OBJECT_DEFINE_TYPE_EXTENDED</code><span class="sig-paren">(</span>ModuleObjName, module_obj_name, MODULE_OBJ_NAME, PARENT_MODULE_OBJ_NAME, ABSTRACT, ...<span class="sig-paren">)</span><a class="headerlink" href="#c.OBJECT_DEFINE_TYPE_EXTENDED" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ModuleObjName</span></code></dt> <dd>the object name with initial caps</dd> <dt><code class="docutils literal notranslate"><span class="pre">module_obj_name</span></code></dt> <dd>the object name in lowercase with underscore separators</dd> <dt><code class="docutils literal notranslate"><span class="pre">MODULE_OBJ_NAME</span></code></dt> <dd>the object name in uppercase with underscore separators</dd> <dt><code class="docutils literal notranslate"><span class="pre">PARENT_MODULE_OBJ_NAME</span></code></dt> <dd>the parent object name in uppercase with underscore separators</dd> <dt><code class="docutils literal notranslate"><span class="pre">ABSTRACT</span></code></dt> <dd>boolean flag to indicate whether the object can be instantiated</dd> <dt><code class="docutils literal notranslate"><span class="pre">...</span></code></dt> <dd>list of initializers for “InterfaceInfo” to declare implemented interfaces</dd> </dl> <p><strong>Description</strong></p> <p>This macro is typically used in a source file, and will:</p> <blockquote> <div><ul class="simple"> <li>declare prototypes for _finalize, _class_init and _init methods</li> <li>declare the TypeInfo struct instance</li> <li>provide the constructor to register the type</li> </ul> </div></blockquote> <p>After using this macro, implementations of the _finalize, _class_init, and _init methods need to be written. Any of these can be zero-line no-op impls if no special logic is required for a given type.</p> <p>This macro should rarely be used, instead one of the more specialized macros is usually a better choice.</p> <dl class="function"> <dt id="c.OBJECT_DEFINE_TYPE"> <code class="descname">OBJECT_DEFINE_TYPE</code><span class="sig-paren">(</span>ModuleObjName, module_obj_name, MODULE_OBJ_NAME, PARENT_MODULE_OBJ_NAME<span class="sig-paren">)</span><a class="headerlink" href="#c.OBJECT_DEFINE_TYPE" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ModuleObjName</span></code></dt> <dd>the object name with initial caps</dd> <dt><code class="docutils literal notranslate"><span class="pre">module_obj_name</span></code></dt> <dd>the object name in lowercase with underscore separators</dd> <dt><code class="docutils literal notranslate"><span class="pre">MODULE_OBJ_NAME</span></code></dt> <dd>the object name in uppercase with underscore separators</dd> <dt><code class="docutils literal notranslate"><span class="pre">PARENT_MODULE_OBJ_NAME</span></code></dt> <dd>the parent object name in uppercase with underscore separators</dd> </dl> <p><strong>Description</strong></p> <p>This is a specialization of OBJECT_DEFINE_TYPE_EXTENDED, which is suitable for the common case of a non-abstract type, without any interfaces.</p> <dl class="function"> <dt id="c.OBJECT_DEFINE_TYPE_WITH_INTERFACES"> <code class="descname">OBJECT_DEFINE_TYPE_WITH_INTERFACES</code><span class="sig-paren">(</span>ModuleObjName, module_obj_name, MODULE_OBJ_NAME, PARENT_MODULE_OBJ_NAME, ...<span class="sig-paren">)</span><a class="headerlink" href="#c.OBJECT_DEFINE_TYPE_WITH_INTERFACES" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ModuleObjName</span></code></dt> <dd>the object name with initial caps</dd> <dt><code class="docutils literal notranslate"><span class="pre">module_obj_name</span></code></dt> <dd>the object name in lowercase with underscore separators</dd> <dt><code class="docutils literal notranslate"><span class="pre">MODULE_OBJ_NAME</span></code></dt> <dd>the object name in uppercase with underscore separators</dd> <dt><code class="docutils literal notranslate"><span class="pre">PARENT_MODULE_OBJ_NAME</span></code></dt> <dd>the parent object name in uppercase with underscore separators</dd> <dt><code class="docutils literal notranslate"><span class="pre">...</span></code></dt> <dd>list of initializers for “InterfaceInfo” to declare implemented interfaces</dd> </dl> <p><strong>Description</strong></p> <p>This is a specialization of OBJECT_DEFINE_TYPE_EXTENDED, which is suitable for the common case of a non-abstract type, with one or more implemented interfaces.</p> <p>Note when passing the list of interfaces, be sure to include the final NULL entry, e.g. { TYPE_USER_CREATABLE }, { NULL }</p> <dl class="function"> <dt id="c.OBJECT_DEFINE_ABSTRACT_TYPE"> <code class="descname">OBJECT_DEFINE_ABSTRACT_TYPE</code><span class="sig-paren">(</span>ModuleObjName, module_obj_name, MODULE_OBJ_NAME, PARENT_MODULE_OBJ_NAME<span class="sig-paren">)</span><a class="headerlink" href="#c.OBJECT_DEFINE_ABSTRACT_TYPE" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ModuleObjName</span></code></dt> <dd>the object name with initial caps</dd> <dt><code class="docutils literal notranslate"><span class="pre">module_obj_name</span></code></dt> <dd>the object name in lowercase with underscore separators</dd> <dt><code class="docutils literal notranslate"><span class="pre">MODULE_OBJ_NAME</span></code></dt> <dd>the object name in uppercase with underscore separators</dd> <dt><code class="docutils literal notranslate"><span class="pre">PARENT_MODULE_OBJ_NAME</span></code></dt> <dd>the parent object name in uppercase with underscore separators</dd> </dl> <p><strong>Description</strong></p> <p>This is a specialization of OBJECT_DEFINE_TYPE_EXTENDED, which is suitable for defining an abstract type, without any interfaces.</p> <dl class="type"> <dt id="c.TypeInfo"> struct <code class="descname">TypeInfo</code><a class="headerlink" href="#c.TypeInfo" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Definition</strong></p> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">struct</span> <span class="n">TypeInfo</span> <span class="p">{</span> <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">name</span><span class="p">;</span> <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">parent</span><span class="p">;</span> <span class="kt">size_t</span> <span class="n">instance_size</span><span class="p">;</span> <span class="kt">size_t</span> <span class="n">instance_align</span><span class="p">;</span> <span class="kt">void</span> <span class="p">(</span><span class="o">*</span><span class="n">instance_init</span><span class="p">)(</span><span class="n">Object</span> <span class="o">*</span><span class="n">obj</span><span class="p">);</span> <span class="kt">void</span> <span class="p">(</span><span class="o">*</span><span class="n">instance_post_init</span><span class="p">)(</span><span class="n">Object</span> <span class="o">*</span><span class="n">obj</span><span class="p">);</span> <span class="kt">void</span> <span class="p">(</span><span class="o">*</span><span class="n">instance_finalize</span><span class="p">)(</span><span class="n">Object</span> <span class="o">*</span><span class="n">obj</span><span class="p">);</span> <span class="kt">bool</span> <span class="n">abstract</span><span class="p">;</span> <span class="kt">size_t</span> <span class="n">class_size</span><span class="p">;</span> <span class="kt">void</span> <span class="p">(</span><span class="o">*</span><span class="n">class_init</span><span class="p">)(</span><span class="n">ObjectClass</span> <span class="o">*</span><span class="n">klass</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">data</span><span class="p">);</span> <span class="kt">void</span> <span class="p">(</span><span class="o">*</span><span class="n">class_base_init</span><span class="p">)(</span><span class="n">ObjectClass</span> <span class="o">*</span><span class="n">klass</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">data</span><span class="p">);</span> <span class="kt">void</span> <span class="o">*</span><span class="n">class_data</span><span class="p">;</span> <span class="n">InterfaceInfo</span> <span class="o">*</span><span class="n">interfaces</span><span class="p">;</span> <span class="p">};</span> </pre></div> </div> <p><strong>Members</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">name</span></code></dt> <dd>The name of the type.</dd> <dt><code class="docutils literal notranslate"><span class="pre">parent</span></code></dt> <dd>The name of the parent type.</dd> <dt><code class="docutils literal notranslate"><span class="pre">instance_size</span></code></dt> <dd>The size of the object (derivative of <a class="reference internal" href="#c.Object" title="Object"><code class="xref c c-type docutils literal notranslate"><span class="pre">Object</span></code></a>). If <strong>instance_size</strong> is 0, then the size of the object will be the size of the parent object.</dd> <dt><code class="docutils literal notranslate"><span class="pre">instance_align</span></code></dt> <dd>The required alignment of the object. If <strong>instance_align</strong> is 0, then normal malloc alignment is sufficient; if non-zero, then we must use qemu_memalign for allocation.</dd> <dt><code class="docutils literal notranslate"><span class="pre">instance_init</span></code></dt> <dd>This function is called to initialize an object. The parent class will have already been initialized so the type is only responsible for initializing its own members.</dd> <dt><code class="docutils literal notranslate"><span class="pre">instance_post_init</span></code></dt> <dd>This function is called to finish initialization of an object, after all <strong>instance_init</strong> functions were called.</dd> <dt><code class="docutils literal notranslate"><span class="pre">instance_finalize</span></code></dt> <dd>This function is called during object destruction. This is called before the parent <strong>instance_finalize</strong> function has been called. An object should only free the members that are unique to its type in this function.</dd> <dt><code class="docutils literal notranslate"><span class="pre">abstract</span></code></dt> <dd>If this field is true, then the class is considered abstract and cannot be directly instantiated.</dd> <dt><code class="docutils literal notranslate"><span class="pre">class_size</span></code></dt> <dd>The size of the class object (derivative of <a class="reference internal" href="#c.ObjectClass" title="ObjectClass"><code class="xref c c-type docutils literal notranslate"><span class="pre">ObjectClass</span></code></a>) for this object. If <strong>class_size</strong> is 0, then the size of the class will be assumed to be the size of the parent class. This allows a type to avoid implementing an explicit class type if they are not adding additional virtual functions.</dd> <dt><code class="docutils literal notranslate"><span class="pre">class_init</span></code></dt> <dd>This function is called after all parent class initialization has occurred to allow a class to set its default virtual method pointers. This is also the function to use to override virtual methods from a parent class.</dd> <dt><code class="docutils literal notranslate"><span class="pre">class_base_init</span></code></dt> <dd>This function is called for all base classes after all parent class initialization has occurred, but before the class itself is initialized. This is the function to use to undo the effects of memcpy from the parent class to the descendants.</dd> <dt><code class="docutils literal notranslate"><span class="pre">class_data</span></code></dt> <dd>Data to pass to the <strong>class_init</strong>, <strong>class_base_init</strong>. This can be useful when building dynamic classes.</dd> <dt><code class="docutils literal notranslate"><span class="pre">interfaces</span></code></dt> <dd>The list of interfaces associated with this type. This should point to a static array that’s terminated with a zero filled element.</dd> </dl> <dl class="function"> <dt id="c.OBJECT"> <code class="descname">OBJECT</code><span class="sig-paren">(</span>obj<span class="sig-paren">)</span><a class="headerlink" href="#c.OBJECT" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">obj</span></code></dt> <dd>A derivative of <a class="reference internal" href="#c.Object" title="Object"><code class="xref c c-type docutils literal notranslate"><span class="pre">Object</span></code></a></dd> </dl> <p><strong>Description</strong></p> <p>Converts an object to a <a class="reference internal" href="#c.Object" title="Object"><code class="xref c c-type docutils literal notranslate"><span class="pre">Object</span></code></a>. Since all objects are <code class="xref c c-type docutils literal notranslate"><span class="pre">Objects</span></code>, this function will always succeed.</p> <dl class="function"> <dt id="c.OBJECT_CLASS"> <code class="descname">OBJECT_CLASS</code><span class="sig-paren">(</span>class<span class="sig-paren">)</span><a class="headerlink" href="#c.OBJECT_CLASS" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">class</span></code></dt> <dd>A derivative of <a class="reference internal" href="#c.ObjectClass" title="ObjectClass"><code class="xref c c-type docutils literal notranslate"><span class="pre">ObjectClass</span></code></a>.</dd> </dl> <p><strong>Description</strong></p> <p>Converts a class to an <a class="reference internal" href="#c.ObjectClass" title="ObjectClass"><code class="xref c c-type docutils literal notranslate"><span class="pre">ObjectClass</span></code></a>. Since all objects are <code class="xref c c-type docutils literal notranslate"><span class="pre">Objects</span></code>, this function will always succeed.</p> <dl class="function"> <dt id="c.OBJECT_CHECK"> <code class="descname">OBJECT_CHECK</code><span class="sig-paren">(</span>type, obj, name<span class="sig-paren">)</span><a class="headerlink" href="#c.OBJECT_CHECK" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">type</span></code></dt> <dd>The C type to use for the return value.</dd> <dt><code class="docutils literal notranslate"><span class="pre">obj</span></code></dt> <dd>A derivative of <strong>type</strong> to cast.</dd> <dt><code class="docutils literal notranslate"><span class="pre">name</span></code></dt> <dd>The QOM typename of <strong>type</strong></dd> </dl> <p><strong>Description</strong></p> <p>A type safe version of <strong>object_dynamic_cast_assert</strong>. Typically each class will define a macro based on this type to perform type safe dynamic_casts to this object type.</p> <p>If an invalid object is passed to this function, a run time assert will be generated.</p> <dl class="function"> <dt id="c.OBJECT_CLASS_CHECK"> <code class="descname">OBJECT_CLASS_CHECK</code><span class="sig-paren">(</span>class_type, class, name<span class="sig-paren">)</span><a class="headerlink" href="#c.OBJECT_CLASS_CHECK" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">class_type</span></code></dt> <dd>The C type to use for the return value.</dd> <dt><code class="docutils literal notranslate"><span class="pre">class</span></code></dt> <dd>A derivative class of <strong>class_type</strong> to cast.</dd> <dt><code class="docutils literal notranslate"><span class="pre">name</span></code></dt> <dd>the QOM typename of <strong>class_type</strong>.</dd> </dl> <p><strong>Description</strong></p> <p>A type safe version of <strong>object_class_dynamic_cast_assert</strong>. This macro is typically wrapped by each type to perform type safe casts of a class to a specific class type.</p> <dl class="function"> <dt id="c.OBJECT_GET_CLASS"> <code class="descname">OBJECT_GET_CLASS</code><span class="sig-paren">(</span>class, obj, name<span class="sig-paren">)</span><a class="headerlink" href="#c.OBJECT_GET_CLASS" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">class</span></code></dt> <dd>The C type to use for the return value.</dd> <dt><code class="docutils literal notranslate"><span class="pre">obj</span></code></dt> <dd>The object to obtain the class for.</dd> <dt><code class="docutils literal notranslate"><span class="pre">name</span></code></dt> <dd>The QOM typename of <strong>obj</strong>.</dd> </dl> <p><strong>Description</strong></p> <p>This function will return a specific class for a given object. Its generally used by each type to provide a type safe macro to get a specific class type from an object.</p> <dl class="type"> <dt id="c.InterfaceInfo"> struct <code class="descname">InterfaceInfo</code><a class="headerlink" href="#c.InterfaceInfo" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Definition</strong></p> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">struct</span> <span class="n">InterfaceInfo</span> <span class="p">{</span> <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">type</span><span class="p">;</span> <span class="p">};</span> </pre></div> </div> <p><strong>Members</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">type</span></code></dt> <dd>The name of the interface.</dd> </dl> <p><strong>Description</strong></p> <p>The information associated with an interface.</p> <dl class="type"> <dt id="c.InterfaceClass"> struct <code class="descname">InterfaceClass</code><a class="headerlink" href="#c.InterfaceClass" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Definition</strong></p> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">struct</span> <span class="n">InterfaceClass</span> <span class="p">{</span> <span class="n">ObjectClass</span> <span class="n">parent_class</span><span class="p">;</span> <span class="p">};</span> </pre></div> </div> <p><strong>Members</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">parent_class</span></code></dt> <dd>the base class</dd> </dl> <p><strong>Description</strong></p> <p>The class for all interfaces. Subclasses of this class should only add virtual methods.</p> <dl class="function"> <dt id="c.INTERFACE_CLASS"> <code class="descname">INTERFACE_CLASS</code><span class="sig-paren">(</span>klass<span class="sig-paren">)</span><a class="headerlink" href="#c.INTERFACE_CLASS" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">klass</span></code></dt> <dd>class to cast from</dd> </dl> <p><strong>Return</strong></p> <p>An <a class="reference internal" href="#c.InterfaceClass" title="InterfaceClass"><code class="xref c c-type docutils literal notranslate"><span class="pre">InterfaceClass</span></code></a> or raise an error if cast is invalid</p> <dl class="function"> <dt id="c.INTERFACE_CHECK"> <code class="descname">INTERFACE_CHECK</code><span class="sig-paren">(</span>interface, obj, name<span class="sig-paren">)</span><a class="headerlink" href="#c.INTERFACE_CHECK" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">interface</span></code></dt> <dd>the type to return</dd> <dt><code class="docutils literal notranslate"><span class="pre">obj</span></code></dt> <dd>the object to convert to an interface</dd> <dt><code class="docutils literal notranslate"><span class="pre">name</span></code></dt> <dd>the interface type name</dd> </dl> <p><strong>Return</strong></p> <p><strong>obj</strong> casted to <strong>interface</strong> if cast is valid, otherwise raise error.</p> <dl class="function"> <dt id="c.object_new_with_class"> <a class="reference internal" href="#c.Object" title="Object">Object</a> * <code class="descname">object_new_with_class</code><span class="sig-paren">(</span><a class="reference internal" href="#c.ObjectClass" title="ObjectClass">ObjectClass</a><em> *klass</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_new_with_class" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ObjectClass</span> <span class="pre">*klass</span></code></dt> <dd>The class to instantiate.</dd> </dl> <p><strong>Description</strong></p> <p>This function will initialize a new object using heap allocated memory. The returned object has a reference count of 1, and will be freed when the last reference is dropped.</p> <p><strong>Return</strong></p> <p>The newly allocated and instantiated object.</p> <dl class="function"> <dt id="c.object_new"> <a class="reference internal" href="#c.Object" title="Object">Object</a> * <code class="descname">object_new</code><span class="sig-paren">(</span>const char<em> *typename</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_new" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*typename</span></code></dt> <dd>The name of the type of the object to instantiate.</dd> </dl> <p><strong>Description</strong></p> <p>This function will initialize a new object using heap allocated memory. The returned object has a reference count of 1, and will be freed when the last reference is dropped.</p> <p><strong>Return</strong></p> <p>The newly allocated and instantiated object.</p> <dl class="function"> <dt id="c.object_new_with_props"> <a class="reference internal" href="#c.Object" title="Object">Object</a> * <code class="descname">object_new_with_props</code><span class="sig-paren">(</span>const char<em> *typename</em>, <a class="reference internal" href="#c.Object" title="Object">Object</a><em> *parent</em>, const char<em> *id</em>, Error<em> **errp</em>, ...<span class="sig-paren">)</span><a class="headerlink" href="#c.object_new_with_props" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*typename</span></code></dt> <dd>The name of the type of the object to instantiate.</dd> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*parent</span></code></dt> <dd>the parent object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*id</span></code></dt> <dd>The unique ID of the object</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>pointer to error object</dd> <dt><code class="docutils literal notranslate"><span class="pre">...</span></code></dt> <dd>list of property names and values</dd> </dl> <p><strong>Description</strong></p> <p>This function will initialize a new object using heap allocated memory. The returned object has a reference count of 1, and will be freed when the last reference is dropped.</p> <p>The <strong>id</strong> parameter will be used when registering the object as a child of <strong>parent</strong> in the composition tree.</p> <p>The variadic parameters are a list of pairs of (propname, propvalue) strings. The propname of <code class="docutils literal notranslate"><span class="pre">NULL</span></code> indicates the end of the property list. If the object implements the user creatable interface, the object will be marked complete once all the properties have been processed.</p> <div class="literal-block-wrapper docutils container" id="id12"> <div class="code-block-caption"><span class="caption-text">Creating an object with properties</span><a class="headerlink" href="#id12" title="Permalink to this code">¶</a></div> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span> <span class="n">Error</span> <span class="o">*</span><span class="n">err</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span> <span class="n">Object</span> <span class="o">*</span><span class="n">obj</span><span class="p">;</span> <span class="n">obj</span> <span class="o">=</span> <span class="n">object_new_with_props</span><span class="p">(</span><span class="n">TYPE_MEMORY_BACKEND_FILE</span><span class="p">,</span> <span class="n">object_get_objects_root</span><span class="p">(),</span> <span class="s">"hostmem0"</span><span class="p">,</span> <span class="o">&</span><span class="n">err</span><span class="p">,</span> <span class="s">"share"</span><span class="p">,</span> <span class="s">"yes"</span><span class="p">,</span> <span class="s">"mem-path"</span><span class="p">,</span> <span class="s">"/dev/shm/somefile"</span><span class="p">,</span> <span class="s">"prealloc"</span><span class="p">,</span> <span class="s">"yes"</span><span class="p">,</span> <span class="s">"size"</span><span class="p">,</span> <span class="s">"1048576"</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">);</span> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">obj</span><span class="p">)</span> <span class="p">{</span> <span class="n">error_reportf_err</span><span class="p">(</span><span class="n">err</span><span class="p">,</span> <span class="s">"Cannot create memory backend: "</span><span class="p">);</span> <span class="p">}</span> </pre></div> </div> </div> <p>The returned object will have one stable reference maintained for as long as it is present in the object hierarchy.</p> <p><strong>Return</strong></p> <p>The newly allocated, instantiated & initialized object.</p> <dl class="function"> <dt id="c.object_new_with_propv"> <a class="reference internal" href="#c.Object" title="Object">Object</a> * <code class="descname">object_new_with_propv</code><span class="sig-paren">(</span>const char<em> *typename</em>, <a class="reference internal" href="#c.Object" title="Object">Object</a><em> *parent</em>, const char<em> *id</em>, Error<em> **errp</em>, va_list<em> vargs</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_new_with_propv" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*typename</span></code></dt> <dd>The name of the type of the object to instantiate.</dd> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*parent</span></code></dt> <dd>the parent object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*id</span></code></dt> <dd>The unique ID of the object</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>pointer to error object</dd> <dt><code class="docutils literal notranslate"><span class="pre">va_list</span> <span class="pre">vargs</span></code></dt> <dd>list of property names and values</dd> </dl> <p><strong>Description</strong></p> <p>See object_new_with_props() for documentation.</p> <dl class="function"> <dt id="c.object_set_props"> bool <code class="descname">object_set_props</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, Error<em> **errp</em>, ...<span class="sig-paren">)</span><a class="headerlink" href="#c.object_set_props" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object instance to set properties on</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>pointer to error object</dd> <dt><code class="docutils literal notranslate"><span class="pre">...</span></code></dt> <dd>list of property names and values</dd> </dl> <p><strong>Description</strong></p> <p>This function will set a list of properties on an existing object instance.</p> <p>The variadic parameters are a list of pairs of (propname, propvalue) strings. The propname of <code class="docutils literal notranslate"><span class="pre">NULL</span></code> indicates the end of the property list.</p> <div class="literal-block-wrapper docutils container" id="id13"> <div class="code-block-caption"><span class="caption-text">Update an object’s properties</span><a class="headerlink" href="#id13" title="Permalink to this code">¶</a></div> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span> <span class="n">Error</span> <span class="o">*</span><span class="n">err</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span> <span class="n">Object</span> <span class="o">*</span><span class="n">obj</span> <span class="o">=</span> <span class="p">...</span><span class="n">get</span> <span class="o">/</span> <span class="n">create</span> <span class="n">object</span><span class="p">...;</span> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">object_set_props</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="o">&</span><span class="n">err</span><span class="p">,</span> <span class="s">"share"</span><span class="p">,</span> <span class="s">"yes"</span><span class="p">,</span> <span class="s">"mem-path"</span><span class="p">,</span> <span class="s">"/dev/shm/somefile"</span><span class="p">,</span> <span class="s">"prealloc"</span><span class="p">,</span> <span class="s">"yes"</span><span class="p">,</span> <span class="s">"size"</span><span class="p">,</span> <span class="s">"1048576"</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">))</span> <span class="p">{</span> <span class="n">error_reportf_err</span><span class="p">(</span><span class="n">err</span><span class="p">,</span> <span class="s">"Cannot set properties: "</span><span class="p">);</span> <span class="p">}</span> </pre></div> </div> </div> <p>The returned object will have one stable reference maintained for as long as it is present in the object hierarchy.</p> <p><strong>Return</strong></p> <p><code class="docutils literal notranslate"><span class="pre">true</span></code> on success, <code class="docutils literal notranslate"><span class="pre">false</span></code> on error.</p> <dl class="function"> <dt id="c.object_set_propv"> bool <code class="descname">object_set_propv</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, Error<em> **errp</em>, va_list<em> vargs</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_set_propv" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object instance to set properties on</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>pointer to error object</dd> <dt><code class="docutils literal notranslate"><span class="pre">va_list</span> <span class="pre">vargs</span></code></dt> <dd>list of property names and values</dd> </dl> <p><strong>Description</strong></p> <p>See object_set_props() for documentation.</p> <p><strong>Return</strong></p> <p><code class="docutils literal notranslate"><span class="pre">true</span></code> on success, <code class="docutils literal notranslate"><span class="pre">false</span></code> on error.</p> <dl class="function"> <dt id="c.object_initialize"> void <code class="descname">object_initialize</code><span class="sig-paren">(</span>void<em> *obj</em>, size_t<em> size</em>, const char<em> *typename</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_initialize" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">*obj</span></code></dt> <dd>A pointer to the memory to be used for the object.</dd> <dt><code class="docutils literal notranslate"><span class="pre">size_t</span> <span class="pre">size</span></code></dt> <dd>The maximum size available at <strong>obj</strong> for the object.</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*typename</span></code></dt> <dd>The name of the type of the object to instantiate.</dd> </dl> <p><strong>Description</strong></p> <p>This function will initialize an object. The memory for the object should have already been allocated. The returned object has a reference count of 1, and will be finalized when the last reference is dropped.</p> <dl class="function"> <dt id="c.object_initialize_child_with_props"> bool <code class="descname">object_initialize_child_with_props</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *parentobj</em>, const char<em> *propname</em>, void<em> *childobj</em>, size_t<em> size</em>, const char<em> *type</em>, Error<em> **errp</em>, ...<span class="sig-paren">)</span><a class="headerlink" href="#c.object_initialize_child_with_props" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*parentobj</span></code></dt> <dd>The parent object to add a property to</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*propname</span></code></dt> <dd>The name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">*childobj</span></code></dt> <dd>A pointer to the memory to be used for the object.</dd> <dt><code class="docutils literal notranslate"><span class="pre">size_t</span> <span class="pre">size</span></code></dt> <dd>The maximum size available at <strong>childobj</strong> for the object.</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*type</span></code></dt> <dd>The name of the type of the object to instantiate.</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>If an error occurs, a pointer to an area to store the error</dd> <dt><code class="docutils literal notranslate"><span class="pre">...</span></code></dt> <dd>list of property names and values</dd> </dl> <p><strong>Description</strong></p> <p>This function will initialize an object. The memory for the object should have already been allocated. The object will then be added as child property to a parent with object_property_add_child() function. The returned object has a reference count of 1 (for the “child<…>” property from the parent), so the object will be finalized automatically when the parent gets removed.</p> <p>The variadic parameters are a list of pairs of (propname, propvalue) strings. The propname of <code class="docutils literal notranslate"><span class="pre">NULL</span></code> indicates the end of the property list. If the object implements the user creatable interface, the object will be marked complete once all the properties have been processed.</p> <p><strong>Return</strong></p> <p><code class="docutils literal notranslate"><span class="pre">true</span></code> on success, <code class="docutils literal notranslate"><span class="pre">false</span></code> on failure.</p> <dl class="function"> <dt id="c.object_initialize_child_with_propsv"> bool <code class="descname">object_initialize_child_with_propsv</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *parentobj</em>, const char<em> *propname</em>, void<em> *childobj</em>, size_t<em> size</em>, const char<em> *type</em>, Error<em> **errp</em>, va_list<em> vargs</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_initialize_child_with_propsv" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*parentobj</span></code></dt> <dd>The parent object to add a property to</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*propname</span></code></dt> <dd>The name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">*childobj</span></code></dt> <dd>A pointer to the memory to be used for the object.</dd> <dt><code class="docutils literal notranslate"><span class="pre">size_t</span> <span class="pre">size</span></code></dt> <dd>The maximum size available at <strong>childobj</strong> for the object.</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*type</span></code></dt> <dd>The name of the type of the object to instantiate.</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>If an error occurs, a pointer to an area to store the error</dd> <dt><code class="docutils literal notranslate"><span class="pre">va_list</span> <span class="pre">vargs</span></code></dt> <dd>list of property names and values</dd> </dl> <p><strong>Description</strong></p> <p>See object_initialize_child() for documentation.</p> <p><strong>Return</strong></p> <p><code class="docutils literal notranslate"><span class="pre">true</span></code> on success, <code class="docutils literal notranslate"><span class="pre">false</span></code> on failure.</p> <dl class="function"> <dt id="c.object_initialize_child"> <code class="descname">object_initialize_child</code><span class="sig-paren">(</span>parent, propname, child, type<span class="sig-paren">)</span><a class="headerlink" href="#c.object_initialize_child" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">parent</span></code></dt> <dd>The parent object to add a property to</dd> <dt><code class="docutils literal notranslate"><span class="pre">propname</span></code></dt> <dd>The name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">child</span></code></dt> <dd>A precisely typed pointer to the memory to be used for the object.</dd> <dt><code class="docutils literal notranslate"><span class="pre">type</span></code></dt> <dd>The name of the type of the object to instantiate.</dd> </dl> <p><strong>Description</strong></p> <p>This is like:</p> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">object_initialize_child_with_props</span><span class="p">(</span><span class="n">parent</span><span class="p">,</span> <span class="n">propname</span><span class="p">,</span> <span class="n">child</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="o">*</span><span class="n">child</span><span class="p">),</span> <span class="n">type</span><span class="p">,</span> <span class="o">&</span><span class="n">error_abort</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">)</span> </pre></div> </div> <dl class="function"> <dt id="c.object_dynamic_cast"> <a class="reference internal" href="#c.Object" title="Object">Object</a> * <code class="descname">object_dynamic_cast</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *typename</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_dynamic_cast" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>The object to cast.</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*typename</span></code></dt> <dd>The <strong>typename</strong> to cast to.</dd> </dl> <p><strong>Description</strong></p> <p>This function will determine if <strong>obj</strong> is-a <strong>typename</strong>. <strong>obj</strong> can refer to an object or an interface associated with an object.</p> <p><strong>Return</strong></p> <p>This function returns <strong>obj</strong> on success or <code class="xref c c-type docutils literal notranslate"><span class="pre">NULL</span></code> on failure.</p> <dl class="function"> <dt id="c.object_dynamic_cast_assert"> <a class="reference internal" href="#c.Object" title="Object">Object</a> * <code class="descname">object_dynamic_cast_assert</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *typename</em>, const char<em> *file</em>, int<em> line</em>, const char<em> *func</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_dynamic_cast_assert" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>The object to cast.</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*typename</span></code></dt> <dd>The <strong>typename</strong> to cast to.</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*file</span></code></dt> <dd>Source code file where function was called</dd> <dt><code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">line</span></code></dt> <dd>Source code line where function was called</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*func</span></code></dt> <dd>Name of function where this function was called</dd> </dl> <p><strong>Description</strong></p> <p>See object_dynamic_cast() for a description of the parameters of this function. The only difference in behavior is that this function asserts instead of returning <code class="xref c c-type docutils literal notranslate"><span class="pre">NULL</span></code> on failure if QOM cast debugging is enabled. This function is not meant to be called directly, but only through the wrapper macro OBJECT_CHECK.</p> <dl class="function"> <dt id="c.object_get_class"> <a class="reference internal" href="#c.ObjectClass" title="ObjectClass">ObjectClass</a> * <code class="descname">object_get_class</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_get_class" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>A derivative of <a class="reference internal" href="#c.Object" title="Object"><code class="xref c c-type docutils literal notranslate"><span class="pre">Object</span></code></a></dd> </dl> <p><strong>Return</strong></p> <p>The <a class="reference internal" href="#c.ObjectClass" title="ObjectClass"><code class="xref c c-type docutils literal notranslate"><span class="pre">ObjectClass</span></code></a> of the type associated with <strong>obj</strong>.</p> <dl class="function"> <dt id="c.object_get_typename"> const char * <code class="descname">object_get_typename</code><span class="sig-paren">(</span>const <a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_get_typename" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>A derivative of <a class="reference internal" href="#c.Object" title="Object"><code class="xref c c-type docutils literal notranslate"><span class="pre">Object</span></code></a>.</dd> </dl> <p><strong>Return</strong></p> <p>The QOM typename of <strong>obj</strong>.</p> <dl class="function"> <dt id="c.type_register_static"> Type <code class="descname">type_register_static</code><span class="sig-paren">(</span>const <a class="reference internal" href="#c.TypeInfo" title="TypeInfo">TypeInfo</a><em> *info</em><span class="sig-paren">)</span><a class="headerlink" href="#c.type_register_static" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">TypeInfo</span> <span class="pre">*info</span></code></dt> <dd>The <a class="reference internal" href="#c.TypeInfo" title="TypeInfo"><code class="xref c c-type docutils literal notranslate"><span class="pre">TypeInfo</span></code></a> of the new type.</dd> </dl> <p><strong>Description</strong></p> <p><strong>info</strong> and all of the strings it points to should exist for the life time that the type is registered.</p> <p><strong>Return</strong></p> <p>the new <code class="xref c c-type docutils literal notranslate"><span class="pre">Type</span></code>.</p> <dl class="function"> <dt id="c.type_register"> Type <code class="descname">type_register</code><span class="sig-paren">(</span>const <a class="reference internal" href="#c.TypeInfo" title="TypeInfo">TypeInfo</a><em> *info</em><span class="sig-paren">)</span><a class="headerlink" href="#c.type_register" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">TypeInfo</span> <span class="pre">*info</span></code></dt> <dd>The <a class="reference internal" href="#c.TypeInfo" title="TypeInfo"><code class="xref c c-type docutils literal notranslate"><span class="pre">TypeInfo</span></code></a> of the new type</dd> </dl> <p><strong>Description</strong></p> <p>Unlike type_register_static(), this call does not require <strong>info</strong> or its string members to continue to exist after the call returns.</p> <p><strong>Return</strong></p> <p>the new <code class="xref c c-type docutils literal notranslate"><span class="pre">Type</span></code>.</p> <dl class="function"> <dt id="c.type_register_static_array"> void <code class="descname">type_register_static_array</code><span class="sig-paren">(</span>const <a class="reference internal" href="#c.TypeInfo" title="TypeInfo">TypeInfo</a><em> *infos</em>, int<em> nr_infos</em><span class="sig-paren">)</span><a class="headerlink" href="#c.type_register_static_array" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">TypeInfo</span> <span class="pre">*infos</span></code></dt> <dd>The array of the new type <a class="reference internal" href="#c.TypeInfo" title="TypeInfo"><code class="xref c c-type docutils literal notranslate"><span class="pre">TypeInfo</span></code></a> structures.</dd> <dt><code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">nr_infos</span></code></dt> <dd>number of entries in <strong>infos</strong></dd> </dl> <p><strong>Description</strong></p> <p><strong>infos</strong> and all of the strings it points to should exist for the life time that the type is registered.</p> <dl class="function"> <dt id="c.DEFINE_TYPES"> <code class="descname">DEFINE_TYPES</code><span class="sig-paren">(</span>type_array<span class="sig-paren">)</span><a class="headerlink" href="#c.DEFINE_TYPES" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">type_array</span></code></dt> <dd>The array containing <a class="reference internal" href="#c.TypeInfo" title="TypeInfo"><code class="xref c c-type docutils literal notranslate"><span class="pre">TypeInfo</span></code></a> structures to register</dd> </dl> <p><strong>Description</strong></p> <p><strong>type_array</strong> should be static constant that exists for the life time that the type is registered.</p> <dl class="function"> <dt id="c.type_print_class_properties"> bool <code class="descname">type_print_class_properties</code><span class="sig-paren">(</span>const char<em> *type</em><span class="sig-paren">)</span><a class="headerlink" href="#c.type_print_class_properties" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*type</span></code></dt> <dd>a QOM class name</dd> </dl> <p><strong>Description</strong></p> <p>Print the object’s class properties to stdout or the monitor. Return whether an object was found.</p> <dl class="function"> <dt id="c.object_set_properties_from_keyval"> void <code class="descname">object_set_properties_from_keyval</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const QDict<em> *qdict</em>, bool<em> from_json</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_set_properties_from_keyval" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>a QOM object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">QDict</span> <span class="pre">*qdict</span></code></dt> <dd>a dictionary with the properties to be set</dd> <dt><code class="docutils literal notranslate"><span class="pre">bool</span> <span class="pre">from_json</span></code></dt> <dd>true if leaf values of <strong>qdict</strong> are typed, false if they are strings</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>pointer to error object</dd> </dl> <p><strong>Description</strong></p> <p>For each key in the dictionary, parse the value string if needed, then set the corresponding property in <strong>obj</strong>.</p> <dl class="function"> <dt id="c.object_class_dynamic_cast_assert"> <a class="reference internal" href="#c.ObjectClass" title="ObjectClass">ObjectClass</a> * <code class="descname">object_class_dynamic_cast_assert</code><span class="sig-paren">(</span><a class="reference internal" href="#c.ObjectClass" title="ObjectClass">ObjectClass</a><em> *klass</em>, const char<em> *typename</em>, const char<em> *file</em>, int<em> line</em>, const char<em> *func</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_class_dynamic_cast_assert" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ObjectClass</span> <span class="pre">*klass</span></code></dt> <dd>The <a class="reference internal" href="#c.ObjectClass" title="ObjectClass"><code class="xref c c-type docutils literal notranslate"><span class="pre">ObjectClass</span></code></a> to attempt to cast.</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*typename</span></code></dt> <dd>The QOM typename of the class to cast to.</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*file</span></code></dt> <dd>Source code file where function was called</dd> <dt><code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">line</span></code></dt> <dd>Source code line where function was called</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*func</span></code></dt> <dd>Name of function where this function was called</dd> </dl> <p><strong>Description</strong></p> <p>See object_class_dynamic_cast() for a description of the parameters of this function. The only difference in behavior is that this function asserts instead of returning <code class="xref c c-type docutils literal notranslate"><span class="pre">NULL</span></code> on failure if QOM cast debugging is enabled. This function is not meant to be called directly, but only through the wrapper macro OBJECT_CLASS_CHECK.</p> <dl class="function"> <dt id="c.object_class_dynamic_cast"> <a class="reference internal" href="#c.ObjectClass" title="ObjectClass">ObjectClass</a> * <code class="descname">object_class_dynamic_cast</code><span class="sig-paren">(</span><a class="reference internal" href="#c.ObjectClass" title="ObjectClass">ObjectClass</a><em> *klass</em>, const char<em> *typename</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_class_dynamic_cast" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ObjectClass</span> <span class="pre">*klass</span></code></dt> <dd>The <a class="reference internal" href="#c.ObjectClass" title="ObjectClass"><code class="xref c c-type docutils literal notranslate"><span class="pre">ObjectClass</span></code></a> to attempt to cast.</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*typename</span></code></dt> <dd>The QOM typename of the class to cast to.</dd> </dl> <p><strong>Return</strong></p> <p>If <strong>typename</strong> is a class, this function returns <strong>klass</strong> if <strong>typename</strong> is a subtype of <strong>klass</strong>, else returns <code class="xref c c-type docutils literal notranslate"><span class="pre">NULL</span></code>.</p> <p><strong>Description</strong></p> <p>If <strong>typename</strong> is an interface, this function returns the interface definition for <strong>klass</strong> if <strong>klass</strong> implements it unambiguously; <code class="xref c c-type docutils literal notranslate"><span class="pre">NULL</span></code> is returned if <strong>klass</strong> does not implement the interface or if multiple classes or interfaces on the hierarchy leading to <strong>klass</strong> implement it. (FIXME: perhaps this can be detected at type definition time?)</p> <dl class="function"> <dt id="c.object_class_get_parent"> <a class="reference internal" href="#c.ObjectClass" title="ObjectClass">ObjectClass</a> * <code class="descname">object_class_get_parent</code><span class="sig-paren">(</span><a class="reference internal" href="#c.ObjectClass" title="ObjectClass">ObjectClass</a><em> *klass</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_class_get_parent" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ObjectClass</span> <span class="pre">*klass</span></code></dt> <dd>The class to obtain the parent for.</dd> </dl> <p><strong>Return</strong></p> <p>The parent for <strong>klass</strong> or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> if none.</p> <dl class="function"> <dt id="c.object_class_get_name"> const char * <code class="descname">object_class_get_name</code><span class="sig-paren">(</span><a class="reference internal" href="#c.ObjectClass" title="ObjectClass">ObjectClass</a><em> *klass</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_class_get_name" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ObjectClass</span> <span class="pre">*klass</span></code></dt> <dd>The class to obtain the QOM typename for.</dd> </dl> <p><strong>Return</strong></p> <p>The QOM typename for <strong>klass</strong>.</p> <dl class="function"> <dt id="c.object_class_is_abstract"> bool <code class="descname">object_class_is_abstract</code><span class="sig-paren">(</span><a class="reference internal" href="#c.ObjectClass" title="ObjectClass">ObjectClass</a><em> *klass</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_class_is_abstract" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ObjectClass</span> <span class="pre">*klass</span></code></dt> <dd>The class to obtain the abstractness for.</dd> </dl> <p><strong>Return</strong></p> <p><code class="docutils literal notranslate"><span class="pre">true</span></code> if <strong>klass</strong> is abstract, <code class="docutils literal notranslate"><span class="pre">false</span></code> otherwise.</p> <dl class="function"> <dt id="c.object_class_by_name"> <a class="reference internal" href="#c.ObjectClass" title="ObjectClass">ObjectClass</a> * <code class="descname">object_class_by_name</code><span class="sig-paren">(</span>const char<em> *typename</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_class_by_name" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*typename</span></code></dt> <dd>The QOM typename to obtain the class for.</dd> </dl> <p><strong>Return</strong></p> <p>The class for <strong>typename</strong> or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> if not found.</p> <dl class="function"> <dt id="c.module_object_class_by_name"> <a class="reference internal" href="#c.ObjectClass" title="ObjectClass">ObjectClass</a> * <code class="descname">module_object_class_by_name</code><span class="sig-paren">(</span>const char<em> *typename</em><span class="sig-paren">)</span><a class="headerlink" href="#c.module_object_class_by_name" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*typename</span></code></dt> <dd>The QOM typename to obtain the class for.</dd> </dl> <p><strong>Description</strong></p> <p>For objects which might be provided by a module. Behaves like object_class_by_name, but additionally tries to load the module needed in case the class is not available.</p> <p><strong>Return</strong></p> <p>The class for <strong>typename</strong> or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> if not found.</p> <dl class="function"> <dt id="c.object_class_get_list"> GSList * <code class="descname">object_class_get_list</code><span class="sig-paren">(</span>const char<em> *implements_type</em>, bool<em> include_abstract</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_class_get_list" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*implements_type</span></code></dt> <dd>The type to filter for, including its derivatives.</dd> <dt><code class="docutils literal notranslate"><span class="pre">bool</span> <span class="pre">include_abstract</span></code></dt> <dd>Whether to include abstract classes.</dd> </dl> <p><strong>Return</strong></p> <p>A singly-linked list of the classes in reverse hashtable order.</p> <dl class="function"> <dt id="c.object_class_get_list_sorted"> GSList * <code class="descname">object_class_get_list_sorted</code><span class="sig-paren">(</span>const char<em> *implements_type</em>, bool<em> include_abstract</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_class_get_list_sorted" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*implements_type</span></code></dt> <dd>The type to filter for, including its derivatives.</dd> <dt><code class="docutils literal notranslate"><span class="pre">bool</span> <span class="pre">include_abstract</span></code></dt> <dd>Whether to include abstract classes.</dd> </dl> <p><strong>Return</strong></p> <p>A singly-linked list of the classes in alphabetical case-insensitive order.</p> <dl class="function"> <dt id="c.object_ref"> <a class="reference internal" href="#c.Object" title="Object">Object</a> * <code class="descname">object_ref</code><span class="sig-paren">(</span>void<em> *obj</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_ref" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> </dl> <p><strong>Description</strong></p> <p>Increase the reference count of a object. A object cannot be freed as long as its reference count is greater than zero.</p> <p><strong>Return</strong></p> <p><strong>obj</strong></p> <dl class="function"> <dt id="c.object_unref"> void <code class="descname">object_unref</code><span class="sig-paren">(</span>void<em> *obj</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_unref" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> </dl> <p><strong>Description</strong></p> <p>Decrease the reference count of a object. A object cannot be freed as long as its reference count is greater than zero.</p> <dl class="function"> <dt id="c.object_property_try_add"> ObjectProperty * <code class="descname">object_property_try_add</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, const char<em> *type</em>, <a class="reference internal" href="#c.ObjectPropertyAccessor" title="ObjectPropertyAccessor">ObjectPropertyAccessor</a><em> *get</em>, <a class="reference internal" href="#c.ObjectPropertyAccessor" title="ObjectPropertyAccessor">ObjectPropertyAccessor</a><em> *set</em>, <a class="reference internal" href="#c.ObjectPropertyRelease" title="ObjectPropertyRelease">ObjectPropertyRelease</a><em> *release</em>, void<em> *opaque</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_try_add" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object to add a property to</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property. This can contain any character except for a forward slash. In general, you should use hyphens ‘-‘ instead of underscores ‘_’ when naming properties.</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*type</span></code></dt> <dd>the type name of the property. This namespace is pretty loosely defined. Sub namespaces are constructed by using a prefix and then to angle brackets. For instance, the type ‘virtio-net-pci’ in the ‘link’ namespace would be ‘link<virtio-net-pci>’.</dd> <dt><code class="docutils literal notranslate"><span class="pre">ObjectPropertyAccessor</span> <span class="pre">*get</span></code></dt> <dd>The getter to be called to read a property. If this is NULL, then the property cannot be read.</dd> <dt><code class="docutils literal notranslate"><span class="pre">ObjectPropertyAccessor</span> <span class="pre">*set</span></code></dt> <dd>the setter to be called to write a property. If this is NULL, then the property cannot be written.</dd> <dt><code class="docutils literal notranslate"><span class="pre">ObjectPropertyRelease</span> <span class="pre">*release</span></code></dt> <dd>called when the property is removed from the object. This is meant to allow a property to free its opaque upon object destruction. This may be NULL.</dd> <dt><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">*opaque</span></code></dt> <dd>an opaque pointer to pass to the callbacks for the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>pointer to error object</dd> </dl> <p><strong>Return</strong></p> <p>The <code class="xref c c-type docutils literal notranslate"><span class="pre">ObjectProperty</span></code>; this can be used to set the <strong>resolve</strong> callback for child and link properties.</p> <dl class="function"> <dt id="c.object_property_add"> ObjectProperty * <code class="descname">object_property_add</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, const char<em> *type</em>, <a class="reference internal" href="#c.ObjectPropertyAccessor" title="ObjectPropertyAccessor">ObjectPropertyAccessor</a><em> *get</em>, <a class="reference internal" href="#c.ObjectPropertyAccessor" title="ObjectPropertyAccessor">ObjectPropertyAccessor</a><em> *set</em>, <a class="reference internal" href="#c.ObjectPropertyRelease" title="ObjectPropertyRelease">ObjectPropertyRelease</a><em> *release</em>, void<em> *opaque</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_add" title="Permalink to this definition">¶</a></dt> <dd><p>Same as object_property_try_add() with <strong>errp</strong> hardcoded to &error_abort.</p> </dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object to add a property to</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property. This can contain any character except for a forward slash. In general, you should use hyphens ‘-‘ instead of underscores ‘_’ when naming properties.</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*type</span></code></dt> <dd>the type name of the property. This namespace is pretty loosely defined. Sub namespaces are constructed by using a prefix and then to angle brackets. For instance, the type ‘virtio-net-pci’ in the ‘link’ namespace would be ‘link<virtio-net-pci>’.</dd> <dt><code class="docutils literal notranslate"><span class="pre">ObjectPropertyAccessor</span> <span class="pre">*get</span></code></dt> <dd>The getter to be called to read a property. If this is NULL, then the property cannot be read.</dd> <dt><code class="docutils literal notranslate"><span class="pre">ObjectPropertyAccessor</span> <span class="pre">*set</span></code></dt> <dd>the setter to be called to write a property. If this is NULL, then the property cannot be written.</dd> <dt><code class="docutils literal notranslate"><span class="pre">ObjectPropertyRelease</span> <span class="pre">*release</span></code></dt> <dd>called when the property is removed from the object. This is meant to allow a property to free its opaque upon object destruction. This may be NULL.</dd> <dt><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">*opaque</span></code></dt> <dd>an opaque pointer to pass to the callbacks for the property</dd> </dl> <dl class="function"> <dt id="c.object_property_set_default_bool"> void <code class="descname">object_property_set_default_bool</code><span class="sig-paren">(</span>ObjectProperty<em> *prop</em>, bool<em> value</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_set_default_bool" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ObjectProperty</span> <span class="pre">*prop</span></code></dt> <dd>the property to set</dd> <dt><code class="docutils literal notranslate"><span class="pre">bool</span> <span class="pre">value</span></code></dt> <dd>the value to be written to the property</dd> </dl> <p><strong>Description</strong></p> <p>Set the property default value.</p> <dl class="function"> <dt id="c.object_property_set_default_str"> void <code class="descname">object_property_set_default_str</code><span class="sig-paren">(</span>ObjectProperty<em> *prop</em>, const char<em> *value</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_set_default_str" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ObjectProperty</span> <span class="pre">*prop</span></code></dt> <dd>the property to set</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*value</span></code></dt> <dd>the value to be written to the property</dd> </dl> <p><strong>Description</strong></p> <p>Set the property default value.</p> <dl class="function"> <dt id="c.object_property_set_default_int"> void <code class="descname">object_property_set_default_int</code><span class="sig-paren">(</span>ObjectProperty<em> *prop</em>, int64_t<em> value</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_set_default_int" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ObjectProperty</span> <span class="pre">*prop</span></code></dt> <dd>the property to set</dd> <dt><code class="docutils literal notranslate"><span class="pre">int64_t</span> <span class="pre">value</span></code></dt> <dd>the value to be written to the property</dd> </dl> <p><strong>Description</strong></p> <p>Set the property default value.</p> <dl class="function"> <dt id="c.object_property_set_default_uint"> void <code class="descname">object_property_set_default_uint</code><span class="sig-paren">(</span>ObjectProperty<em> *prop</em>, uint64_t<em> value</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_set_default_uint" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ObjectProperty</span> <span class="pre">*prop</span></code></dt> <dd>the property to set</dd> <dt><code class="docutils literal notranslate"><span class="pre">uint64_t</span> <span class="pre">value</span></code></dt> <dd>the value to be written to the property</dd> </dl> <p><strong>Description</strong></p> <p>Set the property default value.</p> <dl class="function"> <dt id="c.object_property_find"> ObjectProperty * <code class="descname">object_property_find</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_find" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> </dl> <p><strong>Description</strong></p> <p>Look up a property for an object.</p> <p>Return its <code class="xref c c-type docutils literal notranslate"><span class="pre">ObjectProperty</span></code> if found, or NULL.</p> <dl class="function"> <dt id="c.object_property_find_err"> ObjectProperty * <code class="descname">object_property_find_err</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_find_err" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>returns an error if this function fails</dd> </dl> <p><strong>Description</strong></p> <p>Look up a property for an object.</p> <p>Return its <code class="xref c c-type docutils literal notranslate"><span class="pre">ObjectProperty</span></code> if found, or NULL.</p> <dl class="function"> <dt id="c.object_class_property_find"> ObjectProperty * <code class="descname">object_class_property_find</code><span class="sig-paren">(</span><a class="reference internal" href="#c.ObjectClass" title="ObjectClass">ObjectClass</a><em> *klass</em>, const char<em> *name</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_class_property_find" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ObjectClass</span> <span class="pre">*klass</span></code></dt> <dd>the object class</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> </dl> <p><strong>Description</strong></p> <p>Look up a property for an object class.</p> <p>Return its <code class="xref c c-type docutils literal notranslate"><span class="pre">ObjectProperty</span></code> if found, or NULL.</p> <dl class="function"> <dt id="c.object_class_property_find_err"> ObjectProperty * <code class="descname">object_class_property_find_err</code><span class="sig-paren">(</span><a class="reference internal" href="#c.ObjectClass" title="ObjectClass">ObjectClass</a><em> *klass</em>, const char<em> *name</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_class_property_find_err" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ObjectClass</span> <span class="pre">*klass</span></code></dt> <dd>the object class</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>returns an error if this function fails</dd> </dl> <p><strong>Description</strong></p> <p>Look up a property for an object class.</p> <p>Return its <code class="xref c c-type docutils literal notranslate"><span class="pre">ObjectProperty</span></code> if found, or NULL.</p> <dl class="function"> <dt id="c.object_property_iter_init"> void <code class="descname">object_property_iter_init</code><span class="sig-paren">(</span>ObjectPropertyIterator<em> *iter</em>, <a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_iter_init" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ObjectPropertyIterator</span> <span class="pre">*iter</span></code></dt> <dd>the iterator instance</dd> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> </dl> <p><strong>Description</strong></p> <p>Initializes an iterator for traversing all properties registered against an object instance, its class and all parent classes.</p> <p>It is forbidden to modify the property list while iterating, whether removing or adding properties.</p> <p>Typical usage pattern would be</p> <div class="literal-block-wrapper docutils container" id="id14"> <div class="code-block-caption"><span class="caption-text">Using object property iterators</span><a class="headerlink" href="#id14" title="Permalink to this code">¶</a></div> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span> <span class="n">ObjectProperty</span> <span class="o">*</span><span class="n">prop</span><span class="p">;</span> <span class="n">ObjectPropertyIterator</span> <span class="n">iter</span><span class="p">;</span> <span class="n">object_property_iter_init</span><span class="p">(</span><span class="o">&</span><span class="n">iter</span><span class="p">,</span> <span class="n">obj</span><span class="p">);</span> <span class="k">while</span> <span class="p">((</span><span class="n">prop</span> <span class="o">=</span> <span class="n">object_property_iter_next</span><span class="p">(</span><span class="o">&</span><span class="n">iter</span><span class="p">)))</span> <span class="p">{</span> <span class="p">...</span> <span class="k">do</span> <span class="n">something</span> <span class="n">with</span> <span class="n">prop</span> <span class="p">...</span> <span class="p">}</span> </pre></div> </div> </div> <dl class="function"> <dt id="c.object_class_property_iter_init"> void <code class="descname">object_class_property_iter_init</code><span class="sig-paren">(</span>ObjectPropertyIterator<em> *iter</em>, <a class="reference internal" href="#c.ObjectClass" title="ObjectClass">ObjectClass</a><em> *klass</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_class_property_iter_init" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ObjectPropertyIterator</span> <span class="pre">*iter</span></code></dt> <dd>the iterator instance</dd> <dt><code class="docutils literal notranslate"><span class="pre">ObjectClass</span> <span class="pre">*klass</span></code></dt> <dd>the class</dd> </dl> <p><strong>Description</strong></p> <p>Initializes an iterator for traversing all properties registered against an object class and all parent classes.</p> <p>It is forbidden to modify the property list while iterating, whether removing or adding properties.</p> <p>This can be used on abstract classes as it does not create a temporary instance.</p> <dl class="function"> <dt id="c.object_property_iter_next"> ObjectProperty * <code class="descname">object_property_iter_next</code><span class="sig-paren">(</span>ObjectPropertyIterator<em> *iter</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_iter_next" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ObjectPropertyIterator</span> <span class="pre">*iter</span></code></dt> <dd>the iterator instance</dd> </dl> <p><strong>Description</strong></p> <p>Return the next available property. If no further properties are available, a <code class="docutils literal notranslate"><span class="pre">NULL</span></code> value will be returned and the <strong>iter</strong> pointer should not be used again after this point without re-initializing it.</p> <p><strong>Return</strong></p> <p>the next property, or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> when all properties have been traversed.</p> <dl class="function"> <dt id="c.object_property_get"> bool <code class="descname">object_property_get</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, Visitor<em> *v</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_get" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Visitor</span> <span class="pre">*v</span></code></dt> <dd>the visitor that will receive the property value. This should be an Output visitor and the data will be written with <strong>name</strong> as the name.</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>returns an error if this function fails</dd> </dl> <p><strong>Description</strong></p> <p>Reads a property from a object.</p> <p><strong>Return</strong></p> <p><code class="docutils literal notranslate"><span class="pre">true</span></code> on success, <code class="docutils literal notranslate"><span class="pre">false</span></code> on failure.</p> <dl class="function"> <dt id="c.object_property_set_str"> bool <code class="descname">object_property_set_str</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, const char<em> *value</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_set_str" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*value</span></code></dt> <dd>the value to be written to the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>returns an error if this function fails</dd> </dl> <p><strong>Description</strong></p> <p>Writes a string value to a property.</p> <p><strong>Return</strong></p> <p><code class="docutils literal notranslate"><span class="pre">true</span></code> on success, <code class="docutils literal notranslate"><span class="pre">false</span></code> on failure.</p> <dl class="function"> <dt id="c.object_property_get_str"> char * <code class="descname">object_property_get_str</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_get_str" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>returns an error if this function fails</dd> </dl> <p><strong>Return</strong></p> <p>the value of the property, converted to a C string, or NULL if an error occurs (including when the property value is not a string). The caller should free the string.</p> <dl class="function"> <dt id="c.object_property_set_link"> bool <code class="descname">object_property_set_link</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, <a class="reference internal" href="#c.Object" title="Object">Object</a><em> *value</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_set_link" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*value</span></code></dt> <dd>the value to be written to the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>returns an error if this function fails</dd> </dl> <p><strong>Description</strong></p> <p>Writes an object’s canonical path to a property.</p> <p>If the link property was created with <code class="docutils literal notranslate"><span class="pre">OBJ_PROP_LINK_STRONG</span></code> bit, the old target object is unreferenced, and a reference is added to the new target object.</p> <p><strong>Return</strong></p> <p><code class="docutils literal notranslate"><span class="pre">true</span></code> on success, <code class="docutils literal notranslate"><span class="pre">false</span></code> on failure.</p> <dl class="function"> <dt id="c.object_property_get_link"> <a class="reference internal" href="#c.Object" title="Object">Object</a> * <code class="descname">object_property_get_link</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_get_link" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>returns an error if this function fails</dd> </dl> <p><strong>Return</strong></p> <p>the value of the property, resolved from a path to an Object, or NULL if an error occurs (including when the property value is not a string or not a valid object path).</p> <dl class="function"> <dt id="c.object_property_set_bool"> bool <code class="descname">object_property_set_bool</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, bool<em> value</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_set_bool" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">bool</span> <span class="pre">value</span></code></dt> <dd>the value to be written to the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>returns an error if this function fails</dd> </dl> <p><strong>Description</strong></p> <p>Writes a bool value to a property.</p> <p><strong>Return</strong></p> <p><code class="docutils literal notranslate"><span class="pre">true</span></code> on success, <code class="docutils literal notranslate"><span class="pre">false</span></code> on failure.</p> <dl class="function"> <dt id="c.object_property_get_bool"> bool <code class="descname">object_property_get_bool</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_get_bool" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>returns an error if this function fails</dd> </dl> <p><strong>Return</strong></p> <p>the value of the property, converted to a boolean, or false if an error occurs (including when the property value is not a bool).</p> <dl class="function"> <dt id="c.object_property_set_int"> bool <code class="descname">object_property_set_int</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, int64_t<em> value</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_set_int" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">int64_t</span> <span class="pre">value</span></code></dt> <dd>the value to be written to the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>returns an error if this function fails</dd> </dl> <p><strong>Description</strong></p> <p>Writes an integer value to a property.</p> <p><strong>Return</strong></p> <p><code class="docutils literal notranslate"><span class="pre">true</span></code> on success, <code class="docutils literal notranslate"><span class="pre">false</span></code> on failure.</p> <dl class="function"> <dt id="c.object_property_get_int"> int64_t <code class="descname">object_property_get_int</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_get_int" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>returns an error if this function fails</dd> </dl> <p><strong>Return</strong></p> <p>the value of the property, converted to an integer, or -1 if an error occurs (including when the property value is not an integer).</p> <dl class="function"> <dt id="c.object_property_set_uint"> bool <code class="descname">object_property_set_uint</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, uint64_t<em> value</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_set_uint" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">uint64_t</span> <span class="pre">value</span></code></dt> <dd>the value to be written to the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>returns an error if this function fails</dd> </dl> <p><strong>Description</strong></p> <p>Writes an unsigned integer value to a property.</p> <p><strong>Return</strong></p> <p><code class="docutils literal notranslate"><span class="pre">true</span></code> on success, <code class="docutils literal notranslate"><span class="pre">false</span></code> on failure.</p> <dl class="function"> <dt id="c.object_property_get_uint"> uint64_t <code class="descname">object_property_get_uint</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_get_uint" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>returns an error if this function fails</dd> </dl> <p><strong>Return</strong></p> <p>the value of the property, converted to an unsigned integer, or 0 an error occurs (including when the property value is not an integer).</p> <dl class="function"> <dt id="c.object_property_get_enum"> int <code class="descname">object_property_get_enum</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, const char<em> *typename</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_get_enum" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*typename</span></code></dt> <dd>the name of the enum data type</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>returns an error if this function fails</dd> </dl> <p><strong>Return</strong></p> <p>the value of the property, converted to an integer (which can’t be negative), or -1 on error (including when the property value is not an enum).</p> <dl class="function"> <dt id="c.object_property_set"> bool <code class="descname">object_property_set</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, Visitor<em> *v</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_set" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Visitor</span> <span class="pre">*v</span></code></dt> <dd>the visitor that will be used to write the property value. This should be an Input visitor and the data will be first read with <strong>name</strong> as the name and then written as the property value.</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>returns an error if this function fails</dd> </dl> <p><strong>Description</strong></p> <p>Writes a property to a object.</p> <p><strong>Return</strong></p> <p><code class="docutils literal notranslate"><span class="pre">true</span></code> on success, <code class="docutils literal notranslate"><span class="pre">false</span></code> on failure.</p> <dl class="function"> <dt id="c.object_property_parse"> bool <code class="descname">object_property_parse</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, const char<em> *string</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_parse" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*string</span></code></dt> <dd>the string that will be used to parse the property value.</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>returns an error if this function fails</dd> </dl> <p><strong>Description</strong></p> <p>Parses a string and writes the result into a property of an object.</p> <p><strong>Return</strong></p> <p><code class="docutils literal notranslate"><span class="pre">true</span></code> on success, <code class="docutils literal notranslate"><span class="pre">false</span></code> on failure.</p> <dl class="function"> <dt id="c.object_property_print"> char * <code class="descname">object_property_print</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, bool<em> human</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_print" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">bool</span> <span class="pre">human</span></code></dt> <dd>if true, print for human consumption</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>returns an error if this function fails</dd> </dl> <p><strong>Description</strong></p> <p>Returns a string representation of the value of the property. The caller shall free the string.</p> <dl class="function"> <dt id="c.object_property_get_type"> const char * <code class="descname">object_property_get_type</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_get_type" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>returns an error if this function fails</dd> </dl> <p><strong>Return</strong></p> <p>The type name of the property.</p> <dl class="function"> <dt id="c.object_get_root"> <a class="reference internal" href="#c.Object" title="Object">Object</a> * <code class="descname">object_get_root</code><span class="sig-paren">(</span>void<span class="sig-paren">)</span><a class="headerlink" href="#c.object_get_root" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">void</span></code></dt> <dd>no arguments</dd> </dl> <p><strong>Return</strong></p> <p>the root object of the composition tree</p> <dl class="function"> <dt id="c.object_get_objects_root"> <a class="reference internal" href="#c.Object" title="Object">Object</a> * <code class="descname">object_get_objects_root</code><span class="sig-paren">(</span>void<span class="sig-paren">)</span><a class="headerlink" href="#c.object_get_objects_root" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">void</span></code></dt> <dd>no arguments</dd> </dl> <p><strong>Description</strong></p> <p>Get the container object that holds user created object instances. This is the object at path “/objects”</p> <p><strong>Return</strong></p> <p>the user object container</p> <dl class="function"> <dt id="c.object_get_internal_root"> <a class="reference internal" href="#c.Object" title="Object">Object</a> * <code class="descname">object_get_internal_root</code><span class="sig-paren">(</span>void<span class="sig-paren">)</span><a class="headerlink" href="#c.object_get_internal_root" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">void</span></code></dt> <dd>no arguments</dd> </dl> <p><strong>Description</strong></p> <p>Get the container object that holds internally used object instances. Any object which is put into this container must not be user visible, and it will not be exposed in the QOM tree.</p> <p><strong>Return</strong></p> <p>the internal object container</p> <dl class="function"> <dt id="c.object_get_canonical_path_component"> const char * <code class="descname">object_get_canonical_path_component</code><span class="sig-paren">(</span>const <a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_get_canonical_path_component" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> </dl> <p><strong>Return</strong></p> <p>The final component in the object’s canonical path. The canonical path is the path within the composition tree starting from the root. <code class="docutils literal notranslate"><span class="pre">NULL</span></code> if the object doesn’t have a parent (and thus a canonical path).</p> <dl class="function"> <dt id="c.object_get_canonical_path"> char * <code class="descname">object_get_canonical_path</code><span class="sig-paren">(</span>const <a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_get_canonical_path" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object</dd> </dl> <p><strong>Return</strong></p> <p>The canonical path for a object, newly allocated. This is the path within the composition tree starting from the root. Use g_free() to free it.</p> <dl class="function"> <dt id="c.object_resolve_path"> <a class="reference internal" href="#c.Object" title="Object">Object</a> * <code class="descname">object_resolve_path</code><span class="sig-paren">(</span>const char<em> *path</em>, bool<em> *ambiguous</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_resolve_path" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*path</span></code></dt> <dd>the path to resolve</dd> <dt><code class="docutils literal notranslate"><span class="pre">bool</span> <span class="pre">*ambiguous</span></code></dt> <dd>returns true if the path resolution failed because of an ambiguous match</dd> </dl> <p><strong>Description</strong></p> <p>There are two types of supported paths–absolute paths and partial paths.</p> <p>Absolute paths are derived from the root object and can follow child<> or link<> properties. Since they can follow link<> properties, they can be arbitrarily long. Absolute paths look like absolute filenames and are prefixed with a leading slash.</p> <p>Partial paths look like relative filenames. They do not begin with a prefix. The matching rules for partial paths are subtle but designed to make specifying objects easy. At each level of the composition tree, the partial path is matched as an absolute path. The first match is not returned. At least two matches are searched for. A successful result is only returned if only one match is found. If more than one match is found, a flag is returned to indicate that the match was ambiguous.</p> <p><strong>Return</strong></p> <p>The matched object or NULL on path lookup failure.</p> <dl class="function"> <dt id="c.object_resolve_path_type"> <a class="reference internal" href="#c.Object" title="Object">Object</a> * <code class="descname">object_resolve_path_type</code><span class="sig-paren">(</span>const char<em> *path</em>, const char<em> *typename</em>, bool<em> *ambiguous</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_resolve_path_type" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*path</span></code></dt> <dd>the path to resolve</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*typename</span></code></dt> <dd>the type to look for.</dd> <dt><code class="docutils literal notranslate"><span class="pre">bool</span> <span class="pre">*ambiguous</span></code></dt> <dd>returns true if the path resolution failed because of an ambiguous match</dd> </dl> <p><strong>Description</strong></p> <p>This is similar to object_resolve_path. However, when looking for a partial path only matches that implement the given type are considered. This restricts the search and avoids spuriously flagging matches as ambiguous.</p> <p>For both partial and absolute paths, the return value goes through a dynamic cast to <strong>typename</strong>. This is important if either the link, or the typename itself are of interface types.</p> <p><strong>Return</strong></p> <p>The matched object or NULL on path lookup failure.</p> <dl class="function"> <dt id="c.object_resolve_path_at"> <a class="reference internal" href="#c.Object" title="Object">Object</a> * <code class="descname">object_resolve_path_at</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *parent</em>, const char<em> *path</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_resolve_path_at" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*parent</span></code></dt> <dd>the object in which to resolve the path</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*path</span></code></dt> <dd>the path to resolve</dd> </dl> <p><strong>Description</strong></p> <p>This is like object_resolve_path(), except paths not starting with a slash are relative to <strong>parent</strong>.</p> <p><strong>Return</strong></p> <p>The resolved object or NULL on path lookup failure.</p> <dl class="function"> <dt id="c.object_resolve_path_component"> <a class="reference internal" href="#c.Object" title="Object">Object</a> * <code class="descname">object_resolve_path_component</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *parent</em>, const char<em> *part</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_resolve_path_component" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*parent</span></code></dt> <dd>the object in which to resolve the path</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*part</span></code></dt> <dd>the component to resolve.</dd> </dl> <p><strong>Description</strong></p> <p>This is similar to object_resolve_path with an absolute path, but it only resolves one element (<strong>part</strong>) and takes the others from <strong>parent</strong>.</p> <p><strong>Return</strong></p> <p>The resolved object or NULL on path lookup failure.</p> <dl class="function"> <dt id="c.object_property_try_add_child"> ObjectProperty * <code class="descname">object_property_try_add_child</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, <a class="reference internal" href="#c.Object" title="Object">Object</a><em> *child</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_try_add_child" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object to add a property to</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*child</span></code></dt> <dd>the child object</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>pointer to error object</dd> </dl> <p><strong>Description</strong></p> <p>Child properties form the composition tree. All objects need to be a child of another object. Objects can only be a child of one object.</p> <p>There is no way for a child to determine what its parent is. It is not a bidirectional relationship. This is by design.</p> <p>The value of a child property as a C string will be the child object’s canonical path. It can be retrieved using object_property_get_str(). The child object itself can be retrieved using object_property_get_link().</p> <p><strong>Return</strong></p> <p>The newly added property on success, or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> on failure.</p> <dl class="function"> <dt id="c.object_property_add_child"> ObjectProperty * <code class="descname">object_property_add_child</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, <a class="reference internal" href="#c.Object" title="Object">Object</a><em> *child</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_add_child" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object to add a property to</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*child</span></code></dt> <dd>the child object</dd> </dl> <p><strong>Description</strong></p> <p>Same as object_property_try_add_child() with <strong>errp</strong> hardcoded to &error_abort</p> <dl class="function"> <dt id="c.object_property_allow_set_link"> void <code class="descname">object_property_allow_set_link</code><span class="sig-paren">(</span>const <a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, <a class="reference internal" href="#c.Object" title="Object">Object</a><em> *child</em>, Error<em> **errp</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_allow_set_link" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object to add a property to</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*child</span></code></dt> <dd>the child object</dd> <dt><code class="docutils literal notranslate"><span class="pre">Error</span> <span class="pre">**errp</span></code></dt> <dd>pointer to error object</dd> </dl> <p><strong>Description</strong></p> <p>The default implementation of the object_property_add_link() check() callback function. It allows the link property to be set and never returns an error.</p> <dl class="function"> <dt id="c.object_property_add_link"> ObjectProperty * <code class="descname">object_property_add_link</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, const char<em> *type</em>, <a class="reference internal" href="#c.Object" title="Object">Object</a><em> **targetp</em>, void (<em>*check</em>)(const <a class="reference internal" href="#c.Object" title="Object">Object</a> *obj, const char *name, <a class="reference internal" href="#c.Object" title="Object">Object</a> *val, Error **errp), ObjectPropertyLinkFlags<em> flags</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_add_link" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object to add a property to</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*type</span></code></dt> <dd>the qobj type of the link</dd> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">**targetp</span></code></dt> <dd>a pointer to where the link object reference is stored</dd> <dt><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">(*check)(const</span> <span class="pre">Object</span> <span class="pre">*obj,</span> <span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name,</span> <span class="pre">Object</span> <span class="pre">*val,</span> <span class="pre">Error</span> <span class="pre">**errp)</span></code></dt> <dd>callback to veto setting or NULL if the property is read-only</dd> <dt><code class="docutils literal notranslate"><span class="pre">ObjectPropertyLinkFlags</span> <span class="pre">flags</span></code></dt> <dd>additional options for the link</dd> </dl> <p><strong>Description</strong></p> <p>Links establish relationships between objects. Links are unidirectional although two links can be combined to form a bidirectional relationship between objects.</p> <p>Links form the graph in the object model.</p> <p>The <strong>check()</strong> callback is invoked when object_property_set_link() is called and can raise an error to prevent the link being set. If <strong>check</strong> is NULL, the property is read-only and cannot be set.</p> <p>Ownership of the pointer that <strong>child</strong> points to is transferred to the link property. The reference count for <strong>*child</strong> is managed by the property from after the function returns till the property is deleted with object_property_del(). If the <strong>flags</strong> <code class="docutils literal notranslate"><span class="pre">OBJ_PROP_LINK_STRONG</span></code> bit is set, the reference count is decremented when the property is deleted or modified.</p> <p><strong>Return</strong></p> <p>The newly added property on success, or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> on failure.</p> <dl class="function"> <dt id="c.object_property_add_str"> ObjectProperty * <code class="descname">object_property_add_str</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, char *(<em>*get</em>)(<a class="reference internal" href="#c.Object" title="Object">Object</a> *, Error **), void (*set)(<a class="reference internal" href="#c.Object" title="Object">Object</a> *, const char *, Error **)<span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_add_str" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object to add a property to</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">char</span> <span class="pre">*(*get)(Object</span> <span class="pre">*,</span> <span class="pre">Error</span> <span class="pre">**)</span></code></dt> <dd>the getter or NULL if the property is write-only. This function must return a string to be freed by g_free().</dd> <dt><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">(*set)(Object</span> <span class="pre">*,</span> <span class="pre">const</span> <span class="pre">char</span> <span class="pre">*,</span> <span class="pre">Error</span> <span class="pre">**)</span></code></dt> <dd>the setter or NULL if the property is read-only</dd> </dl> <p><strong>Description</strong></p> <p>Add a string property using getters/setters. This function will add a property of type ‘string’.</p> <p><strong>Return</strong></p> <p>The newly added property on success, or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> on failure.</p> <dl class="function"> <dt id="c.object_property_add_bool"> ObjectProperty * <code class="descname">object_property_add_bool</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, bool (<em>*get</em>)(<a class="reference internal" href="#c.Object" title="Object">Object</a> *, Error **), void (*set)(<a class="reference internal" href="#c.Object" title="Object">Object</a> *, bool, Error **)<span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_add_bool" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object to add a property to</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">bool</span> <span class="pre">(*get)(Object</span> <span class="pre">*,</span> <span class="pre">Error</span> <span class="pre">**)</span></code></dt> <dd>the getter or NULL if the property is write-only.</dd> <dt><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">(*set)(Object</span> <span class="pre">*,</span> <span class="pre">bool,</span> <span class="pre">Error</span> <span class="pre">**)</span></code></dt> <dd>the setter or NULL if the property is read-only</dd> </dl> <p><strong>Description</strong></p> <p>Add a bool property using getters/setters. This function will add a property of type ‘bool’.</p> <p><strong>Return</strong></p> <p>The newly added property on success, or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> on failure.</p> <dl class="function"> <dt id="c.object_property_add_enum"> ObjectProperty * <code class="descname">object_property_add_enum</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, const char<em> *typename</em>, const QEnumLookup<em> *lookup</em>, int (<em>*get</em>)(<a class="reference internal" href="#c.Object" title="Object">Object</a> *, Error **), void (*set)(<a class="reference internal" href="#c.Object" title="Object">Object</a> *, int, Error **)<span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_add_enum" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object to add a property to</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*typename</span></code></dt> <dd>the name of the enum data type</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">QEnumLookup</span> <span class="pre">*lookup</span></code></dt> <dd>enum value namelookup table</dd> <dt><code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">(*get)(Object</span> <span class="pre">*,</span> <span class="pre">Error</span> <span class="pre">**)</span></code></dt> <dd>the getter or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> if the property is write-only.</dd> <dt><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">(*set)(Object</span> <span class="pre">*,</span> <span class="pre">int,</span> <span class="pre">Error</span> <span class="pre">**)</span></code></dt> <dd>the setter or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> if the property is read-only</dd> </dl> <p><strong>Description</strong></p> <p>Add an enum property using getters/setters. This function will add a property of type ‘<strong>typename</strong>’.</p> <p><strong>Return</strong></p> <p>The newly added property on success, or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> on failure.</p> <dl class="function"> <dt id="c.object_property_add_tm"> ObjectProperty * <code class="descname">object_property_add_tm</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, void (<em>*get</em>)(<a class="reference internal" href="#c.Object" title="Object">Object</a> *, struct tm *, Error **)<span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_add_tm" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object to add a property to</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">(*get)(Object</span> <span class="pre">*,</span> <span class="pre">struct</span> <span class="pre">tm</span> <span class="pre">*,</span> <span class="pre">Error</span> <span class="pre">**)</span></code></dt> <dd>the getter or NULL if the property is write-only.</dd> </dl> <p><strong>Description</strong></p> <p>Add a read-only struct tm valued property using a getter function. This function will add a property of type ‘struct tm’.</p> <p><strong>Return</strong></p> <p>The newly added property on success, or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> on failure.</p> <dl class="function"> <dt id="c.object_property_add_uint8_ptr"> ObjectProperty * <code class="descname">object_property_add_uint8_ptr</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, const uint8_t<em> *v</em>, ObjectPropertyFlags<em> flags</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_add_uint8_ptr" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object to add a property to</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">uint8_t</span> <span class="pre">*v</span></code></dt> <dd>pointer to value</dd> <dt><code class="docutils literal notranslate"><span class="pre">ObjectPropertyFlags</span> <span class="pre">flags</span></code></dt> <dd>bitwise-or’d ObjectPropertyFlags</dd> </dl> <p><strong>Description</strong></p> <p>Add an integer property in memory. This function will add a property of type ‘uint8’.</p> <p><strong>Return</strong></p> <p>The newly added property on success, or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> on failure.</p> <dl class="function"> <dt id="c.object_property_add_uint16_ptr"> ObjectProperty * <code class="descname">object_property_add_uint16_ptr</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, const uint16_t<em> *v</em>, ObjectPropertyFlags<em> flags</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_add_uint16_ptr" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object to add a property to</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">uint16_t</span> <span class="pre">*v</span></code></dt> <dd>pointer to value</dd> <dt><code class="docutils literal notranslate"><span class="pre">ObjectPropertyFlags</span> <span class="pre">flags</span></code></dt> <dd>bitwise-or’d ObjectPropertyFlags</dd> </dl> <p><strong>Description</strong></p> <p>Add an integer property in memory. This function will add a property of type ‘uint16’.</p> <p><strong>Return</strong></p> <p>The newly added property on success, or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> on failure.</p> <dl class="function"> <dt id="c.object_property_add_uint32_ptr"> ObjectProperty * <code class="descname">object_property_add_uint32_ptr</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, const uint32_t<em> *v</em>, ObjectPropertyFlags<em> flags</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_add_uint32_ptr" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object to add a property to</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">uint32_t</span> <span class="pre">*v</span></code></dt> <dd>pointer to value</dd> <dt><code class="docutils literal notranslate"><span class="pre">ObjectPropertyFlags</span> <span class="pre">flags</span></code></dt> <dd>bitwise-or’d ObjectPropertyFlags</dd> </dl> <p><strong>Description</strong></p> <p>Add an integer property in memory. This function will add a property of type ‘uint32’.</p> <p><strong>Return</strong></p> <p>The newly added property on success, or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> on failure.</p> <dl class="function"> <dt id="c.object_property_add_uint64_ptr"> ObjectProperty * <code class="descname">object_property_add_uint64_ptr</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, const uint64_t<em> *v</em>, ObjectPropertyFlags<em> flags</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_add_uint64_ptr" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object to add a property to</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">uint64_t</span> <span class="pre">*v</span></code></dt> <dd>pointer to value</dd> <dt><code class="docutils literal notranslate"><span class="pre">ObjectPropertyFlags</span> <span class="pre">flags</span></code></dt> <dd>bitwise-or’d ObjectPropertyFlags</dd> </dl> <p><strong>Description</strong></p> <p>Add an integer property in memory. This function will add a property of type ‘uint64’.</p> <p><strong>Return</strong></p> <p>The newly added property on success, or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> on failure.</p> <dl class="function"> <dt id="c.object_property_add_alias"> ObjectProperty * <code class="descname">object_property_add_alias</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, <a class="reference internal" href="#c.Object" title="Object">Object</a><em> *target_obj</em>, const char<em> *target_name</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_add_alias" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object to add a property to</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*target_obj</span></code></dt> <dd>the object to forward property access to</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*target_name</span></code></dt> <dd>the name of the property on the forwarded object</dd> </dl> <p><strong>Description</strong></p> <p>Add an alias for a property on an object. This function will add a property of the same type as the forwarded property.</p> <p>The caller must ensure that <strong>target_obj</strong> stays alive as long as this property exists. In the case of a child object or an alias on the same object this will be the case. For aliases to other objects the caller is responsible for taking a reference.</p> <p><strong>Return</strong></p> <p>The newly added property on success, or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> on failure.</p> <dl class="function"> <dt id="c.object_property_add_const_link"> ObjectProperty * <code class="descname">object_property_add_const_link</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, <a class="reference internal" href="#c.Object" title="Object">Object</a><em> *target</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_add_const_link" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object to add a property to</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*target</span></code></dt> <dd>the object to be referred by the link</dd> </dl> <p><strong>Description</strong></p> <p>Add an unmodifiable link for a property on an object. This function will add a property of type link<TYPE> where TYPE is the type of <strong>target</strong>.</p> <p>The caller must ensure that <strong>target</strong> stays alive as long as this property exists. In the case <strong>target</strong> is a child of <strong>obj</strong>, this will be the case. Otherwise, the caller is responsible for taking a reference.</p> <p><strong>Return</strong></p> <p>The newly added property on success, or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> on failure.</p> <dl class="function"> <dt id="c.object_property_set_description"> void <code class="descname">object_property_set_description</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, const char<em> *name</em>, const char<em> *description</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_set_description" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object owning the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*description</span></code></dt> <dd>the description of the property on the object</dd> </dl> <p><strong>Description</strong></p> <p>Set an object property’s description.</p> <p><strong>Return</strong></p> <p><code class="docutils literal notranslate"><span class="pre">true</span></code> on success, <code class="docutils literal notranslate"><span class="pre">false</span></code> on failure.</p> <dl class="function"> <dt id="c.object_child_foreach"> int <code class="descname">object_child_foreach</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, int (<em>*fn</em>)(<a class="reference internal" href="#c.Object" title="Object">Object</a> *child, void *opaque), void<em> *opaque</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_child_foreach" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object whose children will be navigated</dd> <dt><code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">(*fn)(Object</span> <span class="pre">*child,</span> <span class="pre">void</span> <span class="pre">*opaque)</span></code></dt> <dd>the iterator function to be called</dd> <dt><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">*opaque</span></code></dt> <dd>an opaque value that will be passed to the iterator</dd> </dl> <p><strong>Description</strong></p> <p>Call <strong>fn</strong> passing each child of <strong>obj</strong> and <strong>opaque</strong> to it, until <strong>fn</strong> returns non-zero.</p> <p>It is forbidden to add or remove children from <strong>obj</strong> from the <strong>fn</strong> callback.</p> <p><strong>Return</strong></p> <p>The last value returned by <strong>fn</strong>, or 0 if there is no child.</p> <dl class="function"> <dt id="c.object_child_foreach_recursive"> int <code class="descname">object_child_foreach_recursive</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *obj</em>, int (<em>*fn</em>)(<a class="reference internal" href="#c.Object" title="Object">Object</a> *child, void *opaque), void<em> *opaque</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_child_foreach_recursive" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*obj</span></code></dt> <dd>the object whose children will be navigated</dd> <dt><code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">(*fn)(Object</span> <span class="pre">*child,</span> <span class="pre">void</span> <span class="pre">*opaque)</span></code></dt> <dd>the iterator function to be called</dd> <dt><code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">*opaque</span></code></dt> <dd>an opaque value that will be passed to the iterator</dd> </dl> <p><strong>Description</strong></p> <p>Call <strong>fn</strong> passing each child of <strong>obj</strong> and <strong>opaque</strong> to it, until <strong>fn</strong> returns non-zero. Calls recursively, all child nodes of <strong>obj</strong> will also be passed all the way down to the leaf nodes of the tree. Depth first ordering.</p> <p>It is forbidden to add or remove children from <strong>obj</strong> (or its child nodes) from the <strong>fn</strong> callback.</p> <p><strong>Return</strong></p> <p>The last value returned by <strong>fn</strong>, or 0 if there is no child.</p> <dl class="function"> <dt id="c.container_get"> <a class="reference internal" href="#c.Object" title="Object">Object</a> * <code class="descname">container_get</code><span class="sig-paren">(</span><a class="reference internal" href="#c.Object" title="Object">Object</a><em> *root</em>, const char<em> *path</em><span class="sig-paren">)</span><a class="headerlink" href="#c.container_get" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">Object</span> <span class="pre">*root</span></code></dt> <dd>root of the #path, e.g., object_get_root()</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*path</span></code></dt> <dd>path to the container</dd> </dl> <p><strong>Description</strong></p> <p>Return a container object whose path is <strong>path</strong>. Create more containers along the path if necessary.</p> <p><strong>Return</strong></p> <p>the container object.</p> <dl class="function"> <dt id="c.object_type_get_instance_size"> size_t <code class="descname">object_type_get_instance_size</code><span class="sig-paren">(</span>const char<em> *typename</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_type_get_instance_size" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*typename</span></code></dt> <dd>Name of the Type whose instance_size is required</dd> </dl> <p><strong>Description</strong></p> <p>Returns the instance_size of the given <strong>typename</strong>.</p> <dl class="function"> <dt id="c.object_property_help"> char * <code class="descname">object_property_help</code><span class="sig-paren">(</span>const char<em> *name</em>, const char<em> *type</em>, QObject<em> *defval</em>, const char<em> *description</em><span class="sig-paren">)</span><a class="headerlink" href="#c.object_property_help" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p><strong>Parameters</strong></p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*name</span></code></dt> <dd>the name of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*type</span></code></dt> <dd>the type of the property</dd> <dt><code class="docutils literal notranslate"><span class="pre">QObject</span> <span class="pre">*defval</span></code></dt> <dd>the default value</dd> <dt><code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*description</span></code></dt> <dd>description of the property</dd> </dl> <p><strong>Return</strong></p> <p>a user-friendly formatted string describing the property for help purposes.</p> </div> </div> </div> </div> </div> <footer> <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> <a href="modules.html" class="btn btn-neutral float-right" title="QEMU modules" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> <a href="clocks.html" class="btn btn-neutral" title="Modelling a clock tree in QEMU" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> </div> <hr/> <div role="contentinfo"> <p> © Copyright 2021, The QEMU Project Developers. </p> </div> Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. <!-- Empty para to force a blank line after "Built with Sphinx ..." --> <p></p> <p>This documentation is for QEMU version 6.2.0.</p> <p><a href="../about/license.html">QEMU and this manual are released under the GNU General Public License, version 2.</a></p> </footer> </div> </div> </section> </div> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT:'../', VERSION:'qemu-kvm-6.2.0-53.module+el8.10.0+2055+8eb7870b.4', LANGUAGE:'None', COLLAPSE_INDEX:false, FILE_SUFFIX:'.html', HAS_SOURCE: false, SOURCELINK_SUFFIX: '.txt' }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/js/theme.js"></script> <script type="text/javascript"> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); </script> </body> </html>
Simpan