<commit_before>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/memory/p9_mss_eff_config.C $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2019                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

///
/// @file p9_mss_eff_config.C
/// @brief Command and Control for the memory subsystem - populate attributes
///
// *HWP HWP Owner: Andre Marin <aamarin@us.ibm.com>
// *HWP HWP Backup: Brian Silver <bsilver@us.ibm.com>
// *HWP Team: Memory
// *HWP Level: 2
// *HWP Consumed by: FSP:HB

#include <p9_mss_eff_config.H>

// std
#include <vector>

// fapi2
#include <fapi2.H>

// mss lib
#include <lib/spd/common/spd_decoder.H>
#include <lib/spd/spd_factory.H>
#include <lib/utils/pos.H>
#include <lib/utils/checker.H>
#include <lib/utils/find.H>
#include <lib/shared/mss_kind.H>
#include <lib/utils/find.H>
#include <lib/dimm/eff_dimm.H>
#include <lib/eff_config/plug_rules.H>

///
/// @brief Configure the attributes for each controller
/// @param[in] i_target the controller (e.g., MCS)
/// @param[in] i_decode_spd_only options to set VPD and SPD attrs only
/// @return FAPI2_RC_SUCCESS iff ok
///
fapi2::ReturnCode p9_mss_eff_config( const fapi2::Target<fapi2::TARGET_TYPE_MCS>& i_target,
                                     const bool i_decode_spd_only )
{
    fapi2::ReturnCode l_rc;
    std::vector< std::shared_ptr<mss::spd::decoder> > l_factory_caches;
    // Caches
    FAPI_TRY( mss::spd::populate_decoder_caches(i_target, l_factory_caches) );

    // We need to decode the VPD. We don't do this in the ctor as we need
    // the rank information and for that we need the SPD caches (which we get when we populate the cache.)
    // However, we need to do the VPD decode before the others so that they might
    // be able to use VPD information to make decisions about setting up eff attributes.
    if( !i_decode_spd_only )
    {
        // Always set VPD attributes unless we enable the SPD_ONLY flag
        // Enables skipping VPD decoder when a valid VPD template isn't available
        FAPI_TRY( mss::eff_dimm::decode_vpd(i_target),
                  "Unable to decode VPD for %s", mss::c_str(i_target) );
    }

    for( const auto& l_cache : l_factory_caches )
    {
        std::shared_ptr<mss::eff_dimm> l_eff_dimm;

        FAPI_TRY( mss::eff_dimm::eff_dimm_factory( l_cache, l_eff_dimm));

        FAPI_TRY( l_eff_dimm->dram_mfg_id() );
        FAPI_TRY( l_eff_dimm->dram_width() );
        FAPI_TRY( l_eff_dimm->dram_density() );
        FAPI_TRY( l_eff_dimm->ranks_per_dimm() );
        FAPI_TRY( l_eff_dimm->prim_die_count() );
        FAPI_TRY( l_eff_dimm->primary_stack_type() );
        FAPI_TRY( l_eff_dimm->dimm_size() );
        FAPI_TRY( l_eff_dimm->hybrid_memory_type() );
        FAPI_TRY( l_eff_dimm->dram_trefi() );
        FAPI_TRY( l_eff_dimm->dram_trfc() );
        FAPI_TRY( l_eff_dimm->dram_trfc_dlr() );
        FAPI_TRY( l_eff_dimm->rcd_mirror_mode() );
        FAPI_TRY( l_eff_dimm->dram_bank_bits() );
        FAPI_TRY( l_eff_dimm->dram_row_bits() );
        FAPI_TRY( l_eff_dimm->dram_dqs_time() );
        FAPI_TRY( l_eff_dimm->dram_tccd_l() );
        FAPI_TRY( l_eff_dimm->dimm_rc00() );
        FAPI_TRY( l_eff_dimm->dimm_rc01() );
        FAPI_TRY( l_eff_dimm->dimm_rc02() );
        FAPI_TRY( l_eff_dimm->dimm_rc03() );
        FAPI_TRY( l_eff_dimm->dimm_rc04() );
        FAPI_TRY( l_eff_dimm->dimm_rc05() );
        FAPI_TRY( l_eff_dimm->dimm_rc06_07() );
        FAPI_TRY( l_eff_dimm->dimm_rc08() );
        FAPI_TRY( l_eff_dimm->dimm_rc09() );
        FAPI_TRY( l_eff_dimm->dimm_rc0a() );
        FAPI_TRY( l_eff_dimm->dimm_rc0b() );
        FAPI_TRY( l_eff_dimm->dimm_rc0c() );
        FAPI_TRY( l_eff_dimm->dimm_rc0d() );
        FAPI_TRY( l_eff_dimm->dimm_rc0e() );
        FAPI_TRY( l_eff_dimm->dimm_rc0f() );
        FAPI_TRY( l_eff_dimm->dimm_rc1x() );
        FAPI_TRY( l_eff_dimm->dimm_rc2x() );
        FAPI_TRY( l_eff_dimm->dimm_rc3x() );
        FAPI_TRY( l_eff_dimm->dimm_rc4x() );
        FAPI_TRY( l_eff_dimm->dimm_rc5x() );
        FAPI_TRY( l_eff_dimm->dimm_rc6x() );
        FAPI_TRY( l_eff_dimm->dimm_rc7x() );
        FAPI_TRY( l_eff_dimm->dimm_rc8x() );
        FAPI_TRY( l_eff_dimm->dimm_rc9x() );
        FAPI_TRY( l_eff_dimm->dimm_rcax() );
        FAPI_TRY( l_eff_dimm->dimm_rcbx() );
        FAPI_TRY( l_eff_dimm->dram_twr() );
        FAPI_TRY( l_eff_dimm->read_burst_type() );
        FAPI_TRY( l_eff_dimm->dram_tm() );
        FAPI_TRY( l_eff_dimm->dram_cwl() );
        FAPI_TRY( l_eff_dimm->dram_lpasr() );
        FAPI_TRY( l_eff_dimm->dll_enable() );
        FAPI_TRY( l_eff_dimm->dll_reset() );
        FAPI_TRY( l_eff_dimm->write_level_enable() );
        FAPI_TRY( l_eff_dimm->output_buffer() );
        FAPI_TRY( l_eff_dimm->vref_dq_train_value() );
        FAPI_TRY( l_eff_dimm->vref_dq_train_range() );
        FAPI_TRY( l_eff_dimm->vref_dq_train_enable() );
        FAPI_TRY( l_eff_dimm->ca_parity_latency() );
        FAPI_TRY( l_eff_dimm->ca_parity_error_status() );
        FAPI_TRY( l_eff_dimm->ca_parity() );
        FAPI_TRY( l_eff_dimm->crc_error_clear() );
        FAPI_TRY( l_eff_dimm->odt_input_buffer() );
        FAPI_TRY( l_eff_dimm->post_package_repair() );
        FAPI_TRY( l_eff_dimm->read_preamble_train() );
        FAPI_TRY( l_eff_dimm->read_preamble() );
        FAPI_TRY( l_eff_dimm->write_preamble() );
        FAPI_TRY( l_eff_dimm->self_refresh_abort() );
        FAPI_TRY( l_eff_dimm->cs_to_cmd_addr_latency() );
        FAPI_TRY( l_eff_dimm->internal_vref_monitor() );
        FAPI_TRY( l_eff_dimm->max_powerdown_mode() );
        FAPI_TRY( l_eff_dimm->mpr_read_format() );
        FAPI_TRY( l_eff_dimm->temp_readout() );
        FAPI_TRY( l_eff_dimm->crc_wr_latency() );
        FAPI_TRY( l_eff_dimm->per_dram_addressability() );
        FAPI_TRY( l_eff_dimm->geardown_mode() );
        FAPI_TRY( l_eff_dimm->mpr_page() );
        FAPI_TRY( l_eff_dimm->mpr_mode() );
        FAPI_TRY( l_eff_dimm->write_crc() );
        FAPI_TRY( l_eff_dimm->zqcal_interval() );
        FAPI_TRY( l_eff_dimm->memcal_interval() );
        FAPI_TRY( l_eff_dimm->dram_trp() );
        FAPI_TRY( l_eff_dimm->dram_trcd() );
        FAPI_TRY( l_eff_dimm->dram_trc() );
        FAPI_TRY( l_eff_dimm->dram_twtr_l() );
        FAPI_TRY( l_eff_dimm->dram_twtr_s() );
        FAPI_TRY( l_eff_dimm->dram_trrd_s() );
        FAPI_TRY( l_eff_dimm->dram_trrd_l() );
        FAPI_TRY( l_eff_dimm->dram_trrd_dlr() );
        FAPI_TRY( l_eff_dimm->dram_tfaw() );
        FAPI_TRY( l_eff_dimm->dram_tfaw_dlr() );
        FAPI_TRY( l_eff_dimm->dram_tras() );
        FAPI_TRY( l_eff_dimm->dram_trtp() );
        FAPI_TRY( l_eff_dimm->read_dbi() );
        FAPI_TRY( l_eff_dimm->write_dbi() );
        FAPI_TRY( l_eff_dimm->additive_latency() );
        FAPI_TRY( l_eff_dimm->data_mask() );
        FAPI_TRY( l_eff_dimm->dimm_bc00());
        FAPI_TRY( l_eff_dimm->dimm_bc01());
        FAPI_TRY( l_eff_dimm->dimm_bc02());
        FAPI_TRY( l_eff_dimm->dimm_bc03());
        FAPI_TRY( l_eff_dimm->dimm_bc04());
        FAPI_TRY( l_eff_dimm->dimm_bc05());
        FAPI_TRY( l_eff_dimm->dimm_bc07());
        FAPI_TRY( l_eff_dimm->dimm_bc08());
        FAPI_TRY( l_eff_dimm->dimm_bc09());
        FAPI_TRY( l_eff_dimm->dimm_bc0a());
        FAPI_TRY( l_eff_dimm->dimm_bc0b());
        FAPI_TRY( l_eff_dimm->dimm_bc0c());
        FAPI_TRY( l_eff_dimm->dimm_bc0d());
        FAPI_TRY( l_eff_dimm->dimm_bc0e());
        FAPI_TRY( l_eff_dimm->dimm_bc0f());
        FAPI_TRY( l_eff_dimm->dram_rtt_nom () );
        FAPI_TRY( l_eff_dimm->dram_rtt_wr  () );
        FAPI_TRY( l_eff_dimm->dram_rtt_park() );

        //Let's do some checking
        FAPI_TRY( mss::check::temp_refresh_mode());
    }// dimm

    // TODO RTC:160060 Clean up hard coded values at bottom of eff_config
    // Don't set these attributes if we only want to set VPD attributes
    // This will be cleaner once we resolve attributes below
    {
        uint16_t l_cal_step[mss::PORTS_PER_MCS] = {0xFAC0, 0xFAC0};
        FAPI_TRY( FAPI_ATTR_SET(fapi2::ATTR_MSS_CAL_STEP_ENABLE, i_target, l_cal_step) );
    }

    // Check plug rules. We check the MCS, and this will iterate down to children as needed.
    FAPI_TRY( mss::plug_rule::enforce_plug_rules(i_target) );

fapi_try_exit:
    return fapi2::current_err;
}
<commit_msg>Updates to run HW VREF cal by default<commit_after>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/memory/p9_mss_eff_config.C $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2019                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

