Commit 990dc0cf authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Pass constant string arguments by reference

parent 7a63a072
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -158,7 +158,7 @@ public:
   * \return config: `GeometryConfiguration*` Pointer to object containing the
   * configuration data.
   */
  static GeometryConfiguration *from_legacy(std::string file_name);
  static GeometryConfiguration *from_legacy(const std::string& file_name);

  /*! \brief Get the value of a parameter by name.
   *
@@ -172,7 +172,7 @@ public:
   * \param param_name: `string` Name of the parameter to be retrieved.
   * \return value: `double` Value of the requested parameter.
   */
  double get_param(std::string param_name);
  double get_param(const std::string& param_name);
  
  /*! \brief Get the X coordinate of a sphere by its index.
   *
@@ -255,7 +255,7 @@ protected:
   * \return config: `ScattererConfiguration*` Pointer to object containing the
   * scatterer configuration data.
   */
  static ScattererConfiguration *from_hdf5(std::string file_name);
  static ScattererConfiguration *from_hdf5(const std::string& file_name);
  
  /*! \brief Build configuration from legacy binary input file.
   *
@@ -268,7 +268,7 @@ protected:
   * \return config: `ScattererConfiguration*` Pointer to object containing the
   * scatterer configuration data.
   */
  static ScattererConfiguration *from_legacy(std::string file_name);
  static ScattererConfiguration *from_legacy(const std::string& file_name);

  /*! \brief Write the scatterer configuration data to HDF5 binary output.
   *
@@ -278,7 +278,7 @@ protected:
   *
   * \param file_name: `string` Name of the binary configuration data file.
   */
  void write_hdf5(std::string file_name);
  void write_hdf5(const std::string& file_name);
  
  /*! \brief Write the scatterer configuration data to legacy binary output.
   *
@@ -289,7 +289,7 @@ protected:
   *
   * \param file_name: `string` Name of the binary configuration data file.
   */
  void write_legacy(std::string file_name);
  void write_legacy(const std::string& file_name);
public:
  /*! \brief Build a scatterer configuration structure.
   *
@@ -318,7 +318,7 @@ public:
			 int configs,
			 double *scale_vector,
			 int nxi,
			 std::string variable_name,
			 const std::string& variable_name,
			 int *iog_vector,
			 double *ros_vector,
			 int *nshl_vector,
@@ -373,7 +373,7 @@ public:
   * \return config: `ScattererConfiguration*` Pointer to object containing the
   * scatterer configuration data.
   */
  static ScattererConfiguration* from_binary(std::string file_name, std::string mode = "LEGACY");
  static ScattererConfiguration* from_binary(const std::string& file_name, const std::string& mode = "LEGACY");

  /*! \brief Build scatterer configuration from legacy configuration input file.
   *
@@ -386,7 +386,7 @@ public:
   * \return config: `ScattererConfiguration*` Pointer to object containing the
   * scatterer configuration data.
   */
  static ScattererConfiguration* from_dedfb(std::string file_name);
  static ScattererConfiguration* from_dedfb(const std::string& file_name);

  /*! \brief Get the dielectric constant of a material for a specific wavelength.
   *
@@ -433,7 +433,7 @@ public:
   * \param param_name: `string` Name of the parameter to be retrieved.
   * \return value: `double` Value of the requested parameter.
   */
  double get_param(std::string param_name);
  double get_param(const std::string& param_name);
  
  /*! \brief Get the radius of a sphere by its index.
   *
@@ -495,7 +495,7 @@ public:
   * \param mode: `string` Binary encoding. Can be one of ["LEGACY", "HDF5"] . Optional
   * (default is "LEGACY").
   */
  void write_binary(std::string file_name, std::string mode="LEGACY");
  void write_binary(const std::string& file_name, const std::string& mode="LEGACY");

  /*! \brief Write the scatterer configuration data to formatted text output.
   *
@@ -507,7 +507,7 @@ public:
   *
   * \param file_name: `string` Name of the file to be written.
   */
  void write_formatted(std::string file_name);
  void write_formatted(const std::string& file_name);

  /*! \brief Test whether two instances of ScattererConfiguration are equal.
   *
@@ -520,7 +520,7 @@ public:
   * \param other: `ScattererConfiguration &` Reference to the instance to be compared with.
   * \return result: `bool` True, if the two instances are equal, false otherwise.
   */
  bool operator ==(ScattererConfiguration &other);
  bool operator ==(const ScattererConfiguration &other);
};

