text:
//---------------------------------------------------------------------------//
//!
//! \file   Data_NuclideProperties.cpp
//! \author Alex Robinson
//! \brief  The nuclide properties class definition
//!
//---------------------------------------------------------------------------//

// Boost Includes
#include <boost/serialization/map.hpp>
#include <boost/serialization/list.hpp>
#include <boost/serialization/shared_ptr.hpp>

// FRENSIE Includes
#include "FRENSIE_Archives.hpp" // Must include first
#include "Data_NuclideProperties.hpp"
#include "Utility_PhysicalConstants.hpp"
#include "Utility_HDF5IArchive.hpp"
#include "Utility_HDF5OArchive.hpp"
#include "Utility_PhysicalConstants.hpp"
#include "Utility_ExceptionTestMacros.hpp"

namespace Data{

// Initialize static member data
double NuclideProperties::s_energy_comp_tol = 1e-9;

// Default constructor
NuclideProperties::NuclideProperties()
{ /* ... */ }

// Constructor
NuclideProperties::NuclideProperties( const Data::ZAID zaid,
                                      const double atomic_weight_ratio )
  : d_zaid( zaid ),
    d_atomic_weight_ratio( atomic_weight_ratio )
{
  TEST_FOR_EXCEPTION( atomic_weight_ratio <= 0.0,
                      InvalidScatteringCenterPropertiesData,
                      "The atomic weight ratio cannot be zero or negative!" );
}

// Tie constructor
NuclideProperties::NuclideProperties( const Data::ZAID zaid,
                                      const AtomicWeight atomic_weight )
  : NuclideProperties( zaid, atomic_weight/Utility::PhysicalConstants::neutron_rest_mass_amu_q )
{ /* ... */ }

// Copy constructor
NuclideProperties::NuclideProperties( const NuclideProperties& other )
  : d_zaid( other.d_zaid ),
    d_atomic_weight_ratio( other.d_atomic_weight_ratio ),
    d_nuclear_data_properties( other.d_nuclear_data_properties ),
    d_thermal_nuclear_data_properties( other.d_thermal_nuclear_data_properties ),
    d_adjoint_nuclear_data_properties( other.d_adjoint_nuclear_data_properties ),
    d_adjoint_thermal_nuclear_data_properties( other.d_adjoint_thermal_nuclear_data_properties ),
    d_photonuclear_data_properties( other.d_photonuclear_data_properties ),
    d_adjoint_photonuclear_data_properties( other.d_adjoint_photonuclear_data_properties )
{ /* ... */ }

// Check if there are no properties
/*! \details Nuclide properties are considered empty if there are no properties
 * stored for nuclear and photonuclear interaction types (there may be stored
 * atomic data).
 */
bool NuclideProperties::empty() const
{
  return d_nuclear_data_properties.empty() &&
    d_thermal_nuclear_data_properties.empty() &&
    d_adjoint_nuclear_data_properties.empty() &&
    d_adjoint_thermal_nuclear_data_properties.empty() &&
    d_photonuclear_data_properties.empty() &&
    d_adjoint_photonuclear_data_properties.empty();
}

// Get the zaid
const Data::ZAID& NuclideProperties::zaid() const
{
  return d_zaid;
}

// Get the atomic weight
auto NuclideProperties::atomicWeight() const -> AtomicWeight
{
  return d_atomic_weight_ratio*Utility::PhysicalConstants::neutron_rest_mass_amu_q;
}

// Get the atomic weight ratio (atomic weight/neutron weight)
double NuclideProperties::atomicWeightRatio() const
{
  return d_atomic_weight_ratio;
}

// Check if there is nuclear data with the desired format
bool NuclideProperties::nuclearDataAvailable(
                        const NuclearDataProperties::FileType file_type ) const
{
  return BaseType::dataAvailable( d_nuclear_data_properties, file_type );
}

// Check if there is nuclear data with the desired format and version
bool NuclideProperties::nuclearDataAvailable(
                               const NuclearDataProperties::FileType file_type,
                               const unsigned table_major_version ) const
{
  return BaseType::dataAvailable( d_nuclear_data_properties,
                                  file_type,
                                  table_major_version );
}

// Check if there is nuclear data at the evaluation temp
bool NuclideProperties::nuclearDataAvailable(
                               const NuclearDataProperties::FileType file_type,
                               const unsigned table_major_version,
                               const Energy evaluation_temp ) const
{
  return this->dataAvailable( d_nuclear_data_properties,
                              file_type,
                              table_major_version,
                              evaluation_temp );
}

// Check if there is nuclear data at the desired evaluation temp
bool NuclideProperties::nuclearDataAvailable(
                               const NuclearDataProperties::FileType file_type,
                               const unsigned table_major_version,
                               const Temperature evaluation_temp ) const
{
  return this->dataAvailable( d_nuclear_data_properties,
                              file_type,
                              table_major_version,
                              evaluation_temp );
}

// Get the nuclear data file types
std::set<NuclearDataProperties::FileType> NuclideProperties::getNuclearDataFileTypes() const
{
  return BaseType::getDataFileTypes( d_nuclear_data_properties );
}

// Get the nuclear data file versions
std::set<unsigned> NuclideProperties::getDataFileVersions(
                        const NuclearDataProperties::FileType file_type ) const
{
  return BaseType::getDataFileVersions( d_nuclear_data_properties,
                                        file_type );
}

// Get the recommended nuclear data file major version (generally the newest version)
unsigned NuclideProperties::getRecommendedDataFileVersion(
                        const NuclearDataProperties::FileType file_type ) const
{
  return BaseType::getMaxDataFileVersion( d_nuclear_data_properties,
                                          file_type,
                                          "Nuclear" );
}

// Get the nuclear data evaluation temps
auto NuclideProperties::getDataEvaluationTempsInMeV(
              const NuclearDataProperties::FileType file_type,
              const unsigned table_major_version ) const -> std::vector<Energy>
{
  return this->getDataEvaluationTempsInMeV( d_nuclear_data_properties,
                                            file_type,
                                            table_major_version );
}

// Get the nuclear data evaluation temps
auto NuclideProperties::getDataEvaluationTemps(
         const NuclearDataProperties::FileType file_type,
         const unsigned table_major_version ) const -> std::vector<Temperature>
{
  return this->getDataEvaluationTemps( d_nuclear_data_properties,
                                       file_type,
                                       table_major_version );
}

// Get the nuclear data properties
const NuclearDataProperties& NuclideProperties::getNuclearDataProperties(
                               const NuclearDataProperties::FileType file_type,
                               const unsigned table_major_version,
                               const Energy evaluation_temp,
                               const bool find_exact ) const
{
  return this->getProperties<NuclearDataProperties>( d_nuclear_data_properties,
                                                     file_type,
                                                     table_major_version,
                                                     evaluation_temp,
                                                     find_exact,
                                                     "Nuclear" );
}

// Get the nuclear data properties
const std::shared_ptr<const NuclearDataProperties>&
NuclideProperties::getSharedNuclearDataProperties(
                               const NuclearDataProperties::FileType file_type,
                               const unsigned table_major_version,
                               const Energy evaluation_temp,
                               const bool find_exact ) const
{
  return this->getSharedProperties<NuclearDataProperties>(
                                                     d_nuclear_data_properties,
                                                     file_type,
                                                     table_major_version,
                                                     evaluation_temp,
                                                     find_exact,
                                                     "Nuclear" );
}

// Get the nuclear data properties
const NuclearDataProperties& NuclideProperties::getNuclearDataProperties(
                              const NuclearDataProperties::FileType file_type,
                              const unsigned table_major_version,
                              const Temperature evaluation_temp,
                              const bool find_exact ) const
{
  return this->getProperties<NuclearDataProperties>( d_nuclear_data_properties,
                                                     file_type,
                                                     table_major_version,
                                                     evaluation_temp,
                                                     find_exact,
                                                     "Nuclear" );
}

// Get the nuclear data properties
const std::shared_ptr<const NuclearDataProperties>&
NuclideProperties::getSharedNuclearDataProperties(
                              const NuclearDataProperties::FileType file_type,
                              const unsigned table_major_version,
                              const Temperature evaluation_temp,
                              const bool find_exact ) const
{
  return this->getSharedProperties<NuclearDataProperties>(
                                                     d_nuclear_data_properties,
                                                     file_type,
                                                     table_major_version,
                                                     evaluation_temp,
                                                     find_exact,
                                                     "Nuclear" );
}

// Set the nuclear data properties
void NuclideProperties::setNuclearDataProperties( const std::shared_ptr<const NuclearDataProperties>& properties )
{
  this->setNuclearProperties( d_nuclear_data_properties,
                              properties,
                              this->zaid(),
                              "Nuclear" );
}

// Check if there is thermal nuclear data available
bool NuclideProperties::thermalNuclearDataAvailable(
                                                const std::string& name ) const
{
  return this->dataAvailable( d_thermal_nuclear_data_properties, name );
}

// Check if there is thermal nuclear data with the desired format
bool NuclideProperties::thermalNuclearDataAvailable(
                 const std::string& name,
                 const ThermalNuclearDataProperties::FileType file_type ) const
{
  return this->dataAvailable( d_thermal_nuclear_data_properties,
                              name,
                              file_type );
}

// Check if there is thermal nuclear data with the desired format
bool NuclideProperties::thermalNuclearDataAvailable(
                        const std::string& name,
                        const ThermalNuclearDataProperties::FileType file_type,
                        const unsigned table_major_version ) const
{
  return this->dataAvailable( d_thermal_nuclear_data_properties,
                              name,
                              file_type,
                              table_major_version );
}

// Check if there is thermal nuclear data with the desired format
bool NuclideProperties::thermalNuclearDataAvailable(
                        const std::string& name,
                        const ThermalNuclearDataProperties::FileType file_type,
                        const unsigned table_major_version,
                        const Energy evaluation_temp ) const
{
  return this->dataAvailable( d_thermal_nuclear_data_properties,
                              name,
                              file_type,
                              table_major_version,
                              evaluation_temp );
}

// Check if there is thermal nuclear data with the desired format
bool NuclideProperties::thermalNuclearDataAvailable(
                        const std::string& name,
                        const ThermalNuclearDataProperties::FileType file_type,
                        const unsigned table_major_version,
                        const Temperature evaluation_temp ) const
{
  return this->dataAvailable( d_thermal_nuclear_data_properties,
                              name,
                              file_type,
                              table_major_version,
                              evaluation_temp );
}

// Get the thermal nuclear data names
std::set<std::string> NuclideProperties::getThermalNuclearDataNames() const
{
  return this->getThermalNuclearDataNames( d_thermal_nuclear_data_properties );
}

// Get the thermal nuclear data file types
std::set<ThermalNuclearDataProperties::FileType> NuclideProperties::getThermalNuclearDataFileTypes( const std::string& name ) const
{
  return this->getDataFileTypes( d_thermal_nuclear_data_properties, name );
}

// Get the thermal nuclear data file versions
std::set<unsigned> NuclideProperties::getDataFileVersions(
                 const std::string& name,
                 const ThermalNuclearDataProperties::FileType file_type ) const
{
  return this->getDataFileVersions( d_thermal_nuclear_data_properties,
                                    name,
                                    file_type );
}

// Get the recommended thermal nuclear data file major version (generally the newest version)
unsigned NuclideProperties::getRecommendedDataFileVersion(
                 const std::string& name,
                 const ThermalNuclearDataProperties::FileType file_type ) const
{
  return this->getMaxDataFileVersion( d_thermal_nuclear_data_properties,
                                      name,
                                      file_type,
                                      "Thermal nuclear" );
}

// Get the thermal nuclear data evaluation temps
auto NuclideProperties::getDataEvaluationTempsInMeV(
              const std::string& name,
              const ThermalNuclearDataProperties::FileType file_type,
              const unsigned table_major_version ) const -> std::vector<Energy>
{
  return this->getDataEvaluationTempsInMeV( d_thermal_nuclear_data_properties,
                                            name,
                                            file_type,
                                            table_major_version );
}

// Get the thermal nuclear data evaluation temps
auto NuclideProperties::getDataEvaluationTemps(
         const std::string& name,
         const ThermalNuclearDataProperties::FileType file_type,
         const unsigned table_major_version ) const -> std::vector<Temperature>
{
  return this->getDataEvaluationTemps( d_thermal_nuclear_data_properties,
                                       name,
                                       file_type,
                                       table_major_version );
}

// Get the thermal nuclear data properties
const ThermalNuclearDataProperties& NuclideProperties::getThermalNuclearDataProperties(
                        const std::string& name,
                        const ThermalNuclearDataProperties::FileType file_type,
                        const unsigned table_major_version,
                        const Energy evaluation_temp,
                        const bool find_exact ) const
{
  return this->getProperties<ThermalNuclearDataProperties>(
                                             d_thermal_nuclear_data_properties,
                                             name,
                                             file_type,
                                             table_major_version,
                                             evaluation_temp,
                                             find_exact,
                                             "Thermal nuclear" );
}

// Get the thermal nuclear data properties
const std::shared_ptr<const ThermalNuclearDataProperties>&
NuclideProperties::getSharedThermalNuclearDataProperties(
                        const std::string& name,
                        const ThermalNuclearDataProperties::FileType file_type,
                        const unsigned table_major_version,
                        const Energy evaluation_temp,
                        const bool find_exact ) const
{
  return this->getSharedProperties<ThermalNuclearDataProperties>(
                                             d_thermal_nuclear_data_properties,
                                             name,
                                             file_type,
                                             table_major_version,
                                             evaluation_temp,
                                             find_exact,
                                             "Thermal nuclear" );
}

// Get the thermal nuclear data properties
const ThermalNuclearDataProperties& NuclideProperties::getThermalNuclearDataProperties(
                        const std::string& name,
                        const ThermalNuclearDataProperties::FileType file_type,
                        const unsigned table_major_version,
                        const Temperature evaluation_temp,
                        const bool find_exact ) const
{
  return this->getProperties<ThermalNuclearDataProperties>(
                                             d_thermal_nuclear_data_properties,
                                             name,
                                             file_type,
                                             table_major_version,
                                             evaluation_temp,
                                             find_exact,
                                             "Thermal nuclear" );
}

// Get the thermal nuclear data properties
const std::shared_ptr<const ThermalNuclearDataProperties>&
NuclideProperties::getSharedThermalNuclearDataProperties(
                        const std::string& name,
                        const ThermalNuclearDataProperties::FileType file_type,
                        const unsigned table_major_version,
                        const Temperature evaluation_temp,
                        const bool find_exact ) const
{
  return this->getSharedProperties<ThermalNuclearDataProperties>(
                                             d_thermal_nuclear_data_properties,
                                             name,
                                             file_type,
                                             table_major_version,
                                             evaluation_temp,
                                             find_exact,
                                             "Thermal nuclear" );
}

// Set the nuclear data properties
void NuclideProperties::setThermalNuclearDataProperties( const std::shared_ptr<const ThermalNuclearDataProperties>& properties )
{
  this->setThermalNuclearProperties( d_thermal_nuclear_data_properties,
                                     properties,
                                     this->zaid(),
                                     "Thermal nuclear" );
}

// Check if there is adjoint nuclear data with the desired format
bool NuclideProperties::adjointNuclearDataAvailable(
                 const AdjointNuclearDataProperties::FileType file_type ) const
{
  return BaseType::dataAvailable( d_adjoint_nuclear_data_properties,
                                  file_type );
}

// Check if there is adjoint nuclear data with the desired format and version
bool NuclideProperties::adjointNuclearDataAvailable(
                        const AdjointNuclearDataProperties::FileType file_type,
                        const unsigned table_major_version ) const
{
  return BaseType::dataAvailable( d_adjoint_nuclear_data_properties,
                                  file_type,
                                  table_major_version );
}

// Check if there is adjoint nuclear data at the evaluation temp
bool NuclideProperties::adjointNuclearDataAvailable(
                        const AdjointNuclearDataProperties::FileType file_type,
                        const unsigned table_major_version,
                        const Energy evaluation_temp ) const
{
  return this->dataAvailable( d_adjoint_nuclear_data_properties,
                              file_type,
                              table_major_version,
                              evaluation_temp );
}

// Check if there is adjoint nuclear data at the desired evaluation temp
bool NuclideProperties::adjointNuclearDataAvailable(
                        const AdjointNuclearDataProperties::FileType file_type,
                        const unsigned table_major_version,
                        const Temperature evaluation_temp ) const
{
  return this->dataAvailable( d_adjoint_nuclear_data_properties,
                              file_type,
                              table_major_version,
                              evaluation_temp );
}

// Get the adjoint nuclear data file types
std::set<AdjointNuclearDataProperties::FileType> NuclideProperties::getAdjointNuclearDataFileTypes() const
{
  return BaseType::getDataFileTypes( d_adjoint_nuclear_data_properties );
}

// Get the adjoint nuclear data file versions
std::set<unsigned> NuclideProperties::getDataFileVersions(
                 const AdjointNuclearDataProperties::FileType file_type ) const
{
  return BaseType::getDataFileVersions( d_adjoint_nuclear_data_properties,
                                        file_type );
}

// Get the recommended adjoint nuclear data file major version (generally the newest version)
unsigned NuclideProperties::getRecommendedDataFileVersion(
                 const AdjointNuclearDataProperties::FileType file_type ) const
{
  return BaseType::getMaxDataFileVersion( d_adjoint_nuclear_data_properties,
                                          file_type,
                                          "Adjoint nuclear" );
}

// Get the adjoint nuclear data evaluation temps
auto NuclideProperties::getDataEvaluationTempsInMeV(
              const AdjointNuclearDataProperties::FileType file_type,
              const unsigned table_major_version ) const -> std::vector<Energy>
{
  return this->getDataEvaluationTempsInMeV( d_adjoint_nuclear_data_properties,
                                            file_type,
                                            table_major_version );
}

// Get the adjoint nuclear data evaluation temps
auto NuclideProperties::getDataEvaluationTemps(
         const AdjointNuclearDataProperties::FileType file_type,
         const unsigned table_major_version ) const -> std::vector<Temperature>
{
  return this->getDataEvaluationTemps( d_adjoint_nuclear_data_properties,
                                       file_type,
                                       table_major_version );
}

// Get the adjoint nuclear data properties
const AdjointNuclearDataProperties& NuclideProperties::getAdjointNuclearDataProperties(
                        const AdjointNuclearDataProperties::FileType file_type,
                        const unsigned table_major_version,
                        const Energy evaluation_temp,
                        const bool find_exact ) const
{
  return this->getProperties<AdjointNuclearDataProperties>(
                                             d_adjoint_nuclear_data_properties,
                                             file_type,
                                             table_major_version,
                                             evaluation_temp,
                                             find_exact,
                                             "Adjoint nuclear" );
}

// Get the shared adjoint nuclear data properties
const std::shared_ptr<const AdjointNuclearDataProperties>&
NuclideProperties::getSharedAdjointNuclearDataProperties(
                        const AdjointNuclearDataProperties::FileType file_type,
                        const unsigned table_major_version,
                        const Energy evaluation_temp,
                        const bool find_exact ) const
{
  return this->getSharedProperties<AdjointNuclearDataProperties>(
                                             d_adjoint_nuclear_data_properties,
                                             file_type,
                                             table_major_version,
                                             evaluation_temp,
                                             find_exact,
                                             "Adjoint nuclear" );
}

// Get the adjoint nuclear data properties
const AdjointNuclearDataProperties& NuclideProperties::getAdjointNuclearDataProperties(
                        const AdjointNuclearDataProperties::FileType file_type,
                        const unsigned table_major_version,
                        const Temperature evaluation_temp,
                        const bool find_exact ) const
{
  return this->getProperties<AdjointNuclearDataProperties>(
                                             d_adjoint_nuclear_data_properties,
                                             file_type,
                                             table_major_version,
                                             evaluation_temp,
                                             find_exact,
                                             "Adjoint nuclear" );
}

// Get the shared adjoint nuclear data properties
const std::shared_ptr<const AdjointNuclearDataProperties>&
NuclideProperties::getSharedAdjointNuclearDataProperties(
                        const AdjointNuclearDataProperties::FileType file_type,
                        const unsigned table_major_version,
                        const Temperature evaluation_temp,
                        const bool find_exact ) const
{
  return this->getSharedProperties<AdjointNuclearDataProperties>(
                                             d_adjoint_nuclear_data_properties,
                                             file_type,
                                             table_major_version,
                                             evaluation_temp,
                                             find_exact,
                                             "Adjoint nuclear" );
}

// Set the adjoint nuclear data properties
void NuclideProperties::setAdjointNuclearDataProperties( const std::shared_ptr<const AdjointNuclearDataProperties>& properties )
{
  this->setNuclearProperties( d_adjoint_nuclear_data_properties,
                              properties,
                              this->zaid(),
                              "Adjoint nuclear" );
}

// Check if there is thermal nuclear data available
bool NuclideProperties::adjointThermalNuclearDataAvailable(
                                                const std::string& name ) const
{
  return this->dataAvailable( d_adjoint_thermal_nuclear_data_properties,
                              name );

}

// Check if there is adjoint thermal nuclear data with the desired format
bool NuclideProperties::adjointThermalNuclearDataAvailable(
     const std::string& name,
     const AdjointThermalNuclearDataProperties::FileType file_type ) const
{
  return this->dataAvailable( d_adjoint_thermal_nuclear_data_properties,
                              name,
                              file_type );
}

// Check if there is adjoint thermal nuclear data with the desired format
bool NuclideProperties::adjointThermalNuclearDataAvailable(
                 const std::string& name,
                 const AdjointThermalNuclearDataProperties::FileType file_type,
                 const unsigned table_major_version ) const
{
  return this->dataAvailable( d_adjoint_thermal_nuclear_data_properties,
                              name,
                              file_type,
                              table_major_version );
}

// Check if there is adjoint thermal nuclear data with the desired format
bool NuclideProperties::adjointThermalNuclearDataAvailable(
                 const std::string& name,
                 const AdjointThermalNuclearDataProperties::FileType file_type,
                 const unsigned table_major_version,
                 const Energy evaluation_temp ) const
{
  return this->dataAvailable( d_adjoint_thermal_nuclear_data_properties,
                              name,
                              file_type,
                              table_major_version,
                              evaluation_temp );
}

// Check if there is adjoint thermal nuclear data with the desired format
bool NuclideProperties::adjointThermalNuclearDataAvailable(
                 const std::string& name,
                 const AdjointThermalNuclearDataProperties::FileType file_type,
                 const unsigned table_major_version,
                 const Temperature evaluation_temp ) const
{
  return this->dataAvailable( d_adjoint_thermal_nuclear_data_properties,
                              name,
                              file_type,
                              table_major_version,
                              evaluation_temp );
}

// Get the adjoint thermal nuclear data names
std::set<std::string> NuclideProperties::getAdjointThermalNuclearDataNames() const
{
  return this->getThermalNuclearDataNames( d_adjoint_thermal_nuclear_data_properties );

}

// Get the adjoint thermal nuclear data file types
std::set<AdjointThermalNuclearDataProperties::FileType> NuclideProperties::getAdjointThermalNuclearDataFileTypes( const std::string& name ) const
{
  return this->getDataFileTypes( d_adjoint_thermal_nuclear_data_properties,
                                  name );
}

// Get the adjoint thermal nuclear data file versions
std::set<unsigned> NuclideProperties::getDataFileVersions(
          const std::string& name,
          const AdjointThermalNuclearDataProperties::FileType file_type ) const
{
  return this->getDataFileVersions( d_adjoint_thermal_nuclear_data_properties,
                                    name,
                                    file_type );
}

// Get the recommended adjoint thermal nuclear data file major version (generally the newest version)
unsigned NuclideProperties::getRecommendedDataFileVersion(
          const std::string& name,
          const AdjointThermalNuclearDataProperties::FileType file_type ) const
{
  return this->getMaxDataFileVersion( d_adjoint_thermal_nuclear_data_properties,
                                      name,
                                      file_type,
                                      "Adjoint thermal nuclear" );
}

// Get the adjoint thermal nuclear data evaluation temps
auto NuclideProperties::getDataEvaluationTempsInMeV(
              const std::string& name,
              const AdjointThermalNuclearDataProperties::FileType file_type,
              const unsigned table_major_version ) const -> std::vector<Energy>
{
  return this->getDataEvaluationTempsInMeV( d_adjoint_thermal_nuclear_data_properties,
                                            name,
                                            file_type,
                                            table_major_version );
}

// Get the adjoint thermal nuclear data evaluation temps
auto NuclideProperties::getDataEvaluationTemps(
         const std::string& name,
         const AdjointThermalNuclearDataProperties::FileType file_type,
         const unsigned table_major_version ) const -> std::vector<Temperature>
{
  return this->getDataEvaluationTemps( d_adjoint_thermal_nuclear_data_properties,
                                       name,
                                       file_type,
                                       table_major_version );
}

// Get the adjoint thermal nuclear data properties
const AdjointThermalNuclearDataProperties& NuclideProperties::getAdjointThermalNuclearDataProperties(
                 const std::string& name,
                 const AdjointThermalNuclearDataProperties::FileType file_type,
                 const unsigned table_major_version,
                 const Energy evaluation_temp,
                 const bool find_exact ) const
{
  return this->getProperties<AdjointThermalNuclearDataProperties>(
                                     d_adjoint_thermal_nuclear_data_properties,
                                     name,
                                     file_type,
                                     table_major_version,
                                     evaluation_temp,
                                     find_exact,
                                     "Adjoint thermal nuclear" );
}

// Get the shared adjoint thermal nuclear data properties
const std::shared_ptr<const AdjointThermalNuclearDataProperties>&
NuclideProperties::getSharedAdjointThermalNuclearDataProperties(
                 const std::string& name,
                 const AdjointThermalNuclearDataProperties::FileType file_type,
                 const unsigned table_major_version,
                 const Energy evaluation_temp,
                 const bool find_exact ) const
{
  return this->getSharedProperties<AdjointThermalNuclearDataProperties>(
                                     d_adjoint_thermal_nuclear_data_properties,
                                     name,
                                     file_type,
                                     table_major_version,
                                     evaluation_temp,
                                     find_exact,
                                     "Adjoint thermal nuclear" );
}

// Get the adjoint thermal nuclear data properties
const AdjointThermalNuclearDataProperties& NuclideProperties::getAdjointThermalNuclearDataProperties(
                 const std::string& name,
                 const AdjointThermalNuclearDataProperties::FileType file_type,
                 const unsigned table_major_version,
                 const Temperature evaluation_temp,
                 const bool find_exact ) const
{
  return this->getProperties<AdjointThermalNuclearDataProperties>(
                                     d_adjoint_thermal_nuclear_data_properties,
                                     name,
                                     file_type,
                                     table_major_version,
                                     evaluation_temp,
                                     find_exact,
                                     "Adjoint thermal nuclear" );
}

// Get the shared adjoint thermal nuclear data properties
const std::shared_ptr<const AdjointThermalNuclearDataProperties>&
NuclideProperties::getSharedAdjointThermalNuclearDataProperties(
                 const std::string& name,
                 const AdjointThermalNuclearDataProperties::FileType file_type,
                 const unsigned table_major_version,
                 const Temperature evaluation_temp,
                 const bool find_exact ) const
{
  return this->getSharedProperties<AdjointThermalNuclearDataProperties>(
                                     d_adjoint_thermal_nuclear_data_properties,
                                     name,
                                     file_type,
                                     table_major_version,
                                     evaluation_temp,
                                     find_exact,
                                     "Adjoint thermal nuclear" );
}

// Set the adjoint thermal nuclear data properties
void NuclideProperties::setAdjointThermalNuclearDataProperties( const std::shared_ptr<const AdjointThermalNuclearDataProperties>& properties )
{
  this->setThermalNuclearProperties( d_adjoint_thermal_nuclear_data_properties,
                                     properties,
                                     this->zaid(),
                                     "Adjoint thermal nuclear" );
}

// Check if there is photonuclear data with the desired format
bool NuclideProperties::photonuclearDataAvailable(
                   const PhotonuclearDataProperties::FileType file_type ) const
{
  return BaseType::dataAvailable( d_photonuclear_data_properties,
                                  file_type );
}

// Check if there is photonuclear data with the desired format and version
bool NuclideProperties::photonuclearDataAvailable(
                          const PhotonuclearDataProperties::FileType file_type,
                          const unsigned table_version ) const
{
  return BaseType::dataAvailable( d_photonuclear_data_properties,
                                  file_type,
                                  table_version );
}

// Get the photonuclear data file types
std::set<PhotonuclearDataProperties::FileType> NuclideProperties::getPhotonuclearDataFileTypes() const
{
  return BaseType::getDataFileTypes( d_photonuclear_data_properties );
}

// Get the photonuclear data file versions
std::set<unsigned> NuclideProperties::getDataFileVersions(
                   const PhotonuclearDataProperties::FileType file_type ) const
{
  return BaseType::getDataFileVersions( d_photonuclear_data_properties,
                                        file_type );
}

// Get the recommended photonuclear data file version
unsigned NuclideProperties::getRecommendedDataFileVersion(
                   const PhotonuclearDataProperties::FileType file_type ) const
{
  return BaseType::getMaxDataFileVersion( d_photonuclear_data_properties,
                                          file_type,
                                          "Photonuclear" );
}

// Get the photonuclear data properties
const PhotonuclearDataProperties& NuclideProperties::getPhotonuclearDataProperties(
                          const PhotonuclearDataProperties::FileType file_type,
                          const unsigned table_version ) const
{
  return BaseType::getProperties<PhotonuclearDataProperties>(
                                                d_photonuclear_data_properties,
                                                file_type,
                                                table_version,
                                                "Photonuclear" );
}

// Get the photonuclear data properties
const std::shared_ptr<const PhotonuclearDataProperties>&
NuclideProperties::getSharedPhotonuclearDataProperties(
                          const PhotonuclearDataProperties::FileType file_type,
                          const unsigned table_version ) const
{
  return BaseType::getSharedProperties<PhotonuclearDataProperties>(
                                                d_photonuclear_data_properties,
                                                file_type,
                                                table_version,
                                                "Photonuclear" );
}

// Set the photonuclear data properties
void NuclideProperties::setPhotonuclearDataProperties( const std::shared_ptr<const PhotonuclearDataProperties>& properties )
{
  this->setPhotonuclearProperties( d_photonuclear_data_properties,
                                   properties,
                                   this->zaid(),
                                   "NuclideProperties",
                                   "Photonuclear" );
}

// Check if there is adjoint photonuclear data with the desired format
bool NuclideProperties::adjointPhotonuclearDataAvailable(
            const AdjointPhotonuclearDataProperties::FileType file_type ) const
{
  return BaseType::dataAvailable( d_adjoint_photonuclear_data_properties,
                                  file_type );
}

// Check if there is adjoint photonuclear data with the desired format and version
bool NuclideProperties::adjointPhotonuclearDataAvailable(
                   const AdjointPhotonuclearDataProperties::FileType file_type,
                   const unsigned table_version ) const
{
  return BaseType::dataAvailable( d_adjoint_photonuclear_data_properties,
                                  file_type,
                                  table_version );
}

// Get the adjoint photonuclear data file types
std::set<AdjointPhotonuclearDataProperties::FileType> NuclideProperties::getAdjointPhotonuclearDataFileTypes() const
{
  return BaseType::getDataFileTypes( d_adjoint_photonuclear_data_properties );
}

// Get the adjoint photonuclear data file versions
std::set<unsigned> NuclideProperties::getDataFileVersions(
            const AdjointPhotonuclearDataProperties::FileType file_type ) const
{
  return BaseType::getDataFileVersions( d_adjoint_photonuclear_data_properties,
                                        file_type );
}

// Get the recommended adjoint photonuclear data file version
unsigned NuclideProperties::getRecommendedDataFileVersion(
            const AdjointPhotonuclearDataProperties::FileType file_type ) const
{
  return BaseType::getMaxDataFileVersion(
                                        d_adjoint_photonuclear_data_properties,
                                        file_type,
                                        "Adjoint photonuclear" );
}

// Get the adjoint photonuclear data properties
const AdjointPhotonuclearDataProperties& NuclideProperties::getAdjointPhotonuclearDataProperties(
                   const AdjointPhotonuclearDataProperties::FileType file_type,
                   const unsigned table_version ) const
{
  return BaseType::getProperties<AdjointPhotonuclearDataProperties>(
                                        d_adjoint_photonuclear_data_properties,
                                        file_type,
                                        table_version,
                                        "Adjoint photonuclear" );
}

// Get the shared adjoint photonuclear data properties
const std::shared_ptr<const AdjointPhotonuclearDataProperties>&
NuclideProperties::getSharedAdjointPhotonuclearDataProperties(
                   const AdjointPhotonuclearDataProperties::FileType file_type,
                   const unsigned table_version ) const
{
  return BaseType::getSharedProperties<AdjointPhotonuclearDataProperties>(
                                        d_adjoint_photonuclear_data_properties,
                                        file_type,
                                        table_version,
                                        "Adjoint photonuclear" );
}

// Set the photonuclear data properties
void NuclideProperties::setAdjointPhotonuclearDataProperties( const std::shared_ptr<const AdjointPhotonuclearDataProperties>& properties )
{
  this->setPhotonuclearProperties( d_adjoint_photonuclear_data_properties,
                                   properties,
                                   this->zaid(),
                                   "NuclideProperties",
                                   "Adjoint photonuclear" );
}

// Place the object in an output stream
void NuclideProperties::toStream( std::ostream& os ) const
{
  // Print the nuclear properties
  this->printNuclearProperties( d_nuclear_data_properties,
                                "Nuclear Data",
                                false,
                                os );

  // Print the thermal nuclear properties
  this->printThermalNuclearProperties( d_thermal_nuclear_data_properties,
                                       "Thermal Nuclear Data",
                                       os );

  // Print the adjoint nuclear properties
  this->printNuclearProperties( d_adjoint_nuclear_data_properties,
                                "Adjoint Nuclear Data",
                                false,
                                os );

  // Print the adjoint thermal nuclear properties
  this->printThermalNuclearProperties( d_thermal_nuclear_data_properties,
                                       "Adjoint Thermal Nuclear Data",
                                       os );

  // Print the photonuclear properties
  this->printProperties( d_photonuclear_data_properties,
                         "Photonuclear Data",
                         os );

  // Print the adjoint photonuclear properties
  this->printProperties( d_adjoint_photonuclear_data_properties,
                         "Adjoint Photonuclear Data",
                         os );

  os.flush();
}

EXPLICIT_CLASS_SAVE_LOAD_INST( NuclideProperties );

} // end Data namespace

