Ejemplo n.º 1
0
 NoteWindow * get_window() const
   {
     if(is_disposing() && !has_buffer()) {
       throw sharp::Exception("Plugin is disposing already");
     }
     return m_note->get_window();
   }
Ejemplo n.º 2
0
 const NoteBuffer::Ptr & get_buffer() const
   {
     if(is_disposing() && !has_buffer()) {
       throw sharp::Exception("Plugin is disposing already");
     }
     return m_note->get_buffer();
   }
Ejemplo n.º 3
0
/**
 * 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;
};
Ejemplo n.º 4
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;
}
Ejemplo n.º 5
0
/**
 * 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_);
  }
}
Ejemplo n.º 6
0
const void *ArrayBase::getBuffer() const {
  if (has_buffer()) {
    if (buffer_ != nullptr && type_ == NTA_BasicType_SDR) {
      return getSDR()->getDense().data();
    }
    return buffer_.get();
  }
  return nullptr;
}
Ejemplo n.º 7
0
	bool peek( size_t len )
	{
		if( has_buffer( len ) )
		{
			m_read_offset += len;
			return true;
		}

		return false;
	}
Ejemplo n.º 8
0
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);
}
Ejemplo n.º 9
0
 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());
 }
Ejemplo n.º 10
0
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;
}
Ejemplo n.º 11
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;
}
Ejemplo n.º 12
0
	bool is_eof() const
	{
		return !has_buffer( 1 );
	}
Ejemplo n.º 13
0
/**
 * 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_;
};
Ejemplo n.º 14
0
/**
 * 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_;
}