std::vector<Vendor> VendorDAOMySQL::getAllVendors() { MySQLManager::ConnectionHolder ch(MySQLManager::getInstance()); std::unique_ptr<sql::PreparedStatement> ps(ch.conn->prepareStatement(ALL_VENDORS)); std::unique_ptr<sql::ResultSet> res(ps->executeQuery()); std::vector<Vendor> vendors; while(res->next()) { vendors.push_back(Vendor(res->getInt(1), res->getString(2))); } return vendors; }
Vendor VendorDAOMySQL::getVendorById(const int &id) { MySQLManager::ConnectionHolder ch(MySQLManager::getInstance()); std::unique_ptr<sql::PreparedStatement> ps(ch.conn->prepareStatement(VENDOR_BY_ID)); ps->setInt(1, id); std::unique_ptr<sql::ResultSet> res(ps->executeQuery()); if(!res->next()) { throw DAOException("Vendor not found!"); } return Vendor(res->getInt(1), res->getString(2)); }
std::vector<Vendor> VendorDAOMySQL::findVendorByName(const std::string &name) { MySQLManager::ConnectionHolder ch(MySQLManager::getInstance()); std::unique_ptr<sql::PreparedStatement> ps(ch.conn->prepareStatement(FIND_VENDOR_BY_NAME)); ps->setString(1, "%" + name + "%"); std::unique_ptr<sql::ResultSet> res(ps->executeQuery()); std::vector<Vendor> vendors; while(res->next()) { vendors.push_back(Vendor(res->getInt(1), res->getString(2))); } return vendors; }
/// List of device filters based on environment variables. inline std::vector< std::function<bool(const boost::compute::device&)> > backend_env_filters() { std::vector< std::function<bool(const boost::compute::device&)> > filter; const char *platform = boost::compute::detail::getenv("OCL_PLATFORM"); const char *vendor = boost::compute::detail::getenv("OCL_VENDOR"); const char *name = boost::compute::detail::getenv("OCL_DEVICE"); const char *devtype = boost::compute::detail::getenv("OCL_TYPE"); const char *extension = boost::compute::detail::getenv("OCL_EXTENSION"); if (platform) filter.push_back(Platform(platform)); if (vendor) filter.push_back(Vendor(vendor)); if (name) filter.push_back(Name(name)); if (devtype) filter.push_back(Type(devtype)); if (extension) filter.push_back(Extension(extension)); return filter; }