BOOST_SERIALIZATION_CLASS_EXPORT_IMPLEMENT( NuclideProperties, Data );

//---------------------------------------------------------------------------//
// end Data_NuclideProperties.cpp
//---------------------------------------------------------------------------//


text:
/*
 * scan.cc
 *
 *  Copyright (C) 2013 Diamond Light Source
 *
 *  Author: James Parkhurst
 *
 *  This code is distributed under the BSD license, a copy of which is
 *  included in the root directory of this package.
 */
#include <boost/python.hpp>
#include <boost/python/def.hpp>
#include <boost/python/make_constructor.hpp>
#include <boost/format.hpp>
#include <string>
#include <scitbx/constants.h>
#include <dxtbx/model/scan_helpers.h>

namespace dxtbx { namespace model { namespace boost_python {

  using namespace boost::python;
  using scitbx::deg_as_rad;
  using scitbx::rad_as_deg;

  static
  vec2<double> deg_as_rad(vec2<double> angles) {
    angles[0] = deg_as_rad(angles[0]);
    angles[1] = deg_as_rad(angles[1]);
    return angles;
  }

  static
  vec2<double> rad_as_deg(vec2<double> angles) {
    angles[0] = rad_as_deg(angles[0]);
    angles[1] = rad_as_deg(angles[1]);
    return angles;
  }

