Declares the C ABI atom-selection parser interface. More...
Typedefs | |
| typedef struct apo_atom_selector | apo_atom_selector |
| Represents an owned atom-selection evaluator in the C ABI. | |
Functions | |
| apo_status | apo_atom_selector_create (apo_atom_selector **out, const apo_charmm_psf *psf) |
| Creates an atom selector for a PSF. | |
| void | apo_atom_selector_destroy (apo_atom_selector *selector) |
| Destroys an owned atom-selector handle. | |
| apo_status | apo_atom_selector_select (apo_atom_selection **out, const apo_atom_selector *selector, const char *selection_string) |
| Evaluates one atom-selection expression. | |
Declares the C ABI atom-selection parser interface.
| typedef struct apo_atom_selector apo_atom_selector |
Represents an owned atom-selection evaluator in the C ABI.
A selector shares ownership of the native PSF supplied at construction. The PSF handle is borrowed by apo_atom_selector_create and may be destroyed after creation; the selector keeps the native topology alive independently. The topology is shared rather than cloned, so mutation through another native owner can affect later selections.
Selection calls read host-resident PSF metadata and produce independently owned apo_atom_selection handles. No CUDA allocation, transfer, stream work, or synchronization is performed by the selector.
A non-NULL pointer must designate a live handle created by apoCHARMM. Passing a dangling, already-destroyed, or foreign pointer has undefined behavior. The implementation provides no internal locking. Do not overlap destruction with another call, and keep the shared PSF immutable during selection.
Status-returning functions clear the calling thread's previous diagnostic at entry. On failure, call apo_last_error immediately on the same thread; its borrowed pointer remains valid only until another diagnostic-changing C ABI call on that thread.
| apo_status apo_atom_selector_create | ( | apo_atom_selector ** | out, |
| const apo_charmm_psf * | psf | ||
| ) |
Creates an atom selector for a PSF.
| [out] | out | Non-NULL address receiving a newly owned selector handle. The function stores NULL before validating psf and leaves *out == NULL on every failure path. Release a successful result with apo_atom_selector_destroy. |
| [in] | psf | Borrowed live PSF handle. The public handle is not retained, but its native shared object is retained by the new selector. The pointer may not be NULL and must contain an initialized native PSF. |
| APO_STATUS_OK | A new owned selector was stored in *out. |
| APO_STATUS_INVALID_ARGUMENT | out is NULL, psf is NULL, or the PSF handle contains no native object. |
| APO_STATUS_NOT_INITIALIZED | The native PSF atom count is negative. |
| APO_STATUS_RUNTIME_ERROR | Allocating the handle, selector, shared ownership, or a diagnostic failed, or another unexpected standard or nonstandard C++ exception crossed the boundary. |
*out owns one selector that keeps the native PSF alive. out pointer, *out == NULL. | void apo_atom_selector_destroy | ( | apo_atom_selector * | selector | ) |
Destroys an owned atom-selector handle.
| [in] | selector | Owned handle to release. NULL is accepted and is a no-op. A non-NULL pointer is invalid after this call returns. |
| apo_status apo_atom_selector_select | ( | apo_atom_selection ** | out, |
| const apo_atom_selector * | selector, | ||
| const char * | selection_string | ||
| ) |
Evaluates one atom-selection expression.
selection_string is parsed as a null-terminated byte string. Keywords and dotted operators use ASCII spellings and case-insensitive matching. The C interface cannot represent an embedded null byte; bytes after the first null are not part of the expression. See Atom Selection for fields, wildcards, ranges, precedence, and expansion operators.
| [out] | out | Non-NULL address receiving a newly owned selection handle. The function stores NULL before validating other arguments and leaves *out == NULL on every failure path. Release a successful result with apo_atom_selection_destroy. |
| [in] | selector | Borrowed live selector handle. The pointer may not be NULL and is not retained. |
| [in] | selection_string | Borrowed nonempty, null-terminated expression. The bytes are copied during tokenization and are not retained. |
| APO_STATUS_OK | A new owned selection was stored in *out. |
| APO_STATUS_INVALID_ARGUMENT | out is NULL, selector is NULL, the selector handle contains no native object, selection_string is NULL or empty, the expression has a lexical, syntax, operator, range, or parenthesis error, or a stored PSF bonded-neighbor index is out of range. |
| APO_STATUS_RUNTIME_ERROR | The shared PSF violates parser residue, group, or bonded-connectivity invariants; an internal parser invariant failed; allocation failed; or another unexpected standard or nonstandard C++ exception crossed the boundary. |
*out owns an immutable selection independent of the selector and PSF lifetimes. out pointer, *out == NULL.