///
/// @file p9_mss_eff_config.C
/// @brief Command and Control for the memory subsystem - populate attributes
///
// *HWP HWP Owner: Andre Marin <aamarin@us.ibm.com>
// *HWP HWP Backup: Brian Silver <bsilver@us.ibm.com>
// *HWP Team: Memory
// *HWP Level: 2
// *HWP Consumed by: FSP:HB

#include <p9_mss_eff_config.H>

// std
#include <vector>

// fapi2
#include <fapi2.H>

// mss lib
#include <lib/spd/common/spd_decoder.H>
#include <lib/spd/spd_factory.H>
#include <lib/utils/pos.H>
#include <lib/utils/checker.H>
#include <lib/utils/find.H>
#include <lib/shared/mss_kind.H>
#include <lib/utils/find.H>
#include <lib/dimm/eff_dimm.H>
#include <lib/eff_config/plug_rules.H>

///
/// @brief Configure the attributes for each controller
/// @param[in] i_target the controller (e.g., MCS)
/// @param[in] i_decode_spd_only options to set VPD and SPD attrs only
/// @return FAPI2_RC_SUCCESS iff ok
///
fapi2::ReturnCode p9_mss_eff_config( const fapi2::Target<fapi2::TARGET_TYPE_MCS>& i_target,
                                     const bool i_decode_spd_only )
{
    fapi2::ReturnCode l_rc;
    std::vector< std::shared_ptr<mss::spd::decoder> > l_factory_caches;
    // Caches
    FAPI_TRY( mss::spd::populate_decoder_caches(i_target, l_factory_caches) );

    // We need to decode the VPD. We don't do this in the ctor as we need
    // the rank information and for that we need the SPD caches (which we get when we populate the cache.)
    // However, we need to do the VPD decode before the others so that they might
    // be able to use VPD information to make decisions about setting up eff attributes.
    if( !i_decode_spd_only )
    {
        // Always set VPD attributes unless we enable the SPD_ONLY flag
        // Enables skipping VPD decoder when a valid VPD template isn't available
        FAPI_TRY( mss::eff_dimm::decode_vpd(i_target),
                  "Unable to decode VPD for %s", mss::c_str(i_target) );
    }

    for( const auto& l_cache : l_factory_caches )
    {
        std::shared_ptr<mss::eff_dimm> l_eff_dimm;

        FAPI_TRY( mss::eff_dimm::eff_dimm_factory( l_cache, l_eff_dimm));

        FAPI_TRY( l_eff_dimm->dram_mfg_id() );
        FAPI_TRY( l_eff_dimm->dram_width() );
        FAPI_TRY( l_eff_dimm->dram_density() );
        FAPI_TRY( l_eff_dimm->ranks_per_dimm() );
        FAPI_TRY( l_eff_dimm->prim_die_count() );
        FAPI_TRY( l_eff_dimm->primary_stack_type() );
        FAPI_TRY( l_eff_dimm->dimm_size() );
        FAPI_TRY( l_eff_dimm->hybrid_memory_type() );
        FAPI_TRY( l_eff_dimm->dram_trefi() );
        FAPI_TRY( l_eff_dimm->dram_trfc() );
        FAPI_TRY( l_eff_dimm->dram_trfc_dlr() );
        FAPI_TRY( l_eff_dimm->rcd_mirror_mode() );
        FAPI_TRY( l_eff_dimm->dram_bank_bits() );
        FAPI_TRY( l_eff_dimm->dram_row_bits() );
        FAPI_TRY( l_eff_dimm->dram_dqs_time() );
        FAPI_TRY( l_eff_dimm->dram_tccd_l() );
        FAPI_TRY( l_eff_dimm->dimm_rc00() );
        FAPI_TRY( l_eff_dimm->dimm_rc01() );
        FAPI_TRY( l_eff_dimm->dimm_rc02() );
        FAPI_TRY( l_eff_dimm->dimm_rc03() );
        FAPI_TRY( l_eff_dimm->dimm_rc04() );
        FAPI_TRY( l_eff_dimm->dimm_rc05() );
        FAPI_TRY( l_eff_dimm->dimm_rc06_07() );
        FAPI_TRY( l_eff_dimm->dimm_rc08() );
        FAPI_TRY( l_eff_dimm->dimm_rc09() );
        FAPI_TRY( l_eff_dimm->dimm_rc0a() );
        FAPI_TRY( l_eff_dimm->dimm_rc0b() );
        FAPI_TRY( l_eff_dimm->dimm_rc0c() );
        FAPI_TRY( l_eff_dimm->dimm_rc0d() );
        FAPI_TRY( l_eff_dimm->dimm_rc0e() );
        FAPI_TRY( l_eff_dimm->dimm_rc0f() );
        FAPI_TRY( l_eff_dimm->dimm_rc1x() );
        FAPI_TRY( l_eff_dimm->dimm_rc2x() );
        FAPI_TRY( l_eff_dimm->dimm_rc3x() );
        FAPI_TRY( l_eff_dimm->dimm_rc4x() );
        FAPI_TRY( l_eff_dimm->dimm_rc5x() );
        FAPI_TRY( l_eff_dimm->dimm_rc6x() );
        FAPI_TRY( l_eff_dimm->dimm_rc7x() );
        FAPI_TRY( l_eff_dimm->dimm_rc8x() );
        FAPI_TRY( l_eff_dimm->dimm_rc9x() );
        FAPI_TRY( l_eff_dimm->dimm_rcax() );
        FAPI_TRY( l_eff_dimm->dimm_rcbx() );
        FAPI_TRY( l_eff_dimm->dram_twr() );
        FAPI_TRY( l_eff_dimm->read_burst_type() );
        FAPI_TRY( l_eff_dimm->dram_tm() );
        FAPI_TRY( l_eff_dimm->dram_cwl() );
        FAPI_TRY( l_eff_dimm->dram_lpasr() );
        FAPI_TRY( l_eff_dimm->dll_enable() );
        FAPI_TRY( l_eff_dimm->dll_reset() );
        FAPI_TRY( l_eff_dimm->write_level_enable() );
        FAPI_TRY( l_eff_dimm->output_buffer() );
        FAPI_TRY( l_eff_dimm->vref_dq_train_value() );
        FAPI_TRY( l_eff_dimm->vref_dq_train_range() );
        FAPI_TRY( l_eff_dimm->vref_dq_train_enable() );
        FAPI_TRY( l_eff_dimm->ca_parity_latency() );
        FAPI_TRY( l_eff_dimm->ca_parity_error_status() );
        FAPI_TRY( l_eff_dimm->ca_parity() );
        FAPI_TRY( l_eff_dimm->crc_error_clear() );
        FAPI_TRY( l_eff_dimm->odt_input_buffer() );
        FAPI_TRY( l_eff_dimm->post_package_repair() );
        FAPI_TRY( l_eff_dimm->read_preamble_train() );
        FAPI_TRY( l_eff_dimm->read_preamble() );
        FAPI_TRY( l_eff_dimm->write_preamble() );
        FAPI_TRY( l_eff_dimm->self_refresh_abort() );
        FAPI_TRY( l_eff_dimm->cs_to_cmd_addr_latency() );
        FAPI_TRY( l_eff_dimm->internal_vref_monitor() );
        FAPI_TRY( l_eff_dimm->max_powerdown_mode() );
        FAPI_TRY( l_eff_dimm->mpr_read_format() );
        FAPI_TRY( l_eff_dimm->temp_readout() );
        FAPI_TRY( l_eff_dimm->crc_wr_latency() );
        FAPI_TRY( l_eff_dimm->per_dram_addressability() );
        FAPI_TRY( l_eff_dimm->geardown_mode() );
        FAPI_TRY( l_eff_dimm->mpr_page() );
        FAPI_TRY( l_eff_dimm->mpr_mode() );
        FAPI_TRY( l_eff_dimm->write_crc() );
        FAPI_TRY( l_eff_dimm->zqcal_interval() );
        FAPI_TRY( l_eff_dimm->memcal_interval() );
        FAPI_TRY( l_eff_dimm->dram_trp() );
        FAPI_TRY( l_eff_dimm->dram_trcd() );
        FAPI_TRY( l_eff_dimm->dram_trc() );
        FAPI_TRY( l_eff_dimm->dram_twtr_l() );
        FAPI_TRY( l_eff_dimm->dram_twtr_s() );
        FAPI_TRY( l_eff_dimm->dram_trrd_s() );
        FAPI_TRY( l_eff_dimm->dram_trrd_l() );
        FAPI_TRY( l_eff_dimm->dram_trrd_dlr() );
        FAPI_TRY( l_eff_dimm->dram_tfaw() );
        FAPI_TRY( l_eff_dimm->dram_tfaw_dlr() );
        FAPI_TRY( l_eff_dimm->dram_tras() );
        FAPI_TRY( l_eff_dimm->dram_trtp() );
        FAPI_TRY( l_eff_dimm->read_dbi() );
        FAPI_TRY( l_eff_dimm->write_dbi() );
        FAPI_TRY( l_eff_dimm->additive_latency() );
        FAPI_TRY( l_eff_dimm->data_mask() );
        FAPI_TRY( l_eff_dimm->dimm_bc00());
        FAPI_TRY( l_eff_dimm->dimm_bc01());
        FAPI_TRY( l_eff_dimm->dimm_bc02());
        FAPI_TRY( l_eff_dimm->dimm_bc03());
        FAPI_TRY( l_eff_dimm->dimm_bc04());
        FAPI_TRY( l_eff_dimm->dimm_bc05());
        FAPI_TRY( l_eff_dimm->dimm_bc07());
        FAPI_TRY( l_eff_dimm->dimm_bc08());
        FAPI_TRY( l_eff_dimm->dimm_bc09());
        FAPI_TRY( l_eff_dimm->dimm_bc0a());
        FAPI_TRY( l_eff_dimm->dimm_bc0b());
        FAPI_TRY( l_eff_dimm->dimm_bc0c());
        FAPI_TRY( l_eff_dimm->dimm_bc0d());
        FAPI_TRY( l_eff_dimm->dimm_bc0e());
        FAPI_TRY( l_eff_dimm->dimm_bc0f());
        FAPI_TRY( l_eff_dimm->dram_rtt_nom () );
        FAPI_TRY( l_eff_dimm->dram_rtt_wr  () );
        FAPI_TRY( l_eff_dimm->dram_rtt_park() );

        // Sets up the calibration steps
        FAPI_TRY( l_eff_dimm->cal_step_enable() );
        FAPI_TRY( l_eff_dimm->vref_enable_bit() );

        //Let's do some checking
        FAPI_TRY( mss::check::temp_refresh_mode());
    }// dimm

    // Check plug rules. We check the MCS, and this will iterate down to children as needed.
    FAPI_TRY( mss::plug_rule::enforce_plug_rules(i_target) );

fapi_try_exit:
    return fapi2::current_err;
}
<|endoftext|>


<commit_before>/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTTIMERMANAGER_HXX
#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTTIMERMANAGER_HX

#include <IDocumentTimerAccess.hxx>
#include <boost/utility.hpp>

#include <vcl/timer.hxx>
#include <sal/types.h>
#include <tools/link.hxx>

class SwDoc;

namespace sw
{

class DocumentTimerManager : public IDocumentTimerAccess,
                             public ::boost::noncopyable
{
public:

    DocumentTimerManager( SwDoc& i_rSwdoc );

    void StartIdling() SAL_OVERRIDE;

    void StopIdling() SAL_OVERRIDE;

    void BlockIdling() SAL_OVERRIDE;

    void UnblockIdling() SAL_OVERRIDE;

    void StartBackgroundJobs() SAL_OVERRIDE;

    // Our own 'IdleTimer' calls the following method
    DECL_LINK( DoIdleJobs, Timer * );

    virtual ~DocumentTimerManager();

private:

     SwDoc& m_rSwdoc;

     bool mbStartIdleTimer; //< idle timer mode start/stop
     sal_Int32 mIdleBlockCount;
     Timer maIdleTimer;
};

}

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<commit_msg>-Werror,-Wheader-guard<commit_after>/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTTIMERMANAGER_HXX
#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTTIMERMANAGER_HXX

#include <IDocumentTimerAccess.hxx>
#include <boost/utility.hpp>

#include <vcl/timer.hxx>
#include <sal/types.h>
#include <tools/link.hxx>

class SwDoc;

namespace sw
{

class DocumentTimerManager : public IDocumentTimerAccess,
                             public ::boost::noncopyable
{
public:

    DocumentTimerManager( SwDoc& i_rSwdoc );

    void StartIdling() SAL_OVERRIDE;

    void StopIdling() SAL_OVERRIDE;

    void BlockIdling() SAL_OVERRIDE;

    void UnblockIdling() SAL_OVERRIDE;

    void StartBackgroundJobs() SAL_OVERRIDE;

    // Our own 'IdleTimer' calls the following method
    DECL_LINK( DoIdleJobs, Timer * );

    virtual ~DocumentTimerManager();

private:

     SwDoc& m_rSwdoc;

     bool mbStartIdleTimer; //< idle timer mode start/stop
     sal_Int32 mIdleBlockCount;
     Timer maIdleTimer;
};

}

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<|endoftext|>


<commit_before>#include <QmitkPropertyListViewItemFactory.h>
#include <QmitkPropertyListViewItem.h>
#include <mitkPropertyList.h>
#include <mitkPropertyManager.h>
#include <mitkProperties.h>
#include <mitkBaseProperty.h>
#include <mitkEnumerationProperty.h>
#include <mitkMaterialProperty.h>

// QT related includes
#include <qcheckbox.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qpixmap.h>
#include <qcolordialog.h>
#include <qvalidator.h>
#include <qhbox.h>
#include <qslider.h>
#include <qcombobox.h>

#include <iostream>

QmitkPropertyListViewItemFactory* QmitkPropertyListViewItemFactory::GetInstance() {
   static QmitkPropertyListViewItemFactory* instance = new QmitkPropertyListViewItemFactory();
   return instance;
}
QmitkPropertyListViewItem* QmitkPropertyListViewItemFactory::CreateQmitkPropertyListViewItem(mitk::PropertyList *propList, const std::string name, QWidget* parent, bool createOnlyControl) const {

  QmitkPropertyListViewItem* newItem = NULL;
  if (m_Extension) {
    // try the registered extension
    newItem = m_Extension->CreateQmitkPropertyListViewItem(propList,name,parent,createOnlyControl);
  }
  if (!newItem) {

    mitk::PropertyList::PropertyMap::const_iterator it = propList->GetMap()->find(name.c_str());
    mitk::BaseProperty* baseProp = NULL;
    if (it != propList->GetMap()->end())
    {
      baseProp = it->second.first;
    }
    if (mitk::BoolProperty* boolProp = dynamic_cast<mitk::BoolProperty*>(baseProp))
    {
      newItem = new QmitkPropertyListViewItem(name,propList,parent,createOnlyControl);
      newItem->m_Control = new QCheckBox(parent);
      ((QCheckBox*)(newItem->m_Control))->setChecked(boolProp->GetValue());
      QObject::QObject::connect((QObject*)(newItem->m_Control),SIGNAL(toggled(bool)),(QObject*)(newItem),SLOT(CheckBoxControlActivated(bool)));
    }
    else if (mitk::StringProperty* stringProp = dynamic_cast<mitk::StringProperty*>(baseProp))
    {
      newItem = new QmitkPropertyListViewItem(name,propList,parent,createOnlyControl);
      newItem->m_Control = new QLineEdit(QString(stringProp->GetValue()),parent);
      QObject::connect((QObject*)(newItem->m_Control),SIGNAL(textChanged(const QString &)),(QObject*)(newItem),SLOT(StringControlActivated(const QString &)));
    }
    else if (mitk::ColorProperty* colorProp = dynamic_cast<mitk::ColorProperty*>(baseProp))
    {
      newItem = new QmitkPropertyListViewItem(name,propList,parent,createOnlyControl);
      newItem->m_Control = new QPushButton(parent);
      QPixmap pm(20,20);
      mitk::Color col = colorProp->GetColor();
      QColor qcol((int)(col.GetRed() * 255), (int)(col.GetGreen() * 255),(int)( col.GetBlue() * 255));
      pm.fill(qcol);
      // newItem->m_Control->setBackgroundPixmap(pm);
      newItem->m_Control->setPaletteBackgroundColor(qcol);
      QObject::connect((QObject*)(newItem->m_Control),SIGNAL(clicked()),(QObject*)(newItem),SLOT(ColorControlActivated()));
    }
    else if (mitk::EnumerationProperty* enumProp = dynamic_cast<mitk::EnumerationProperty*>(baseProp))
    {
      newItem = new QmitkPropertyListViewItem( name,propList,parent,createOnlyControl );
      newItem->m_Control = new QComboBox( parent );

      //
      // Fill the combo box with the possible enumeration values.
      // Keep track of the index of the current value set in the enumeration property
      // to set it as current item in the  combobox
      //
      int indexOfCurrentValue = -1;
      int index = 0;
      for ( mitk::EnumerationProperty::EnumConstIterator it = enumProp->Begin(); it !=enumProp->End(); ++it, ++index )
      {
        if ( enumProp->GetValueAsString() == it->second )
        {
          indexOfCurrentValue = index;
        }
        ( ( QComboBox* )( newItem->m_Control ) )->insertItem( it->second.c_str() );
      }

      //
      // select the current item of the combo box to the value defined in the
      // enumeration property
      //
      assert( indexOfCurrentValue != -1 );
      ( ( QComboBox* )( newItem->m_Control ) )->setCurrentItem( indexOfCurrentValue );

      QObject::connect((QObject*)(newItem->m_Control),SIGNAL( activated(const QString&) ),(QObject*)(newItem),SLOT(ComboBoxItemActivated(const QString&)));
    }
    else if (mitk::FloatProperty* floatProp = dynamic_cast<mitk::FloatProperty*>(baseProp))
    {
      std::pair<float,float> minMax;
      QString text;
      text.setNum(floatProp->GetValue());

      if (mitk::PropertyManager::GetInstance()->GetDefaultLimits(name,minMax) && (minMax.first == 0.0f && minMax.second == 1.0f))
      {
        // condition to use slider instead of lineedit

        QmitkPropertyListViewFloatSlider* sliderItem = new QmitkPropertyListViewFloatSlider(name,propList,parent,createOnlyControl);
        sliderItem->m_Control =  new QHBox(parent);
        sliderItem->m_Slider = new QSlider(Qt::Horizontal,sliderItem->m_Control);
        sliderItem->m_ValueLabel = new QLabel(text,sliderItem->m_Control);
        sliderItem->m_Slider->setMinValue(0);
        sliderItem->m_Slider->setMaxValue(100);
        sliderItem->UpdateView();
        newItem = sliderItem;
        QObject::connect((QObject*)(sliderItem->m_Slider),SIGNAL(valueChanged(int)),(QObject*)(sliderItem),SLOT(SliderValueChanged(int)));
      }
      else
      {
        newItem = new QmitkPropertyListViewItem(name,propList,parent,createOnlyControl);
        newItem->m_Control = new QLineEdit(text,parent);
        ((QLineEdit*)(newItem->m_Control))->setValidator(new QDoubleValidator(minMax.first,minMax.second,3,newItem->m_Control));
        QObject::connect((QObject*)(newItem->m_Control),SIGNAL(textChanged(const QString &)),(QObject*)(newItem),SLOT(FloatControlActivated(const QString &)));
      }
    }
    else if (mitk::IntProperty* intProp = dynamic_cast<mitk::IntProperty*>(baseProp))
    {
      newItem = new QmitkPropertyListViewItem(name,propList,parent,createOnlyControl);
      QString text;
      text.setNum(intProp->GetValue());
      newItem->m_Control = new QLineEdit(text,parent);
      std::pair<float,float> minMax;
      if (mitk::PropertyManager::GetInstance()->GetDefaultLimits(newItem->m_Name,minMax))
      {
        ((QLineEdit*)(newItem->m_Control))->setValidator(new QIntValidator((int)minMax.first,(int)minMax.second,newItem->m_Control));
      }
      else
      {
        ((QLineEdit*)(newItem->m_Control))->
          setValidator(new QIntValidator(std::numeric_limits<int>::min(),std::numeric_limits<int>::max(),newItem->m_Control));
      }
      QObject::connect((QObject*)(newItem->m_Control),SIGNAL(textChanged(const QString &)),(QObject*)(newItem),SLOT(IntControlActivated(const QString &)));
    }
    else if (dynamic_cast<mitk::MaterialProperty*>(baseProp))
    {
      newItem = new QmitkPropertyListViewItem(name,propList,parent,createOnlyControl);
      newItem->m_Control = new QPushButton("Edit",parent);
      QObject::connect((QObject*)(newItem->m_Control),SIGNAL(clicked()),(QObject*)(newItem),SLOT(MaterialEditorActivated()));
    }
    else
    {
      newItem = new QmitkPropertyListViewItem(name,propList,parent,createOnlyControl);
      if (baseProp)
      {
        newItem->m_Control = new QLabel(QString(baseProp->GetValueAsString().c_str()),parent);
      }
      else
      {
        newItem->m_Control = new QLabel("n/a",parent);
      }
    }
  }
  if (newItem && newItem->m_Control) {
    newItem->m_Control->setName((name + "_" + "QmitkPropertyListViewItem_control").c_str());
    newItem->m_Control->show();
  }
  return newItem;
}

<commit_msg>COMP: syntax error<commit_after>#include <QmitkPropertyListViewItemFactory.h>
#include <QmitkPropertyListViewItem.h>
#include <mitkPropertyList.h>
#include <mitkPropertyManager.h>
#include <mitkProperties.h>
#include <mitkBaseProperty.h>
#include <mitkEnumerationProperty.h>
#include <mitkMaterialProperty.h>

// QT related includes
#include <qcheckbox.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qpixmap.h>
#include <qcolordialog.h>
#include <qvalidator.h>
#include <qhbox.h>
#include <qslider.h>
#include <qcombobox.h>

#include <iostream>

QmitkPropertyListViewItemFactory* QmitkPropertyListViewItemFactory::GetInstance() {
   static QmitkPropertyListViewItemFactory* instance = new QmitkPropertyListViewItemFactory();
   return instance;
}
QmitkPropertyListViewItem* QmitkPropertyListViewItemFactory::CreateQmitkPropertyListViewItem(mitk::PropertyList *propList, const std::string name, QWidget* parent, bool createOnlyControl) const {

  QmitkPropertyListViewItem* newItem = NULL;
  if (m_Extension) {
    // try the registered extension
    newItem = m_Extension->CreateQmitkPropertyListViewItem(propList,name,parent,createOnlyControl);
  }
  if (!newItem) {

    mitk::PropertyList::PropertyMap::const_iterator it = propList->GetMap()->find(name.c_str());
    mitk::BaseProperty* baseProp = NULL;
    if (it != propList->GetMap()->end())
    {
      baseProp = it->second.first;
    }
    if (mitk::BoolProperty* boolProp = dynamic_cast<mitk::BoolProperty*>(baseProp))
    {
      newItem = new QmitkPropertyListViewItem(name,propList,parent,createOnlyControl);
      newItem->m_Control = new QCheckBox(parent);
      ((QCheckBox*)(newItem->m_Control))->setChecked(boolProp->GetValue());
      QObject::connect((QObject*)(newItem->m_Control),SIGNAL(toggled(bool)),(QObject*)(newItem),SLOT(CheckBoxControlActivated(bool)));
    }
    else if (mitk::StringProperty* stringProp = dynamic_cast<mitk::StringProperty*>(baseProp))
    {
      newItem = new QmitkPropertyListViewItem(name,propList,parent,createOnlyControl);
      newItem->m_Control = new QLineEdit(QString(stringProp->GetValue()),parent);
      QObject::connect((QObject*)(newItem->m_Control),SIGNAL(textChanged(const QString &)),(QObject*)(newItem),SLOT(StringControlActivated(const QString &)));
    }
    else if (mitk::ColorProperty* colorProp = dynamic_cast<mitk::ColorProperty*>(baseProp))
    {
      newItem = new QmitkPropertyListViewItem(name,propList,parent,createOnlyControl);
      newItem->m_Control = new QPushButton(parent);
      QPixmap pm(20,20);
      mitk::Color col = colorProp->GetColor();
      QColor qcol((int)(col.GetRed() * 255), (int)(col.GetGreen() * 255),(int)( col.GetBlue() * 255));
      pm.fill(qcol);
      // newItem->m_Control->setBackgroundPixmap(pm);
      newItem->m_Control->setPaletteBackgroundColor(qcol);
      QObject::connect((QObject*)(newItem->m_Control),SIGNAL(clicked()),(QObject*)(newItem),SLOT(ColorControlActivated()));
    }
    else if (mitk::EnumerationProperty* enumProp = dynamic_cast<mitk::EnumerationProperty*>(baseProp))
    {
      newItem = new QmitkPropertyListViewItem( name,propList,parent,createOnlyControl );
      newItem->m_Control = new QComboBox( parent );

      //
      // Fill the combo box with the possible enumeration values.
      // Keep track of the index of the current value set in the enumeration property
      // to set it as current item in the  combobox
      //
      int indexOfCurrentValue = -1;
      int index = 0;
      for ( mitk::EnumerationProperty::EnumConstIterator it = enumProp->Begin(); it !=enumProp->End(); ++it, ++index )
      {
        if ( enumProp->GetValueAsString() == it->second )
        {
          indexOfCurrentValue = index;
        }
        ( ( QComboBox* )( newItem->m_Control ) )->insertItem( it->second.c_str() );
      }

      //
      // select the current item of the combo box to the value defined in the
      // enumeration property
      //
      assert( indexOfCurrentValue != -1 );
      ( ( QComboBox* )( newItem->m_Control ) )->setCurrentItem( indexOfCurrentValue );

      QObject::connect((QObject*)(newItem->m_Control),SIGNAL( activated(const QString&) ),(QObject*)(newItem),SLOT(ComboBoxItemActivated(const QString&)));
    }
    else if (mitk::FloatProperty* floatProp = dynamic_cast<mitk::FloatProperty*>(baseProp))
    {
      std::pair<float,float> minMax;
      QString text;
      text.setNum(floatProp->GetValue());

      if (mitk::PropertyManager::GetInstance()->GetDefaultLimits(name,minMax) && (minMax.first == 0.0f && minMax.second == 1.0f))
      {
        // condition to use slider instead of lineedit

        QmitkPropertyListViewFloatSlider* sliderItem = new QmitkPropertyListViewFloatSlider(name,propList,parent,createOnlyControl);
        sliderItem->m_Control =  new QHBox(parent);
        sliderItem->m_Slider = new QSlider(Qt::Horizontal,sliderItem->m_Control);
        sliderItem->m_ValueLabel = new QLabel(text,sliderItem->m_Control);
        sliderItem->m_Slider->setMinValue(0);
        sliderItem->m_Slider->setMaxValue(100);
        sliderItem->UpdateView();
        newItem = sliderItem;
        QObject::connect((QObject*)(sliderItem->m_Slider),SIGNAL(valueChanged(int)),(QObject*)(sliderItem),SLOT(SliderValueChanged(int)));
      }
      else
      {
        newItem = new QmitkPropertyListViewItem(name,propList,parent,createOnlyControl);
        newItem->m_Control = new QLineEdit(text,parent);
        ((QLineEdit*)(newItem->m_Control))->setValidator(new QDoubleValidator(minMax.first,minMax.second,3,newItem->m_Control));
        QObject::connect((QObject*)(newItem->m_Control),SIGNAL(textChanged(const QString &)),(QObject*)(newItem),SLOT(FloatControlActivated(const QString &)));
      }
    }
    else if (mitk::IntProperty* intProp = dynamic_cast<mitk::IntProperty*>(baseProp))
    {
      newItem = new QmitkPropertyListViewItem(name,propList,parent,createOnlyControl);
      QString text;
      text.setNum(intProp->GetValue());
      newItem->m_Control = new QLineEdit(text,parent);
      std::pair<float,float> minMax;
      if (mitk::PropertyManager::GetInstance()->GetDefaultLimits(newItem->m_Name,minMax))
      {
        ((QLineEdit*)(newItem->m_Control))->setValidator(new QIntValidator((int)minMax.first,(int)minMax.second,newItem->m_Control));
      }
      else
      {
        ((QLineEdit*)(newItem->m_Control))->
          setValidator(new QIntValidator(std::numeric_limits<int>::min(),std::numeric_limits<int>::max(),newItem->m_Control));
      }
      QObject::connect((QObject*)(newItem->m_Control),SIGNAL(textChanged(const QString &)),(QObject*)(newItem),SLOT(IntControlActivated(const QString &)));
    }
    else if (dynamic_cast<mitk::MaterialProperty*>(baseProp))
    {
      newItem = new QmitkPropertyListViewItem(name,propList,parent,createOnlyControl);
      newItem->m_Control = new QPushButton("Edit",parent);
      QObject::connect((QObject*)(newItem->m_Control),SIGNAL(clicked()),(QObject*)(newItem),SLOT(MaterialEditorActivated()));
    }
    else
    {
      newItem = new QmitkPropertyListViewItem(name,propList,parent,createOnlyControl);
      if (baseProp)
      {
        newItem->m_Control = new QLabel(QString(baseProp->GetValueAsString().c_str()),parent);
      }
      else
      {
        newItem->m_Control = new QLabel("n/a",parent);
      }
    }
  }
  if (newItem && newItem->m_Control) {
    newItem->m_Control->setName((name + "_" + "QmitkPropertyListViewItem_control").c_str());
    newItem->m_Control->show();
  }
  return newItem;
}

<|endoftext|>


<commit_before>// 51NOD #1240 莫比乌斯函数
// description
// created by Shengjia Yan
// 2016年5月9日 下午7:40

//#define LOCAL
//#define SPEED

#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <string.h>
#include <sstream>
#include <cmath>

using namespace std;

bool isPrimeNumber(int n)
{
    if(n <= 1)  return false;
    else if(n == 2) return true;
    else
    {
        for(int i=2; i*i<n; i++)
        {
            if(n%i == 0)    return false;
        }
        return true;
    }
}

// 莫比乌斯函数
int miu(int n)
{
    int counter = 0;

    // 将 n 表示为 k 个质因子的乘积
    for(int i=2; i<=n; i++)
    {
        if(n%i == 0)    // i 是 n 的因子
        {
            counter++;

            int flag = 0;  // 平方因子旗帜

            while(n%i == 0)
            {
                flag++;
                n /= i;
                if(flag >= 2)   return 0;
            }

            if(isPrimeNumber(n))
            {
            counter++;
            break;
            }
        }
    }

    return counter%2==0 ? 1 : -1;
}

int main()
{
	#ifdef LOCAL
    freopen("1.txt","r",stdin);
    #endif

    #ifdef SPEED
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    #endif

    int n;
    cin>>n;

    cout<<miu(n);

    return 0;
}<commit_msg>Update<commit_after>// 51NOD #1240 莫比乌斯函数
// description
// created by Shengjia Yan
// 2016年5月9日 下午7:40

//#define LOCAL
//#define SPEED

#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <string.h>
#include <sstream>
#include <cmath>

using namespace std;

#define ll long long int

bool isPrimeNumber(ll n)
{
    if(n <= 1)  return false;
    else if(n == 2) return true;
    else
    {
        for(ll i=2; i*i<n; i++)
        {
            if(n%i == 0)    return false;
        }
        return true;
    }
}

// 莫比乌斯函数
int miu(ll n)
{
    int counter = 0;

    // 将 n 表示为 k 个质因子的乘积
    for(ll i=2; i<=n; i++)
    {
        if(n%i == 0)    // i 是 n 的因子
        {
            counter++;

            int flag = 0;  // 平方因子旗帜

            while(n%i == 0)
            {
                flag++;
                n /= i;
                if(flag >= 2)   return 0;
            }

            if(isPrimeNumber(n))
            {
            counter++;
            break;
            }
        }
    }

    return counter%2==0 ? 1 : -1;
}

int main()
{
	#ifdef LOCAL
    freopen("1.txt","r",stdin);
    #endif

    #ifdef SPEED
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    #endif

    ll n;
    cin>>n;

    cout<<miu(n);

    return 0;
}<|endoftext|>


<commit_before>#include "include/rados/librados.h"
#include "test/rados-api/test.h"

#include "gtest/gtest.h"
#include <errno.h>
#include <vector>

#define POOL_LIST_BUF_SZ 32768