  static
  bool is_angle_in_range_wrapper(vec2<double> range, double angle,
      bool deg) {
    return is_angle_in_range(
      deg ? deg_as_rad(range) : range,
      deg ? deg_as_rad(angle) : angle);
  }

  static vec2 <double>
  get_range_of_mod2pi_angles_wrapper(vec2<double> range, double angle,
      bool deg) {
    return rad_as_deg(get_range_of_mod2pi_angles(
      deg ? deg_as_rad(range) : range,
      deg ? deg_as_rad(angle) : angle));
  }

  static scitbx::af::shared<double>
  get_mod2pi_angles_in_range_wrapper(vec2 <double> range, double angle,
      bool deg) {
    scitbx::af::shared<double> result = get_mod2pi_angles_in_range(
      deg ? deg_as_rad(range) : range,
      deg ? deg_as_rad(angle) : angle);
    if (deg) {
      for (std::size_t i = 0; i < result.size(); ++i) {
        result[i] = rad_as_deg(result[i]);
      }
    }
    return result;
  }

  void export_scan_helpers()
  {
    def("is_angle_in_range", &is_angle_in_range_wrapper, (
        arg("range"), arg("angle"), arg("deg") = false));

    def("get_range_of_mod2pi_angles", &get_range_of_mod2pi_angles_wrapper, (
        arg("range"), arg("angle"), arg("deg") = false));

    def("get_mod2pi_angles_in_range", &get_mod2pi_angles_in_range_wrapper, (
        arg("range"), arg("angle"), arg("deg") = false));
  }

}}} // namespace = dxtbx::model::boost_python

ext: cc


text:
#pragma once

#include "TypeRegistry.hpp"

#include <cstddef>
#include <string>
#include <boost/spirit/home/x3/support/ast/position_tagged.hpp>
#include <boost/type_index.hpp>

namespace pdl::spirit {

// Global using.
namespace x3 = boost::spirit::x3;

struct BaseStatement
{
    virtual std::string position() const = 0;
    virtual std::string info() const = 0;

    virtual ~BaseStatement() = default;
};

template <typename Statement>
struct Annotation : BaseStatement, x3::position_tagged
{
    Annotation();

    std::string position() const final;
    std::string info() const override;

    std::string tag;
    std::string input;
    std::size_t lineBegin = 0;
    std::size_t columnBegin = 0;
    std::size_t lineEnd = 0;
    std::size_t columnEnd = 0;
};

template <typename Statement>
Annotation<Statement>::Annotation()
{
    tag = boost::typeindex::type_id<Statement>().pretty_name();
}

template <typename Statement>
std::string Annotation<Statement>::position() const
{
    return std::to_string(lineBegin) + '.' +
           std::to_string(columnBegin) + '-' +
           std::to_string(lineEnd) + '.' +
           std::to_string(columnEnd);
}

template <typename Statement>
std::string Annotation<Statement>::info() const
{
    return input;
}

}  // namespace spirit.

ext: hpp

max_stars_repo_name: Vitaliy-Grigoriev/PDL

max_issues_repo_name: Vitaliy-Grigoriev/PDL

max_forks_repo_name: Vitaliy-Grigoriev/PDL


text:
// test/tree/tree.cpp

#include <boost/test/unit_test.hpp>

#include <wordring/tree/tree.hpp>

#include <algorithm>
#include <iterator>
#include <list>
#include <string>
#include <type_traits>
#include <vector>

namespace
{
	struct test_tree : public wordring::tree<int>
	{
		using base_type = wordring::tree<int>;
		using typename base_type::container;

		using base_type::allocate;
		using base_type::free;

		using base_type::m_c;
	};

	struct test_iterator : public test_tree::iterator
	{
		using base_type = test_tree::iterator;

		using base_type::m_index;
		using base_type::m_parent;

		test_iterator(base_type const& it) : base_type(it) {}

