Loading...
Searching...
No Matches
gpr::capi::Atoms Class Reference

#include <gpr/capi/gpridge.hpp>

Public Member Functions

 Atoms ()=default
 Atoms (gpr_atoms_t h, adopt_t) noexcept
 Atoms (gpr_atoms_t h, borrow_t) noexcept
 ~Atoms ()
 Atoms (const Atoms &)=delete
Atoms & operator= (const Atoms &)=delete
 Atoms (Atoms &&other) noexcept
Atoms & operator= (Atoms &&other) noexcept
void reset () noexcept
gpr_atoms_t release () noexcept
bool owns () const noexcept
gpr_atoms_t handle () const noexcept
 operator bool () const noexcept
int n_moving () const
int n_pairtypes () const

Static Public Member Functions

static Atoms simple (int n_atoms)
static Atoms create (const AtomsConfig &config)

Detailed Description

Definition at line 1278 of file gpridge.hpp.

Constructor & Destructor Documentation

◆ Atoms() [1/5]

gpr::capi::Atoms::Atoms ( )
default

◆ Atoms() [2/5]

gpr::capi::Atoms::Atoms ( gpr_atoms_t h,
adopt_t  )
inlinenoexcept

Definition at line 1281 of file gpridge.hpp.

1281: handle_(h), owns_(true) { }

◆ Atoms() [3/5]

gpr::capi::Atoms::Atoms ( gpr_atoms_t h,
borrow_t  )
inlinenoexcept

Definition at line 1282 of file gpridge.hpp.

1282: handle_(h), owns_(false) { }

◆ ~Atoms()

gpr::capi::Atoms::~Atoms ( )
inline

Definition at line 1283 of file gpridge.hpp.

1284 {
1285 reset();
1286 }
void reset() noexcept
Definition gpridge.hpp:1321

◆ Atoms() [4/5]

gpr::capi::Atoms::Atoms ( const Atoms & )
delete

◆ Atoms() [5/5]

gpr::capi::Atoms::Atoms ( Atoms && other)
inlinenoexcept

Definition at line 1290 of file gpridge.hpp.

1290 : handle_(other.handle_), owns_(other.owns_)
1291 {
1292 other.handle_ = nullptr;
1293 other.owns_ = false;
1294 }

Member Function Documentation

◆ create()

Atoms gpr::capi::Atoms::create ( const AtomsConfig & config)
inlinestaticnodiscard

Definition at line 1314 of file gpridge.hpp.

1315 {
1316 gpr_atoms_t h = gpr_atoms_create(&config);
1317 if (!h) throw Error(gpr_last_status(), gpr_last_error_message());
1318 return Atoms(h, adopt);
1319 }
gpr_atoms_t gpr_atoms_create(const gpr_atoms_config_t *config)
Create an atoms configuration handle from descriptor. Returns NULL on failure (check gpr_last_error()...
int gpr_last_status(void)
Status of the last call on this thread that failed (ABI 1.1), like errno: a constructor that returns ...
const char * gpr_last_error_message(void)
The same string as gpr_last_error (ABI 1.6). Never NULL. Fortran and the other bindings call this nam...
struct gpr_atoms_s * gpr_atoms_t
Definition gpridge_c.h:389
constexpr adopt_t adopt
Definition gpridge.hpp:37

◆ handle()

gpr_atoms_t gpr::capi::Atoms::handle ( ) const
inlinenodiscardnoexcept

Definition at line 1342 of file gpridge.hpp.

1343 {
1344 return handle_;
1345 }

◆ n_moving()

int gpr::capi::Atoms::n_moving ( ) const
inlinenodiscard

Definition at line 1351 of file gpridge.hpp.

1352 {
1353 return gpr_atoms_n_moving(handle_);
1354 }
int gpr_atoms_n_moving(gpr_atoms_t atoms)
Number of moving (non-frozen) atoms.

◆ n_pairtypes()

int gpr::capi::Atoms::n_pairtypes ( ) const
inlinenodiscard

Definition at line 1355 of file gpridge.hpp.

1356 {
1357 return gpr_atoms_n_pairtypes(handle_);
1358 }
int gpr_atoms_n_pairtypes(gpr_atoms_t atoms)
Number of pair types.

◆ operator bool()

gpr::capi::Atoms::operator bool ( ) const
inlineexplicitnodiscardnoexcept

Definition at line 1346 of file gpridge.hpp.

1347 {
1348 return handle_ != nullptr;
1349 }

◆ operator=() [1/2]

Atoms & gpr::capi::Atoms::operator= ( Atoms && other)
inlinenoexcept

Definition at line 1295 of file gpridge.hpp.

1296 {
1297 if (this != &other) {
1298 reset();
1299 handle_ = other.handle_;
1300 owns_ = other.owns_;
1301 other.handle_ = nullptr;
1302 other.owns_ = false;
1303 }
1304 return *this;
1305 }

◆ operator=() [2/2]

Atoms & gpr::capi::Atoms::operator= ( const Atoms & )
delete

◆ owns()

bool gpr::capi::Atoms::owns ( ) const
inlinenodiscardnoexcept

Definition at line 1338 of file gpridge.hpp.

1339 {
1340 return owns_;
1341 }

◆ release()

gpr_atoms_t gpr::capi::Atoms::release ( )
inlinenodiscardnoexcept

Definition at line 1330 of file gpridge.hpp.

1331 {
1332 gpr_atoms_t h = handle_;
1333 handle_ = nullptr;
1334 owns_ = false;
1335 return h;
1336 }

◆ reset()

void gpr::capi::Atoms::reset ( )
inlinenoexcept

Definition at line 1321 of file gpridge.hpp.

1322 {
1323 if (handle_ && owns_) {
1324 gpr_atoms_destroy(handle_);
1325 }
1326 handle_ = nullptr;
1327 owns_ = false;
1328 }
void gpr_atoms_destroy(gpr_atoms_t atoms)
Destroy atoms configuration. Destroying NULL or a live handle clears gpr_last_status() and gpr_last_e...

◆ simple()

Atoms gpr::capi::Atoms::simple ( int n_atoms)
inlinestaticnodiscard

Definition at line 1307 of file gpridge.hpp.

1308 {
1310 if (!h) throw Error(gpr_last_status(), gpr_last_error_message());
1311 return Atoms(h, adopt);
1312 }
gpr_atoms_t gpr_atoms_create_simple(int n_atoms)
Convenience: create an atoms handle for N identical moving atoms. Equivalent to gpr_atoms_create(&gpr...

The documentation for this class was generated from the following file: