本文整理汇总了C++中Datum::getInteger方法的典型用法代码示例。如果您正苦于以下问题:C++ Datum::getInteger方法的具体用法?C++ Datum::getInteger怎么用?C++ Datum::getInteger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Datum
的用法示例。
在下文中一共展示了Datum::getInteger方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getNumber
Datum ComponentRegistry::getNumber(std::string expression, GenericDataType type){
Datum value;
switch(type){
case M_FLOAT:
case M_INTEGER:
case M_BOOLEAN:
case M_STRING:
value = getValue(expression, type);
if (value.getDataType() == type) {
return value;
}
break;
default:
throw FatalParserException("Attempt to cast a number of invalid type");
}
switch (type){
case M_FLOAT:
return Datum(value.getFloat());
case M_INTEGER:
return Datum(value.getInteger());
case M_STRING:
return Datum(value.getString());
case M_BOOLEAN:
return Datum(value.getBool());
default:
return value;
}
}
示例2: stateSystemCallback
void StimulusDisplay::stateSystemCallback(const Datum &data, MWorksTime time) {
unique_lock lock(display_lock);
int newState = data.getInteger();
if ((IDLE == newState) && displayLinksRunning) {
// If another thread is waiting for a display refresh, allow it to complete before stopping
// the display link
while (waitingForRefresh) {
refreshCond.wait(lock);
}
displayLinksRunning = false;
currentOutputTimeUS = -1;
// We need to release the lock before calling CVDisplayLinkStop, because
// StimulusDisplay::displayLinkCallback could be blocked waiting for the lock, and
// CVDisplayLinkStop won't return until displayLinkCallback exits, leading to deadlock.
lock.unlock();
// NOTE: As of OS X 10.11, stopping the display links from a non-main thread causes issues
dispatch_sync(dispatch_get_main_queue(), ^{
for (auto dl : displayLinks) {
if (kCVReturnSuccess != CVDisplayLinkStop(dl)) {
merror(M_DISPLAY_MESSAGE_DOMAIN,
"Unable to stop updates on display %d",
CVDisplayLinkGetCurrentCGDisplay(dl));
}
}
});
mprintf(M_DISPLAY_MESSAGE_DOMAIN, "Display updates stopped");
} else if ((RUNNING == newState) && !displayLinksRunning) {
示例3: notify
void IODeviceVariableNotification::notify(const Datum& data, MWTime timeUS) {
if(data.getInteger() == IDLE) {
shared_ptr<IODevice> io_dev_shared = io_device.lock();
if(io_dev_shared != NULL){
io_dev_shared->stopDeviceIO();
}
}
}
示例4: srg
boost::python::object convert_datum_to_python(const Datum &datum) {
ScopedRecursionGuard srg(" while converting MWorks datum to Python object");
if (datum.isUndefined()) {
return boost::python::object();
}
switch (datum.getDataType()) {
case M_INTEGER:
return convert_longlong_to_python(datum.getInteger());
case M_FLOAT:
return manageNewRef( PyFloat_FromDouble(datum.getFloat()) );
case M_BOOLEAN:
return manageNewRef( PyBool_FromLong(datum.getBool()) );
case M_STRING: {
auto &str = datum.getString();
return manageNewRef( PyString_FromStringAndSize(str.c_str(), str.size()) );
}
case M_LIST: {
auto &listValue = datum.getList();
boost::python::object list = manageNewRef( PyList_New(listValue.size()) );
for (Py_ssize_t i = 0; i < listValue.size(); i++) {
boost::python::object item = convert_datum_to_python(listValue.at(i));
// PyList_SetItem "steals" the item reference, so we need to INCREF it
Py_INCREF(item.ptr());
if (PyList_SetItem(list.ptr(), i, item.ptr()))
throw_error_already_set();
}
return list;
}
case M_DICTIONARY: {
boost::python::object dict = manageNewRef( PyDict_New() );
for (auto &item : datum.getDict()) {
if (PyDict_SetItem(dict.ptr(),
convert_datum_to_python(item.first).ptr(),
convert_datum_to_python(item.second).ptr()))
{
throw_error_already_set();
}
}
return dict;
}
default:
PyErr_Format(PyExc_TypeError, "Cannot convert Datum of unknown type (%d)", datum.getDataType());
throw_error_already_set();
return boost::python::object(); // Never reached
}
}
示例5: stateSystemCallback
void StimulusDisplay::stateSystemCallback(const Datum &data, MWorksTime time) {
unique_lock lock(display_lock);
int newState = data.getInteger();
if (IDLE == newState) {
if (CVDisplayLinkIsRunning(displayLink)) {
// If another thread is waiting for a display refresh, allow it to complete before stopping
// the display link
while (waitingForRefresh) {
refreshCond.wait(lock);
}
// We need to release the lock before calling CVDisplayLinkStop, because
// StimulusDisplay::displayLinkCallback could be blocked waiting for the lock, and
// CVDisplayLinkStop won't return until displayLinkCallback exits, leading to deadlock.
lock.unlock();
if (kCVReturnSuccess != CVDisplayLinkStop(displayLink)) {
merror(M_DISPLAY_MESSAGE_DOMAIN, "Unable to stop display updates");
} else {
currentOutputTimeUS = -1;
mprintf(M_DISPLAY_MESSAGE_DOMAIN, "Display updates stopped");
}
}
} else if (RUNNING == newState) {
if (!CVDisplayLinkIsRunning(displayLink)) {
lastFrameTime = 0;
if (kCVReturnSuccess != CVDisplayLinkStart(displayLink)) {
merror(M_DISPLAY_MESSAGE_DOMAIN, "Unable to start display updates");
} else {
// Wait for a refresh to complete, so we know that getCurrentOutputTimeUS() will return a valid time
ensureRefresh(lock);
mprintf(M_DISPLAY_MESSAGE_DOMAIN,
"Display updates started (main = %d, current = %d)",
CGMainDisplayID(),
CVDisplayLinkGetCurrentCGDisplay(displayLink));
}
}
}
}
示例6: stateSystemCallback
void DynamicStimulusDriver::stateSystemCallback(const Datum &data, MWorksTime time) {
switch (data.getInteger()) {
case IDLE:
stop();
break;
case RUNNING:
unpause();
break;
case PAUSED:
pause();
break;
}
}