		test_iterator(typename test_tree::container& c, index_type parent, index_type idx)
			: base_type(c, parent, idx)
		{
		}
	};

	struct const_test_iterator : public test_tree::const_iterator
	{
		using base_type = test_tree::const_iterator;
		using typename base_type::index_type;

		using base_type::m_index;
		using base_type::m_parent;

		const_test_iterator(base_type const& it) : base_type(it) {}

		const_test_iterator(typename test_tree::container const& c, index_type parent, index_type idx)
			: base_type(c, parent, idx)
		{
		}
	};
}

BOOST_AUTO_TEST_SUITE(tree_test)

// ----------------------------------------------------------------------------
// tree_node
// ----------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE(tree_node_construct_1)
{
	using namespace wordring::detail;

	static_assert(std::is_pod_v<tree_node<int>>);

	tree_node<int> n{};

	BOOST_CHECK(n.m_value == 0);
}

// ----------------------------------------------------------------------------
// tree_node_iterator
// ----------------------------------------------------------------------------

/*
空のイテレータを作成する

tree_node_iterator() noexcept
*/
BOOST_AUTO_TEST_CASE(tree_node_iterator_construct_1)
{
	using namespace wordring::detail;

	tree_node_iterator<test_tree::container> it;
}

BOOST_AUTO_TEST_CASE(tree_node_iterator_construct_2)
{
	using namespace wordring::detail;

	test_tree::container v;
	auto it = test_iterator(v, 0, 0);
}

/*
const_iterator を取得する

operator tree_node_iterator<container const>() const
*/
BOOST_AUTO_TEST_CASE(tree_node_iterator_cast_1)
{
	using namespace wordring;
	using namespace wordring::detail;

	test_tree::container v;
	auto it = test_iterator(v, 0, 0);
	tree_node_iterator<test_tree::container> it1 = it;
	tree_node_iterator<test_tree::container const> it2 = it;

	BOOST_CHECK(it1 == it2);
}

/*
イテレータが指す要素の参照を取得する

auto& operator*() const
*/
BOOST_AUTO_TEST_CASE(tree_node_iterator_reference_1)
{
	test_tree t;
	t.insert(t.end(), 100);

	auto it1 = t.begin();
	BOOST_CHECK(*it1 == 100);
	*it1 = 90;
	BOOST_CHECK(*it1 == 90);

	// const_iterator の返す参照の値が const 修飾されているか確認
	static_assert(std::is_const_v<std::remove_reference_t<decltype(*t.cbegin())>>);
}

/*
イテレータが指す要素のポインタを取得する

auto operator->() const
*/
BOOST_AUTO_TEST_CASE(tree_node_iterator_reference_2)
{
	using namespace wordring;

	tree<std::string> t;
	t.insert(t.end(), "100");

	auto it1 = t.begin();
	BOOST_CHECK(it1->at(0) == '1');
	it1->at(0) = '2';
	BOOST_CHECK(it1->at(0) == '2');

	// const_iterator の返すポインタの値が const 修飾されているか確認
	static_assert(std::is_const_v<std::remove_reference_t<decltype(t.cbegin()->at(0))>>);
}

/*
インクリメントする

tree_node_iterator& operator++()
tree_node_iterator operator++(int)
*/
BOOST_AUTO_TEST_CASE(tree_node_iterator_increment_1)
{
	test_tree t;
	auto it1 = t.insert(t.begin(), 1);
	auto it2 = t.insert(it1.end(), 2);
	auto it3 = t.insert(it1.end(), 3);
	auto it4 = t.insert(it1.end(), 4);

	BOOST_CHECK(*it1 == 1);
	BOOST_CHECK(++it1 == t.end());

	BOOST_CHECK(*it2++ == 2);
	BOOST_CHECK(it2++ == it3);
	BOOST_CHECK(it2++ == it4);
	BOOST_CHECK(it2 == t.begin().end());
}

/*
デクリメントする

tree_node_iterator& operator--()
tree_node_iterator operator--(int)
*/
BOOST_AUTO_TEST_CASE(tree_node_iterator_decrement_1)
{
	test_tree t;
	auto it1 = t.insert(t.begin(), 1);
	t.insert(it1.end(), 2);
	t.insert(it1.end(), 3);
	t.insert(it1.end(), 4);

	BOOST_CHECK(*it1 == 1);
	BOOST_CHECK(--t.end() == t.begin());

	std::vector<int> v;
	auto it5 = std::make_reverse_iterator(it1.end());
	auto it6 = std::make_reverse_iterator(it1.begin());
	std::copy(it5, it6, std::back_inserter(v));

	BOOST_CHECK(v == std::vector<int>({ 4, 3, 2 }));
}

/*
子の先頭を指すイテレータを取得する
子の終端を指すイテレータを取得する

tree_node_iterator begin() const
tree_node_iterator end() const
*/
BOOST_AUTO_TEST_CASE(tree_node_iterator_begin_1)
{
	test_tree t;
	auto it1 = t.insert(t.begin(), 1);
	t.insert(it1.end(), 2);
	t.insert(it1.end(), 3);
	t.insert(it1.end(), 4);

	BOOST_CHECK(*it1 == 1);
	BOOST_CHECK(--t.end() == t.begin());

	std::vector<int> v;
	auto it5 = std::make_reverse_iterator(it1.end());
	auto it6 = std::make_reverse_iterator(it1.begin());
	std::copy(it5, it6, std::back_inserter(v));

	BOOST_CHECK(v == std::vector<int>({ 4, 3, 2 }));
}

/*
子の末尾を指す逆走イテレータを取得する
子の先頭の前を指す逆走イテレータを取得する

reverse_iterator rbegin() const
reverse_iterator rend() const
*/
BOOST_AUTO_TEST_CASE(tree_node_iterator_rbegin_1)
{
	test_tree t;
	auto it1 = t.insert(t.begin(), 1);
	t.insert(it1.end(), 2);
	t.insert(it1.end(), 3);
	t.insert(it1.end(), 4);

	BOOST_CHECK(*it1 == 1);
	BOOST_CHECK(--t.end() == t.begin());

	std::vector<int> v;
	auto it5 = it1.rbegin();
	auto it6 = it1.rend();
	std::copy(it5, it6, std::back_inserter(v));

	BOOST_CHECK(v == std::vector<int>({ 4, 3, 2 }));
}

/*
親を指すイテレータを取得する

tree_node_iterator parent() const
*/
BOOST_AUTO_TEST_CASE(tree_node_iterator_parent_1)
{
	test_tree t;
	auto it1 = t.insert(t.begin(), 1);
	auto it2 = t.insert(it1.end(), 2);

	BOOST_CHECK(it2.parent() == it1);
}

BOOST_AUTO_TEST_CASE(tree_node_iterator_parent_2)
{
	// 根の親を取得する。
	test_tree t;
	auto it1 = t.insert(t.begin(), 1);

	BOOST_CHECK(it1.parent() == decltype(it1)());
}

// ----------------------------------------------------------------------------
// tree
// ----------------------------------------------------------------------------

/*
空のコンテナを構築する

tree()
*/
BOOST_AUTO_TEST_CASE(tree_construct_1)
{
	using namespace wordring;

	tree<int> t;
	BOOST_CHECK(t.size() == 0);
}

/*
アロケータを指定して空のコンテナを構築する

explicit tree(allocator_type const& alloc)
*/
BOOST_AUTO_TEST_CASE(tree_construct_2)
{
	using namespace wordring;

	auto t = tree<int>(std::allocator<int>());

	BOOST_CHECK(t.size() == 0);
}

/*
要素からコンテナを構築する

explicit tree(value_type const& value, allocator_type const& alloc = allocator_type())
*/
BOOST_AUTO_TEST_CASE(tree_construct_3)
{
	using namespace wordring;

	int i = 100;
	auto t = tree<int>(i);

	BOOST_CHECK(t.size() == 1);
}

/*
要素からコンテナを構築する

explicit tree(value_type&& value, allocator_type const& alloc = allocator_type())
*/
BOOST_AUTO_TEST_CASE(tree_construct_4)
{
	using namespace wordring;

	tree<int> t(1);

	BOOST_CHECK(t.size() == 1);
}

// 変更 -----------------------------------------------------------------------

BOOST_AUTO_TEST_CASE(tree_clear_1)
{
	using namespace wordring;

	test_tree t;
}

/*
要素を挿入する

iterator insert(const_iterator pos, value_type const& value)
*/
BOOST_AUTO_TEST_CASE(tree_insert_1)
{
	using namespace wordring;

	test_tree t;
	int i = 100;
	test_iterator it = t.insert(t.begin(), i);

	BOOST_CHECK(it.m_parent == 0);
	BOOST_CHECK(it.m_index == 1);

	BOOST_CHECK(t.size() == 1);

	BOOST_CHECK(t.m_c[0].m_child == 1);

	BOOST_CHECK(t.m_c[1].m_prev == 1);
	BOOST_CHECK(t.m_c[1].m_next == 0);
}

/*
根を挿入する

iterator insert(const_iterator pos, value_type&& value)
*/
BOOST_AUTO_TEST_CASE(tree_insert_2)
{
	using namespace wordring;

	test_tree t;
	test_iterator it = t.insert(t.begin(), 100);

	BOOST_CHECK(it.m_parent == 0);
	BOOST_CHECK(it.m_index == 1);

	BOOST_CHECK(t.size() == 1);

	BOOST_CHECK(t.m_c[0].m_child == 1);

	BOOST_CHECK(t.m_c[1].m_parent == 0);
	BOOST_CHECK(t.m_c[1].m_prev == 1);
	BOOST_CHECK(t.m_c[1].m_next == 0);
	BOOST_CHECK(t.m_c[1].m_child == 0);
}

/*
ノードの間に挿入する
*/
BOOST_AUTO_TEST_CASE(tree_insert_3)
{
	using namespace wordring;

	test_tree t;
	t.m_c.assign(4, { 0, 0, 0, 0 });
	t.m_c[0] = { 3, 0, 0, 1 };
	t.m_c[1] = { 0, 0, 0, 2 };
	t.m_c[2] = { 1, 3, 3, 0 };
	t.m_c[3] = { 1, 2, 0, 0 };

	test_iterator it = t.insert(const_test_iterator(t.m_c, 1, 3), 100);

	BOOST_CHECK(it.m_parent == 1);
	BOOST_CHECK(it.m_index == 4);

	BOOST_CHECK(t.size() == 4);

	BOOST_CHECK(t.m_c[0].m_child == 1);

	BOOST_CHECK(t.m_c[1].m_parent == 0);
	BOOST_CHECK(t.m_c[1].m_child == 2);

	BOOST_CHECK(t.m_c[2].m_parent == 1);
	BOOST_CHECK(t.m_c[2].m_prev == 3);
	BOOST_CHECK(t.m_c[2].m_next == 4);
	BOOST_CHECK(t.m_c[2].m_child == 0);

	BOOST_CHECK(t.m_c[4].m_parent == 1);
	BOOST_CHECK(t.m_c[4].m_prev == 2);
	BOOST_CHECK(t.m_c[4].m_next == 3);
	BOOST_CHECK(t.m_c[4].m_child == 0);

	BOOST_CHECK(t.m_c[3].m_parent == 1);
	BOOST_CHECK(t.m_c[3].m_prev == 4);
	BOOST_CHECK(t.m_c[3].m_next == 0);
	BOOST_CHECK(t.m_c[3].m_child == 0);
}

/*
子が無い場合の挿入
*/
BOOST_AUTO_TEST_CASE(tree_insert_4)
{
	using namespace wordring;

	test_tree t;
	t.m_c.assign(2, { 0, 0, 0, 0 });
	t.m_c[0] = { 1, 0, 0, 1 };
	t.m_c[1] = { 0, 0, 0, 0 };

	test_iterator it = t.insert(const_test_iterator(t.m_c, 1, 0), 100);

	BOOST_CHECK(it.m_parent == 1);
	BOOST_CHECK(it.m_index == 2);

	BOOST_CHECK(t.size() == 2);

	BOOST_CHECK(t.m_c[0].m_child == 1);

	BOOST_CHECK(t.m_c[1].m_parent == 0);
	BOOST_CHECK(t.m_c[1].m_child == 2);

	BOOST_CHECK(t.m_c[2].m_parent == 1);
	BOOST_CHECK(t.m_c[2].m_prev == 2);
	BOOST_CHECK(t.m_c[2].m_next == 0);
	BOOST_CHECK(t.m_c[2].m_child == 0);
}

/*
先頭の前に挿入
*/
BOOST_AUTO_TEST_CASE(tree_insert_5)
{
	using namespace wordring;

	test_tree t;
	t.m_c.assign(4, { 0, 0, 0, 0 });
	t.m_c[0] = { 3, 0, 0, 1 };
	t.m_c[1] = { 0, 0, 0, 2 };
	t.m_c[2] = { 1, 3, 3, 0 };
	t.m_c[3] = { 1, 2, 0, 0 };

	test_iterator it = t.insert(const_test_iterator(t.m_c, 1, 2), 100);

	BOOST_CHECK(it.m_parent == 1);
	BOOST_CHECK(it.m_index == 4);

	BOOST_CHECK(t.size() == 4);

	BOOST_CHECK(t.m_c[0].m_child == 1);

	BOOST_CHECK(t.m_c[1].m_parent == 0);
	BOOST_CHECK(t.m_c[1].m_child == 4);

	BOOST_CHECK(t.m_c[4].m_parent == 1);
	BOOST_CHECK(t.m_c[4].m_prev == 3);
	BOOST_CHECK(t.m_c[4].m_next == 2);
	BOOST_CHECK(t.m_c[4].m_child == 0);

	BOOST_CHECK(t.m_c[2].m_parent == 1);
	BOOST_CHECK(t.m_c[2].m_prev == 4);
	BOOST_CHECK(t.m_c[2].m_next == 3);
	BOOST_CHECK(t.m_c[2].m_child == 0);

	BOOST_CHECK(t.m_c[3].m_parent == 1);
	BOOST_CHECK(t.m_c[3].m_prev == 2);
	BOOST_CHECK(t.m_c[3].m_next == 0);
	BOOST_CHECK(t.m_c[3].m_child == 0);
}

