本文整理汇总了C++中sentinel函数的典型用法代码示例。如果您正苦于以下问题:C++ sentinel函数的具体用法?C++ sentinel怎么用?C++ sentinel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sentinel函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: project_bounding_on_axis
void project_bounding_on_axis(const Bounding *b, const Vector *axis, double *projection_start, double *projection_end)
{
assert(b && "Bad bounding pointer.");
assert(axis && "Bad axis pointer.");
assert(projection_start && projection_end && "Bad projection pointers.");
switch (b->bounding_type)
{
case bounding_box:
project_box_on_axis(b, axis, projection_start, projection_end);
return;
case bounding_sphere:
project_sphere_on_axis(b, axis, projection_start, projection_end);
return;
case bounding_composite:
sentinel("Cannot project composite bounding.", "");
default:
sentinel("Unknown bounding type.", "");
}
error:
assert(false);
}
开发者ID:aquirel,项目名称:morrigan,代码行数:26,代码来源:bounding.c
示例2: sky_property_get_standard_data_type_name
// Retrieves a reference to a standardized bstring that represents the name
// of the data type.
//
// type_name - The name of the type.
// ret - A pointer to where the standardized type name should be returned.
//
// Returns 0 if successful, otherwise returns -1.
int sky_property_get_standard_data_type_name(bstring type_name, bstring *ret)
{
check(type_name != NULL, "Type name required");
check(ret != NULL, "Return pointer required");
// Check against standard types.
if(biseq(&SKY_DATA_TYPE_INT, type_name)) {
*ret = &SKY_DATA_TYPE_INT;
}
else if(biseq(&SKY_DATA_TYPE_FLOAT, type_name)) {
*ret = &SKY_DATA_TYPE_FLOAT;
}
else if(biseq(&SKY_DATA_TYPE_BOOLEAN, type_name)) {
*ret = &SKY_DATA_TYPE_BOOLEAN;
}
else if(biseq(&SKY_DATA_TYPE_STRING, type_name)) {
*ret = &SKY_DATA_TYPE_STRING;
}
// If this is not a standard type then return the name that came in.
else {
sentinel("Type is not a standard type: %s", bdata(type_name));
}
return 0;
error:
return -1;
}
开发者ID:dasfaha,项目名称:sky,代码行数:35,代码来源:property.c
示例3: Command_install
int Command_install(
apr_pool_t *p, const char *url, const char *configure_opts,
const char *make_opts, const char *install_opts
) {
int rc = 0;
// first clean up
check(Shell_exec(CLEANUP_SH, NULL) == 0,
"Faild to clean up before building.");
// next, make sure it isn't already installed
rc = DB_find(url);
check(rc != -1, "Error checking the installed database");
if (rc == 1) {
log_info("Package already installed.");
return 0;
}
// it isn't installed. So, fetch.
rc = Command_fetch(p, url, 0);
// if fetch worked, build.
if (rc == 1) {
rc = Command_build(p, url, configure_opts, make_opts, install_opts);
} else if (rc == 0) {
// no install needed... I haven't read fetch yet so I'm not sure how
// this would happen.
log_info("Depends successfully installed: %s", url);
} else {
sentinel("Install failed: %s", url);
}
// cleanup again. It doesn't matter whether we check errors this time.
Shell_exec(CLEANUP_SH, NULL);
return 0;
error:
return -1;
}
开发者ID:stroxler,项目名称:lcthw,代码行数:33,代码来源:commands.c
示例4: qip_ast_node_get_type
// Recursively determines the type of a node.
//
// node - The node to determine the type for.
// module - The compilation unit this node is a part of.
// type - A pointer to where the type should be returned.
//
// Returns 0 if successful, otherwise returns -1.
int qip_ast_node_get_type(qip_ast_node *node, qip_module *module,
qip_ast_node **type)
{
int rc;
check(node != NULL, "Node required");
// Delegate to each type.
switch(node->type) {
case QIP_AST_TYPE_INT_LITERAL: rc = qip_ast_int_literal_get_type(node, type); break;
case QIP_AST_TYPE_FLOAT_LITERAL: rc = qip_ast_float_literal_get_type(node, type); break;
case QIP_AST_TYPE_BOOLEAN_LITERAL: rc = qip_ast_boolean_literal_get_type(node, type); break;
case QIP_AST_TYPE_STRING_LITERAL: rc = qip_ast_string_literal_get_type(node, type); break;
case QIP_AST_TYPE_NULL_LITERAL: rc = qip_ast_null_literal_get_type(node, type); break;
case QIP_AST_TYPE_ARRAY_LITERAL: rc = qip_ast_array_literal_get_type(node, type); break;
case QIP_AST_TYPE_BINARY_EXPR: rc = qip_ast_binary_expr_get_type(node, module, type); break;
case QIP_AST_TYPE_VAR_REF: rc = qip_ast_var_ref_get_type(node, module, type); break;
case QIP_AST_TYPE_SIZEOF: rc = qip_ast_sizeof_get_type(node, type); break;
case QIP_AST_TYPE_OFFSETOF: rc = qip_ast_offsetof_get_type(node, type); break;
case QIP_AST_TYPE_ALLOCA: rc = qip_ast_alloca_get_type(node, type); break;
default: {
sentinel("AST node does not have a type");
break;
}
}
check(rc == 0, "Unable to retrieve type name");
return 0;
error:
*type = NULL;
return -1;
}
开发者ID:dasfaha,项目名称:sky,代码行数:39,代码来源:node.c
示例5: qip_ast_node_get_var_pointer
// Retrieves a variable pointer to a given node. This only works with variable
// references and struct member accesses.
//
// node - The variable node to retrieve the pointer for.
// module - The compilation unit this node is a part of.
// value - A pointer to where the LLVM value should be returned.
//
// Returns 0 if successful, otherwise returns -1.
int qip_ast_node_get_var_pointer(qip_ast_node *node, qip_module *module,
LLVMValueRef *value)
{
int rc;
check(node != NULL, "Node is required");
check(module != NULL, "Module is required");
check(module->llvm_module != NULL, "LLVM Module is required");
check(module->compiler != NULL, "Module compiler is required");
check(module->compiler->llvm_builder != NULL, "LLVM Builder is required");
// Delegate codegen to AST nodes.
switch(node->type) {
case QIP_AST_TYPE_VAR_REF: {
rc = qip_ast_var_ref_get_pointer(node, module, NULL, value);
check(rc == 0, "Unable to retrieve pointer to variable reference");
break;
}
default:
{
sentinel("Unable to retrieve pointer for AST node");
break;
}
}
return 0;
error:
*value = NULL;
return -1;
}
开发者ID:dasfaha,项目名称:sky,代码行数:39,代码来源:node.c
示例6: sky_event_data_sizeof
// Calculates the total number of bytes needed to store an event data.
//
// data - The event data item.
size_t sky_event_data_sizeof(sky_event_data *data)
{
size_t sz = 0;
sz += sizeof(data->key);
switch(data->data_type) {
case SKY_DATA_TYPE_INT:
sz += minipack_sizeof_int(data->int_value);
break;
case SKY_DATA_TYPE_DOUBLE:
sz += minipack_sizeof_double(data->double_value);
break;
case SKY_DATA_TYPE_BOOLEAN:
sz += minipack_sizeof_bool(data->boolean_value);
break;
case SKY_DATA_TYPE_STRING:
sz += minipack_sizeof_raw(blength(data->string_value));
sz += blength(data->string_value);
break;
default:
sentinel("Invalid data type (%d) for event data", data->data_type);
}
return sz;
error:
return 0;
}
开发者ID:emiddleton,项目名称:sky,代码行数:29,代码来源:event_data.c
示例7: sky_event_data_copy
// Creates a copy of an event data item.
//
// source - The event data to copy.
// target - A reference to the new event data item.
//
// Returns 0 if successful, otherwise returns -1.
int sky_event_data_copy(sky_event_data *source, sky_event_data **target)
{
check(source != NULL, "Event data source required for copy");
switch(source->data_type) {
case SKY_DATA_TYPE_STRING:
*target = sky_event_data_create_string(source->key, source->string_value);
break;
case SKY_DATA_TYPE_INT:
*target = sky_event_data_create_int(source->key, source->int_value);
break;
case SKY_DATA_TYPE_DOUBLE:
*target = sky_event_data_create_double(source->key, source->double_value);
break;
case SKY_DATA_TYPE_BOOLEAN:
*target = sky_event_data_create_boolean(source->key, source->boolean_value);
break;
default:
sentinel("Invalid data type (%d) for event data", source->data_type);
}
return 0;
error:
if(*target) sky_event_data_free(*target);
*target = NULL;
return -1;
}
开发者ID:emiddleton,项目名称:sky,代码行数:35,代码来源:event_data.c
示例8: Map_del
void* Map_del(Map *map, char* key) {
sentinel("not yet implemented");
// if (map->length == 0) {
// return NULL;
// }
void *data = map->last->data;
// if (map->length == 1) {
// free(map->last);
// map->last = NULL;
// map->first = NULL;
// }
// if (map->length > 1) {
// struct MapNode *removee = map->last;
// map->last = removee->prev;
// free(removee);
// map->last->next = NULL;
// }
// map->length--;
return data;
error:
return NULL;
}
开发者ID:schnauzer,项目名称:cream,代码行数:27,代码来源:map.c
示例9: malloc
Value *Value_create(ValueType type, void *data) {
Value *val = malloc(sizeof(Value));
val->type = type;
switch(val->type) {
case VAL_QSTRING: val->as.string = data;
break;
case VAL_NUMBER: val->as.number = data;
break;
case VAL_CLASS: val->as.cls = data;
break;
case VAL_LIST: val->as.list = data;
break;
case VAL_HASH: val->as.hash = data;
break;
case VAL_IDENT: val->as.ident = data;
break;
case VAL_REF: val->as.ref = data;
break;
default:
sentinel("Unknown value type: %d", val->type);
}
return val;
error:
return val;
}
开发者ID:304471720,项目名称:mongrel2,代码行数:27,代码来源:ast.c
示例10: GTBoard_Parse
int GTBoard_Parse(GTBoard* b, char* s)
{
b->err = GTBoardError_None;
int parsedUnits = 0;
char* tok;
GTLexer l;
GTLexer_Init(&l, s);
GTLexer_Skip(&l, whitespace);
while ((tok = GTLexer_GetToken(&l, whitespace)) != NULL) {
GTLexer_GetToken(&l, "{");
char* s = GTLexer_GetToken(&l, "}");
if (strcmp(tok, fileTokens[GTBoardFileToken_Units]) == 0) {
check(GTBoard_ParseUnits(b, s) == 0, "parsing units failed");
parsedUnits = 1;
} else if (strcmp(tok, fileTokens[GTBoardFileToken_Tiles]) == 0) {
check(!parsedUnits, "tiles must be read before units");
check(GTBoard_ParseTiles(b, s) == 0, "parsing tiles failed");
} else if (strcmp(tok, fileTokens[GTBoardFileToken_Options]) == 0) {
// do nothing
} else {
sentinel("unidentified token %.*s", 80, tok);
}
GTLexer_Skip(&l, whitespace);
}
return 0;
error:
b->err = GTBoardError_BadParse;
return -1;
}
开发者ID:ryutaroikeda,项目名称:gatherers,代码行数:29,代码来源:board.c
示例11: GTBoard_ParseUnit
int GTBoard_ParseUnit(GTBoard* b, char* tok, int pos)
{
char u = tok[0];
char l = tok[1];
GTPlayer p = GTPlayer_None;
if ('a' <= u && u <= 'z') {
p = GTPlayer_Black;
} else if ('A' <= u && u <= 'Z') {
p = GTPlayer_White;
} else {
sentinel("invalid unit token %c", u);
}
GTUnitType t = GTUnitType_None;
int i;
for (i = 0; i < GTUnitType_Size; i++) {
if (u != unitChar[p][i]) { continue; }
t = i;
}
check(t != GTUnitType_None, "unrecognized unit %c", u);
int life = l - '0';
check(life > 0, "life = %d too low", life);
check(GTBoard_CreateUnit(b, p, t, pos) == 0, "create unit failed");
b->units[b->board[pos]].life = life;
return 0;
error:
return -1;
}
开发者ID:ryutaroikeda,项目名称:gatherers,代码行数:27,代码来源:board.c
示例12: sky_path_add_event
// Adds an event to a path. An event can only be added if the event's object id
// matches the path's object id.
//
// path - The path to add the event to.
// event - The event to add to the path.
//
// Returns 0 if successful, otherwise returns -1.
int sky_path_add_event(sky_path *path, sky_event *event)
{
// Validation.
check(path != NULL, "Path required");
check(path->object_id != 0, "Path object id cannot be null");
check(event != NULL, "Event required");
check(path->object_id == event->object_id, "Event object id (%d) does not match path object id (%d)", event->object_id, path->object_id);
// Raise error if event has already been added.
unsigned int i;
for(i=0; i<path->event_count; i++) {
if(path->events[i] == event) {
sentinel("Event has already been added to path");
}
}
// Allocate space for event.
path->event_count++;
path->events = realloc(path->events, sizeof(sky_event*) * path->event_count);
check_mem(path->events);
// Append event to the end.
path->events[path->event_count-1] = event;
// Sort events.
sort_events(path);
return 0;
error:
return -1;
}
开发者ID:gitaccount2,项目名称:sky,代码行数:39,代码来源:path.c
示例13: sentinel
void
ComputeIndicatorThread::onElement(const Elem * elem)
{
for (const auto & it : _aux_sys._elem_vars[_tid])
{
MooseVariable * var = it.second;
var->prepareAux();
}
_fe_problem.prepare(elem, _tid);
_fe_problem.reinitElem(elem, _tid);
// Set up Sentinel class so that, even if reinitMaterials() throws, we
// still remember to swap back during stack unwinding.
SwapBackSentinel sentinel(_fe_problem, &FEProblemBase::swapBackMaterials, _tid);
_fe_problem.reinitMaterials(_subdomain, _tid);
// Compute
if (!_finalize)
{
if (_indicator_whs.hasActiveBlockObjects(_subdomain, _tid))
{
const std::vector<std::shared_ptr<Indicator>> & indicators =
_indicator_whs.getActiveBlockObjects(_subdomain, _tid);
for (const auto & indicator : indicators)
indicator->computeIndicator();
}
}
// Finalize
else
{
if (_indicator_whs.hasActiveBlockObjects(_subdomain, _tid))
{
const std::vector<std::shared_ptr<Indicator>> & indicators =
_indicator_whs.getActiveBlockObjects(_subdomain, _tid);
for (const auto & indicator : indicators)
indicator->finalize();
}
if (_internal_side_indicators.hasActiveBlockObjects(_subdomain, _tid))
{
const std::vector<std::shared_ptr<InternalSideIndicator>> & internal_indicators =
_internal_side_indicators.getActiveBlockObjects(_subdomain, _tid);
for (const auto & internal_indicator : internal_indicators)
internal_indicator->finalize();
}
}
if (!_finalize) // During finalize the Indicators should be setting values in the vectors manually
{
Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
for (const auto & it : _aux_sys._elem_vars[_tid])
{
MooseVariable * var = it.second;
var->add(_aux_sys.solution());
}
}
}
开发者ID:mangerij,项目名称:moose,代码行数:60,代码来源:ComputeIndicatorThread.C
示例14: bind_this_thread
bool bind_this_thread( const std::pair<unsigned,unsigned> coord )
{
if ( ! sentinel() ) return false ;
#if DEBUG_PRINT
std::cout << "Kokkos::bind_this_thread() at " ;
hwloc_get_last_cpu_location( s_hwloc_topology ,
s_hwloc_location , HWLOC_CPUBIND_THREAD );
print_bitmap( std::cout , s_hwloc_location );
std::cout << " to " ;
print_bitmap( std::cout , s_core[ coord.second + coord.first * s_core_topology.second ] );
std::cout << std::endl ;
#endif
// As safe and fast as possible.
// Fast-lookup by caching the coordinate -> hwloc cpuset mapping in 's_core'.
return coord.first < s_core_topology.first &&
coord.second < s_core_topology.second &&
0 == hwloc_set_cpubind( s_hwloc_topology ,
s_core[ coord.second + coord.first * s_core_topology.second ] ,
HWLOC_CPUBIND_THREAD | HWLOC_CPUBIND_STRICT );
}
开发者ID:UoB-HPC,项目名称:TeaLeaf,代码行数:29,代码来源:Kokkos_hwloc.cpp
示例15: free_sexp
/* free_sexp: free all the memory allocated by reading an s-expression
*/
void free_sexp( struct node *sexp )
{
if( sexp != NULL )
{
switch( sexp->tag )
{
case NAME:
free( sexp->str );
sexp->str = NULL;
break;
case NUM:
break;
case LST:
free_sexp( sexp->sublst );
sexp->sublst = NULL;
break;
default:
sentinel("Non-existent tag: %d", sexp->tag);
break;
}
free_sexp( sexp->rest );
sexp->rest = NULL;
free( sexp );
sexp = NULL;
}
error:
return;
}
开发者ID:mjparrott,项目名称:FauxRacket,代码行数:31,代码来源:Sexp.c
示例16: sentinel
void
ComputeElemAuxVarsThread::onElement(const Elem * elem)
{
if (_aux_kernels.hasActiveBlockObjects(_subdomain, _tid))
{
const std::vector<std::shared_ptr<AuxKernel>> & kernels =
_aux_kernels.getActiveBlockObjects(_subdomain, _tid);
_fe_problem.prepare(elem, _tid);
_fe_problem.reinitElem(elem, _tid);
// Set up the sentinel so that, even if reinitMaterials() throws, we
// still remember to swap back.
SwapBackSentinel sentinel(_fe_problem, &FEProblem::swapBackMaterials, _tid, _need_materials);
if (_need_materials)
_fe_problem.reinitMaterials(elem->subdomain_id(), _tid);
for (const auto & aux : kernels)
aux->compute();
// update the solution vector
{
Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
for (const auto & it : _aux_sys._elem_vars[_tid])
{
MooseVariable * var = it.second;
var->insert(_aux_sys.solution());
}
}
}
}
开发者ID:radioactivekate,项目名称:moose,代码行数:31,代码来源:ComputeElemAuxVarsThread.C
示例17: synaptic_current_data_filled
bool synaptic_current_data_filled (address_t address, uint32_t flags)
{
use(flags);
log_info("synaptic_current_data_filled: starting");
// Loop through synapse types
for(index_t s = 0; s < SYNAPSE_TYPE_COUNT; s++)
{
log_info("\tCopying %u synapse type %u parameters of size %u", num_neurons, s, sizeof(synapse_param_t));
// Allocate block of memory for this synapse type's pre-calculated per-neuron decay
neuron_synapse_params[s] = (synapse_param_t*) spin1_malloc(sizeof(synapse_param_t) * num_neurons);
// Check for success
if(neuron_synapse_params[s] == NULL)
{
sentinel("Cannot allocate neuron synapse decay parameters - Out of DTCM");
return false;
}
log_info("\tCopying %u bytes to %u", num_neurons * sizeof(synapse_param_t), address + ((num_neurons * s * sizeof(synapse_param_t)) / 4));
memcpy(neuron_synapse_params[s], address + ((num_neurons * s * sizeof(synapse_param_t)) / 4),
num_neurons * sizeof(synapse_param_t));
}
log_info("synaptic_current_data_filled: completed successfully");
return true;
}
开发者ID:BRML,项目名称:HBP-spinnaker-cerebellum,代码行数:29,代码来源:synapses.c
示例18: sky_importer_process_event
int sky_importer_process_event(sky_importer *importer, bstring source,
jsmntok_t *tokens, uint32_t *index)
{
int rc;
check(importer != NULL, "Importer required");
check(source != NULL, "Source required");
check(tokens != NULL, "Tokens required");
check(index != NULL, "Token index required");
jsmntok_t *event_token = &tokens[*index];
(*index)++;
// Open table if it hasn't been already.
if(!importer->table->opened) {
check(sky_table_open(importer->table) == 0, "Unable to open table");
}
// Create the event object.
sky_event *event = sky_event_create(0, 0, 0); check_mem(event);
// Process over child tokens.
int32_t i;
for(i=0; i<(event_token->size/2); i++) {
jsmntok_t *token = &tokens[*index];
(*index)++;
if(sky_importer_tokstr_equal(source, token, "timestamp")) {
bstring timestamp = sky_importer_token_parse_bstring(source, &tokens[(*index)++]);
rc = sky_timestamp_parse(timestamp, &event->timestamp);
check(rc == 0, "Unable to parse timestamp");
bdestroy(timestamp);
}
else if(sky_importer_tokstr_equal(source, token, "objectId")) {
event->object_id = (sky_object_id_t)sky_importer_token_parse_int(source, &tokens[(*index)++]);
}
else if(sky_importer_tokstr_equal(source, token, "action")) {
sky_action *action = NULL;
bstring action_name = sky_importer_token_parse_bstring(source, &tokens[(*index)++]);
rc = sky_action_file_find_action_by_name(importer->table->action_file, action_name, &action);
check(rc == 0, "Unable to find action: %s", bdata(action_name));
event->action_id = action->id;
}
else if(sky_importer_tokstr_equal(source, token, "data")) {
rc = sky_importer_process_event_data(importer, event, source, tokens, index);
check(rc == 0, "Unable to import event data");
}
else {
sentinel("Invalid token at char %d", tokens[*index].start);
}
}
// Add event.
rc = sky_table_add_event(importer->table, event);
check(rc == 0, "Unable to add event");
return 0;
error:
return -1;
}
开发者ID:dasfaha,项目名称:sky,代码行数:60,代码来源:importer.c
示例19: while
void bounded_set<Key, Hash, bound>::clear() {
while (first != sentinel()) {
Pair *tmp = first;
first = first->next;
tmp->next = nullptr;
}
}
开发者ID:hivert,项目名称:IVMPG,代码行数:7,代码来源:bounded_set.hpp
示例20: foreach
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void DataContainer::ReadDataContainerStructure(hid_t dcArrayGroupId, DataContainerArrayProxy& proxy, QString h5InternalPath)
{
QList<QString> dataContainers;
QH5Utilities::getGroupObjects(dcArrayGroupId, H5Utilities::H5Support_GROUP, dataContainers);
foreach(QString dataContainerName, dataContainers)
{
if(__SHOW_DEBUG_MSG__)
{
std::cout << "Data Container:" << dataContainerName.toStdString() << std::endl;
}
hid_t containerGid = H5Gopen(dcArrayGroupId, dataContainerName.toLatin1().constData(), H5P_DEFAULT);
if (containerGid < 0)
{
continue;
}
HDF5ScopedGroupSentinel sentinel(&containerGid, false);
DataContainerProxy dcProxy(dataContainerName);
dcProxy.name = dataContainerName;
dcProxy.flag = Qt::Checked;
QString h5Path = h5InternalPath + "/" + dataContainerName;
// Read the Attribute Matricies for this Data Container
AttributeMatrix::ReadAttributeMatrixStructure(containerGid, dcProxy, h5Path);
// Insert the DataContainerProxy proxy into the DataContainerArrayProxy
proxy.dataContainers.insert(dcProxy.name, dcProxy);
}
}
开发者ID:ravishivaraman,项目名称:DREAM3D,代码行数:31,代码来源:DataContainer.cpp
注:本文中的sentinel函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论