CASM  1.1.0
A Clusters Approach to Statistical Mechanics
API

Detailed Description

Relates to the CASM API.

All primary CASM functionality is included in the CASM library 'libcasm'.

The CASM API refers to the actions that can be performed by passing string commands through the extern "C" function casm_capi which in turn calls functions in libcasm. The casm_capi function and a limited set of others that allow for constructing PrimClex objects and input/output streams are available in the library 'libccasm'.

The CASM API is primarily intended to be used via the command line executable 'casm', which provides documentation of the allowed options, or the 'casm' Python package, but can be also be accessed directly to enable integration with other software.

Classes

struct  CASM::CommandArgs
 Data structure holding basic CASM command info. More...
 
class  CASM::InterfaceBase< OptionType >
 Base class for generic use of algorithms through the API. More...
 

Typedefs

typedef std::function< int(const CommandArgs &)> CASM::Command
 
typedef std::map< std::string, CommandCASM::CommandMap
 
template<typename OptionType >
using CASM::InterfaceMap = notstd::unique_cloneable_map< std::string, InterfaceBase< OptionType > >
 Used to hold a list of all algorithms that may be accessed via the API. More...
 

Functions

CommandMapCASM::command_map ()
 Return static CommandMap containing all CASM API commands. More...
 
int CASM::casm_api (const CommandArgs &args)
 Executes CASM commands specified by args. More...
 
PrimClexCASM::make_primclex_if_not (const CommandArgs &args, std::unique_ptr< PrimClex > &uniq_primclex)
 If !_primclex, construct new PrimClex stored in uniq_primclex, then return reference to existing or constructed PrimClex. More...
 
std::ostream & CASM::make_ostream_if (bool output, std::ostream &sout, std::unique_ptr< std::ostream > &fout, fs::path out_path, bool gzip)
 Return a reference to proper std::ostream. More...
 
int CASM::help_command (const CommandArgs &args)
 Print CASM help info to log() More...
 
int CASM::version_command (const CommandArgs &args)
 
template<typename OptionType >
std::unique_ptr< InterfaceMap< OptionType > > CASM::make_interface_map ()
 Use to construct an InterfaceMap. More...
 
typedef struct cPrimClex cPrimClex
 For CASM::PrimClex*. More...
 
typedef struct costream costream
 For std::ostream*. More...
 
costreamcasm_STDOUT ()
 
costreamcasm_STDERR ()
 
costreamcasm_nullstream_new ()
 
costreamcasm_ostringstream_new ()
 
void casm_ostringstream_delete (costream *ptr)
 
unsigned long casm_ostringstream_size (costream *ptr)
 
char * casm_ostringstream_strcpy (costream *ptr, char *c_str)
 
cPrimClexcasm_primclex_null ()
 
cPrimClexcasm_primclex_new (char *path, costream *log, costream *err_log)
 
void casm_primclex_delete (cPrimClex *ptr)
 
void casm_primclex_refresh (cPrimClex *ptr, costream *log, costream *err_log, bool read_settings, bool read_composition, bool read_chem_ref, bool read_configs, bool clear_clex)
 
void casm_command_list (costream *ostringstream_log)
 Print to log the recognized casm commands as a JSON array. More...
 
int casm_capi (char *args, cPrimClex *primclex, char *root, costream *log, costream *err_log)
 

Typedef Documentation

◆ Command

typedef std::function<int(const CommandArgs &)> CASM::Command

Definition at line 85 of file casm_functions.hh.

◆ CommandMap

typedef std::map<std::string, Command> CASM::CommandMap

Definition at line 86 of file casm_functions.hh.

◆ costream

typedef struct costream costream

For std::ostream*.

Definition at line 1 of file api.hh.

◆ cPrimClex

typedef struct cPrimClex cPrimClex

For CASM::PrimClex*.

Definition at line 1 of file api.hh.

◆ InterfaceMap

template<typename OptionType >
using CASM::InterfaceMap = typedef notstd::unique_cloneable_map<std::string, InterfaceBase<OptionType> >

Used to hold a list of all algorithms that may be accessed via the API.

Definition at line 114 of file casm_functions.hh.

