Chemfiles internals

Sources organisation

You may find the following directory in the chemfiles sources :

  • cmake: some CMake modules used for build configuration;
  • doc: this documentation;
  • examples: usage examples for C and C++ interfaces;
  • external: external libraries used by chemfiles;
  • include: the headers of chemfiles;
  • scripts: some python scripts used for developpement.
  • src: the sources of the library;
  • tests: the sources of the unit tests;

Classes organisation

Chemfiles is written in C++11, in an object-oriented fashion. A Trajectory is built on the top of two other private classes: a File and a Format. The File classes provides IO operation, and the Format classes do all the work for reading/writing information from the File.

../_images/classes.png

All the File to Format associations are managed by the TrajectoryFactory class.

class chemfiles::TrajectoryFactory

This class allow to register at compile time various Format and the associated File class, giving at runtime the good format when asked politely.

Each couple (File, Format) is represented by a trajectory_builder_t instance, and can be registered by an extension, or by a Format name.

Public Functions

trajectory_builder_t format(const string & name)

Get a trajectory_builder from a format type name.

Throws an error if the format can not be found

Return
A trajectory_builder corresponding to the format, if the format name is found in the list of registered formats.
Parameters
  • name -

    the format name

trajectory_builder_t by_extension(const string & ext)

Get a trajectory_builder from a format extention.

Throws an error if the format can not be found

Return
A trajectory_builder corresponding to the format, if the format extension is found in the list of registered extensions.
Parameters
  • ext -

    the format extention

void register_format(const string & name, trajectory_builder_t tb)

Register a trajectory_builder in the internal format names list.

void register_extension(const string & ext, trajectory_builder_t tb)

Register an trajectory_builder in the internal extensions list.

Public Static Functions

TrajectoryFactory & get()

Get the instance of the TrajectoryFactory.