TEST(LibRadosPools, PoolList) {
  std::vector<char> pool_list_buf(POOL_LIST_BUF_SZ, '\0');
  char *buf = &pool_list_buf[0];
  rados_t cluster;
  std::string pool_name = get_temp_pool_name();
  ASSERT_EQ("", create_one_pool(pool_name, &cluster));
  ASSERT_LT(rados_pool_list(cluster, buf, POOL_LIST_BUF_SZ), POOL_LIST_BUF_SZ);

  bool found_pool = false;
  while (buf[0] != '\0') {
    if ((found_pool == false) && (strcmp(buf, pool_name.c_str()) == 0)) {
      found_pool = true;
    }
    buf += strlen(buf) + 1;
  }
  ASSERT_EQ(found_pool, true);
  ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
}

int rados_pool_lookup(rados_t cluster, const char *pool_name);

TEST(LibRadosPools, PoolLookup) {
  rados_t cluster;
  std::string pool_name = get_temp_pool_name();
  ASSERT_EQ("", create_one_pool(pool_name, &cluster));
  ASSERT_LT(0, rados_pool_lookup(cluster, pool_name.c_str()));
  ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
}

TEST(LibRadosPools, PoolDelete) {
  rados_t cluster;
  std::string pool_name = get_temp_pool_name();
  ASSERT_EQ("", create_one_pool(pool_name, &cluster));
  ASSERT_EQ(0, rados_pool_delete(cluster, pool_name.c_str()));
  ASSERT_GT(0, rados_pool_lookup(cluster, pool_name.c_str()));
  ASSERT_EQ(0, rados_pool_create(cluster, pool_name.c_str()));
  ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
}

TEST(LibRadosPools, AuidTest1) {
  rados_t cluster;
  std::string pool_name = get_temp_pool_name();
  ASSERT_EQ("", create_one_pool(pool_name, &cluster));
  rados_ioctx_t ioctx;
  ASSERT_EQ(0, rados_ioctx_create(cluster, pool_name.c_str(), &ioctx));
  ASSERT_EQ(0, rados_ioctx_pool_set_auid(ioctx, 123));
  uint64_t auid;
  ASSERT_EQ(0, rados_ioctx_pool_get_auid(ioctx, &auid));
  ASSERT_EQ(123ull, auid);
  rados_ioctx_destroy(ioctx);
  ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
}

TEST(LibRadosPools, AuidTest2) {
  rados_t cluster;
  std::string pool_name = get_temp_pool_name();
  ASSERT_EQ("", create_one_pool(pool_name, &cluster));
  ASSERT_EQ(0, rados_pool_delete(cluster, pool_name.c_str()));
  ASSERT_EQ(0, rados_pool_create_with_auid(cluster, pool_name.c_str(), 456));
  rados_ioctx_t ioctx;
  ASSERT_EQ(0, rados_ioctx_create(cluster, pool_name.c_str(), &ioctx));
  uint64_t auid;
  ASSERT_EQ(0, rados_ioctx_pool_get_auid(ioctx, &auid));
  ASSERT_EQ(456ull, auid);
  rados_ioctx_destroy(ioctx);
  ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
}
<commit_msg>test/rados-api/pool.cc: test rados_ioctx_get_id<commit_after>#include "include/rados/librados.h"
#include "test/rados-api/test.h"

#include "gtest/gtest.h"
#include <errno.h>
#include <vector>

#define POOL_LIST_BUF_SZ 32768

TEST(LibRadosPools, PoolList) {
  std::vector<char> pool_list_buf(POOL_LIST_BUF_SZ, '\0');
  char *buf = &pool_list_buf[0];
  rados_t cluster;
  std::string pool_name = get_temp_pool_name();
  ASSERT_EQ("", create_one_pool(pool_name, &cluster));
  ASSERT_LT(rados_pool_list(cluster, buf, POOL_LIST_BUF_SZ), POOL_LIST_BUF_SZ);

  bool found_pool = false;
  while (buf[0] != '\0') {
    if ((found_pool == false) && (strcmp(buf, pool_name.c_str()) == 0)) {
      found_pool = true;
    }
    buf += strlen(buf) + 1;
  }
  ASSERT_EQ(found_pool, true);
  ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
}

int rados_pool_lookup(rados_t cluster, const char *pool_name);

TEST(LibRadosPools, PoolLookup) {
  rados_t cluster;
  std::string pool_name = get_temp_pool_name();
  ASSERT_EQ("", create_one_pool(pool_name, &cluster));
  ASSERT_LT(0, rados_pool_lookup(cluster, pool_name.c_str()));
  ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
}

TEST(LibRadosPools, PoolLookup2) {
  rados_t cluster;
  std::string pool_name = get_temp_pool_name();
  ASSERT_EQ("", create_one_pool(pool_name, &cluster));
  int pool_id = rados_pool_lookup(cluster, pool_name.c_str());
  ASSERT_GT(pool_id, 0);
  rados_ioctx_t ioctx;
  ASSERT_EQ(0, rados_ioctx_create(cluster, pool_name.c_str(), &ioctx));
  int pool_id2 = rados_ioctx_get_id(ioctx);
  ASSERT_EQ(pool_id, pool_id2);
  rados_ioctx_destroy(ioctx);
  ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
}

TEST(LibRadosPools, PoolDelete) {
  rados_t cluster;
  std::string pool_name = get_temp_pool_name();
  ASSERT_EQ("", create_one_pool(pool_name, &cluster));
  ASSERT_EQ(0, rados_pool_delete(cluster, pool_name.c_str()));
  ASSERT_GT(0, rados_pool_lookup(cluster, pool_name.c_str()));
  ASSERT_EQ(0, rados_pool_create(cluster, pool_name.c_str()));
  ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
}

TEST(LibRadosPools, AuidTest1) {
  rados_t cluster;
  std::string pool_name = get_temp_pool_name();
  ASSERT_EQ("", create_one_pool(pool_name, &cluster));
  rados_ioctx_t ioctx;
  ASSERT_EQ(0, rados_ioctx_create(cluster, pool_name.c_str(), &ioctx));
  ASSERT_EQ(0, rados_ioctx_pool_set_auid(ioctx, 123));
  uint64_t auid;
  ASSERT_EQ(0, rados_ioctx_pool_get_auid(ioctx, &auid));
  ASSERT_EQ(123ull, auid);
  rados_ioctx_destroy(ioctx);
  ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
}

TEST(LibRadosPools, AuidTest2) {
  rados_t cluster;
  std::string pool_name = get_temp_pool_name();
  ASSERT_EQ("", create_one_pool(pool_name, &cluster));
  ASSERT_EQ(0, rados_pool_delete(cluster, pool_name.c_str()));
  ASSERT_EQ(0, rados_pool_create_with_auid(cluster, pool_name.c_str(), 456));
  rados_ioctx_t ioctx;
  ASSERT_EQ(0, rados_ioctx_create(cluster, pool_name.c_str(), &ioctx));
  uint64_t auid;
  ASSERT_EQ(0, rados_ioctx_pool_get_auid(ioctx, &auid));
  ASSERT_EQ(456ull, auid);
  rados_ioctx_destroy(ioctx);
  ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
}

<|endoftext|>