Function Documentation

◆ casm_api()

int CASM::casm_api ( const CommandArgs args)

Executes CASM commands specified by args.

Definition at line 201 of file casm_functions.cc.

◆ casm_capi()

int casm_capi ( char *  args,
cPrimClex primclex,
char *  root,
costream log,
costream err_log 
)

Construct a CommandArgs instance and call casm_api

  • Will construct temporary PrimClex if necessary
  • If primclex is not null, then root is ignored.

Definition at line 88 of file api.cc.

◆ casm_command_list()

void casm_command_list ( costream ostringstream_log)

Print to log the recognized casm commands as a JSON array.

Definition at line 73 of file api.cc.

◆ casm_nullstream_new()

costream* casm_nullstream_new ( )

◆ casm_ostringstream_delete()

void casm_ostringstream_delete ( costream ptr)

Definition at line 31 of file api.cc.

◆ casm_ostringstream_new()

costream* casm_ostringstream_new ( )

Definition at line 27 of file api.cc.

◆ casm_ostringstream_size()

unsigned long casm_ostringstream_size ( costream ptr)

Definition at line 35 of file api.cc.

◆ casm_ostringstream_strcpy()

char* casm_ostringstream_strcpy ( costream ptr,
char *  c_str 
)

Definition at line 40 of file api.cc.

◆ casm_primclex_delete()

void casm_primclex_delete ( cPrimClex ptr)

Definition at line 56 of file api.cc.

◆ casm_primclex_new()

cPrimClex* casm_primclex_new ( char *  path,
costream log,
costream err_log 
)

Definition at line 48 of file api.cc.

◆ casm_primclex_null()

cPrimClex* casm_primclex_null ( )

Definition at line 46 of file api.cc.

◆ casm_primclex_refresh()

void casm_primclex_refresh ( cPrimClex ptr,
costream log,
costream err_log,
bool  read_settings,
bool  read_composition,
bool  read_chem_ref,
bool  read_configs,
bool  clear_clex 
)

Definition at line 60 of file api.cc.

◆ casm_STDERR()

costream* casm_STDERR ( )

Definition at line 21 of file api.cc.

◆ casm_STDOUT()

costream* casm_STDOUT ( )

Definition at line 19 of file api.cc.

◆ command_map()

CommandMap & CASM::command_map ( )

Return static CommandMap containing all CASM API commands.

Definition at line 115 of file casm_functions.cc.

◆ help_command()

int CASM::help_command ( const CommandArgs args)

Print CASM help info to log()

Definition at line 277 of file casm_functions.cc.

◆ make_interface_map()

template<typename OptionType >
std::unique_ptr<InterfaceMap<OptionType> > CASM::make_interface_map ( )

Use to construct an InterfaceMap.

Definition at line 142 of file casm_functions.hh.

◆ make_ostream_if()

std::ostream & CASM::make_ostream_if ( bool  output,
std::ostream &  sout,
std::unique_ptr< std::ostream > &  fout,
fs::path  out_path,
bool  gzip 
)

Return a reference to proper std::ostream.

Parameters
outputOutput mode: False: use 'sout', True: check 'out_path' and 'gzip' to decide
soutstream to use if not writing to file
foutwill be given an open file if writing to file
out_path,whereto write if 'output': if "STDOUT", use 'sout'; otherwise filename
gzipif true, write to gzip file
Returns
reference to stream to use

Definition at line 254 of file casm_functions.cc.

◆ make_primclex_if_not()

PrimClex & CASM::make_primclex_if_not ( const CommandArgs args,
std::unique_ptr< PrimClex > &  uniq_primclex 
)

If !_primclex, construct new PrimClex stored in uniq_primclex, then return reference to existing or constructed PrimClex.

Parameters
argsCommandArgs reference
uniq_primclexReference to null std::unique_ptr<PrimClex> to manage PrimClex, if it is constructed
Returns
reference to PrimClex (either newly constructed managed by uniq_primclex, or existing pointed at by args.primclex)

Definition at line 235 of file casm_functions.cc.

◆ version_command()

int CASM::version_command ( const CommandArgs args)

Definition at line 308 of file casm_functions.cc.