/*
単独の子の前に挿入
*/
BOOST_AUTO_TEST_CASE(tree_insert_6)
{
	using namespace wordring;

	test_tree t;
	t.m_c.assign(3, { 0, 0, 0, 0 });
	t.m_c[0] = { 2, 0, 0, 1 };
	t.m_c[1] = { 0, 0, 0, 2 };
	t.m_c[2] = { 1, 2, 0, 0 };

	test_iterator it = t.insert(const_test_iterator(t.m_c, 1, 2), 100);

	BOOST_CHECK(it.m_parent == 1);
	BOOST_CHECK(it.m_index == 3);

	BOOST_CHECK(t.size() == 3);

	BOOST_CHECK(t.m_c[0].m_child == 1);

	BOOST_CHECK(t.m_c[1].m_parent == 0);
	BOOST_CHECK(t.m_c[1].m_child == 3);

	BOOST_CHECK(t.m_c[3].m_parent == 1);
	BOOST_CHECK(t.m_c[3].m_prev == 2);
	BOOST_CHECK(t.m_c[3].m_next == 2);
	BOOST_CHECK(t.m_c[3].m_child == 0);

	BOOST_CHECK(t.m_c[2].m_parent == 1);
	BOOST_CHECK(t.m_c[2].m_prev == 3);
	BOOST_CHECK(t.m_c[2].m_next == 0);
	BOOST_CHECK(t.m_c[2].m_child == 0);
}

/*
終端の前に挿入
*/
BOOST_AUTO_TEST_CASE(tree_insert_7)
{
	using namespace wordring;

	test_tree t;
	t.m_c.assign(4, { 0, 0, 0, 0 });
	t.m_c[0] = { 3, 0, 0, 1 };
	t.m_c[1] = { 0, 0, 0, 2 };
	t.m_c[2] = { 1, 3, 3, 0 };
	t.m_c[3] = { 1, 2, 0, 0 };

	test_iterator it = t.insert(const_test_iterator(t.m_c, 1, 0), 100);

	BOOST_CHECK(it.m_parent == 1);
	BOOST_CHECK(it.m_index == 4);

	BOOST_CHECK(t.size() == 4);

	BOOST_CHECK(t.m_c[0].m_child == 1);

	BOOST_CHECK(t.m_c[1].m_parent == 0);
	BOOST_CHECK(t.m_c[1].m_child == 2);

	BOOST_CHECK(t.m_c[2].m_parent == 1);
	BOOST_CHECK(t.m_c[2].m_prev == 4);
	BOOST_CHECK(t.m_c[2].m_next == 3);
	BOOST_CHECK(t.m_c[2].m_child == 0);

	BOOST_CHECK(t.m_c[3].m_parent == 1);
	BOOST_CHECK(t.m_c[3].m_prev == 2);
	BOOST_CHECK(t.m_c[3].m_next == 4);
	BOOST_CHECK(t.m_c[3].m_child == 0);

	BOOST_CHECK(t.m_c[4].m_parent == 1);
	BOOST_CHECK(t.m_c[4].m_prev == 3);
	BOOST_CHECK(t.m_c[4].m_next == 0);
	BOOST_CHECK(t.m_c[4].m_child == 0);
}

/*
単独の子の後に挿入
*/
BOOST_AUTO_TEST_CASE(tree_insert_8)
{
	using namespace wordring;

	test_tree t;
	t.m_c.assign(3, { 0, 0, 0, 0 });
	t.m_c[0] = { 2, 0, 0, 1 };
	t.m_c[1] = { 0, 0, 0, 2 };
	t.m_c[2] = { 1, 2, 0, 0 };

	test_iterator it = t.insert(const_test_iterator(t.m_c, 1, 0), 100);

	BOOST_CHECK(it.m_parent == 1);
	BOOST_CHECK(it.m_index == 3);

	BOOST_CHECK(t.size() == 3);

	BOOST_CHECK(t.m_c[0].m_child == 1);

	BOOST_CHECK(t.m_c[1].m_parent == 0);
	BOOST_CHECK(t.m_c[1].m_child == 2);

	BOOST_CHECK(t.m_c[2].m_parent == 1);
	BOOST_CHECK(t.m_c[2].m_prev == 3);
	BOOST_CHECK(t.m_c[2].m_next == 3);
	BOOST_CHECK(t.m_c[2].m_child == 0);

	BOOST_CHECK(t.m_c[3].m_parent == 1);
	BOOST_CHECK(t.m_c[3].m_prev == 2);
	BOOST_CHECK(t.m_c[3].m_next == 0);
	BOOST_CHECK(t.m_c[3].m_child == 0);
}

/*
部分木を挿入する

iterator insert(const_iterator pos, const_iterator sub)
*/
BOOST_AUTO_TEST_CASE(tree_insert_9)
{
	using namespace wordring;

	test_tree t1;
	auto it1 = t1.insert(t1.begin(), 1);
	auto it2 = t1.insert(it1.end(), 2);
	t1.insert(it2.end(), 4);
	t1.insert(it2.end(), 5);
	auto it3 = t1.insert(it1.end(), 3);
	t1.insert(it3.end(), 6);
	t1.insert(it3.end(), 7);

	test_tree t2;
	t2.insert(t2.cend(), t1.cbegin());

	BOOST_CHECK(t2.size() == t1.size());

	auto p1 = t2.begin();
	BOOST_CHECK(*p1 == 1);

	auto p2 = p1.begin();
	BOOST_CHECK(*p2 == 2);
	auto p3 = ++p1.begin();
	BOOST_CHECK(*p3 == 3);

	auto p4 = p2.begin();
	BOOST_CHECK(*p4 == 4);
	auto p5 = ++p2.begin();
	BOOST_CHECK(*p5 == 5);

	auto p6 = p3.begin();
	BOOST_CHECK(*p6 == 6);
	auto p7 = ++p3.begin();
	BOOST_CHECK(*p7 == 7);
}

/*
部分木を移動する

iterator move(const_iterator pos, const_iterator sub)
*/
BOOST_AUTO_TEST_CASE(tree_move_1)
{
	// 祖先を子孫へ移動。
	using namespace wordring;

	test_tree t;
	auto it1 = t.insert(t.end(), 1);
	auto it2 = t.insert(it1.end(), 2);
	auto it3 = t.insert(it2.end(), 3);

	BOOST_CHECK_THROW(t.move(it3, it1), std::invalid_argument);
}

BOOST_AUTO_TEST_CASE(tree_move_2)
{
	// 移動元と移動先が同じ
	using namespace wordring;

	test_tree t;
	auto it1 = t.insert(t.end(), 1);
	auto it2 = t.insert(it1.end(), 2);
	t.insert(it2.end(), 3);

	BOOST_CHECK_THROW(t.move(it1, it1), std::invalid_argument);
}

BOOST_AUTO_TEST_CASE(tree_move_3)
{
	using namespace wordring;

	test_tree t;
	auto it1 = t.insert(t.end(), 1);
	auto it2 = t.insert(it1.end(), 2);
	auto it3 = t.insert(it2.end(), 3);

	t.move(it1.begin(), it3);

	BOOST_CHECK(*it1 == 1);
	BOOST_CHECK(*it1.begin() == 3);
	BOOST_CHECK(*++(it1.begin()) == 2);
}

BOOST_AUTO_TEST_CASE(tree_move_4)
{
	// 根に複数のノードを入れる
	using namespace wordring;

	test_tree t;
	auto it1 = t.insert(t.end(), 1);
	t.insert(it1.end(), 2);
	auto it3 = t.insert(it1.end(), 3);

	t.move(t.end(), it3);

	BOOST_CHECK(*it1 == 1);
	BOOST_CHECK(*std::next(it1) == 3);
	BOOST_CHECK(*it1.begin() == 2);
}

BOOST_AUTO_TEST_CASE(tree_move_5)
{
}

/*
根を削除

iterator erase(const_iterator pos)
*/
BOOST_AUTO_TEST_CASE(tree_erase_1)
{
	using namespace wordring;

	test_tree t;
	t.m_c.assign(2, { 0, 0, 0, 0 });
	t.m_c[0] = { 1, 0, 0, 1 };
	t.m_c[1] = { 0, 1, 0, 0 };

	test_iterator it = t.erase(const_test_iterator(t.m_c, 0, 1));

	BOOST_CHECK(it.m_parent == 0);
	BOOST_CHECK(it.m_index == 0);

	BOOST_CHECK(t.size() == 0);

	BOOST_CHECK(t.m_c[0].m_child == 0);
}

/*
ノードの間を削除
*/
BOOST_AUTO_TEST_CASE(tree_erase_2)
{
	using namespace wordring;

	test_tree t;
	t.m_c.assign(5, { 0, 0, 0, 0 });
	t.m_c[0] = { 4, 0, 0, 1 };
	t.m_c[1] = { 0, 0, 0, 2 };
	t.m_c[2] = { 1, 3, 4, 0 };
	t.m_c[4] = { 1, 2, 3, 0 };
	t.m_c[3] = { 1, 4, 0, 0 };

	test_iterator it = t.erase(const_test_iterator(t.m_c, 1, 4));

	BOOST_CHECK(it.m_parent == 1);
	BOOST_CHECK(it.m_index == 3);

	BOOST_CHECK(t.size() == 3);

	BOOST_CHECK(t.m_c[0].m_child == 1);

	BOOST_CHECK(t.m_c[1].m_child == 2);

	BOOST_CHECK(t.m_c[2].m_prev == 3);
	BOOST_CHECK(t.m_c[2].m_next == 3);

	BOOST_CHECK(t.m_c[3].m_prev == 2);
	BOOST_CHECK(t.m_c[3].m_next == 0);
}

/*
先頭の前を削除
*/
BOOST_AUTO_TEST_CASE(tree_erase_3)
{
	using namespace wordring;

	test_tree t;
	t.m_c.assign(5, { 0, 0, 0, 0 });
	t.m_c[0] = { 4, 0, 0, 1 };
	t.m_c[1] = { 0, 0, 0, 4 };
	t.m_c[4] = { 1, 3, 2, 0 };
	t.m_c[2] = { 1, 4, 3, 0 };
	t.m_c[3] = { 1, 2, 0, 0 };

	test_iterator it = t.erase(const_test_iterator(t.m_c, 1, 4));

	BOOST_CHECK(it.m_parent == 1);
	BOOST_CHECK(it.m_index == 2);

	BOOST_CHECK(t.size() == 3);

	BOOST_CHECK(t.m_c[0].m_child == 1);

	BOOST_CHECK(t.m_c[1].m_child == 2);

	BOOST_CHECK(t.m_c[2].m_prev == 3);
	BOOST_CHECK(t.m_c[2].m_next == 3);

	BOOST_CHECK(t.m_c[3].m_prev == 2);
	BOOST_CHECK(t.m_c[3].m_next == 0);
}

/*
削除で単独になる子の前を削除
*/
BOOST_AUTO_TEST_CASE(tree_erase_4)
{
	using namespace wordring;

	test_tree t;
	t.m_c.assign(4, { 0, 0, 0, 0 });
	t.m_c[0] = { 3, 0, 0, 1 };
	t.m_c[1] = { 0, 0, 0, 3 };
	t.m_c[3] = { 1, 2, 2, 0 };
	t.m_c[2] = { 1, 3, 0, 0 };

	test_iterator it = t.erase(const_test_iterator(t.m_c, 1, 3));

	BOOST_CHECK(it.m_parent == 1);
	BOOST_CHECK(it.m_index == 2);

	BOOST_CHECK(t.size() == 2);

	BOOST_CHECK(t.m_c[0].m_child == 1);

	BOOST_CHECK(t.m_c[1].m_child == 2);

	BOOST_CHECK(t.m_c[2].m_prev == 2);
	BOOST_CHECK(t.m_c[2].m_next == 0);
}

/*
終端の前を削除
*/
BOOST_AUTO_TEST_CASE(tree_erase_5)
{
	using namespace wordring;

	test_tree t;
	t.m_c.assign(5, { 0, 0, 0, 0 });
	t.m_c[0] = { 4, 0, 0, 1 };
	t.m_c[1] = { 0, 0, 0, 2 };
	t.m_c[2] = { 1, 4, 3, 0 };
	t.m_c[3] = { 1, 2, 4, 0 };
	t.m_c[4] = { 1, 3, 0, 0 };

	test_iterator it = t.erase(const_test_iterator(t.m_c, 1, 4));

	BOOST_CHECK(it.m_parent == 1);
	BOOST_CHECK(it.m_index == 0);

	BOOST_CHECK(t.size() == 3);

	BOOST_CHECK(t.m_c[0].m_child == 1);

	BOOST_CHECK(t.m_c[1].m_child == 2);

	BOOST_CHECK(t.m_c[2].m_prev == 3);
	BOOST_CHECK(t.m_c[2].m_next == 3);

	BOOST_CHECK(t.m_c[3].m_prev == 2);
	BOOST_CHECK(t.m_c[3].m_next == 0);
}

/*
削除で単独になる子の終端の前を削除
*/
BOOST_AUTO_TEST_CASE(tree_erase_6)
{
	using namespace wordring;

	test_tree t;
	t.m_c.assign(4, { 0, 0, 0, 0 });
	t.m_c[0] = { 3, 0, 0, 1 };
	t.m_c[1] = { 0, 0, 0, 2 };
	t.m_c[2] = { 1, 3, 3, 0 };
	t.m_c[3] = { 1, 2, 0, 0 };

	test_iterator it = t.erase(const_test_iterator(t.m_c, 1, 3));

	BOOST_CHECK(it.m_parent == 1);
	BOOST_CHECK(it.m_index == 0);

	BOOST_CHECK(t.size() == 2);

	BOOST_CHECK(t.m_c[0].m_child == 1);

	BOOST_CHECK(t.m_c[1].m_child == 2);

	BOOST_CHECK(t.m_c[2].m_prev == 2);
	BOOST_CHECK(t.m_c[2].m_next == 0);
}

/*
子孫削除
*/
BOOST_AUTO_TEST_CASE(tree_erase_7)
{
	using namespace wordring;

	test_tree t;
	t.m_c.assign(6, { 0, 0, 0, 0 });
	t.m_c[0] = { 5, 0, 0, 1 };
	t.m_c[1] = { 0, 0, 0, 2 };
	t.m_c[2] = { 1, 3, 4, 0 };
	t.m_c[4] = { 1, 2, 3, 5 };
	t.m_c[3] = { 1, 4, 0, 0 };
	t.m_c[5] = { 4, 0, 0, 0 };

	test_iterator it = t.erase(const_test_iterator(t.m_c, 0, 1));

	BOOST_CHECK(it.m_parent == 0);
	BOOST_CHECK(it.m_index == 0);

	BOOST_CHECK(t.size() == 0);
}

// 内部 -----------------------------------------------------------------------

/*
index_type allocate()

未使用ノードが無い状態から、ノードを確保する
*/
BOOST_AUTO_TEST_CASE(tree_allocate_1)
{
	using namespace wordring;

	test_tree t;
	t.m_c.assign({ { 0, 0, 0, 0 } });

	auto idx = t.allocate(100);

	BOOST_CHECK(idx == 1);

	BOOST_CHECK(t.m_c[0].m_prev == 0);
	BOOST_CHECK(t.m_c[0].m_next == 0);

	BOOST_CHECK(t.m_c.size() == 2);
}

/*
[0]に関連するよう、ノードを確保する
*/
BOOST_AUTO_TEST_CASE(tree_allocate_2)
{
	using namespace wordring;

	test_tree t;
	t.m_c.assign({ { 0, 1, 1, 0 }, { 0, 0, 0, 0 } });

	auto idx = t.allocate(100);

	BOOST_CHECK(idx == 1);

	BOOST_CHECK(t.m_c[0].m_prev == 0);
	BOOST_CHECK(t.m_c[0].m_next == 0);

	BOOST_CHECK(t.m_c.size() == 2);
}

/*
後ろに未使用ノードが有る状態から、ノードを確保する
*/
BOOST_AUTO_TEST_CASE(tree_allocate_3)
{
	using namespace wordring;

	test_tree t;
	t.m_c.assign({ { 0, 3, 2, 0 }, { 0, 0, 0, 0 }, { 0, 0, 3, 0 }, { 0, 2, 0, 0 } });

	auto idx = t.allocate(100);

	BOOST_CHECK(idx == 2);

	BOOST_CHECK(t.m_c[0].m_prev == 3);
	BOOST_CHECK(t.m_c[0].m_next == 3);

	BOOST_CHECK(t.m_c[1].m_prev == 0);
	BOOST_CHECK(t.m_c[1].m_next == 0);

	BOOST_CHECK(t.m_c.size() == 4);
}

/*
void free(index_type idx)

未使用ノードが無い状態から、使用済みノードを開放する
*/
BOOST_AUTO_TEST_CASE(tree_free_1)
{
	using namespace wordring;

	test_tree t;
	t.m_c.assign({ { 0, 0, 0, 0 }, { 0, 0, 0, 0 } });

	t.free(1);

	BOOST_CHECK(t.m_c[0].m_prev == 1);
	BOOST_CHECK(t.m_c[0].m_next == 1);
}

/*
前に未使用ノードが有り、後ろに未使用ノードが無い状態から、使用済みノードを開放する
*/
BOOST_AUTO_TEST_CASE(tree_free_2)
{
	using namespace wordring;

	test_tree t;
	t.m_c.assign({ { 0, 1, 1, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } });

	t.free(2);

	BOOST_CHECK(t.m_c[0].m_prev == 2);
	BOOST_CHECK(t.m_c[0].m_next == 1);

	BOOST_CHECK(t.m_c[1].m_prev == 0);
	BOOST_CHECK(t.m_c[1].m_next == 2);

	BOOST_CHECK(t.m_c[2].m_prev == 1);
	BOOST_CHECK(t.m_c[2].m_next == 0);
}

/*
前に未使用ノードが無く、後ろに未使用ノードが有る状態から、使用済みノードを開放する
*/
BOOST_AUTO_TEST_CASE(tree_free_3)
{
	using namespace wordring;

	test_tree t;
	t.m_c.assign({ { 0, 2, 2, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } });

	t.free(1);

	BOOST_CHECK(t.m_c[0].m_prev == 2);
	BOOST_CHECK(t.m_c[0].m_next == 1);

	BOOST_CHECK(t.m_c[1].m_prev == 0);
	BOOST_CHECK(t.m_c[1].m_next == 2);

	BOOST_CHECK(t.m_c[2].m_prev == 1);
	BOOST_CHECK(t.m_c[2].m_next == 0);
}

/*
前後に未使用ノードが有る状態から、使用済みノードを開放する
*/
BOOST_AUTO_TEST_CASE(tree_free_4)
{
	using namespace wordring;

	test_tree t;
	t.m_c.assign({ { 0, 3, 1, 0 }, { 0, 0, 3, 0 }, { 0, 0, 0, 0 }, { 0, 1, 0, 0 } });

	t.free(2);

	BOOST_CHECK(t.m_c[0].m_prev == 3);
	BOOST_CHECK(t.m_c[0].m_next == 1);

	BOOST_CHECK(t.m_c[1].m_prev == 0);
	BOOST_CHECK(t.m_c[1].m_next == 2);

	BOOST_CHECK(t.m_c[2].m_prev == 1);
	BOOST_CHECK(t.m_c[2].m_next == 3);

	BOOST_CHECK(t.m_c[3].m_prev == 2);
	BOOST_CHECK(t.m_c[3].m_next == 0);
}

BOOST_AUTO_TEST_SUITE_END()

ext: cpp

max_stars_repo_name: wordring/wordring

max_issues_repo_name: wordring/libwordring

max_forks_repo_name: wordring/libwordring


text:
/**
 * Copyright (2012) JDSU
 * Author: Bob Andrews
 */

#include "xtreme/iwf/classify_parser.h"
#include <string>
#include <utility>
#include <map>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_object.hpp>
#include <log4cxx/logger.h>  // NOLINT(build/include_order)
#include "xtreme/iwf/classification_rules.h"

namespace qi = boost::spirit::qi;
namespace phoenix = boost::phoenix;
namespace ascii = boost::spirit::ascii;

namespace xtreme {
namespace iwf {

log4cxx::LoggerPtr logger_(log4cxx::Logger::getLogger("xtreme.iwf.cp-up-classifier"));

template< typename Iterator >
struct classify_rule_parser
    : boost::spirit::qi::grammar< Iterator, classify_rule*(), ascii::space_type > {

    // Setup the grammar
    classify_rule_parser() : classify_rule_parser::base_type(start_) {
        LOG4CXX_TRACE(logger_, "CP-UP classifier, creating grammar: unquoted_string");
        // to extract an unquoted string
        unquoted_string_ %= qi::lexeme[ +(qi::char_ - ' ') ];

        LOG4CXX_TRACE(logger_, "CP-UP classifier, creating grammar: match_type");
        // matches a simple matching rule, e.g.
        // match ip_transport.dest_port = 100
        // first line matches, second line creates the rule object with the values extracted.
        match_type_ =
          (qi::lit("match") >> unquoted_string_ >> qi::lit("=") >> qi::int_ >> qi::eps)
          [ qi::_val = phoenix::new_< classify_match >(qi::_1, qi::_2) ];

        LOG4CXX_TRACE(logger_, "CP-UP classifier, creating grammar: match_range");
        // matches a range, e.g.
        // match_range ip_transport.dest_port between 100 and 110
        // first line matches, second line creates the rule object with the values extracted.
        match_range_type_ =
          (qi::lit("match_range") >> unquoted_string_ >> qi::lit("between")
              >> qi::int_ >> qi::lit("and") >> qi::int_ >> qi::eps)
          [ qi::_val = phoenix::new_< classify_match_range >(qi::_1, qi::_2, qi::_3) ];

        LOG4CXX_INFO(logger_, "CP-UP classifier, creating grammar: parser start");
        // match either a simple match or a range
        start_ =
          (match_type_[ qi::_val = qi::_1 ]
          | match_range_type_[ qi::_val = qi::_1 ]);
    }
    qi::rule<Iterator, std::string(), ascii::space_type> unquoted_string_;
    qi::rule< Iterator, classify_rule*(), ascii::space_type > start_;
    qi::rule< Iterator, classify_match*(), ascii::space_type > match_type_;
    qi::rule< Iterator, classify_match_range*(), ascii::space_type > match_range_type_;
};

void ClassifyRuleList::build_list(const std::string &rules) {
    LOG4CXX_TRACE(logger_, "CP-UP classifier, parsing rules: ----!" << rules << "!----");
    std::istringstream ss(rules);

    LOG4CXX_TRACE(logger_, "CP-UP classifier, creating grammar. ");
    classify_rule_parser< std::string::const_iterator > grammar;

    LOG4CXX_TRACE(logger_, "CP-UP classifier, created grammar. ");

    clear_list();
    while (ss.good()) {
        std::string line;
        std::getline(ss, line);
        LOG4CXX_TRACE(logger_, "CP-UP classifier, parsing line: " << line);
        std::string::const_iterator iter = line.begin();
        std::string::const_iterator end = line.end();
        classify_rule *rule = NULL;
        bool result = qi::phrase_parse(iter, end, grammar, ascii::space, rule);
        if (result && rule) {
            rule_list_.push_back(rule);
        }
    }
    LOG4CXX_TRACE(logger_, "done parsing ");
}

void ClassifyRuleList::clear_list() {
    BOOST_FOREACH(classify_rule *rule, rule_list_) {
        delete rule;
    }
    rule_list_.clear();
}

bool ClassifyRuleList::evaluate(const xtreme::ParsedFrame &frame) const {
    BOOST_FOREACH(const classify_rule *rules_list, optimized_rule_list_) {
        bool cp = rules_list->evaluate(frame);
        if (cp) {
            return true;
        }
    }
    return false;
};

// friend
std::ostream & operator <<(std::ostream &ostr, const ClassifyRuleList &lst) {
    BOOST_FOREACH(classify_rule *rule, lst.rule_list_) {
        rule->print(ostr);
    }
    return ostr;
}

void ClassifyRuleList::collect_rules() {
    typedef std::multimap< uint64_t, classify_rule * > rules_map_t;
    rules_map_t rule_builder;
    BOOST_FOREACH(classify_rule *rule, rule_list_) {
        rule_builder.insert(std::make_pair(rule->ie() , rule));
    }
    int64_t ie = -1;
    classify_match_optimized *opt = NULL;
    BOOST_FOREACH(rules_map_t::value_type &rule, rule_builder) {
        if (ie != (int64_t) rule.first) {
            ie = rule.first;
            opt = new classify_match_optimized(rule.first, rule.second->ie_name());
            optimized_rule_list_.push_back(opt);
        }
        opt->add_rule(rule.second);
    }
}
}}  // xtreme::iwf


