void KeyFrameAnimationState::play_animation(const std::string& name) { auto animatable = animatable_.lock(); if(!animatable) { L_WARN("Animatable has been destroyed, not animating"); current_animation_ = next_animation_ = nullptr; } auto anim = animatable->animation(name); if(!anim) { L_WARN("No such animation: " + name); return; } if(current_animation_ == anim) { return; } current_animation_ = anim; current_animation_duration_ = current_animation_->duration; next_animation_ = nullptr; //Wipe out the next animation, otherwise we'll get unexpected behaviour //Set the current frame and next frame appropriately current_frame_ = current_animation_->frames.first; next_frame_ = current_frame_ + 1; if(next_frame_ > current_animation_->frames.second) { //Handle the case where the animation is just a single frame next_frame_ = current_frame_; } interp_ = 0.0; refresh_animation_state_(current_frame_, next_frame_, interp_); }
void KeyFrameAnimationState::queue_next_animation(const std::string& name) { auto animatable = animatable_.lock(); if(!animatable) { L_WARN("Animatable has been destroyed, not animating"); current_animation_ = next_animation_ = nullptr; return; } auto anim = animatable->animation(name); if(!anim) { L_WARN("No such animation: " + name); return; } next_animation_ = anim; }
void Task::init() { L_FUNC(""); L_INFO("+++ test Logger"); L_FATAL("L_FATAL"); L_ERROR("L_ERROR"); L_WARN("L_WARN"); L_INFO("L_INFO"); L_DEBUG("L_DEBUG"); L_INFO("--- test Logger"); L_INFO(QString()); // --> "?" L_INFO(" \n Trimmed \n\n"); // --> whitespace removed from start and end L_INFO("UTF-8 Unicode text: äöü àéè"); QString formattedOutput1 = "JSON output 1:\n" "{\n" " \"firstName\": \"Mario\",\n" " \"age\": 44\n" "}" ; L_INFO(formattedOutput1); QString formattedOutput2 = "{<br> \"firstName\": \"Mario\",<br> \"age\": 44<br>}"; L_INFO(formattedOutput2.prepend("JSON output 2:<br>").replace("<br>", "\n")); QTimer::singleShot(1000, this, SLOT(slotRun())); QTimer::singleShot(1000, this, SLOT(slotRun())); QTimer::singleShot(3000, this, SLOT(slotRun())); QTimer::singleShot(6000, this, SLOT(theEnd())); }
void sample(void) { int r; L_DEBUG("debug"); L_INFO("info"); L_NOTICE("notice"); L_WARN("warn"); L_ERR("err"); sput_fail_if(0, "0 isn't false!"); sput_fail_unless(1, "1 isn't true!"); /* Play with smock */ sput_fail_unless(smock_empty(), "smock empty"); smock_push_int("in", 1); sput_fail_unless(!smock_empty(), "smock not empty"); smock_push_int("out", 2); smock_push_int("in", 3); smock_push_int("out", 6); r = dummy_callback(1); sput_fail_unless(r == 2, "dummy_callback broken"); r = dummy_callback(3); sput_fail_unless(r == 6, "dummy_callback broken"); /* In the end, we should be again gone. */ sput_fail_unless(smock_empty(), "smock empty"); }
/** copies data from the head of the queue into passed buffer. * * if data from the head of the queue copied successfully * removes head of the queue. \n * if head of the queue was not removed successfully * logs warning. * * @param _root root node of the queue * @param _data buffer in which head's data would be copied * @param _size passed buffer size * * @return #true if successfully poped \n * #false otherwise * * @see d_list_get_head * @see d_list_remove_head */ bool d_queue_pop(QUEUE_ROOT* _root, void* _data, size_t _size) { /* #ifdef _DEBUG */ /* L_DEBUG( "0x%08x\n", _root ); */ /* #endif */ if ( !_root ) { L_ERROR( "_root == NULL\n", "" ); return false; } if ( d_list_get_head((LIST_ROOT*)_root, _data, _size) ) { if ( !d_list_remove_head((LIST_ROOT*)_root) ) { // pointer moved anyway // just let developers know that here is memleaks L_WARN( "unable to remove QUEUE_HEAD\n", "" ); } return true; } return false; }
/** deinitializes #LIST_ROOT. * * removes all nodes in the list (by calling #d_list_remove_head) * and zeroes passed pointer to the #LIST_ROOT * * logs warning if #d_list_remove_head was not successfully done * * @param _root pointer to the root node * * @return currently #true in case of non-null pointer \n * #false otherwise */ bool d_list_deinit(LIST_ROOT* _root) { /* #ifdef _DEBUG */ /* L_DEBUG( "0x%08x\n", _root ); */ /* #endif */ if ( !_root ) { L_ERROR( "_root == NULL\n", "" ); return false; } bool clr = true; while ( _root->count ) { clr &= d_list_remove_head( _root ); } if ( !clr ) { L_WARN( "memleaks are possible\n", "" ); } memset( _root, 0, sizeof(_root) ); return true; }
int32_t ShaderProgram::get_attrib_loc(const std::string& name) { GLint location = glGetAttribLocation(program_id_, name.c_str()); if(location < 0) { L_WARN("No attribute with name: " + name); } return location; }
int32_t ShaderProgram::get_uniform_loc(const std::string& name) { if(container::contains(cached_uniform_locations_, name)) { return cached_uniform_locations_[name]; } GLint location = glGetUniformLocation(program_id_, name.c_str()); if(location < 0) { L_WARN("No uniform with name: " + name); } cached_uniform_locations_[name] = location; return location; }
void SubMesh::set_diffuse(const smlt::Colour& colour) { if(uses_shared_data_) { L_WARN("Tried to set the diffuse colour on shared_data, use Mesh::set_diffuse instead"); return; } vertex_data->move_to_start(); for(uint16_t i = 0; i < vertex_data->count(); ++i) { vertex_data->diffuse(colour); vertex_data->move_next(); } vertex_data->done(); }
void Mesh::delete_submesh(const std::string& name) { auto it = submeshes_.find(name); if(it != submeshes_.end()) { auto submesh = (*it).second; submeshes_.erase(it); ordered_submeshes_.remove(submesh.get()); signal_submesh_destroyed_(id(), submesh.get()); } else { #ifndef NDEBUG L_WARN(_F("Tried to delete non-existent mesh with name: {0}").format(name)); #endif } }
Dialog::Dialog(QWidget *parent) : QDialog(parent) , ui(new Ui::Dialog) { L_FUNC(""); // qDebug("Dialog::Dialog"); ui->setupUi(this); EventLog *eventLog = new EventLog(this); QObject::connect(eventLog, SIGNAL(eventInfo(const QString&)), this, SLOT(eventInfo(const QString&)), Qt::QueuedConnection); // Qt::QueuedConnection: Qt 5.4.x Debian installEventFilter(eventLog); L_INFO("+++ test Logger"); L_FATAL("L_FATAL"); L_ERROR("L_ERROR"); L_WARN("L_WARN"); L_NOTE("L_NOTE"); L_INFO("L_INFO"); L_DEBUG("L_DEBUG"); L_INFO("--- test Logger"); L_NOTE("Start"); }
/** get data in the node with position. * * searches the position in the list, * copies data in the node into passed buffer * if there is enough space. * * if passed position is greater than LIST_ROOT#count or negative * then nothing is copied and #false returned. \n * if passed buffer size is lesser than requested data * then nothing copied, error logged and #false returned. \n * if passed buffer size is greater then requested data * then data is copied and warning raised. * * NOTE: passed buffer filled with NULLs before copying requested data. * * @param _root root node of the list * @param _position number of node which data to get (zero-based) * @param _data pointer to the buffer in which to copy node's data * @param _size size of _data buffer * * @return #true if data in the node fits into passed _data \n * #false otherwise or any argument is bad */ bool d_list_get(LIST_ROOT* _root, const int _position, void* _data, size_t _size) { /* #ifdef _DEBUG */ /* L_DEBUG( "0x%08x %d\n", _root, _position ); */ /* #endif */ if ( !_root ) { L_ERROR( "_root == NULL\n", "" ); return false; } if ( !_root->count ) { L_WARN( "nothing to get. list is empty\n", "" ); return false; } if ( _position < 0 || _position >= _root->count ) { L_ERROR( "incorrect _position: %d. list size: %d\n", _position, _root->count ); return false; } if ( !_data ) { L_ERROR( "_data == NULL\n", "" ); return false; } int position = _position; /* TODO: rewrite using head and tail pointers */ LIST_NODE* current = _root->head; LIST_NODE* prev = current; /* L_DEBUG( "current = 0x%08x; pos = %d\n", */ /* current, position */ /* ); */ while ( current && position ) { if ( current->next ) { prev = current; current = current->next; } else { break; } position--; /* L_DEBUG( "in-cycle: current = 0x%08x; prev = 0x%08x; pos = %d\n", */ /* current, prev, position */ /* ); */ } if ( !current ) { L_ERROR( "broken list? prev 0x%08x; current 0x%08x; position %d\n", prev, current, position ); return false; } else { if ( current->sz > _size ) { L_ERROR( "not enough space(%d) for data(%d) passed\n", _size, current->sz ); return false; } else if ( current->sz < _size ) { L_WARN( "current->sz(%d) lesser than _size(%d)\n", current->sz, _size ); } memset( _data, 0, _size); memcpy( _data, current->data, current->sz ); } return true; }
/** removes node of the list. * * searches the position in the list, * deallocates memory with data, * deallocates memory with node, * links previous node with next * updates LIST_ROOT#head and LIST_ROOT#tail pointers if necessary * * if passed _position is greater than list count (LIST_ROOT#count) * or negative than nothing removed and #false returned. * * @param _root root node of the list * @param _position number of node to remove (zero-based) * * @return #true if removed successfully \n * #false otherwise (see logs for details in this case) */ bool d_list_remove(LIST_ROOT* _root, const int _position) { /* #ifdef _DEBUG */ /* L_DEBUG( "0x%08x %d\n", _root, _position ); */ /* #endif */ if ( !_root ) { L_ERROR( "_root == NULL\n", "" ); return false; } if ( !(_root->count) ) { L_WARN( "nothing to remove. list is empty\n", "" ); return true; } if ( _position < 0 || _position >= _root->count ) { L_ERROR( "incorrect _position: %d. list contains %d\n", _position, _root->count ); return false; } int position = _position; LIST_NODE* current = _root->head; LIST_NODE* prev = current; /* L_DEBUG( "current = 0x%08x; position = %d\n", */ /* current, position */ /* ); */ if ( _position ) { while ( current && position ) { if ( current->next ) { prev = current; current = current->next; } else { break; } position--; /* L_DEBUG( "in-cycle: current = 0x%08x; prev = 0x%08x; pos = %d\n", */ /* current, prev, position */ /* ); */ } if ( position ) { L_ERROR( "broken list? prev 0x%08x; current 0x%08x; position %d\n", prev, current, position ); return false; } prev->next = current->next; if ( !(prev->next) ) // in case of new tail { _root->tail = prev; /* L_DEBUG( "new tail 0x%08x\n", _root->tail ); */ } } else // in case of rm head { _root->head = current->next; if ( !_root->head ) { _root->tail = NULL; /* L_DEBUG( "tail = head = NULL\n", "" ); */ } /* L_DEBUG( "new head 0x%08x\n", _root->head ); */ } if ( current ) { if ( current->data ) { free( current->data ); } free( current ); _root->count--; /* L_DEBUG( "new count %d\n", _root->count ); */ } return true; }
/** inserts data into the list. * * searches the position in the list, * allocates memory for the new node and data (according passed _size), * links previous node with new one, * links new node with the next node, * updates LIST_ROOT#head and LIST_ROOT#tail pointers if necessary * * if passed _position is greater than list count (LIST_ROOT#count) * than tail-insert performed. \n * if passed _position is lesser than list count (LIST_ROOT#count) * than normal insert performed. \n * if passed _position is negative than head-insert performed. * * if list already contains 2 nodes and insert into _position=1 * requested, then current tail will be replaced with the new node, * current tail will be new tail. * * @param _root root node of the list * @param _position position where to insert new node (zero-based) * @param _data data to insert into new node * @param _size size of data to be inserted * * @return #true if insert was successful \n * #false otherwise (see logs for details in this case) */ bool d_list_insert(LIST_ROOT* _root, const int _position, const void* _data, const size_t _size) { /* #ifdef _DEBUG */ /* L_DEBUG( "0x%08x %d\n", _root, _position ); */ /* #endif */ if ( !_root ) { L_ERROR( "_root == NULL\n", "" ); return false; } int position = _position; if ( position < 0 ) { L_WARN( "_position is NEGATIVE(%d). insert HEAD\n", position ); position = 0; } else if ( position > _root->count ) { L_WARN( "_position(%d) is GREATER than count(%d). insert tail\n", position, _root->count ); position = _root->count; } LIST_NODE* current = _root->head; LIST_NODE* prev = current; /* L_DEBUG( "current = 0x%08x; position = %d\n", */ /* current, position */ /* ); */ if ( position != _root->count ) // insert somewhere inside list { while ( current && position ) { prev = current; current = current->next; position--; /* L_DEBUG( "in-cycle: current = 0x%08x; prev = 0x%08x; pos = %d\n", */ /* current, prev, position */ /* ); */ } } else { current = NULL; prev = _root->tail; position = 0; /* L_DEBUG( "insert new tail. skip cycle and goto end of the list\n", "" ); */ } if ( position ) { /* L_ERROR( "broken list? prev 0x%08x; current 0x%08x; position %d\n", */ /* prev, current, position */ /* ); */ return false; } LIST_NODE* node = (LIST_NODE*)calloc( 1, sizeof(LIST_NODE) ); if ( !node ) { L_ERROR( "unable to allocate node\n", "" ); return false; } void* data = calloc( 1, _size ); if ( !data ) { L_ERROR( "unable to allocate data\n", "" ); return false; } /* L_DEBUG( "new node 0x%08x with data 0x%08x\n", */ /* node, data */ /* ); */ memcpy( data, _data, _size ); node->data = data; node->sz = _size; node->next = current; if ( prev == current ) // in case of new head { /* L_DEBUG( "new head inserted\n", "" ); */ _root->head = node; } else { /* L_DEBUG( "new node inserted\n", "" ); */ prev->next = node; } /* L_DEBUG( "p(0x%08x)->0x%08x; n(0x%08x)->0x%08x; c(0x%08x)->0x%08x\n", */ /* prev, ( prev ? prev->next : NULL ), */ /* node, node->next, */ /* current, ( current ? current->next : NULL ) */ /* ); */ if ( _position == _root->count ) // in case of new tail { /* L_DEBUG( "new tail inserted\n", "" ); */ _root->tail = node; } /* L_DEBUG( "node(0x%08x)->0x%08x\n", */ /* node, node->next */ /* ); */ _root->count++; /* L_DEBUG( "new count %d\n", _root->count ); */ return true; }