Public Member Functions | Private Attributes

cfg_DriveVendor Class Reference
[Parser for config files; validation]

#include <cfg_drive.h>

Inheritance diagram for cfg_DriveVendor:
Inheritance graph
[legend]
Collaboration diagram for cfg_DriveVendor:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 cfg_DriveVendor ()
virtual ~cfg_DriveVendor ()
 cfg_DriveVendor (const string &a_prodID, const pf_Group &a_group)
virtual void ConvertGroup (const string &a_type, const pf_Group &a_group)
UInt64_t GetThreshold (const string &a_vnd, const string &a_prod, ivd_MediaType_e a_type) const
 Returns threshold value or 0 if not found.

Private Attributes

 log_CLASSID_m
string m_vendor
string m_product
UInt64_t m_threshold
vector< cfg_DriveTypem_types

Detailed Description

Definition at line 62 of file cfg_drive.h.


Constructor & Destructor Documentation

cfg_DriveVendor::cfg_DriveVendor (  ) 

Definition at line 86 of file cfg_drive.cpp.

  : m_threshold(0) {
  // Empty
}

cfg_DriveVendor::~cfg_DriveVendor (  )  [virtual]

Definition at line 93 of file cfg_drive.cpp.

References log_FUNC_m.

cfg_DriveVendor::cfg_DriveVendor ( const string &  a_prodID,
const pf_Group a_group 
)

Definition at line 99 of file cfg_drive.cpp.

References val_RuleVec::Add(), cfg_KILOBYTE, cfg_TERABYTE, cfg_Base::Convert(), dbg_NORM, log_DBG_m, log_FUNC_A_m, m_product, m_threshold, cfg_DriveType::m_threshold_c, m_types, and m_vendor.

  : m_vendor(a_group.grpType),
    m_product(a_prodID),
    m_threshold(0) {

    log_FUNC_A_m(cfg_DriveVendor,
        "vendor: \'" << m_vendor << "\' product: \'" << m_product << "\'");

    val_RuleVec  rules;
    rules.Add(new val_Size(
        cfg_DriveType::m_threshold_c, val_Limit(cfg_KILOBYTE, cfg_TERABYTE), 0, 1), m_threshold);

    Convert(a_group, rules);

    log_DBG_m(dbg_NORM, "Parsed " << m_types.size() << " types.");
}

Here is the call graph for this function:


Member Function Documentation

void cfg_DriveVendor::ConvertGroup ( const string &  a_type,
const pf_Group a_group 
) [virtual]

Reimplemented from cfg_Base.

Definition at line 118 of file cfg_drive.cpp.

References log_FUNC_m, log_WRN_m, and m_types.

                                                                                {
    log_FUNC_m(ConvertGroup);

    try {
        cfg_DriveType type(a_type, a_group);
        m_types.push_back(type);
    }
    catch (const ivd_Exception& ie) {
        log_WRN_m("Ignoring invalid entry when converting type "
                << a_type << ". Error: " << ie );
    }
}

UInt64_t cfg_DriveVendor::GetThreshold ( const string &  a_vnd,
const string &  a_prod,
ivd_MediaType_e  a_type 
) const

Returns threshold value or 0 if not found.

Definition at line 133 of file cfg_drive.cpp.

References dbg_DETAIL, dbg_NORM, ivd_MediaTypeToText(), log_DBG_m, log_FUNC_m, m_product, m_threshold, m_types, and m_vendor.

                                  {

    log_FUNC_m(GetThreshold);

    //
    // Compare only strings up to the length of the string in the
    // config file.
    //
    string subVendor(a_vnd.substr(0, m_vendor.size()) );
    string subProduct(a_prod.substr(0, m_product.size()) );

    log_DBG_m(dbg_DETAIL,
        "a_vnd: " << a_vnd << ", m_vendor: " << m_vendor << ", subVendor: " << subVendor);
    log_DBG_m(dbg_DETAIL,
        "a_prod: " << a_prod << ", m_product: " << m_product << ", subVendor: " << subProduct);

    if (m_vendor != subVendor || m_product != subProduct) {
        // Product ID or vendor ID don't match with supplied
        // return 0
        return 0;
    }

    // Search for value for specific drive type
    vector<cfg_DriveType>::const_iterator drvType_i;
    for (drvType_i = m_types.begin(); drvType_i != m_types.end(); ++drvType_i) {
        if (a_type == drvType_i->m_type) {
            log_DBG_m(dbg_DETAIL,
                "Value for type: " << ivd_MediaTypeToText(a_type)
                << " = " << drvType_i->m_threshold);
            return drvType_i->m_threshold;
        }
    }

    // Values for specific drive type not found. Return general value for all
    // devices matching vendor/product pair
    log_DBG_m(dbg_NORM,
        "Not found specific value. Using generic: " << m_threshold);
    return m_threshold;
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from cfg_Base.

Definition at line 78 of file cfg_drive.h.

string cfg_DriveVendor::m_product [private]

Definition at line 81 of file cfg_drive.h.

Referenced by cfg_DriveVendor(), and GetThreshold().

Definition at line 82 of file cfg_drive.h.

Referenced by cfg_DriveVendor(), and GetThreshold().

Definition at line 83 of file cfg_drive.h.

Referenced by cfg_DriveVendor(), ConvertGroup(), and GetThreshold().

string cfg_DriveVendor::m_vendor [private]

Definition at line 80 of file cfg_drive.h.

Referenced by cfg_DriveVendor(), and GetThreshold().


The documentation for this class was generated from the following files: