本文整理汇总了C++中params类的典型用法代码示例。如果您正苦于以下问题:C++ params类的具体用法?C++ params怎么用?C++ params使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了params类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copy_vector
// Copy vector from builtin backend.
static boost::shared_ptr<vector>
copy_vector(typename builtin<real>::vector const &x, const params &prm)
{
precondition(!prm.context().empty(), "Empty VexCL context!");
return boost::make_shared<vector>(prm.context(), x);
}
示例2: GlyphAtlasGL
//////////////////////////////////////////////////////////////////
// fastuidraw::gl::GlyphAtlasGL methods
fastuidraw::gl::GlyphAtlasGL::
GlyphAtlasGL(const params &P):
GlyphAtlas(TexelStoreGL::create(P.texel_store_dimensions(), P.delayed()),
GeometryStoreGL::create(P.number_floats(), P.delayed(), P.alignment()))
{
m_d = FASTUIDRAWnew GlyphAtlasGLPrivate(P);
}
示例3: create_vector
// Create vector of the specified size.
static boost::shared_ptr<vector>
create_vector(size_t size, const params &prm)
{
precondition(!prm.context().empty(), "Empty VexCL context!");
return boost::make_shared<vector>(prm.context(), size);
}
示例4: wrapper
wrapper(size_t n, params prm = params(),
const backend_params &bprm = backend_params(),
const InnerProduct &inner_product = InnerProduct()
)
: s(prm.get("type", runtime::solver::bicgstab)), handle(0)
{
if (!prm.erase("type")) AMGCL_PARAM_MISSING("type");
switch(s) {
#define AMGCL_RUNTIME_SOLVER(type) \
case type: \
handle = static_cast<void*>(new amgcl::solver::type<Backend, InnerProduct>(n, prm, bprm, inner_product)); \
break
AMGCL_RUNTIME_SOLVER(cg);
AMGCL_RUNTIME_SOLVER(bicgstab);
AMGCL_RUNTIME_SOLVER(bicgstabl);
AMGCL_RUNTIME_SOLVER(gmres);
AMGCL_RUNTIME_SOLVER(lgmres);
AMGCL_RUNTIME_SOLVER(fgmres);
AMGCL_RUNTIME_SOLVER(idrs);
#undef AMGCL_RUNTIME_SOLVER
default:
throw std::invalid_argument("Unsupported solver type");
}
}
示例5: setup
int ctable_factory_base::setup(int dfd, const char * name, const params & config, dtype::ctype key_type)
{
istr base;
params base_config;
if(!config.get("base", &base) || !config.get("base_config", &base_config))
return NULL;
return setup(base, dfd, name, base_config, key_type);
}
示例6: loadParams
params loadParams(const std::string& filename, params& p) {
CSVInput input(filename);
CSVHeader header(filename);
p.setInput(input);
p.setHeader(header);
return p;
}
示例7: lemon_interface
lemon_interface(const params &p) {
state_ = ::ParseAlloc(&pooled::tracked_byte_alloc);
if (p.trace()) {
#if NERVE_TRACE_PARSER
::ParseTrace(stdout, detail::parse_trace_prefix);
#endif
}
context_ = p.context();
}
示例8: create
int exist_dtable::create(int dfd, const char * file, const params & config, dtable::iter * source, const ktable * shadow)
{
int e_dfd, r;
params base_config, dnebase_config;
const dtable_factory * base = dtable_factory::lookup(config, "base");
const dtable_factory * dnebase = dtable_factory::lookup(config, "dnebase");
if(!base || !dnebase)
return -ENOENT;
if(!config.get("base_config", &base_config, params()))
return -EINVAL;
if(!config.get("dnebase_config", &dnebase_config, params()))
return -EINVAL;
if(!source_shadow_ok(source, shadow))
return -EINVAL;
r = mkdirat(dfd, file, 0755);
if(r < 0)
return r;
e_dfd = openat(dfd, file, O_RDONLY);
if(e_dfd < 0)
goto fail_open;
/* just to be sure */
source->first();
{
dtable_skip_iter<dne_skip_test> base_source(source);
r = base->create(e_dfd, "base", base_config, &base_source, NULL);
if(r < 0)
goto fail_base;
}
source->first();
{
full_ktable full_shadow(source);
nonshadow_skip_test skip_test(shadow);
dtable_skip_iter<nonshadow_skip_test> dnebase_source(source, skip_test);
r = dnebase->create(e_dfd, "dnebase", dnebase_config, &dnebase_source, &full_shadow);
if(r < 0)
goto fail_dnebase;
}
close(e_dfd);
return 0;
fail_dnebase:
util::rm_r(e_dfd, "base");
fail_base:
close(e_dfd);
fail_open:
unlinkat(dfd, file, AT_REMOVEDIR);
return (r < 0) ? r : -1;
}
示例9: deinit
int deltaint_dtable::init(int dfd, const char * file, const params & config, sys_journal * sysj)
{
const dtable_factory * base_factory;
const dtable_factory * ref_factory;
params base_config, ref_config;
int di_dfd;
if(base)
deinit();
base_factory = dtable_factory::lookup(config, "base");
ref_factory = dtable_factory::lookup(config, "ref");
if(!base_factory || !ref_factory)
return -ENOENT;
if(!config.get("base_config", &base_config, params()))
return -EINVAL;
if(!config.get("ref_config", &ref_config, params()))
return -EINVAL;
di_dfd = openat(dfd, file, O_RDONLY);
if(di_dfd < 0)
return di_dfd;
base = base_factory->open(di_dfd, "base", base_config, sysj);
if(!base)
goto fail_base;
reference = ref_factory->open(di_dfd, "ref", ref_config, sysj);
if(!reference)
goto fail_reference;
ktype = base->key_type();
cmp_name = base->get_cmp_name();
assert(ktype == reference->key_type());
scan_iter = base->iterator();
if(!scan_iter)
goto fail_scan;
ref_iter = reference->iterator();
if(!ref_iter)
goto fail_iter;
close(di_dfd);
return 0;
fail_iter:
delete scan_iter;
scan_iter = NULL;
fail_scan:
reference->destroy();
reference = NULL;
fail_reference:
base->destroy();
base = NULL;
fail_base:
close(di_dfd);
return -1;
}
示例10: copy_matrix
// Copy matrix from builtin backend.
static boost::shared_ptr<matrix>
copy_matrix(boost::shared_ptr< typename builtin<real>::matrix > A, const params &prm)
{
precondition(!prm.context().empty(), "Empty VexCL context!");
const typename builtin<real>::matrix &a = *A;
BOOST_AUTO(Aptr, a.ptr_data());
BOOST_AUTO(Acol, a.col_data());
BOOST_AUTO(Aval, a.val_data());
return boost::make_shared<matrix>(prm.context(), rows(*A), cols(*A), Aptr, Acol, Aval);
}
示例11: amg
amg(
const Matrix &A,
const params &prm = params(),
const backend_params &backend_prm = backend_params()
)
: coarsening(prm.get("coarsening.type", runtime::coarsening::smoothed_aggregation)),
relaxation(prm.get("relaxation.type", runtime::relaxation::spai0)),
handle(0)
{
runtime::detail::process_amg<Backend>(
coarsening, relaxation,
runtime::detail::amg_create<Backend, Matrix>(handle, A, prm, backend_prm)
);
}
示例12: deinit
int exception_dtable::init(int dfd, const char * file, const params & config, sys_journal * sysj)
{
const dtable_factory * base_factory;
const dtable_factory * alt_factory;
params base_config, alt_config;
int excp_dfd;
if(base || alt)
deinit();
base_factory = dtable_factory::lookup(config, "base");
alt_factory = dtable_factory::lookup(config, "alt");
if(!base_factory || !alt_factory)
return -EINVAL;
if(!config.get("base_config", &base_config, params()))
return -EINVAL;
if(!config.get("alt_config", &alt_config, params()))
return -EINVAL;
if(!config.get_blob_or_string("reject_value", &reject_value))
return -EINVAL;
/* the reject value must exist, because nonexistent values
* can get pruned out if the shadow does not require them */
if(!reject_value.exists())
return -EINVAL;
excp_dfd = openat(dfd, file, O_RDONLY);
if(excp_dfd < 0)
return excp_dfd;
base = base_factory->open(excp_dfd, "base", base_config, sysj);
if(!base)
goto fail_base;
alt = alt_factory->open(excp_dfd, "alt", alt_config, sysj);
if(!alt)
goto fail_alt;
ktype = base->key_type();
if(ktype != alt->key_type())
goto fail_ktype;
cmp_name = base->get_cmp_name();
close(excp_dfd);
return 0;
fail_ktype:
alt->destroy();
alt = NULL;
fail_alt:
base->destroy();
base = NULL;
fail_base:
close(excp_dfd);
return -1;
}
示例13: read
inline void read(const FileNode& node, params &x, const params & default_value = params())
{
if(node.empty())
x = default_value;
else
x.read(node);
}
示例14: deinit
int btree_dtable::init(int dfd, const char * file, const params & config, sys_journal * sysj)
{
const dtable_factory * factory;
params base_config;
int r, bt_dfd;
if(base)
deinit();
factory = dtable_factory::lookup(config, "base");
if(!factory)
return -ENOENT;
if(!config.get("base_config", &base_config, params()))
return -EINVAL;
if(!factory->indexed_access(base_config))
return -ENOSYS;
bt_dfd = openat(dfd, file, O_RDONLY);
if(bt_dfd < 0)
return bt_dfd;
base = factory->open(bt_dfd, "base", base_config, sysj);
if(!base)
goto fail_base;
ktype = base->key_type();
assert(ktype == dtype::UINT32);
cmp_name = base->get_cmp_name();
/* open the btree */
btree = rofile::open<BTREE_PAGE_KB, 8>(bt_dfd, "btree");
if(!btree)
goto fail_open;
r = btree->read_type(0, &header);
if(r < 0)
goto fail_format;
/* check the header */
if(header.magic != BTREE_DTABLE_MAGIC || header.version != BTREE_DTABLE_VERSION)
goto fail_format;
if(header.page_size != BTREE_PAGE_SIZE || header.pageno_size != BTREE_PAGENO_SIZE)
goto fail_format;
if(header.key_size != BTREE_KEY_SIZE || header.index_size != BTREE_INDEX_SIZE)
goto fail_format;
/* 1 -> uint32, and even with an empty table there will be a root page */
if(header.key_type != 1 || !header.root_page)
goto fail_format;
close(bt_dfd);
return 0;
fail_format:
delete btree;
fail_open:
base->destroy();
base = NULL;
fail_base:
close(bt_dfd);
return -1;
}
示例15: create
int simple_stable::create(int dfd, const char * name, const params & config, dtype::ctype key_type)
{
int md_dfd, r;
params meta_config, data_config;
const dtable_factory * meta = dtable_factory::lookup(config, "meta");
const ctable_factory * data = ctable_factory::lookup(config, "data");
if(!meta || !data)
return -ENOENT;
if(!config.get("meta_config", &meta_config, params()))
return -EINVAL;
if(!config.get("data_config", &data_config, params()))
return -EINVAL;
r = mkdirat(dfd, name, 0755);
if(r < 0)
return r;
md_dfd = openat(dfd, name, O_RDONLY);
if(md_dfd < 0)
{
r = md_dfd;
goto fail_open;
}
/* the metadata is keyed by named properties (strings) */
r = meta->create(md_dfd, "st_meta", meta_config, dtype::STRING);
if(r < 0)
goto fail_meta;
r = data->create(md_dfd, "st_data", data_config, key_type);
if(r < 0)
goto fail_data;
close(md_dfd);
return 0;
fail_data:
util::rm_r(md_dfd, "st_meta");
fail_meta:
close(md_dfd);
fail_open:
unlinkat(dfd, name, AT_REMOVEDIR);
return r;
}