<commit_before>/*=========================================================================

  Program:   ORFEO Toolbox
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
  See OTBCopyright.txt for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <cmath>

#include "otb/HermiteInterpolator.h"
#include "itkTimeProbe.h"

int ossimpluginsHermiteInterpolationTest(int argc, char * argv[])
{
  itk::TimeProbe chrono;
  double epsilon = 0.0000001;

  double xref[11];
  xref[0] = 56640.0;
  xref[1] = 56700.0;
  xref[2] = 56760.0;
  xref[3] = 56820.0;
  xref[4] = 56880.0;
  xref[5] = 56940.0;
  xref[6] = 57000.0;
  xref[7] = 57060.0;
  xref[8] = 57120.0;
  xref[9] = 57180.0;
  xref[10] = 57240.0;

  double yref[11];

  yref[0] = -1556122.3685;
  yref[1] = -1489827.1436;
  yref[2] = -1416422.8137;
  yref[3] = -1336447.1933;
  yref[4] = -1250469.0644;
  yref[5] = -1159084.8222;
  yref[6] = -1062914.9785;
  yref[7] = -962600.5575;
  yref[8] = -858799.3885;
  yref[9] = -752182.3142;
  yref[10] = -643429.3481;

  double dyref[11];

  dyref[0] = 1042.82980;
  dyref[1] = 1165.61122;
  dyref[2] = 1279.70506;
  dyref[3] = 1384.56817;
  dyref[4] = 1479.71193;
  dyref[5] = 1564.70493;
  dyref[6] = 1639.17497;
  dyref[7] = 1702.81080;
  dyref[8] = 1755.36374;
  dyref[9] = 1796.64883;
  dyref[10] = 1826.54539;

  double x = 56942.862208;

  std::cout << " *** Test y and dy ***"  << std::endl;
  ossimplugins::HermiteInterpolator* interp = new ossimplugins::HermiteInterpolator(11, xref, yref, dyref);

  double yExpected = -1154600.87561283;
  double dyExpected = 1568.49913322402;
  double y = 0;
  double dy = 0;
  interp->Interpolate(x, y, dy);

  std::cout << std::setprecision(15) << "Value at " << x << " : " << y << " (derivative " << dy << ")\n";
  std::cout << "- Should be :           " << yExpected << " (derivative " << dyExpected << ")" << std::endl;

  if ( std::isnan(y) || ( (y - yExpected)/yExpected  > epsilon)) return EXIT_FAILURE;
  if ( std::isnan(dy) ||  ( (dy - dyExpected)/dyExpected  > epsilon)) return EXIT_FAILURE;

  //Test limit situation
  x = 56640.0;
  yExpected = -1556122.3685;
  dyExpected = 1042.82980;
  interp->Interpolate(x, y, dy);
  std::cout << std::setprecision(15) << "Value at " << x << " : " << y << " (derivative " << dy << ")\n";
  std::cout << "- Should be :    " << yExpected << " (derivative " << dyExpected << ")" << std::endl;

  if ( std::isnan(y) || ( (y - yExpected)/yExpected  > epsilon)) return EXIT_FAILURE;
  if ( std::isnan(dy) || ( (dy - dyExpected)/dyExpected  > epsilon)) return EXIT_FAILURE;

  x = 56700.0;
  yExpected = -1489827.1436;
  dyExpected = 1165.61122;
  interp->Interpolate(x, y, dy);
  std::cout << std::setprecision(15) << "Value at " << x << " : " << y << " (derivative " << dy << ")\n";
  std::cout << "- Should be :    " << yExpected << " (derivative " << dyExpected << ")" << std::endl;

  if ( std::isnan(y) ||  ( (y - yExpected)/yExpected  > epsilon)) return EXIT_FAILURE;
  if ( std::isnan(dy) || ( (dy - dyExpected)/dyExpected  > epsilon)) return EXIT_FAILURE;

  x = 56942.862208;

  //Performance test
  int nTest = 1000000;
  chrono.Start();
  for (int i = 0; i < nTest; ++i)
    {
    double x2 = x + 200./nTest;
    interp->Interpolate(x2, y, dy);
    }

  chrono.Stop();
  std::cout << "Computation time: " << chrono.GetMeanTime() <<  " s" << std::endl;

  std::cout << " *** Test y only ***"  << std::endl;
  ossimplugins::HermiteInterpolator* interp2 = new ossimplugins::HermiteInterpolator(11, xref, yref, dyref);

  double y2 = 0;
  interp2->Interpolate(x, y2);

   std::cout << std::setprecision(15) << "Value at " << x << " : " << y2 << "\n";
   std::cout << "- Should be :           -1154600.87561283" << std::endl;

   //Performance test
   chrono.Start();

   for (int i = 0; i < nTest; ++i)
     {
     double x2 = x + 200./nTest;
     interp2->Interpolate(x2, y2);
     }

   chrono.Stop();
   std::cout << chrono.GetMeanTime() << " s" << std::endl;

  return EXIT_SUCCESS;
}
<commit_msg>COMP: fix windows compilation<commit_after>/*=========================================================================

  Program:   ORFEO Toolbox
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
  See OTBCopyright.txt for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <cmath>

#include "otb/HermiteInterpolator.h"
#include "itkTimeProbe.h"

int ossimpluginsHermiteInterpolationTest(int argc, char * argv[])
{
  double epsilon = 0.0000001;

  double xref[11];
  xref[0] = 56640.0;
  xref[1] = 56700.0;
  xref[2] = 56760.0;
  xref[3] = 56820.0;
  xref[4] = 56880.0;
  xref[5] = 56940.0;
  xref[6] = 57000.0;
  xref[7] = 57060.0;
  xref[8] = 57120.0;
  xref[9] = 57180.0;
  xref[10] = 57240.0;

  double yref[11];

  yref[0] = -1556122.3685;
  yref[1] = -1489827.1436;
  yref[2] = -1416422.8137;
  yref[3] = -1336447.1933;
  yref[4] = -1250469.0644;
  yref[5] = -1159084.8222;
  yref[6] = -1062914.9785;
  yref[7] = -962600.5575;
  yref[8] = -858799.3885;
  yref[9] = -752182.3142;
  yref[10] = -643429.3481;

  double dyref[11];

  dyref[0] = 1042.82980;
  dyref[1] = 1165.61122;
  dyref[2] = 1279.70506;
  dyref[3] = 1384.56817;
  dyref[4] = 1479.71193;
  dyref[5] = 1564.70493;
  dyref[6] = 1639.17497;
  dyref[7] = 1702.81080;
  dyref[8] = 1755.36374;
  dyref[9] = 1796.64883;
  dyref[10] = 1826.54539;

  double x = 56942.862208;

  std::cout << " *** Test y and dy ***"  << std::endl;
  ossimplugins::HermiteInterpolator* interp = new ossimplugins::HermiteInterpolator(11, xref, yref, dyref);

  double yExpected = -1154600.87561283;
  double dyExpected = 1568.49913322402;
  double y = 0;
  double dy = 0;
  interp->Interpolate(x, y, dy);

  std::cout << std::setprecision(15) << "Value at " << x << " : " << y << " (derivative " << dy << ")\n";
  std::cout << "- Should be :           " << yExpected << " (derivative " << dyExpected << ")" << std::endl;

  if ( ossim::isnan(y) || ( (y - yExpected)/yExpected  > epsilon)) return EXIT_FAILURE;
  if ( ossim::isnan(dy) ||  ( (dy - dyExpected)/dyExpected  > epsilon)) return EXIT_FAILURE;

  //Test limit situation
  x = 56640.0;
  yExpected = -1556122.3685;
  dyExpected = 1042.82980;
  interp->Interpolate(x, y, dy);
  std::cout << std::setprecision(15) << "Value at " << x << " : " << y << " (derivative " << dy << ")\n";
  std::cout << "- Should be :    " << yExpected << " (derivative " << dyExpected << ")" << std::endl;

  if ( ossim::isnan(y) || ( (y - yExpected)/yExpected  > epsilon)) return EXIT_FAILURE;
  if ( ossim::isnan(dy) || ( (dy - dyExpected)/dyExpected  > epsilon)) return EXIT_FAILURE;

  x = 56700.0;
  yExpected = -1489827.1436;
  dyExpected = 1165.61122;
  interp->Interpolate(x, y, dy);
  std::cout << std::setprecision(15) << "Value at " << x << " : " << y << " (derivative " << dy << ")\n";
  std::cout << "- Should be :    " << yExpected << " (derivative " << dyExpected << ")" << std::endl;

  if ( ossim::isnan(y) ||  ( (y - yExpected)/yExpected  > epsilon)) return EXIT_FAILURE;
  if ( ossim::isnan(dy) || ( (dy - dyExpected)/dyExpected  > epsilon)) return EXIT_FAILURE;

  x = 56942.862208;

  //Performance test
  int nTest = 1000000;
  itk::TimeProbe chrono;
  chrono.Start();
  for (int i = 0; i < nTest; ++i)
    {
    double x2 = x + 200./nTest;
    interp->Interpolate(x2, y, dy);
    }

  chrono.Stop();
  std::cout << "Computation time: " << chrono.GetMean() <<  " s" << std::endl;

  std::cout << " *** Test y only ***"  << std::endl;
  ossimplugins::HermiteInterpolator* interp2 = new ossimplugins::HermiteInterpolator(11, xref, yref, dyref);

  double y2 = 0;
  interp2->Interpolate(x, y2);

   std::cout << std::setprecision(15) << "Value at " << x << " : " << y2 << "\n";
   std::cout << "- Should be :           -1154600.87561283" << std::endl;

   //Performance test
   itk::TimeProbe chrono2;
   chrono2.Start();

   for (int i = 0; i < nTest; ++i)
     {
     double x2 = x + 200./nTest;
     interp2->Interpolate(x2, y2);
     }

   chrono2.Stop();
   std::cout << "Computation time: " << chrono2.GetMean() << " s" << std::endl;

  return EXIT_SUCCESS;
}
<|endoftext|>


<commit_before>/*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <fstream>

#include "base/stringprintf.h"
#include "builder.h"
#include "dex_file.h"
#include "dex_instruction.h"
#include "graph_visualizer.h"
#include "nodes.h"
#include "optimizing_unit_test.h"
#include "pretty_printer.h"
#include "ssa_builder.h"
#include "ssa_liveness_analysis.h"
#include "utils/arena_allocator.h"

#include "gtest/gtest.h"

namespace art {

static void TestCode(const uint16_t* data, const int* expected_order, size_t number_of_blocks) {
  ArenaPool pool;
  ArenaAllocator allocator(&pool);
  HGraphBuilder builder(&allocator);
  const DexFile::CodeItem* item = reinterpret_cast<const DexFile::CodeItem*>(data);
  HGraph* graph = builder.BuildGraph(*item);
  ASSERT_NE(graph, nullptr);

  graph->BuildDominatorTree();
  graph->FindNaturalLoops();
  SsaLivenessAnalysis liveness(*graph);
  liveness.Analyze();

  ASSERT_EQ(liveness.GetLinearPostOrder().Size(), number_of_blocks);
  for (size_t i = 0; i < number_of_blocks; ++i) {
    ASSERT_EQ(liveness.GetLinearPostOrder().Get(number_of_blocks - i - 1)->GetBlockId(),
              expected_order[i]);
  }
}

TEST(LinearizeTest, CFG1) {
  // Structure of this graph (* are back edges)
  //            Block0
  //              |
  //            Block1
  //              |
  //            Block2 ******
  //            /   \       *
  //       Block5   Block7  *
  //         |        |     *
  //       Block6   Block3  *
  //               * /   \  *
  //           Block4   Block8

  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
    Instruction::CONST_4 | 0 | 0,
    Instruction::IF_EQ, 5,
    Instruction::IF_EQ, 0xFFFE,
    Instruction::GOTO | 0xFE00,
    Instruction::RETURN_VOID);

  const int blocks[] = {0, 1, 2, 7, 3, 4, 8, 5, 6};
  TestCode(data, blocks, 9);
}

TEST(LinearizeTest, CFG2) {
  // Structure of this graph (* are back edges)
  //            Block0
  //              |
  //            Block1
  //              |
  //            Block2 ******
  //            /   \       *
  //       Block3   Block7  *
  //         |        |     *
  //       Block6   Block4  *
  //               * /   \  *
  //           Block5   Block8

  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
    Instruction::CONST_4 | 0 | 0,
    Instruction::IF_EQ, 3,
    Instruction::RETURN_VOID,
    Instruction::IF_EQ, 0xFFFD,
    Instruction::GOTO | 0xFE00);

  const int blocks[] = {0, 1, 2, 7, 4, 5, 8, 3, 6};
  TestCode(data, blocks, 9);
}

TEST(LinearizeTest, CFG3) {
  // Structure of this graph (* are back edges)
  //            Block0
  //              |
  //            Block1
  //              |
  //            Block2 ******
  //            /   \       *
  //       Block3   Block8  *
  //         |        |     *
  //       Block7   Block5  *
  //                 / *  \ *
  //           Block6  * Block9
  //             |     *
  //           Block4 **
  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
    Instruction::CONST_4 | 0 | 0,
    Instruction::IF_EQ, 4,
    Instruction::RETURN_VOID,
    Instruction::GOTO | 0x0100,
    Instruction::IF_EQ, 0xFFFC,
    Instruction::GOTO | 0xFD00);

  const int blocks[] = {0, 1, 2, 8, 5, 6, 4, 9, 3, 7};
  TestCode(data, blocks, 10);
}

TEST(LinearizeTest, CFG4) {
  // Structure of this graph (* are back edges)
  //            Block0
  //              |
  //            Block1
  //              |
  //            Block2
  //            / *  \
  //       Block6 * Block8
  //         |    *   |
  //       Block7 * Block3 *******
  //              *  /  \        *
  //           Block9   Block10  *
  //                      |      *
  //                    Block4   *
  //                   */    \   *
  //                Block5  Block11
  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
    Instruction::CONST_4 | 0 | 0,
    Instruction::IF_EQ, 7,
    Instruction::IF_EQ, 0xFFFE,
    Instruction::IF_EQ, 0xFFFE,
    Instruction::GOTO | 0xFE00,
    Instruction::RETURN_VOID);

  const int blocks[] = {0, 1, 2, 8, 3, 10, 4, 5, 11, 9, 6, 7};
  TestCode(data, blocks, 12);
}

