Example #1
0
inline void Descriptor::insert_column_link(size_t col_ndx, DataType type, StringData name, Table& target,
                                           LinkType link_type)
{
    typedef _impl::TableFriend tf;

    if (REALM_UNLIKELY(!is_attached() || !target.is_attached()))
        throw LogicError(LogicError::detached_accessor);
    if (REALM_UNLIKELY(col_ndx > get_column_count()))
        throw LogicError(LogicError::column_index_out_of_range);
    if (REALM_UNLIKELY(!tf::is_link_type(ColumnType(type))))
        throw LogicError(LogicError::illegal_type);
    if (REALM_UNLIKELY(!is_root()))
        throw LogicError(LogicError::wrong_kind_of_descriptor);
    // Both origin and target must be group-level tables, and in the same group.
    Group* origin_group = tf::get_parent_group(*get_root_table());
    Group* target_group = tf::get_parent_group(target);
    if (!origin_group || !target_group)
        throw LogicError(LogicError::wrong_kind_of_table);
    if (origin_group != target_group)
        throw LogicError(LogicError::group_mismatch);

    LinkTargetInfo link(&target);
    tf::insert_column(*this, col_ndx, type, name, link); // Throws
    adj_insert_column(col_ndx);

    tf::set_link_type(*get_root_table(), col_ndx, link_type); // Throws
}
Example #2
0
object_id comm_link::resolve(std::string const& name, bool& cache)
{
	if(cache)
	{
		// try to get id from cached
		boost::lock_guard<boost::mutex> lock(m_proxies_mutex);
		named_proxies::iterator iter = m_named_proxies.find(name);
		if(iter != m_named_proxies.end())
			return iter->second;
	}

	cache = false;

	comm_request request(shared_from_this(), m_comm_oid);

	if(!is_attached())
	{
		pool_node_ptr node = m_weak_node.lock();
		BOOST_ASSERT(node);

		attach(request.initialize(node->get_service_pool().id()));
	}

	object_id id = request.resolve(name);
	if(id != 0)
	{
		// put the newly resolved id to cache
		boost::lock_guard<boost::mutex> lock(m_proxies_mutex);
		m_named_proxies[name] = id;
	}

	return id;
}
Example #3
0
inline void Descriptor::move_column(size_t from_ndx, size_t to_ndx)
{
    REALM_ASSERT(is_attached());
    typedef _impl::TableFriend tf;
    tf::move_column(*this, from_ndx, to_ndx); // Throws
    adj_move_column(from_ndx, to_ndx);
}
Example #4
0
inline void Descriptor::attach(Table* table, DescriptorRef parent, Spec* spec) noexcept
{
    REALM_ASSERT(!is_attached());
    REALM_ASSERT(!table->has_shared_type());
    m_root_table.reset(table);
    m_parent = parent;
    m_spec = spec;
}
Example #5
0
void destroy(list<int> int_params, list<string> string_params, sp_session *session, sp_track *track) {
    log("Exiting main run loop");
	if (is_attached()) {
	    detach_current_thread();
	}
	pthread_exit(0);
	destroy_audio_player();
}
Example #6
0
inline std::size_t LinkView::size() const noexcept
{
    REALM_ASSERT(is_attached());

    if (!m_row_indexes.is_attached())
        return 0;

    return m_row_indexes.size();
}
Example #7
0
inline bool LinkView::is_empty() const noexcept
{
    REALM_ASSERT(is_attached());

    if (!m_row_indexes.is_attached())
        return true;

    return m_row_indexes.is_empty();
}
Example #8
0
inline Table::RowExpr LinkView::get(std::size_t link_ndx) noexcept
{
    REALM_ASSERT(is_attached());
    REALM_ASSERT(m_row_indexes.is_attached());
    REALM_ASSERT_3(link_ndx, <, m_row_indexes.size());

    Table& target_table = m_origin_column.get_target_table();
    std::size_t target_row_ndx = to_size_t(m_row_indexes.get(link_ndx));
    return target_table[target_row_ndx];
}
Example #9
0
inline size_t LinkView::size() const noexcept
{
    if (!is_attached())
        return 0;

    if (!m_row_indexes.is_attached())
        return 0;

    return m_row_indexes.size();
}
Example #10
0
inline void Descriptor::rename_column(size_t col_ndx, StringData name)
{
    typedef _impl::TableFriend tf;

    if (REALM_UNLIKELY(!is_attached()))
        throw LogicError(LogicError::detached_accessor);
    if (REALM_UNLIKELY(col_ndx >= get_column_count()))
        throw LogicError(LogicError::column_index_out_of_range);

    tf::rename_column(*this, col_ndx, name); // Throws
}
Example #11
0
inline std::size_t LinkView::find(std::size_t target_row_ndx, std::size_t start) const noexcept
{
    REALM_ASSERT(is_attached());
    REALM_ASSERT_3(target_row_ndx, <, m_origin_column.get_target_table().size());
    REALM_ASSERT_3(start, <=, size());

    if (!m_row_indexes.is_attached())
        return not_found;

    return m_row_indexes.find_first(target_row_ndx, start);
}
template<class T> void BasicArray<T>::truncate(std::size_t size)
{
    TIGHTDB_ASSERT(is_attached());
    TIGHTDB_ASSERT(size <= m_size);

    copy_on_write(); // Throws

    // Update size in accessor and in header. This leaves the capacity
    // unchanged.
    m_size = size;
    set_header_size(size);
}
Example #13
0
inline void Descriptor::set_link_type(size_t col_ndx, LinkType link_type)
{
    typedef _impl::TableFriend tf;

    if (REALM_UNLIKELY(!is_attached()))
        throw LogicError(LogicError::detached_accessor);
    if (REALM_UNLIKELY(col_ndx >= get_column_count()))
        throw LogicError(LogicError::column_index_out_of_range);
    if (REALM_UNLIKELY(!tf::is_link_type(ColumnType(get_column_type(col_ndx)))))
        throw LogicError(LogicError::illegal_type);

    tf::set_link_type(*get_root_table(), col_ndx, link_type); // Throws
}
MemRef BasicArray<T>::slice(std::size_t offset, std::size_t size, Allocator& target_alloc) const
{
    TIGHTDB_ASSERT(is_attached());

    // FIXME: This can be optimized as a single contiguous copy
    // operation.
    BasicArray slice(target_alloc);
    _impl::ShallowArrayDestroyGuard dg(&slice);
    slice.create(); // Throws
    size_t begin = offset;
    size_t end   = offset + size;
    for (size_t i = begin; i != end; ++i) {
        T value = get(i);
        slice.add(value); // Throws
    }
    dg.release();
    return slice.get_mem();
}
Example #15
0
inline void Descriptor::insert_column(size_t col_ndx, DataType type, StringData name, DescriptorRef* subdesc,
                                      bool nullable)
{
    typedef _impl::TableFriend tf;

    if (REALM_UNLIKELY(!is_attached()))
        throw LogicError(LogicError::detached_accessor);
    if (REALM_UNLIKELY(col_ndx > get_column_count()))
        throw LogicError(LogicError::column_index_out_of_range);
    if (REALM_UNLIKELY(tf::is_link_type(ColumnType(type))))
        throw LogicError(LogicError::illegal_type);

    LinkTargetInfo invalid_link;
    tf::insert_column(*this, col_ndx, type, name, invalid_link, nullable); // Throws
    adj_insert_column(col_ndx);
    if (subdesc && type == type_Table)
        *subdesc = get_subdescriptor(col_ndx);
}
bool DFInstanceLinux::attach() {
    TRACE << "STARTING ATTACH" << m_attach_count;
    if (is_attached()) {
        m_attach_count++;
        TRACE << "ALREADY ATTACHED SKIPPING..." << m_attach_count;
        return true;
    }

    if (ptrace(PTRACE_ATTACH, m_pid, 0, 0) == -1) { // unable to attach
        perror("ptrace attach");
        LOGE << "Could not attach to PID" << m_pid;
        return false;
    }

    wait_for_stopped();

    m_attach_count++;
    TRACE << "FINISHED ATTACH" << m_attach_count;
    return m_attach_count > 0;
}
Example #17
0
/** Associate a specific configuration entry to a *local* client (this
 * is the one which used in accepting the connection). Note, that this
 * automatically changes the attachment if there was an old one...
 * @param cptr Client to attach \a aconf to
 * @param aconf ConfItem to attach
 * @return Authorization check result.
 */
enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf)
{
  struct SLink *lp;

  if (is_attached(aconf, cptr))
    return ACR_ALREADY_AUTHORIZED;
  if (IsIllegal(aconf))
    return ACR_NO_AUTHORIZATION;
  if ((aconf->status & (CONF_OPERATOR | CONF_CLIENT)) &&
      ConfLinks(aconf) >= ConfMaxLinks(aconf) && ConfMaxLinks(aconf) > 0)
    return ACR_TOO_MANY_IN_CLASS;  /* Use this for printing error message */
  lp = make_link();
  lp->next = cli_confs(cptr);
  lp->value.aconf = aconf;
  cli_confs(cptr) = lp;
  ++aconf->clients;
  if (aconf->status & CONF_CLIENT_MASK)
    ConfLinks(aconf)++;
  return ACR_OK;
}
Example #18
0
inline void LinkView::set_origin_row_index(std::size_t row_ndx) noexcept
{
    REALM_ASSERT(is_attached());
    m_row_indexes.get_root_array()->set_ndx_in_parent(row_ndx);
}
Example #19
0
inline bool SlabAlloc::nonempty_attachment() const noexcept
{
    return is_attached() && m_data;
}
Example #20
0
inline size_t Descriptor::get_column_count() const noexcept
{
    REALM_ASSERT(is_attached());
    return m_spec->get_public_column_count();
}
Example #21
0
Plugin::~Plugin()
{
	assert(!is_attached());
}
Example #22
0
inline size_t Descriptor::get_column_link_target(size_t column_ndx) const noexcept
{
    REALM_ASSERT(is_attached());
    return m_spec->get_opposite_link_table_ndx(column_ndx);
}
Example #23
0
inline size_t Descriptor::get_column_index(StringData name) const noexcept
{
    REALM_ASSERT(is_attached());
    return m_spec->get_column_index(name);
}
Example #24
0
inline bool Descriptor::is_nullable(size_t ndx) const noexcept
{
    REALM_ASSERT(is_attached());
    return m_spec->get_column_attr(ndx) & col_attr_Nullable;
}
Example #25
0
inline DataType Descriptor::get_column_type(size_t ndx) const noexcept
{
    REALM_ASSERT(is_attached());
    return m_spec->get_public_column_type(ndx);
}
Example #26
0
inline StringData Descriptor::get_column_name(size_t ndx) const noexcept
{
    REALM_ASSERT(is_attached());
    return m_spec->get_column_name(ndx);
}
Example #27
0
inline ConstTableRef Descriptor::get_link_target(size_t col_ndx) const noexcept
{
    REALM_ASSERT(is_attached());
    REALM_ASSERT(is_root());
    return get_root_table()->get_link_target(col_ndx);
}
Example #28
0
inline size_t SlabAlloc::get_baseline() const noexcept
{
    REALM_ASSERT_DEBUG(is_attached());
    return m_baseline;
}
Example #29
0
inline bool Descriptor::operator==(const Descriptor& d) const noexcept
{
    REALM_ASSERT(is_attached());
    REALM_ASSERT(d.is_attached());
    return *m_spec == *d.m_spec;
}
Example #30
0
void
edit_main_rep::notify_page_change () {
  if (is_attached (this)) send_invalidate_all (this);
}