NoteWindow * get_window() const { if(is_disposing() && !has_buffer()) { throw sharp::Exception("Plugin is disposing already"); } return m_note->get_window(); }
const NoteBuffer::Ptr & get_buffer() const { if(is_disposing() && !has_buffer()) { throw sharp::Exception("Plugin is disposing already"); } return m_note->get_buffer(); }
/** * max number of elements this buffer can hold. * We use this to determine if there is extra space in the buffer * to hold the new data so we can avoid having to re-allocate. */ size_t ArrayBase::getMaxElementsCount() const { if (has_buffer()) { if (type_ == NTA_BasicType_SDR) return getCount(); return capacity_ / BasicType::getSize(type_); } else return 0; };
const SDR *ArrayBase::getSDR() const { NTA_CHECK(type_ == NTA_BasicType_SDR) << "Does not contain an SDR object"; if (has_buffer()) { const SDR *sdr = (SDR *)buffer_.get(); return sdr; } return nullptr; }
/** * Will fill the buffer with 0's. */ void ArrayBase::zeroBuffer() { if (has_buffer()) { if (type_ == NTA_BasicType_SDR) { getSDR()->zero(); } else std::memset(buffer_.get(), 0, capacity_); } }
const void *ArrayBase::getBuffer() const { if (has_buffer()) { if (buffer_ != nullptr && type_ == NTA_BasicType_SDR) { return getSDR()->getDense().data(); } return buffer_.get(); } return nullptr; }
bool peek( size_t len ) { if( has_buffer( len ) ) { m_read_offset += len; return true; } return false; }
inline void AsyncFile::set_buffer(Uint32 rg, Ptr<GlobalPage> ptr, Uint32 cnt) { assert(!has_buffer()); m_resource_group = rg; m_page_ptr = ptr; m_page_cnt = cnt; theWriteBuffer = (char*)ptr.p; theWriteBufferSize = cnt * sizeof(GlobalPage); }
Gtk::Window *NoteAddin::get_host_window() const { if(is_disposing() && !has_buffer()) { throw sharp::Exception(_("Plugin is disposing already")); } NoteWindow *note_window = m_note->get_window(); if(!note_window->host()) { throw std::runtime_error(_("Window is not embedded")); } return dynamic_cast<Gtk::Window*>(note_window->host()); }
inline void AsyncFile::clear_buffer(Uint32 & rg, Ptr<GlobalPage> & ptr, Uint32 & cnt) { assert(has_buffer()); rg = m_resource_group; ptr = m_page_ptr; cnt = m_page_cnt; m_resource_group = RNIL; m_page_cnt = 0; m_page_ptr.setNull(); theWriteBuffer = 0; theWriteBufferSize = 0; }
//////////////////////////////////////////////////////////////////////////////// // Stream Serialization (as binary) //////////////////////////////////////////////////////////////////////////////// void ArrayBase::save(std::ostream &outStream) const { outStream << "[ " << count_ << " " << BasicType::getName(type_) << " "; if (has_buffer() && type_ == NTA_BasicType_SDR) { const SDR *sdr = getSDR(); sdr->save(outStream); } else { if (count_ > 0) { Size size = count_ * BasicType::getSize(type_); outStream.write((const char *)buffer_.get(), size); } } outStream << "]" << std::endl; }
bool is_eof() const { return !has_buffer( 1 ); }
/** * number of elements of the given type in the buffer. */ size_t ArrayBase::getCount() const { if (has_buffer() && type_ == NTA_BasicType_SDR) { return ((SDR *)(buffer_.get()))->size; } return count_; };
/** * Actual size in bytes of the space allocated for the buffer. */ size_t ArrayBase::getBufferSize() const { if (has_buffer() && type_ == NTA_BasicType_SDR) { return getSDR()->size; } return capacity_; }