#endif
+1 −1
Original line number Diff line number Diff line
@@ -32,6 +32,6 @@
 * \return array_lines `string*` An array of strings, one for each input
 * file line.
 */
std::string *load_file(std::string file_name, int *count);
std::string *load_file(const std::string& file_name, int *count);

#endif /* INCLUDE_PARSERS_H_ */
+14 −14
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ class TransitionMatrix {
   * \return config: `TransitionMatrix *` Pointer to object containing the
   * transition matrix data.
   */
  static TransitionMatrix *from_hdf5(std::string file_name);
  static TransitionMatrix *from_hdf5(const std::string& file_name);
  
  /*! \brief Build transition matrix from a legacy binary input file.
   *
@@ -44,7 +44,7 @@ class TransitionMatrix {
   * \return config: `TransitionMatrix *` Pointer to object containing the
   * transition matrix data.
   */
  static TransitionMatrix *from_legacy(std::string file_name);
  static TransitionMatrix *from_legacy(const std::string& file_name);

  /*! \brief Write the Transition Matrix to HDF5 binary output.
   *
@@ -54,7 +54,7 @@ class TransitionMatrix {
   *
   * \param file_name: `string` Name of the binary configuration data file.
   */
  void write_hdf5(std::string file_name);
  void write_hdf5(const std::string& file_name);
  
  /*! \brief Write transition matrix data to HDF5 binary output.
   *
@@ -71,7 +71,7 @@ class TransitionMatrix {
   * \param _am0m: `complex double **`
   */
  static void write_hdf5(
			 std::string file_name, np_int _nlemt, int _lm, double _vk,
			 const std::string& file_name, np_int _nlemt, int _lm, double _vk,
			 double _exri, dcomplex **_am0m
  );
  
@@ -91,7 +91,7 @@ class TransitionMatrix {
   * \param _sphere_radius: `double` Radius of the sphere.
   */
  static void write_hdf5(
			 std::string file_name, int _lm, double _vk, double _exri,
			 const std::string& file_name, int _lm, double _vk, double _exri,
			 dcomplex **_rmi, dcomplex **_rei, double _sphere_radius
  );

@@ -99,7 +99,7 @@ class TransitionMatrix {
   *
   * \param file_name: `string` Name of the binary configuration data file.
   */
  void write_legacy(std::string file_name);
  void write_legacy(const std::string& file_name);

  /*! \brief Write transition matrix data to binary output using legacy format.
   *
@@ -116,7 +116,7 @@ class TransitionMatrix {
   * \param _am0m: `complex double **`
   */
  static void write_legacy(
			   std::string file_name, np_int _nlemt, int _lm, double _vk,
			   const std::string& file_name, np_int _nlemt, int _lm, double _vk,
			   double _exri, dcomplex **_am0m
  );
  
@@ -136,7 +136,7 @@ class TransitionMatrix {
   * \param _sphere_radius: `double` Radius of the sphere.
   */
  static void write_legacy(
			   std::string file_name, int _lm, double _vk, double _exri,
			   const std::string& file_name, int _lm, double _vk, double _exri,
			   dcomplex **_rmi, dcomplex **_rei, double _sphere_radius
  );

@@ -205,7 +205,7 @@ class TransitionMatrix {
   * \return config: `TransitionMatrix *` Pointer to object containing the transition
   * matrix data.
   */
  static TransitionMatrix* from_binary(std::string file_name, std::string mode="LEGACY");
  static TransitionMatrix* from_binary(const std::string& file_name, const std::string& mode="LEGACY");

  /*! \brief Write the Transition Matrix to a binary file.
   *
@@ -219,7 +219,7 @@ class TransitionMatrix {
   * \param mode: `string` Binary encoding. Can be one of ["LEGACY", "HDF5"] . Optional
   * (default is "LEGACY").
   */
  void write_binary(std::string file_name, std::string mode="LEGACY");
  void write_binary(const std::string& file_name, const std::string& mode="LEGACY");
  
  /*! \brief Write a cluster Transition Matrix to a binary file without instanciating it.
   *
@@ -244,8 +244,8 @@ class TransitionMatrix {
   * (default is "LEGACY").
   */
  static void write_binary(
			   std::string file_name, np_int _nlemt, int _lm, double _vk,
			   double _exri, dcomplex **_am0m, std::string mode="LEGACY"
			   const std::string& file_name, np_int _nlemt, int _lm, double _vk,
			   double _exri, dcomplex **_am0m, const std::string& mode="LEGACY"
  );
  
  /*! \brief Write a single sphere Transition Matrix to a binary file without instanciating it.
@@ -272,9 +272,9 @@ class TransitionMatrix {
   * (default is "LEGACY").
   */
  static void write_binary(
			   std::string file_name, int _lm, double _vk, double _exri,
			   const std::string& file_name, int _lm, double _vk, double _exri,
			   dcomplex **_rmi, dcomplex **_rei, double _sphere_radius,
			   std::string mode="LEGACY"
			   const std::string& mode="LEGACY"
  );

  /*! \brief Test whether two instances of TransitionMatrix are equal.
+5 −5
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ public:
   *
   * \param name: `string` Name of the file that was accessed.
   */
  OpenConfigurationFileException(std::string name) { file_name = name; }
  OpenConfigurationFileException(const std::string& name) { file_name = name; }

  /**
   * \brief Exception message.
@@ -86,7 +86,7 @@ public:
   *
   * \param problem: `string` Description of the problem that occurred.
   */
  MatrixOutOfBoundsException(std::string problem) { message = problem; }
  MatrixOutOfBoundsException(const std::string& problem) { message = problem; }
  /**
   * \brief Exception message.
   */
@@ -107,7 +107,7 @@ public:
   *
   * \param problem: `string` Description of the problem that occurred.
   */
  UnrecognizedConfigurationException(std::string problem) { message = problem; }
  UnrecognizedConfigurationException(const std::string& problem) { message = problem; }
  /**
   * \brief Exception message.
   */
@@ -128,7 +128,7 @@ public:
   *
   * \param problem: `string` Description of the problem that occurred.
   */
  UnrecognizedFormatException(std::string problem) { message = problem; }
  UnrecognizedFormatException(const std::string& problem) { message = problem; }
  /**
   * \brief Exception message.
   */
@@ -149,7 +149,7 @@ public:
   *
   * \param problem: `string` Description of the problem that occurred.
   */
  UnrecognizedParameterException(std::string problem) { message = problem; }
  UnrecognizedParameterException(const std::string& problem) { message = problem; }
  /**
   * \brief Exception message.
   */
+5 −5
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ class FileSchema {
   * \param rec_types: `string *` Description of the records in the file.
   * \param rec_names: `string *` Names of the records in the file.
   */
  FileSchema(int num_rec, std::string *rec_types, std::string *rec_names=NULL);
  FileSchema(int num_rec, const std::string *rec_types, const std::string *rec_names=NULL);

  /*! \brief FileSchema instance destroyer.
   */
@@ -83,7 +83,7 @@ class HDFFile {
   * \param fapl_id: `hid_t` File access property list identifier (default is `H5P_DEFAULT`).
   */
  HDFFile(
	  std::string name, unsigned int flags=H5F_ACC_EXCL,
	  const std::string& name, unsigned int flags=H5F_ACC_EXCL,
	  hid_t fcpl_id=H5P_DEFAULT, hid_t fapl_id=H5P_DEFAULT
  );

@@ -105,7 +105,7 @@ class HDFFile {
   * \return hdf_file: `HDFFile *` Pointer to a new, open HDF5 file.
   */
  static HDFFile* from_schema(
			      FileSchema &schema, std::string name, unsigned int flags=H5F_ACC_EXCL,
			      FileSchema &schema, const std::string& name, unsigned int flags=H5F_ACC_EXCL,
			      hid_t fcpl_id=H5P_DEFAULT, hid_t fapl_id=H5P_DEFAULT
  );

@@ -133,7 +133,7 @@ class HDFFile {
   * \return status: `herr_t` Exit status of the operation.
   */
  herr_t read(
	       std::string dataset_name, std::string data_type, void *buffer,
	       const std::string& dataset_name, const std::string& data_type, void *buffer,
	       hid_t mem_space_id=H5S_ALL, hid_t file_space_id=H5S_ALL,
	       hid_t dapl_id=H5P_DEFAULT, hid_t dxpl_id=H5P_DEFAULT
  );
@@ -150,7 +150,7 @@ class HDFFile {
   * \return status: `herr_t` Exit status of the operation.
   */
  herr_t write(
	       std::string dataset_name, std::string data_type, const void *buffer,
	       const std::string& dataset_name, const std::string& data_type, const void *buffer,
	       hid_t mem_space_id=H5S_ALL, hid_t file_space_id=H5S_ALL,
	       hid_t dapl_id=H5P_DEFAULT, hid_t dxpl_id=H5P_DEFAULT
  );
Loading