/* * BaseInfoDriver.cpp * * Created on: 2017-10-8 * Author: fasiondog */ #include #include "BlockInfoDriver.h" namespace hku { HKU_API std::ostream& operator<<(std::ostream& os, const BlockInfoDriver& driver) { os << "BlockInfoDriver(" << driver.name() << ", " << driver.getParameter() << ")"; return os; } HKU_API std::ostream& operator<<(std::ostream& os, const BlockInfoDriverPtr& driver) { if (driver) { os << *driver; } else { os << "BlockInfoDriver(NULL)"; } return os; } BlockInfoDriver::BlockInfoDriver(const string& name) : m_name(name) { to_upper(m_name); } bool BlockInfoDriver::checkType() { bool result = false; try { string type = getParam("type"); to_upper(type); if (type == m_name) { result = true; } else { result = false; HKU_WARN("Type of driver mismatch! ({} != {})", type, m_name); } } catch (...) { result = false; HKU_ERROR("Can't get type of driver!"); } return result; } bool BlockInfoDriver::init(const Parameter& params) { if (m_params == params) return true; m_params = params; if (!checkType()) { return false; } return _init(); } } /* namespace hku */