TEST(LinearizeTest, CFG5) {
  // Structure of this graph (* are back edges)
  //            Block0
  //              |
  //            Block1
  //              |
  //            Block2
  //            / *  \
  //       Block3 * Block8
  //         |    *   |
  //       Block7 * Block4 *******
  //              *  /  \        *
  //           Block9   Block10  *
  //                      |      *
  //                    Block5   *
  //                   */    \   *
  //                Block6  Block11
  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
    Instruction::CONST_4 | 0 | 0,
    Instruction::IF_EQ, 3,
    Instruction::RETURN_VOID,
    Instruction::IF_EQ, 0xFFFD,
    Instruction::IF_EQ, 0xFFFE,
    Instruction::GOTO | 0xFE00);

  const int blocks[] = {0, 1, 2, 8, 4, 10, 5, 6, 11, 9, 3, 7};
  TestCode(data, blocks, 12);
}

}  // namespace art
<commit_msg>Workaround for multi-line comment error when compiled with g++.<commit_after>/*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <fstream>

#include "base/stringprintf.h"
#include "builder.h"
#include "dex_file.h"
#include "dex_instruction.h"
#include "graph_visualizer.h"
#include "nodes.h"
#include "optimizing_unit_test.h"
#include "pretty_printer.h"
#include "ssa_builder.h"
#include "ssa_liveness_analysis.h"
#include "utils/arena_allocator.h"

#include "gtest/gtest.h"

namespace art {

static void TestCode(const uint16_t* data, const int* expected_order, size_t number_of_blocks) {
  ArenaPool pool;
  ArenaAllocator allocator(&pool);
  HGraphBuilder builder(&allocator);
  const DexFile::CodeItem* item = reinterpret_cast<const DexFile::CodeItem*>(data);
  HGraph* graph = builder.BuildGraph(*item);
  ASSERT_NE(graph, nullptr);

  graph->BuildDominatorTree();
  graph->FindNaturalLoops();
  SsaLivenessAnalysis liveness(*graph);
  liveness.Analyze();

  ASSERT_EQ(liveness.GetLinearPostOrder().Size(), number_of_blocks);
  for (size_t i = 0; i < number_of_blocks; ++i) {
    ASSERT_EQ(liveness.GetLinearPostOrder().Get(number_of_blocks - i - 1)->GetBlockId(),
              expected_order[i]);
  }
}

TEST(LinearizeTest, CFG1) {
  // Structure of this graph (+ are back edges)
  //            Block0
  //              |
  //            Block1
  //              |
  //            Block2 ++++++
  //            /   \       +
  //       Block5   Block7  +
  //         |        |     +
  //       Block6   Block3  +
  //               + /   \  +
  //           Block4   Block8

  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
    Instruction::CONST_4 | 0 | 0,
    Instruction::IF_EQ, 5,
    Instruction::IF_EQ, 0xFFFE,
    Instruction::GOTO | 0xFE00,
    Instruction::RETURN_VOID);

  const int blocks[] = {0, 1, 2, 7, 3, 4, 8, 5, 6};
  TestCode(data, blocks, 9);
}

TEST(LinearizeTest, CFG2) {
  // Structure of this graph (+ are back edges)
  //            Block0
  //              |
  //            Block1
  //              |
  //            Block2 ++++++
  //            /   \       +
  //       Block3   Block7  +
  //         |        |     +
  //       Block6   Block4  +
  //               + /   \  +
  //           Block5   Block8

  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
    Instruction::CONST_4 | 0 | 0,
    Instruction::IF_EQ, 3,
    Instruction::RETURN_VOID,
    Instruction::IF_EQ, 0xFFFD,
    Instruction::GOTO | 0xFE00);

  const int blocks[] = {0, 1, 2, 7, 4, 5, 8, 3, 6};
  TestCode(data, blocks, 9);
}

TEST(LinearizeTest, CFG3) {
  // Structure of this graph (+ are back edges)
  //            Block0
  //              |
  //            Block1
  //              |
  //            Block2 ++++++
  //            /   \       +
  //       Block3   Block8  +
  //         |        |     +
  //       Block7   Block5  +
  //                 / +  \ +
  //           Block6  + Block9
  //             |     +
  //           Block4 ++
  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
    Instruction::CONST_4 | 0 | 0,
    Instruction::IF_EQ, 4,
    Instruction::RETURN_VOID,
    Instruction::GOTO | 0x0100,
    Instruction::IF_EQ, 0xFFFC,
    Instruction::GOTO | 0xFD00);

  const int blocks[] = {0, 1, 2, 8, 5, 6, 4, 9, 3, 7};
  TestCode(data, blocks, 10);
}

TEST(LinearizeTest, CFG4) {
  /* Structure of this graph (+ are back edges)
  //            Block0
  //              |
  //            Block1
  //              |
  //            Block2
  //            / +  \
  //       Block6 + Block8
  //         |    +   |
  //       Block7 + Block3 +++++++
  //              +  /  \        +
  //           Block9   Block10  +
  //                      |      +
  //                    Block4   +
  //                  + /    \   +
  //                Block5  Block11
  */
  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
    Instruction::CONST_4 | 0 | 0,
    Instruction::IF_EQ, 7,
    Instruction::IF_EQ, 0xFFFE,
    Instruction::IF_EQ, 0xFFFE,
    Instruction::GOTO | 0xFE00,
    Instruction::RETURN_VOID);

  const int blocks[] = {0, 1, 2, 8, 3, 10, 4, 5, 11, 9, 6, 7};
  TestCode(data, blocks, 12);
}

TEST(LinearizeTest, CFG5) {
  /* Structure of this graph (+ are back edges)
  //            Block0
  //              |
  //            Block1
  //              |
  //            Block2
  //            / +  \
  //       Block3 + Block8
  //         |    +   |
  //       Block7 + Block4 +++++++
  //              +  /  \        +
  //           Block9   Block10  +
  //                      |      +
  //                    Block5   +
  //                   +/    \   +
  //                Block6  Block11
  */
  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
    Instruction::CONST_4 | 0 | 0,
    Instruction::IF_EQ, 3,
    Instruction::RETURN_VOID,
    Instruction::IF_EQ, 0xFFFD,
    Instruction::IF_EQ, 0xFFFE,
    Instruction::GOTO | 0xFE00);

  const int blocks[] = {0, 1, 2, 8, 4, 10, 5, 6, 11, 9, 3, 7};
  TestCode(data, blocks, 12);
}

}  // namespace art
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: PColumn.cxx,v $
 *
 *  $Revision: 1.13 $
 *
 *  last change: $Author: obo $ $Date: 2006-07-10 14:37:58 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_
#include "connectivity/PColumn.hxx"
#endif
#ifndef _CONNECTIVITY_DBTOOLS_HXX_
#include "connectivity/dbtools.hxx"
#endif
#ifndef CONNECTIVITY_CONNECTION_HXX
#include "TConnection.hxx"
#endif
#ifndef _COMPHELPER_TYPES_HXX_
#include <comphelper/types.hxx>
#endif

using namespace ::comphelper;
using namespace connectivity;
using namespace dbtools;
using namespace connectivity::parse;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::beans;

// -------------------------------------------------------------------------
OParseColumn::OParseColumn(const Reference<XPropertySet>& _xColumn,sal_Bool     _bCase)
    : connectivity::sdbcx::OColumn( getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)))
                                ,   getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)))
                                ,   getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)))
                                ,   getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)))
                                ,   getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)))
                                ,   getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))
                                ,   getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))
                                ,   getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)))
                                ,   sal_False
                                ,   getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))
                                ,   _bCase
                                )
    , m_bFunction(sal_False)
    , m_bDbasePrecisionChanged(sal_False)
    , m_bAggregateFunction(sal_False)
{
    construct();
}

// -------------------------------------------------------------------------
OParseColumn::OParseColumn( const ::rtl::OUString& _Name,
                    const ::rtl::OUString& _TypeName,
                    const ::rtl::OUString& _DefaultValue,
                    sal_Int32       _IsNullable,
                    sal_Int32       _Precision,
                    sal_Int32       _Scale,
                    sal_Int32       _Type,
                    sal_Bool        _IsAutoIncrement,
                    sal_Bool        _IsCurrency,
                    sal_Bool        _bCase
                ) : connectivity::sdbcx::OColumn(_Name,
                                  _TypeName,
                                  _DefaultValue,
                                  _IsNullable,
                                  _Precision,
                                  _Scale,
                                  _Type,
                                  _IsAutoIncrement,
                                  sal_False,
                                  _IsCurrency,
                                  _bCase)
    , m_bFunction(sal_False)
    , m_bDbasePrecisionChanged(sal_False)
    , m_bAggregateFunction(sal_False)
{
    construct();
}

// -------------------------------------------------------------------------
::vos::ORef< OSQLColumns > OParseColumn::createColumnsForResultSet( const Reference< XResultSetMetaData >& _rxResMetaData,
    const Reference< XDatabaseMetaData >& _rxDBMetaData )
{
    sal_Int32 nColumnCount = _rxResMetaData->getColumnCount();
    ::vos::ORef< OSQLColumns > aReturn( new OSQLColumns ); aReturn->reserve( nColumnCount );

    for ( sal_Int32 i = 1; i <= nColumnCount; ++i )
        aReturn->push_back( createColumnForResultSet( _rxResMetaData, _rxDBMetaData, i ) );

    return aReturn;
}

// -------------------------------------------------------------------------
OParseColumn* OParseColumn::createColumnForResultSet( const Reference< XResultSetMetaData >& _rxResMetaData,
    const Reference< XDatabaseMetaData >& _rxDBMetaData, sal_Int32 _nColumnPos )
{
    OParseColumn* pColumn = new OParseColumn(
        _rxResMetaData->getColumnName( _nColumnPos ),
        _rxResMetaData->getColumnTypeName( _nColumnPos ),
        ::rtl::OUString(),
        _rxResMetaData->isNullable( _nColumnPos ),
        _rxResMetaData->getPrecision( _nColumnPos ),
        _rxResMetaData->getScale( _nColumnPos ),
        _rxResMetaData->getColumnType( _nColumnPos ),
        _rxResMetaData->isAutoIncrement( _nColumnPos ),
        _rxResMetaData->isCurrency( _nColumnPos ),
        _rxDBMetaData->storesMixedCaseQuotedIdentifiers()
    );
    pColumn->setTableName(  ::dbtools::composeTableName( _rxDBMetaData,
        _rxResMetaData->getCatalogName( _nColumnPos ),
        _rxResMetaData->getSchemaName( _nColumnPos ),
        _rxResMetaData->getTableName( _nColumnPos ),
        sal_False,
        eComplete
    ) );
    return pColumn;
}

// -------------------------------------------------------------------------
OParseColumn::~OParseColumn()
{
}
// -------------------------------------------------------------------------
void OParseColumn::construct()
{
    sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;

    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION),                PROPERTY_ID_FUNCTION,               0,&m_bFunction,     ::getCppuType(reinterpret_cast< sal_Bool*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_AGGREGATEFUNCTION),       PROPERTY_ID_AGGREGATEFUNCTION,      0,&m_bAggregateFunction,        ::getCppuType(reinterpret_cast< sal_Bool*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME),               PROPERTY_ID_TABLENAME,              nAttrib,&m_aTableName,      ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME),                PROPERTY_ID_REALNAME,               0,&m_aRealName,     ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DBASEPRECISIONCHANGED),   PROPERTY_ID_DBASEPRECISIONCHANGED,  nAttrib,&m_bDbasePrecisionChanged,      ::getCppuType(reinterpret_cast<sal_Bool*>(NULL)));

}
// -----------------------------------------------------------------------------
::cppu::IPropertyArrayHelper* OParseColumn::createArrayHelper() const
{
    return doCreateArrayHelper();
}
// -----------------------------------------------------------------------------
::cppu::IPropertyArrayHelper & SAL_CALL OParseColumn::getInfoHelper()
{
    OSL_ENSURE( !isNew(), "OParseColumn::OOrderColumn: a *new* OrderColumn?" );
    return *OParseColumn_PROP::getArrayHelper();
}
// -----------------------------------------------------------------------------
OOrderColumn::OOrderColumn( const Reference<XPropertySet>& _xColumn
                                     ,sal_Bool  _bCase
                                     ,sal_Bool _bAscending)
    : connectivity::sdbcx::OColumn( getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)))
                                ,   getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)))
                                ,   getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)))
                                ,   getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)))
                                ,   getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)))
                                ,   getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))
                                ,   getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))
                                ,   getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)))
                                ,   sal_False
                                ,   getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))
                                ,   _bCase
                                )
    , m_bAscending(_bAscending)
{
    construct();
}
// -------------------------------------------------------------------------
OOrderColumn::OOrderColumn( const ::rtl::OUString& _Name,
                    const ::rtl::OUString& _TypeName,
                    const ::rtl::OUString& _DefaultValue,
                    sal_Int32       _IsNullable,
                    sal_Int32       _Precision,
                    sal_Int32       _Scale,
                    sal_Int32       _Type,
                    sal_Bool        _IsAutoIncrement,
                    sal_Bool        _IsCurrency,
                    sal_Bool        _bCase
                    ,sal_Bool _bAscending
                ) : connectivity::sdbcx::OColumn(_Name,
                                  _TypeName,
                                  _DefaultValue,
                                  _IsNullable,
                                  _Precision,
                                  _Scale,
                                  _Type,
                                  _IsAutoIncrement,
                                  sal_False,
                                  _IsCurrency,
                                  _bCase)
    , m_bAscending(_bAscending)
{
    construct();
}
// -------------------------------------------------------------------------
OOrderColumn::~OOrderColumn()
{
}
// -------------------------------------------------------------------------
void OOrderColumn::construct()
{
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISASCENDING),PROPERTY_ID_ISASCENDING,0,&m_bAscending,     ::getCppuType(reinterpret_cast< sal_Bool*>(NULL)));
}
// -----------------------------------------------------------------------------
::cppu::IPropertyArrayHelper* OOrderColumn::createArrayHelper() const
{
    return doCreateArrayHelper();
}
// -----------------------------------------------------------------------------
::cppu::IPropertyArrayHelper & SAL_CALL OOrderColumn::getInfoHelper()
{
    OSL_ENSURE( !isNew(), "OOrderColumn::OOrderColumn: a *new* OrderColumn?" );
    return *OOrderColumn_PROP::getArrayHelper();
}
// -----------------------------------------------------------------------------
::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OOrderColumn::getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException)
{
    ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1);
    if ( m_bOrder )
        aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.OrderColumn");
    else
        aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.GroupColumn");

    return aSupported;
}
// -----------------------------------------------------------------------------
<commit_msg>INTEGRATION: CWS pchfix02 (1.13.42); FILE MERGED 2006/09/01 17:22:35 kaib 1.13.42.1: #i68856# Added header markers and pch files<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: PColumn.cxx,v $
 *
 *  $Revision: 1.14 $
 *
 *  last change: $Author: obo $ $Date: 2006-09-17 03:08:54 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_connectivity.hxx"

#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_
#include "connectivity/PColumn.hxx"
#endif
#ifndef _CONNECTIVITY_DBTOOLS_HXX_
#include "connectivity/dbtools.hxx"
#endif
#ifndef CONNECTIVITY_CONNECTION_HXX
#include "TConnection.hxx"
#endif
#ifndef _COMPHELPER_TYPES_HXX_
#include <comphelper/types.hxx>
#endif

using namespace ::comphelper;
using namespace connectivity;
using namespace dbtools;
using namespace connectivity::parse;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::beans;

// -------------------------------------------------------------------------
OParseColumn::OParseColumn(const Reference<XPropertySet>& _xColumn,sal_Bool     _bCase)
    : connectivity::sdbcx::OColumn( getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)))
                                ,   getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)))
                                ,   getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)))
                                ,   getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)))
                                ,   getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)))
                                ,   getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))
                                ,   getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))
                                ,   getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)))
                                ,   sal_False
                                ,   getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))
                                ,   _bCase
                                )
    , m_bFunction(sal_False)
    , m_bDbasePrecisionChanged(sal_False)
    , m_bAggregateFunction(sal_False)
{
    construct();
}

// -------------------------------------------------------------------------
OParseColumn::OParseColumn( const ::rtl::OUString& _Name,
                    const ::rtl::OUString& _TypeName,
                    const ::rtl::OUString& _DefaultValue,
                    sal_Int32       _IsNullable,
                    sal_Int32       _Precision,
                    sal_Int32       _Scale,
                    sal_Int32       _Type,
                    sal_Bool        _IsAutoIncrement,
                    sal_Bool        _IsCurrency,
                    sal_Bool        _bCase
                ) : connectivity::sdbcx::OColumn(_Name,
                                  _TypeName,
                                  _DefaultValue,
                                  _IsNullable,
                                  _Precision,
                                  _Scale,
                                  _Type,
                                  _IsAutoIncrement,
                                  sal_False,
                                  _IsCurrency,
                                  _bCase)
    , m_bFunction(sal_False)
    , m_bDbasePrecisionChanged(sal_False)
    , m_bAggregateFunction(sal_False)
{
    construct();
}

// -------------------------------------------------------------------------
::vos::ORef< OSQLColumns > OParseColumn::createColumnsForResultSet( const Reference< XResultSetMetaData >& _rxResMetaData,
    const Reference< XDatabaseMetaData >& _rxDBMetaData )
{
    sal_Int32 nColumnCount = _rxResMetaData->getColumnCount();
    ::vos::ORef< OSQLColumns > aReturn( new OSQLColumns ); aReturn->reserve( nColumnCount );

    for ( sal_Int32 i = 1; i <= nColumnCount; ++i )
        aReturn->push_back( createColumnForResultSet( _rxResMetaData, _rxDBMetaData, i ) );

    return aReturn;
}

// -------------------------------------------------------------------------
OParseColumn* OParseColumn::createColumnForResultSet( const Reference< XResultSetMetaData >& _rxResMetaData,
    const Reference< XDatabaseMetaData >& _rxDBMetaData, sal_Int32 _nColumnPos )
{
    OParseColumn* pColumn = new OParseColumn(
        _rxResMetaData->getColumnName( _nColumnPos ),
        _rxResMetaData->getColumnTypeName( _nColumnPos ),
        ::rtl::OUString(),
        _rxResMetaData->isNullable( _nColumnPos ),
        _rxResMetaData->getPrecision( _nColumnPos ),
        _rxResMetaData->getScale( _nColumnPos ),
        _rxResMetaData->getColumnType( _nColumnPos ),
        _rxResMetaData->isAutoIncrement( _nColumnPos ),
        _rxResMetaData->isCurrency( _nColumnPos ),
        _rxDBMetaData->storesMixedCaseQuotedIdentifiers()
    );
    pColumn->setTableName(  ::dbtools::composeTableName( _rxDBMetaData,
        _rxResMetaData->getCatalogName( _nColumnPos ),
        _rxResMetaData->getSchemaName( _nColumnPos ),
        _rxResMetaData->getTableName( _nColumnPos ),
        sal_False,
        eComplete
    ) );
    return pColumn;
}

// -------------------------------------------------------------------------
OParseColumn::~OParseColumn()
{
}
// -------------------------------------------------------------------------
void OParseColumn::construct()
{
    sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;

    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION),                PROPERTY_ID_FUNCTION,               0,&m_bFunction,     ::getCppuType(reinterpret_cast< sal_Bool*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_AGGREGATEFUNCTION),       PROPERTY_ID_AGGREGATEFUNCTION,      0,&m_bAggregateFunction,        ::getCppuType(reinterpret_cast< sal_Bool*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME),               PROPERTY_ID_TABLENAME,              nAttrib,&m_aTableName,      ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME),                PROPERTY_ID_REALNAME,               0,&m_aRealName,     ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DBASEPRECISIONCHANGED),   PROPERTY_ID_DBASEPRECISIONCHANGED,  nAttrib,&m_bDbasePrecisionChanged,      ::getCppuType(reinterpret_cast<sal_Bool*>(NULL)));

}
// -----------------------------------------------------------------------------
::cppu::IPropertyArrayHelper* OParseColumn::createArrayHelper() const
{
    return doCreateArrayHelper();
}
// -----------------------------------------------------------------------------
::cppu::IPropertyArrayHelper & SAL_CALL OParseColumn::getInfoHelper()
{
    OSL_ENSURE( !isNew(), "OParseColumn::OOrderColumn: a *new* OrderColumn?" );
    return *OParseColumn_PROP::getArrayHelper();
}
// -----------------------------------------------------------------------------
OOrderColumn::OOrderColumn( const Reference<XPropertySet>& _xColumn
                                     ,sal_Bool  _bCase
                                     ,sal_Bool _bAscending)
    : connectivity::sdbcx::OColumn( getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)))
                                ,   getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)))
                                ,   getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)))
                                ,   getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)))
                                ,   getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)))
                                ,   getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))
                                ,   getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))
                                ,   getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)))
                                ,   sal_False
                                ,   getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))
                                ,   _bCase
                                )
    , m_bAscending(_bAscending)
{
    construct();
}
// -------------------------------------------------------------------------
OOrderColumn::OOrderColumn( const ::rtl::OUString& _Name,
                    const ::rtl::OUString& _TypeName,
                    const ::rtl::OUString& _DefaultValue,
                    sal_Int32       _IsNullable,
                    sal_Int32       _Precision,
                    sal_Int32       _Scale,
                    sal_Int32       _Type,
                    sal_Bool        _IsAutoIncrement,
                    sal_Bool        _IsCurrency,
                    sal_Bool        _bCase
                    ,sal_Bool _bAscending
                ) : connectivity::sdbcx::OColumn(_Name,
                                  _TypeName,
                                  _DefaultValue,
                                  _IsNullable,
                                  _Precision,
                                  _Scale,
                                  _Type,
                                  _IsAutoIncrement,
                                  sal_False,
                                  _IsCurrency,
                                  _bCase)
    , m_bAscending(_bAscending)
{
    construct();
}
// -------------------------------------------------------------------------
OOrderColumn::~OOrderColumn()
{
}
// -------------------------------------------------------------------------
void OOrderColumn::construct()
{
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISASCENDING),PROPERTY_ID_ISASCENDING,0,&m_bAscending,     ::getCppuType(reinterpret_cast< sal_Bool*>(NULL)));
}
// -----------------------------------------------------------------------------
::cppu::IPropertyArrayHelper* OOrderColumn::createArrayHelper() const
{
    return doCreateArrayHelper();
}
// -----------------------------------------------------------------------------
::cppu::IPropertyArrayHelper & SAL_CALL OOrderColumn::getInfoHelper()
{
    OSL_ENSURE( !isNew(), "OOrderColumn::OOrderColumn: a *new* OrderColumn?" );
    return *OOrderColumn_PROP::getArrayHelper();
}
// -----------------------------------------------------------------------------
::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OOrderColumn::getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException)
{
    ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1);
    if ( m_bOrder )
        aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.OrderColumn");
    else
        aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.GroupColumn");

    return aSupported;
}
// -----------------------------------------------------------------------------
<|endoftext|>