9090// NOLINTEND(bugprone-macro-parentheses)
9191
9292namespace qdmi ::na {
93+ /* *
94+ * @brief Constructs the device and initializes its metadata and supported entities.
95+ *
96+ * Initializes the device name, number of qubits, minimum atom distance, length and
97+ * duration units/scale factors, and populates the site and operation lists.
98+ */
9399Device::Device () {
94100 // NOLINTBEGIN(cppcoreguidelines-prefer-member-initializer)
95101 INITIALIZE_NAME (name_);
@@ -120,6 +126,26 @@ auto Device::sessionFree(MQT_NA_QDMI_Device_Session session) -> void {
120126 }
121127 }
122128}
129+ /* *
130+ * @brief Retrieve a device-level property value.
131+ *
132+ * Query a named device property and copy its value into the provided buffer
133+ * (or report the required size). Supported properties include metadata
134+ * (name, version), numeric characteristics (qubit count, minimum atom
135+ * distance, units/scale factors), lists (sites, operations), and device
136+ * capabilities.
137+ *
138+ * @param prop The device property being queried.
139+ * @param size Size of the buffer pointed to by `value` in bytes; may be 0
140+ * when `value` is nullptr to request the required size.
141+ * @param value Pointer to a buffer to receive the property value, or nullptr
142+ * to only retrieve the required size.
143+ * @param sizeRet If non-null, receives the number of bytes written or the
144+ * number of bytes required.
145+ * @return int `QDMI_SUCCESS` on success; `QDMI_ERROR_INVALIDARGUMENT` if
146+ * arguments are invalid; `QDMI_ERROR_NOTSUPPORTED` if the property
147+ * is not recognized or not supported.
148+ */
123149auto Device::queryProperty (const QDMI_Device_Property prop, const size_t size,
124150 void * value, size_t * sizeRet) -> int {
125151 if ((value != nullptr && size == 0 ) || prop >= QDMI_DEVICE_PROPERTY_MAX) {
@@ -161,7 +187,13 @@ auto Device::queryProperty(const QDMI_Device_Property prop, const size_t size,
161187 operations_, prop, size, value, sizeRet)
162188 return QDMI_ERROR_NOTSUPPORTED;
163189}
164- } // namespace qdmi::na
190+ } /* *
191+ * @brief Initialize the device session by transitioning it from ALLOCATED to INITIALIZED.
192+ *
193+ * Sets the session's internal state to INITIALIZED when it is currently ALLOCATED.
194+ *
195+ * @return int `QDMI_SUCCESS` on successful initialization, `QDMI_ERROR_BADSTATE` if the session was not in the ALLOCATED state.
196+ */
165197
166198auto MQT_NA_QDMI_Device_Session_impl_d::init () -> int {
167199 if (status_ != Status::ALLOCATED) {
@@ -201,6 +233,15 @@ auto MQT_NA_QDMI_Device_Session_impl_d::freeDeviceJob(
201233 jobs_.erase (job);
202234 }
203235}
236+ /* *
237+ * @brief Query a device-level property for this session.
238+ *
239+ * @param prop The device property to query.
240+ * @param size Size of the caller-provided buffer pointed to by `value`, in bytes.
241+ * @param value Pointer to a buffer to receive the property's value; may be null to query required size.
242+ * @param sizeRet Pointer to receive the number of bytes written or required; may be null if not needed.
243+ * @return int QDMI status code: `QDMI_SUCCESS` on success, `QDMI_ERROR_BADSTATE` if the session is not initialized, `QDMI_ERROR_NOTSUPPORTED` if the property is not supported, or other QDMI error codes on failure.
244+ */
204245auto MQT_NA_QDMI_Device_Session_impl_d::queryDeviceProperty (
205246 const QDMI_Device_Property prop, const size_t size, void * value,
206247 size_t * sizeRet) const -> int {
@@ -209,6 +250,20 @@ auto MQT_NA_QDMI_Device_Session_impl_d::queryDeviceProperty(
209250 }
210251 return qdmi::na::Device::get ().queryProperty (prop, size, value, sizeRet);
211252}
253+ /* *
254+ * @brief Query a property of the specified site within this session.
255+ *
256+ * Validates the session state and the site handle before performing the query.
257+ *
258+ * @param site Site handle to query; must not be `nullptr`.
259+ * @param prop Property to query.
260+ * @param size Size of the buffer pointed to by `value`, in bytes.
261+ * @param value Output buffer for the property value; may be `nullptr` to obtain required size.
262+ * @param sizeRet Receives the number of bytes written or required; may be `nullptr` if not needed.
263+ * @return int `QDMI_ERROR_INVALIDARGUMENT` if `site` is `nullptr`.
264+ * `QDMI_ERROR_BADSTATE` if the session is not initialized.
265+ * Otherwise, returns the status code produced while retrieving the site's property.
266+ */
212267auto MQT_NA_QDMI_Device_Session_impl_d::querySiteProperty (
213268 MQT_NA_QDMI_Site site, const QDMI_Site_Property prop, const size_t size,
214269 void * value, size_t * sizeRet) const -> int {
@@ -542,7 +597,27 @@ auto MQT_NA_QDMI_Operation_impl_d::queryProperty(
542597 *duration_, prop, size, value, sizeRet)
543598 }
544599 if (fidelity_) {
545- ADD_SINGLE_VALUE_PROPERTY (QDMI_OPERATION_PROPERTY_FIDELITY, double ,
600+ /* *
601+ * @brief Query an operation property for the specified sites and parameters.
602+ *
603+ * Validates the provided site pointers and parameter pointers, checks that the
604+ * supplied sites are compatible with this operation (including ordering for
605+ * two-qubit operations), and writes the requested property into the provided
606+ * buffer if supported.
607+ *
608+ * @param numSites Number of sites in `sites`.
609+ * @param sites Pointer to an array of site handles to query against.
610+ * @param numParams Number of numeric parameters in `params`.
611+ * @param params Pointer to an array of parameter values (may be nullptr if none).
612+ * @param prop The operation property to query.
613+ * @param size Size of the `value` buffer in bytes.
614+ * @param value Buffer to receive the property value (may be nullptr to query required size).
615+ * @param sizeRet If non-null, receives the number of bytes written or required.
616+ * @return int `QDMI_ERROR_SUCCESS` if the property was written to `value`;
617+ * `QDMI_ERROR_NOTSUPPORTED` if the property or the supplied site/parameter
618+ * combination is not supported; `QDMI_ERROR_BADARG` for invalid input arguments.
619+ */
620+ ADD_SINGLE_VALUE_PROPERTY (QDMI_OPERATION_PROPERTY_FIDELITY, double ,
546621 *fidelity_, prop, size, value, sizeRet)
547622 }
548623 if (numQubits_) {
@@ -558,28 +633,69 @@ auto MQT_NA_QDMI_Operation_impl_d::queryProperty(
558633 return QDMI_ERROR_NOTSUPPORTED;
559634}
560635
636+ /* *
637+ * @brief Initializes the NA QDMI device subsystem by ensuring the Device singleton exists.
638+ *
639+ * @return QDMI_SUCCESS on success.
640+ */
561641int MQT_NA_QDMI_device_initialize () {
562642 std::ignore = qdmi::na::Device::get (); // Ensure the singleton is created
563643 return QDMI_SUCCESS;
564644}
565645
646+ /* *
647+ * @brief Finalizes the NA QDMI device subsystem and releases any global resources.
648+ *
649+ * Performs any final cleanup required by the device subsystem prior to library unload.
650+ *
651+ * @return int `QDMI_SUCCESS` on success.
652+ */
566653int MQT_NA_QDMI_device_finalize () { return QDMI_SUCCESS; }
567654
655+ /* *
656+ * @brief Allocates a new device session and returns its handle.
657+ *
658+ * @param session Pointer to storage that receives the new MQT_NA_QDMI_Device_Session handle; must not be null.
659+ * @return int Status code indicating success or failure. On success the out-parameter `session` is set to the allocated session handle.
660+ */
568661int MQT_NA_QDMI_device_session_alloc (MQT_NA_QDMI_Device_Session* session) {
569662 return qdmi::na::Device::get ().sessionAlloc (session);
570663}
571664
665+ /* *
666+ * @brief Initializes a device session.
667+ *
668+ * @param session Pointer to an allocated device session handle.
669+ * @return int QDMI_SUCCESS on success; QDMI_ERROR_INVALIDARGUMENT if `session` is null; otherwise the status code returned by the session initialization.
670+ */
572671int MQT_NA_QDMI_device_session_init (MQT_NA_QDMI_Device_Session session) {
573672 if (session == nullptr ) {
574673 return QDMI_ERROR_INVALIDARGUMENT;
575674 }
576675 return session->init ();
577676}
578677
678+ /* *
679+ * @brief Release a device session handle and free its internal resources.
680+ *
681+ * If `session` is non-null and corresponds to an allocated session, the session
682+ * is removed and its resources are freed; passing a null handle has no effect.
683+ *
684+ * @param session Session handle to free.
685+ */
579686void MQT_NA_QDMI_device_session_free (MQT_NA_QDMI_Device_Session session) {
580687 qdmi::na::Device::get ().sessionFree (session);
581688}
582689
690+ /* *
691+ * @brief Set a parameter for a device session.
692+ *
693+ * @param session Handle to an allocated device session.
694+ * @param param Identifier of the session parameter to set.
695+ * @param size Size in bytes of the data pointed to by `value`.
696+ * @param value Pointer to the parameter data.
697+ * @return int QDMI status code: `QDMI_ERROR_INVALIDARGUMENT` if `session` is null; otherwise the status returned by the session implementation.
698+ */
583699int MQT_NA_QDMI_device_session_set_parameter (
584700 MQT_NA_QDMI_Device_Session session, QDMI_Device_Session_Parameter param,
585701 const size_t size, const void * value) {
@@ -723,4 +839,4 @@ int MQT_NA_QDMI_device_session_query_operation_property(
723839 }
724840 return session->queryOperationProperty (operation, numSites, sites, numParams,
725841 params, prop, size, value, sizeRet);
726- }
842+ }
0 commit comments