text:
/*=============================================================================
    Copyright (c) 2010-2011 Daniel James

    Use, modification and distribution is subject to the Boost Software
    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
    http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/

#if !defined(BOOST_SPIRIT_QUICKBOOK_VALUES_PARSE_HPP)
#define BOOST_SPIRIT_QUICKBOOK_VALUES_PARSE_HPP

#include "values.hpp"
#include "parsers.hpp"
#include "scoped.hpp"
#include <boost/spirit/include/phoenix1_functions.hpp>

#include <iostream>

namespace quickbook {
    namespace ph = phoenix;

    struct value_builder_save : scoped_action_base
    {
        explicit value_builder_save(value_builder& builder_) : builder(builder_) {}

        bool start()
        {
            builder.save();
            return true;
        }

        void cleanup() { builder.restore(); }

        value_builder& builder;

    private:
        value_builder_save& operator=(value_builder_save const&);
    };

    struct value_builder_list : scoped_action_base
    {
        explicit value_builder_list(value_builder& builder_) : builder(builder_) {}

        bool start(value::tag_type tag = value::default_tag)
        {
            builder.start_list(tag);
            return true;
        }

        void success(parse_iterator, parse_iterator) { builder.finish_list(); }
        void failure() { builder.clear_list(); }

        value_builder& builder;

    private:
        value_builder_list& operator=(value_builder_list const&);
    };

    struct value_entry
    {
        template <typename Arg1, typename Arg2 = void, typename Arg3 = void, typename Arg4 = void>
        struct result {
            typedef void type;
        };

        explicit value_entry(value_builder& builder_, file_ptr* current_file_)
            : builder(builder_), current_file(current_file_) {}

        void operator()(parse_iterator begin, parse_iterator end,
                value::tag_type tag = value::default_tag) const
        {
            builder.insert(qbk_value(*current_file, begin.base(), end.base(), tag));
        }

        void operator()(int v,
            value::tag_type tag = value::default_tag) const
        {
            builder.insert(int_value(v, tag));
        }

        value_builder& builder;
        file_ptr* current_file;

    private:
        value_entry& operator=(value_entry const&);
    };

    struct value_sort
    {
        typedef void result_type;

        explicit value_sort(value_builder& builder_)
            : builder(builder_) {}

        void operator()() const {
            builder.sort_list();
        }

        value_builder& builder;

    private:
        value_sort& operator=(value_sort const&);
    };

    struct value_parser
    {
        explicit value_parser(file_ptr* current_file)
            : builder()
            , save(value_builder_save(builder))
            , list(value_builder_list(builder))
            , entry(value_entry(builder, current_file))
            , sort(value_sort(builder))
            {}

        value release() { return builder.release(); }

        value_builder builder;
        scoped_parser<value_builder_save> save;
        scoped_parser<value_builder_list> list;
        ph::function<value_entry> entry;
        ph::function<value_sort> sort;
    };
}

#endif

max_stars_repo_name: yinhangfeng/react-native

max_issues_repo_name: yinhangfeng/react-native

max_forks_repo_name: yinhangfeng/react-native


text:
#include "multipart_response_stream.h"

#include <cstring>

#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>

#include "exceptions.h"
#include "null_stream.h"
#include "headers.h"

#define MULTIPART_RESPONSE_STREAM_BOUNDARY "b8fab5184c29c9038f729361d27d1935"
#define MULTIPART_RESPONSE_STREAM_BOUNDARY_START "--" MULTIPART_RESPONSE_STREAM_BOUNDARY "\r\n"
#define MULTIPART_RESPONSE_STREAM_BOUNDARY_END "\r\n--" MULTIPART_RESPONSE_STREAM_BOUNDARY "--"

const char* rs::httpserver::MultipartResponseStream::boundary = MULTIPART_RESPONSE_STREAM_BOUNDARY;
const char* rs::httpserver::MultipartResponseStream::boundaryStart = MULTIPART_RESPONSE_STREAM_BOUNDARY_START;
const char* rs::httpserver::MultipartResponseStream::boundaryEnd = MULTIPART_RESPONSE_STREAM_BOUNDARY_END;
const unsigned rs::httpserver::MultipartResponseStream::boundaryEndLength = std::strlen(boundaryEnd);

rs::httpserver::MultipartResponseStream::MultipartResponseStream(Stream& stream) : stream_(stream) {

}

void rs::httpserver::MultipartResponseStream::Flush() {
    Stream::Write(stream_, boundaryEnd, 0, boundaryEndLength);
    stream_.Flush();
}

int rs::httpserver::MultipartResponseStream::Read(Stream::byte*, int, int, bool) {
    throw InvalidStreamOperationException();
}

int rs::httpserver::MultipartResponseStream::Write(const Stream::byte* buffer, int offset, int count) {
    return stream_.Write(buffer, offset, count);
}

long rs::httpserver::MultipartResponseStream::getPosition() {
    return stream_.getPosition();
}

long rs::httpserver::MultipartResponseStream::getLength() {
    return stream_.getLength();
}

void rs::httpserver::MultipartResponseStream::EmitPart(const char* contentType, const char* filename, std::int64_t contentLength) {
    std::string headerBuffer;
    headerBuffer.reserve(256);

    if (partCount_ > 0) {
        headerBuffer += "\r\n";
    }

    headerBuffer += boundaryStart;
    headerBuffer += Headers::ContentType + ": " + contentType + "\r\n";

    if (filename) {
        headerBuffer += Headers::ContentDisposition + ": " + (boost::format("attachment; filename=\"%1%\"") % filename).str() + "\r\n";
    }

    if (contentLength >= 0) {
        headerBuffer += Headers::ContentLength + ": " + boost::lexical_cast<std::string>(contentLength) + "\r\n";
    }

    headerBuffer += "\r\n";

    Stream::Write(stream_, headerBuffer);

    ++partCount_;
}

max_stars_repo_name: RipcordSoftware/libhttpserver

max_issues_repo_name: RipcordSoftware/libhttpserver

max_forks_repo_name: RipcordSoftware/libhttpserver


text:
#include "Param.h"

#include <boost/property_tree/xml_parser.hpp>
#include <iostream>
#include <string>
#include <math.h>

namespace pt = boost::property_tree;
namespace QSP_IO{
using std::string;
using std::vector;

#define PARAM_DESCRIPTION_FIELD_COUNT 3
const char* _description[][PARAM_DESCRIPTION_FIELD_COUNT] =
{
    //simulation settings
    {"QSP.simulation.start","",""},//0
    {"QSP.simulation.step","",""},//1
    {"QSP.simulation.n_step","",""},//2
    {"QSP.simulation.tol_rel","",""},//3
    {"QSP.simulation.tol_abs","",""},//4
    //compartments
    {"QSP.init_value.Compartment.Cent","",""},//5|5
    {"QSP.init_value.Compartment.Peri","",""},//6|6
    {"QSP.init_value.Compartment.Tum","",""},//7|7
    {"QSP.init_value.Compartment.LN","",""},//8|8
    {"QSP.init_value.Compartment.mAPC_Endo","",""},//9|9
    {"QSP.init_value.Compartment.mAPC_Surf","",""},//10|10
    //species
    {"QSP.init_value.Species.Cent_Nivo","",""},//11|11
    {"QSP.init_value.Species.Cent_nT_CD8","",""},//12|12
    {"QSP.init_value.Species.Cent_nT_CD4","",""},//13|13
    {"QSP.init_value.Species.Cent_Treg","",""},//14|14
    {"QSP.init_value.Species.Cent_Teff_1_0","",""},//15|15
    {"QSP.init_value.Species.Peri_Nivo","",""},//16|16
    {"QSP.init_value.Species.Peri_Treg","",""},//17|17
    {"QSP.init_value.Species.Peri_Teff_1_0","",""},//18|18
    {"QSP.init_value.Species.Tum_Nivo","",""},//19|19
    {"QSP.init_value.Species.Tum_C1","",""},//20|20
    {"QSP.init_value.Species.Tum_Cp","",""},//21|21
    {"QSP.init_value.Species.Tum_DAMP","",""},//22|22
    {"QSP.init_value.Species.Tum_APC","",""},//23|23
    {"QSP.init_value.Species.Tum_mAPC","",""},//24|24
    {"QSP.init_value.Species.Tum_Ckine_Mat","",""},//25|25
    {"QSP.init_value.Species.Tum_Treg","",""},//26|26
    {"QSP.init_value.Species.Tum_Teff_PD1","",""},//27|27
    {"QSP.init_value.Species.Tum_Teff_PD1_syn","",""},//28|28
    {"QSP.init_value.Species.Tum_Teff_PD1_Nivo","",""},//29|29
    {"QSP.init_value.Species.Tum_Teff_PD1_Nivo_syn","",""},//30|30
    {"QSP.init_value.Species.Tum_Teff_PD1_Nivo_PD1_syn","",""},//31|31
    {"QSP.init_value.Species.Tum_C1_PDL1","",""},//32|32
    {"QSP.init_value.Species.Tum_C1_PDL1_syn","",""},//33|33
    {"QSP.init_value.Species.Tum_C1_PDL2","",""},//34|34
    {"QSP.init_value.Species.Tum_C1_PDL2_syn","",""},//35|35
    {"QSP.init_value.Species.Tum_C1_PDL1_Teff_PD1","",""},//36|36
    {"QSP.init_value.Species.Tum_C1_PDL2_Teff_PD1","",""},//37|37
    {"QSP.init_value.Species.Tum_D1_0","",""},//38|38
    {"QSP.init_value.Species.Tum_Teff_1_0","",""},//39|39
    {"QSP.init_value.Species.Tum_Teff_exhausted","",""},//40|40
    {"QSP.init_value.Species.LN_Nivo","",""},//41|41
    {"QSP.init_value.Species.LN_APC","",""},//42|42
    {"QSP.init_value.Species.LN_mAPC","",""},//43|43
    {"QSP.init_value.Species.LN_nT_CD8","",""},//44|44
    {"QSP.init_value.Species.LN_nT_CD4","",""},//45|45
    {"QSP.init_value.Species.LN_aTreg_CD4","",""},//46|46
    {"QSP.init_value.Species.LN_Treg","",""},//47|47
    {"QSP.init_value.Species.LN_IL2","",""},//48|48
    {"QSP.init_value.Species.LN_TCR_p1_0_M","",""},//49|49
    {"QSP.init_value.Species.LN_Cp","",""},//50|50
    {"QSP.init_value.Species.LN_D1_0","",""},//51|51
    {"QSP.init_value.Species.LN_aT_1_0","",""},//52|52
    {"QSP.init_value.Species.LN_Teff_1_0","",""},//53|53
    {"QSP.init_value.Species.mAPC_Endo_Cp","",""},//54|54
    {"QSP.init_value.Species.mAPC_Endo_cpt","",""},//55|55
    {"QSP.init_value.Species.mAPC_Endo_M1","",""},//56|56
    {"QSP.init_value.Species.mAPC_Endo_cpt_M1","",""},//57|57
    {"QSP.init_value.Species.mAPC_Endo_D1_0","",""},//58|58
    {"QSP.init_value.Species.mAPC_Endo_p1_0","",""},//59|59
    {"QSP.init_value.Species.mAPC_Endo_p1_0_M1","",""},//60|60
    {"QSP.init_value.Species.mAPC_Surf_cpt_M1","",""},//61|61
    {"QSP.init_value.Species.mAPC_Surf_M1","",""},//62|62
    {"QSP.init_value.Species.mAPC_Surf_cpt_M","",""},//63|63
    {"QSP.init_value.Species.mAPC_Surf_p1_0_M1","",""},//64|64
    {"QSP.init_value.Species.mAPC_Surf_p1_0_M","",""},//65|65
    //parameters
    {"QSP.init_value.Parameter.AvogadroN","",""},//66|66
    {"QSP.init_value.Parameter.cell","",""},//67|67
    {"QSP.init_value.Parameter.pat_weight","",""},//68|68
    {"QSP.init_value.Parameter.pat_density","",""},//69|69
    {"QSP.init_value.Parameter.pat_volume","",""},//70|70
    {"QSP.init_value.Parameter.f_w_peri","",""},//71|71
    {"QSP.init_value.Parameter.vol_LN_single","",""},//72|72
    {"QSP.init_value.Parameter.nLN","",""},//73|73
    {"QSP.init_value.Parameter.vol_cent","",""},//74|74
    {"QSP.init_value.Parameter.vol_peri","",""},//75|75
    {"QSP.init_value.Parameter.vol_tum","",""},//76|76
    {"QSP.init_value.Parameter.vol_LN","",""},//77|77
    {"QSP.init_value.Parameter.vol_tum_max","",""},//78|78
    {"QSP.init_value.Parameter.vol_tum_app","",""},//79|79
    {"QSP.init_value.Parameter.D_tum_app","",""},//80|80
    {"QSP.init_value.Parameter.D_tum_app_0","",""},//81|81
    {"QSP.init_value.Parameter.D_tum_app_percent","",""},//82|82
    {"QSP.init_value.Parameter.f_vol_cent","",""},//83|83
    {"QSP.init_value.Parameter.f_vol_peri","",""},//84|84
    {"QSP.init_value.Parameter.f_vol_tum","",""},//85|85
    {"QSP.init_value.Parameter.f_vol_LN","",""},//86|86
    {"QSP.init_value.Parameter.f_vol_BV","",""},//87|87
    {"QSP.init_value.Parameter.D_C","",""},//88|88
    {"QSP.init_value.Parameter.D_T","",""},//89|89
    {"QSP.init_value.Parameter.D_APC","",""},//90|90
    {"QSP.init_value.Parameter.vol_C","",""},//91|91
    {"QSP.init_value.Parameter.vol_T","",""},//92|92
    {"QSP.init_value.Parameter.vol_APC","",""},//93|93
    {"QSP.init_value.Parameter.A_C","",""},//94|94
    {"QSP.init_value.Parameter.A_T","",""},//95|95
    {"QSP.init_value.Parameter.A_APC","",""},//96|96
    {"QSP.init_value.Parameter.A_syn","",""},//97|97
    {"QSP.init_value.Parameter.d_syn","",""},//98|98
    {"QSP.init_value.Parameter.C1_min","",""},//99|99
    {"QSP.init_value.Parameter.C_presence","",""},//100|100
    {"QSP.init_value.Parameter.k_C_growth","",""},//101|101
    {"QSP.init_value.Parameter.K_C_max","",""},//102|102
    {"QSP.init_value.Parameter.k_C_death","",""},//103|103
    {"QSP.init_value.Parameter.k_C_death_by_T","",""},//104|104
    {"QSP.init_value.Parameter.Therapy","",""},//105|105
    {"QSP.init_value.Parameter.k_C_death_by_Therapy","",""},//106|106
    {"QSP.init_value.Parameter.D_per_C","",""},//107|107
    {"QSP.init_value.Parameter.Cp_per_C","",""},//108|108
    {"QSP.init_value.Parameter.DAMP_per_C","",""},//109|109
    {"QSP.init_value.Parameter.k_deg_D","",""},//110|110
    {"QSP.init_value.Parameter.t_resection","",""},//111|111
    {"QSP.init_value.Parameter.C1_resection","",""},//112|112
    {"QSP.init_value.Parameter.Teff_resection","",""},//113|113
    {"QSP.init_value.Parameter.Treg_resection","",""},//114|114
    {"QSP.init_value.Parameter.perm_CP_Ab","",""},//115|115
    {"QSP.init_value.Parameter.perm_CT_Ab","",""},//116|116
    {"QSP.init_value.Parameter.perm_CL_Ab","",""},//117|117
    {"QSP.init_value.Parameter.S_CP","",""},//118|118
    {"QSP.init_value.Parameter.S_CT","",""},//119|119
    {"QSP.init_value.Parameter.S_CL","",""},//120|120
    {"QSP.init_value.Parameter.Q_TL","",""},//121|121
    {"QSP.init_value.Parameter.Kd_Nivo","",""},//122|122
    {"QSP.init_value.Parameter.k_on_Nivo","",""},//123|123
    {"QSP.init_value.Parameter.k_off_Nivo","",""},//124|124
    {"QSP.init_value.Parameter.MW_Nivo","",""},//125|125
    {"QSP.init_value.Parameter.dose_mg_Nivo","",""},//126|126
    {"QSP.init_value.Parameter.dose_Nivo","",""},//127|127
    {"QSP.init_value.Parameter.Ki","",""},//128|128
    {"QSP.init_value.Parameter.k_on1_Nivo","",""},//129|129
    {"QSP.init_value.Parameter.k_off1_Nivo","",""},//130|130
    {"QSP.init_value.Parameter.k_on2_Nivo","",""},//131|131
    {"QSP.init_value.Parameter.k_off2_Nivo","",""},//132|132
    {"QSP.init_value.Parameter.t_init_Nivo","",""},//133|133
    {"QSP.init_value.Parameter.t_inter_Nivo","",""},//134|134
    {"QSP.init_value.Parameter.n_dose_Nivo","",""},//135|135
    {"QSP.init_value.Parameter.t_infus_Nivo","",""},//136|136
    {"QSP.init_value.Parameter.t_off_Nivo","",""},//137|137
    {"QSP.init_value.Parameter.t_on_Nivo","",""},//138|138
    {"QSP.init_value.Parameter.count_dose_Nivo","",""},//139|139
    {"QSP.init_value.Parameter.k_infus_Nivo","",""},//140|140
    {"QSP.init_value.Parameter.cl_Nivo","",""},//141|141
    {"QSP.init_value.Parameter.f_vol_peri_Nivo","",""},//142|142
    {"QSP.init_value.Parameter.P_ratio_Nivo","",""},//143|143
    {"QSP.init_value.Parameter.f_vol_cent_Nivo","",""},//144|144
    {"QSP.init_value.Parameter.Teff_PD1_tot","",""},//145|145
    {"QSP.init_value.Parameter.C1_PDL1_tot","",""},//146|146
    {"QSP.init_value.Parameter.C1_PDL2_tot","",""},//147|147
    {"QSP.init_value.Parameter.Kd_PD1_PDL1","",""},//148|148
    {"QSP.init_value.Parameter.k_on_PD1_PDL1","",""},//149|149
    {"QSP.init_value.Parameter.k_off_PD1_PDL1","",""},//150|150
    {"QSP.init_value.Parameter.K_C1_PDLX_Teff_PD1","",""},//151|151
    {"QSP.init_value.Parameter.Kd_PD1_PDL2","",""},//152|152
    {"QSP.init_value.Parameter.k_on_PD1_PDL2","",""},//153|153
    {"QSP.init_value.Parameter.k_off_PD1_PDL2","",""},//154|154
    {"QSP.init_value.Parameter.n_PD1_PDLX","",""},//155|155
    {"QSP.init_value.Parameter.V_E","",""},//156|156
    {"QSP.init_value.Parameter.V_intake","",""},//157|157
    {"QSP.init_value.Parameter.p_per_P","",""},//158|158
    {"QSP.init_value.Parameter.k_int_Cp","",""},//159|159
    {"QSP.init_value.Parameter.k_deg_Cp","",""},//160|160
    {"QSP.init_value.Parameter.k_deg_cpt","",""},//161|161
    {"QSP.init_value.Parameter.k_deg_cpt_M","",""},//162|162
    {"QSP.init_value.Parameter.k_int_Dend","",""},//163|163
    {"QSP.init_value.Parameter.k_deg_Dend","",""},//164|164
    {"QSP.init_value.Parameter.k_deg_p","",""},//165|165
    {"QSP.init_value.Parameter.k_deg_p_M","",""},//166|166
    {"QSP.init_value.Parameter.M1_0","",""},//167|167
    {"QSP.init_value.Parameter.k_deg_M","",""},//168|168
    {"QSP.init_value.Parameter.k_int_M","",""},//169|169
    {"QSP.init_value.Parameter.k_ext_p_M","",""},//170|170
    {"QSP.init_value.Parameter.n_clone_Treg","",""},//171|171
    {"QSP.init_value.Parameter.n_clone_p1_0","",""},//172|172
    {"QSP.init_value.Parameter.Kd_p1_0_M1","",""},//173|173
    {"QSP.init_value.Parameter.k_on_p1_0_M1","",""},//174|174
    {"QSP.init_value.Parameter.k_off_p1_0_M1","",""},//175|175
    {"QSP.init_value.Parameter.Kd_cpt_M1","",""},//176|176
    {"QSP.init_value.Parameter.k_on_cpt_M1","",""},//177|177
    {"QSP.init_value.Parameter.k_off_cpt_M1","",""},//178|178
    {"QSP.init_value.Parameter.k_ext_cpt_M","",""},//179|179
    {"QSP.init_value.Parameter.APC0_Tum","",""},//180|180
    {"QSP.init_value.Parameter.APC0_LN","",""},//181|181
    {"QSP.init_value.Parameter.k_APC_death","",""},//182|182
    {"QSP.init_value.Parameter.k_mAPC_death","",""},//183|183
    {"QSP.init_value.Parameter.Ckine_Mat0","",""},//184|184
    {"QSP.init_value.Parameter.k_Ckine_Mat_deg","",""},//185|185
    {"QSP.init_value.Parameter.K_Ckine_Mat_Cp","",""},//186|186
    {"QSP.init_value.Parameter.k_APC_mat","",""},//187|187
    {"QSP.init_value.Parameter.K_APC_mat","",""},//188|188
    {"QSP.init_value.Parameter.k_mAPC_mig","",""},//189|189
    {"QSP.init_value.Parameter.nT_CD8_dens","",""},//190|190
    {"QSP.init_value.Parameter.nT_CD4_dens","",""},//191|191
    {"QSP.init_value.Parameter.k_nT_entry","",""},//192|192
    {"QSP.init_value.Parameter.k_nT_exit","",""},//193|193
    {"QSP.init_value.Parameter.nT_CD8_diver","",""},//194|194
    {"QSP.init_value.Parameter.nT_CD4_diver","",""},//195|195
    {"QSP.init_value.Parameter.k_nTCD8_mAPC","",""},//196|196
    {"QSP.init_value.Parameter.n_sites_mAPC","",""},//197|197
    {"QSP.init_value.Parameter.K_p_M","",""},//198|198
    {"QSP.init_value.Parameter.k_aT_prolif","",""},//199|199
    {"QSP.init_value.Parameter.k_Teff_death","",""},//200|200
    {"QSP.init_value.Parameter.k_Teff_death_peri","",""},//201|201
    {"QSP.init_value.Parameter.k_Teff_death_by_C","",""},//202|202
    {"QSP.init_value.Parameter.k_Teff_egress","",""},//203|203
    {"QSP.init_value.Parameter.k_Teff_transmig","",""},//204|204
    {"QSP.init_value.Parameter.k_Teff_exit","",""},//205|205
    {"QSP.init_value.Parameter.S_adhesion_tot","",""},//206|206
    {"QSP.init_value.Parameter.S_adhesion_peri_tot","",""},//207|207
    {"QSP.init_value.Parameter.S_adhesion","",""},//208|208
    {"QSP.init_value.Parameter.S_adhesion_peri","",""},//209|209
    {"QSP.init_value.Parameter.T_all_Cent","",""},//210|210
    {"QSP.init_value.Parameter.T_all_Tum","",""},//211|211
    {"QSP.init_value.Parameter.clonality","",""},//212|212
    {"QSP.init_value.Parameter.n_aT_prolif_TCR0","",""},//213|213
    {"QSP.init_value.Parameter.n_aT_prolif_IL20","",""},//214|214
    {"QSP.init_value.Parameter.n_aT_prolif_Coestim0","",""},//215|215
    {"QSP.init_value.Parameter.K_IL2_Teff","",""},//216|216
    {"QSP.init_value.Parameter.k_IL2_rel","",""},//217|217
    {"QSP.init_value.Parameter.k_IL2_deg","",""},//218|218
    {"QSP.init_value.Parameter.k_IL2_consump","",""},//219|219
    {"QSP.init_value.Parameter.n_aT_prolif_TCR","",""},//220|220
    {"QSP.init_value.Parameter.n_aT_prolif_IL2","",""},//221|221
    {"QSP.init_value.Parameter.n_aT_prolif_Coestim","",""},//222|222
    {"QSP.init_value.Parameter.n_aT_prolif","",""},//223|223
    {"QSP.init_value.Parameter.k_nTCD4_APC","",""},//224|224
    {"QSP.init_value.Parameter.n_sites_APC","",""},//225|225
    {"QSP.init_value.Parameter.K_Cp","",""},//226|226
    {"QSP.init_value.Parameter.k_aTreg_prolif","",""},//227|227
    {"QSP.init_value.Parameter.K_IL2_Treg","",""},//228|228
    {"QSP.init_value.Parameter.nTreg_basal","",""},//229|229
    {"QSP.init_value.Parameter.k_Treg_death","",""},//230|230
    {"QSP.init_value.Parameter.k_Treg_egress","",""},//231|231
    {"QSP.init_value.Parameter.k_Treg_transmig","",""},//232|232
    {"QSP.init_value.Parameter.k_Treg_exit","",""},//233|233
    {"QSP.init_value.Parameter.k_Teff_inhibBy_Treg","",""},//234|234
    {"QSP.init_value.Parameter.K_Treg_inhib","",""},//235|235
    {"QSP.init_value.Parameter.n_Treg_prolif_IL2","",""},//236|236
    {"QSP.init_value.Parameter.Teff2TregRatio","",""},//237|237
    {"QSP.init_value.Parameter.k_Teff_exh_death","",""},//238|238
    {"QSP.init_value.Parameter.n_Treg_prolif_IL20","",""},//239|239
};

Param::Param()
    :ParamBase()
{
    setupParam();
}

void Param::setupParam(){
    for (size_t i = 0; i < 240; i++)
    {
        _paramDesc.push_back(vector<string>(_description[i],
            _description[i]+ PARAM_DESCRIPTION_FIELD_COUNT));
		// combine paramter files
		_paramDesc[i][0] = "Param." + _paramDesc[i][0];
    }
    _paramFloat = vector<double>(240, 0);
}

};


text:
///////////////////////////////////////////////////////////////////////////////
// distribution::toolkit::map_pdf::inverse_pdf::is_pseudo_scalar_distribution.hpp //
//                                                                           //
//  (C) Copyright 2009 Erwann Rogard                                         //
//  Use, modification and distribution are subject to the                    //
//  Boost Software License, Version 1.0. (See accompanying file              //
//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)         //
///////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_STATISTICS_DETAIL_DISTRIBUTION_TOOLKIT_MAP_PDF_INVERSE_PDF_IS_PSEUDO_SCALAR_DISTRIBUTION_HPP_ER_2009
#define BOOST_STATISTICS_DETAIL_DISTRIBUTION_TOOLKIT_MAP_PDF_INVERSE_PDF_IS_PSEUDO_SCALAR_DISTRIBUTION_HPP_ER_2009
#include <boost/mpl/bool.hpp>
#include <boost/statistics/detail/distribution_toolkit/meta/is_pseudo_scalar_distribution.hpp>
#include <boost/statistics/detail/distribution_toolkit/map_pdf/inverse_pdf/inverse_pdf.hpp>

namespace boost{
namespace statistics{
namespace detail{
namespace distribution{
namespace toolkit{

namespace meta{

    template<typename D>
    struct is_pseudo_scalar_distribution<
        inverse_pdf<D>
    > : is_pseudo_scalar_distribution<D> {};

}// meta
}// distribution
}// toolkit

}// detail
}// statistics
}// boost

#endif