コード例 #1
0
ファイル: FlexMap.cpp プロジェクト: jredmondson/madara
void madara::knowledge::containers::FlexMap::set_name(
    const std::string& var_name, KnowledgeBase& knowledge)
{
  if (context_ != &(knowledge.get_context()) || name_ != var_name)
  {
    context_ = &(knowledge.get_context());

    ContextGuard context_guard(*context_);
    MADARA_GUARD_TYPE guard(mutex_);

    name_ = var_name;

    if (context_->exists(var_name, settings_))
    {
      KnowledgeUpdateSettings keep_local(true);

      variable_ = context_->get_ref(var_name, keep_local);
    }
    else
    {
      // reset variable reference
      variable_ = VariableReference();
    }
  }
}
コード例 #2
0
void
madara::knowledge::containers::NativeDoubleVector::set_name (
  const std::string & var_name,
  ThreadSafeContext & knowledge, int size)
{
  if (context_ != &knowledge || name_ != var_name)
  {
    context_ = &knowledge;

    ContextGuard context_guard (*context_);
    MADARA_GUARD_TYPE guard (mutex_);

    madara_logger_ptr_log (logger::global_logger.get (),
      logger::LOG_MAJOR,
      "NativeDoubleVector::set_name: setting name to %s\n",
      var_name.c_str ());

    name_ = var_name;
    
    vector_ = knowledge.get_ref (var_name, settings_);

    if (size > 0)
      resize (size_t (size));
  }
}
コード例 #3
0
std::string
madara::knowledge::containers::IntegerVector::get_debug_info (void)
{
  std::stringstream result;

  result << "Integer Vector: ";

  if (context_)
  {
    ContextGuard context_guard (*context_);
    MADARA_GUARD_TYPE guard (mutex_);
    size_t elements = vector_.size ();

    result << this->name_;
    result << " [" << elements << "]";
    result << " = [";

    if (elements > 0)
    {
      result << context_->get (vector_[0]).to_string ();

      for (size_t index = 1; index < elements; ++index)
      {
        result << ", " << context_->get (vector_[index]).to_string ();
      }
    }

    result << "]";
  }

  return result.str ();
}
コード例 #4
0
ファイル: FlexMap.cpp プロジェクト: jredmondson/madara
bool madara::knowledge::containers::FlexMap::exists(
    const std::string& key, bool first_level_key) const
{
  bool result(false);

  if (context_)
  {
    ContextGuard context_guard(*context_);
    MADARA_GUARD_TYPE guard(mutex_);

    // check if the key exists
    std::string exact_key = name_ + delimiter_ + key;
    result = context_->exists(exact_key);

    if (!result && first_level_key)
    {
      std::vector<std::string> curkeys;
      keys(curkeys);

      std::vector<std::string>::iterator found;

      // look for the key in the sub keys
      found = std::find(curkeys.begin(), curkeys.end(), key);

      result = found != curkeys.end();
    }
  }

  return result;
}
コード例 #5
0
int
madara::knowledge::containers::NativeDoubleVector::set (
  size_t index,
  type value, 
  const KnowledgeUpdateSettings & settings)
{
  int result = -1;

  if (context_)
  {
    ContextGuard context_guard (*context_);
    MADARA_GUARD_TYPE guard (mutex_);

    madara_logger_ptr_log (logger::global_logger.get (),
      logger::LOG_MAJOR,
      "NativeDoubleVector::set: %s: setting element [%d] "
      "to %f with custom settings\n",
      this->name_.c_str (),
      (int)index, value);

    result = context_->set_index (vector_, index, value, settings);
  }
  
  return result;
}
コード例 #6
0
ファイル: FlexMap.cpp プロジェクト: jredmondson/madara
size_t madara::knowledge::containers::FlexMap::size(
    bool first_level_keys_only) const
{
  ContextGuard context_guard(*context_);
  MADARA_GUARD_TYPE guard(mutex_);

  size_t result(0);

  if (!first_level_keys_only)
  {
    // get all children
    KnowledgeBase knowledge;
    knowledge.facade_for(*context_);
    Map map(name_, knowledge, settings_, delimiter_);

    result = map.size();
  }
  else
  {
    // use the context's specialized mapping feature
    std::vector<std::string> next_keys;
    std::map<std::string, madara::knowledge::KnowledgeRecord> all_record_vars;
    context_->to_map(name_, delimiter_, "", next_keys, all_record_vars, true);

    result = next_keys.size();
  }

  return result;
}
コード例 #7
0
size_t
madara::knowledge::containers::NativeDoubleVector::size (void) const
{
  ContextGuard context_guard (*context_);
  MADARA_GUARD_TYPE guard (mutex_);

  return context_->get (vector_, settings_).size ();
}
コード例 #8
0
void
madara::knowledge::containers::IntegerVector::modify (size_t index)
{
  if (context_ && name_ != "" && index < vector_.size ())
  {
    ContextGuard context_guard (*context_);
    context_->mark_modified (vector_[index]);
  }
}
コード例 #9
0
ファイル: FlexMap.cpp プロジェクト: jredmondson/madara
void madara::knowledge::containers::FlexMap::update_variable(void) const
{
  if (context_ && name_ != "")
  {
    ContextGuard context_guard(*context_);
    MADARA_GUARD_TYPE guard(mutex_);

    KnowledgeUpdateSettings keep_local(true);

    variable_ = context_->get_ref(name_, keep_local);
  }
}
コード例 #10
0
ファイル: FlexMap.cpp プロジェクト: jredmondson/madara
void madara::knowledge::containers::FlexMap::to_container(String& target) const
{
  if (context_)
  {
    ContextGuard context_guard(*context_);
    MADARA_GUARD_TYPE guard(mutex_);

    // get all children
    KnowledgeBase knowledge;
    knowledge.facade_for(*context_);

    target.set_name(name_, knowledge);
  }
}
コード例 #11
0
void
madara::knowledge::containers::IntegerVector::set_quality (
  size_t index,
  uint32_t quality,
  const KnowledgeReferenceSettings & settings)
{
  if (index < vector_.size () && context_)
  {
    ContextGuard context_guard (*context_);
    MADARA_GUARD_TYPE guard (mutex_);
    context_->set_quality (vector_[index].get_name (), quality,
      true, settings);
  }
}
コード例 #12
0
ファイル: FlexMap.cpp プロジェクト: jredmondson/madara
/**
 * Checks if the value in the record is false (0)
 * @return  true if value is false
 **/
bool madara::knowledge::containers::FlexMap::is_false(void) const
{
  ContextGuard context_guard(*context_);
  bool result(true);

  KnowledgeUpdateSettings keep_local(true);

  if (!variable_.is_valid())
  {
    result = context_->get(variable_, keep_local).is_true();
  }

  return result;
}
コード例 #13
0
void
madara::knowledge::containers::IntegerVector::set_delimiter (
const std::string & delimiter)
{
  delimiter_ = delimiter;
  if (context_)
  {
    ContextGuard context_guard (*context_);
    MADARA_GUARD_TYPE guard (mutex_);

    vector_.clear ();
    resize (-1);
  }
}
コード例 #14
0
madara::knowledge::containers::IntegerVector::type
madara::knowledge::containers::IntegerVector::inc (
size_t index)
{
  type result (0);

  if (index < vector_.size () && context_)
  {
    ContextGuard context_guard (*context_);
    MADARA_GUARD_TYPE guard (mutex_);
    result = context_->inc (vector_[index], settings_).to_integer ();
  }

  return result;
}
コード例 #15
0
bool
madara::knowledge::containers::IntegerVector::exists (
  size_t index) const
{
  bool result (false);

  if (index < vector_.size () && context_)
  {
    ContextGuard context_guard (*context_);
    MADARA_GUARD_TYPE guard (mutex_);
    result = context_->exists (vector_[index]);
  }

  return result;
}
コード例 #16
0
  void NormalizationSubRenderer::
  render_sub_pass(Pipeline& pipe, PipelinePassDescription const& desc,
  				  gua::plod_shared_resources& shared_resources,
  				  std::vector<node::Node*>& sorted_models,
                  std::unordered_map<node::PLodNode*, std::unordered_set<lamure::node_t> >& nodes_in_frustum_per_model,
                  lamure::context_t context_id,
  				  lamure::view_t lamure_view_id
  				  ) {


  	RenderContext const& ctx(pipe.get_context());
    auto& target = *pipe.current_viewstate().target;

    scm::gl::context_all_guard context_guard(ctx.render_context);

	  _check_for_shader_program();

	  assert(shader_program_);


    if(!fullscreen_quad_) {
      fullscreen_quad_.reset(new scm::gl::quad_geometry(ctx.render_device, 
                                                scm::math::vec2(-1.0f, -1.0f), scm::math::vec2(1.0f, 1.0f )));
    }
    bool write_depth = true;
    target.bind(ctx, write_depth);



    std::string const gpu_query_name_normalization_pass = "******" + std::to_string(pipe.current_viewstate().viewpoint_uuid) + " / PLodRenderer::NormalizationPass";
    pipe.begin_gpu_query(ctx, gpu_query_name_normalization_pass);


    shader_program_->use(ctx);
    {

      _upload_normalization_pass_uniforms(ctx, shared_resources);
      
      ctx.render_context->apply();

      fullscreen_quad_->draw(ctx.render_context);
    }
    shader_program_->unuse(ctx);

    target.unbind(ctx);

    pipe.end_gpu_query(ctx, gpu_query_name_normalization_pass);
  }
コード例 #17
0
madara::knowledge::KnowledgeRecord
madara::knowledge::containers::IntegerVector::to_record (
  size_t index) const
{
  knowledge::KnowledgeRecord result;
  KnowledgeUpdateSettings keep_local (true);

  if (index < vector_.size () && context_)
  {
    ContextGuard context_guard (*context_);
    MADARA_GUARD_TYPE guard (mutex_);
    result = context_->get (vector_[index], keep_local);
  }

  return result;
}
コード例 #18
0
int
madara::knowledge::containers::IntegerVector::set (
  size_t index,
  const type & value)
{
  int result = -1;
  
  if (index < vector_.size () && context_)
  {
    ContextGuard context_guard (*context_);
    MADARA_GUARD_TYPE guard (mutex_);
    result = context_->set (vector_[index], value, settings_);
  }
  
  return result;
}
コード例 #19
0
ファイル: FlexMap.cpp プロジェクト: jredmondson/madara
void madara::knowledge::containers::FlexMap::set_quality(
    uint32_t quality, const KnowledgeReferenceSettings& settings)
{
  if (context_)
  {
    ContextGuard context_guard(*context_);
    MADARA_GUARD_TYPE guard(mutex_);

    if (!variable_.is_valid())
    {
      update_variable();
    }

    context_->set_quality(name_, quality, true, settings);
  }
}
コード例 #20
0
ファイル: FlexMap.cpp プロジェクト: jredmondson/madara
madara::knowledge::containers::FlexMap madara::knowledge::containers::FlexMap::
operator[](const std::string& key)
{
  FlexMap map(settings_, delimiter_);

  if (key != "" && context_)
  {
    ContextGuard context_guard(*context_);
    MADARA_GUARD_TYPE guard(mutex_);

    KnowledgeBase knowledge;
    knowledge.facade_for(*context_);
    map.set_name(name_ + delimiter_ + key, knowledge);
  }

  return map;
}
コード例 #21
0
void
madara::knowledge::containers::NativeDoubleVector::transfer_to (
  NativeDoubleVector & other)
{
  if (context_ && other.context_)
  {
    ContextGuard context_guard (*context_);
    ContextGuard other_context_guard (*other.context_);
    MADARA_GUARD_TYPE guard (mutex_);
    MADARA_GUARD_TYPE guard2 (other.mutex_);

    madara_logger_ptr_log (logger::global_logger.get (),
      logger::LOG_MAJOR,
      "NativeDoubleVector::transfer_to: %s transfering to %s\n",
      this->name_.c_str (),
      other.name_.c_str ());

    size_t other_size = other.size ();
    size_t this_size = this->size ();

    if (this_size > 0)
    {
      madara_logger_ptr_log (logger::global_logger.get (),
        logger::LOG_MINOR,
        "NativeDoubleVector::transfer_to: %s has elements\n",
        this->name_.c_str ());

      size_t size = other_size + this_size;
      other.resize ((int)size);

      knowledge::KnowledgeRecord rhs (other.context_->get (other.vector_));
      knowledge::KnowledgeRecord lhs (context_->get (vector_));

      rhs.set_index (size - 1, lhs.retrieve_index (this_size - 1).to_double ());

      for (size_t i = 0, j = other_size; i < this_size - 1; ++i, ++j)
      {
        rhs.set_index (other_size, lhs.retrieve_index (i).to_double ());
      }

      other.context_->set (other.vector_, rhs, other.settings_);

      this->resize (0);
    }
  }
}
コード例 #22
0
void
madara::knowledge::containers::IntegerVector::copy_to (
std::vector <type> & target) const
{
  if (context_)
  {
    ContextGuard context_guard (*context_);
    MADARA_GUARD_TYPE guard (mutex_);

    target.resize (vector_.size ());

    for (size_t i = 0; i < vector_.size (); ++i)
    {
      target[i] = (*this)[i];
    }
  }
}
コード例 #23
0
ファイル: FlexMap.cpp プロジェクト: jredmondson/madara
void madara::knowledge::containers::FlexMap::clear(void)
{
  if (context_)
  {
    ContextGuard context_guard(*context_);
    MADARA_GUARD_TYPE guard(mutex_);

    // use the Map container, which already has clear implemented
    KnowledgeBase knowledge;
    knowledge.facade_for(*context_);
    Map map(name_, knowledge, settings_, delimiter_);

    map.clear();

    context_->delete_variable(name_, settings_);
  }
}
コード例 #24
0
bool
madara::knowledge::containers::IntegerVector::is_true (void) const
{
  bool result (false);

  madara_logger_log (context_->get_logger (), logger::LOG_MAJOR,
    "IntegerVector::is_true: Checking for truth\n");

  if (context_)
  {
    ContextGuard context_guard (*context_);
    MADARA_GUARD_TYPE guard (mutex_);

    result = true;

    madara_logger_log (context_->get_logger (), logger::LOG_MINOR,
      "IntegerVector::is_true: context was not null. Result changed to %d\n",
      (int)result);

    for (size_t index = 0; index < vector_.size (); ++index)
    {

      madara_logger_log (context_->get_logger (), logger::LOG_DETAILED,
        "IntegerVector::is_true: checking index %d, is_false of %d. \n",
        (int)result, (int)context_->get (vector_[index]).is_false ());

      if (context_->get (vector_[index]).is_false ())
      {
        madara_logger_log (context_->get_logger (), logger::LOG_MAJOR,
          "IntegerVector::is_true: result is false, breaking\n");

        result = false;
        break;
      }
    }

    if (vector_.size () == 0)
      result = false;
  }

  madara_logger_log (context_->get_logger (), logger::LOG_MAJOR,
    "IntegerVector::is_true: final result is %d\n", (int)result);

  return result;
}
コード例 #25
0
void
madara::knowledge::containers::NativeDoubleVector::modify (void)
{
  madara_logger_ptr_log (logger::global_logger.get (),
    logger::LOG_MAJOR,
    "NativeDoubleVector::modify called\n");

  ContextGuard context_guard (*context_);
  if (context_ && name_ != "")
  {
    madara_logger_ptr_log (logger::global_logger.get (),
      logger::LOG_MAJOR,
      "NativeDoubleVector::modify: context is valid. Marking %s.\n",
      this->name_.c_str ());

    context_->mark_modified (vector_);
  }
}
コード例 #26
0
void
madara::knowledge::containers::IntegerVector::set_name (
  const std::string & var_name,
  Variables & knowledge, int size)
{
  if (context_ != knowledge.get_context () || name_ != var_name)
  {
    context_ = knowledge.get_context ();

    ContextGuard context_guard (*context_);
    MADARA_GUARD_TYPE guard (mutex_);

    name_ = var_name;

    vector_.clear ();
    resize (size);
  }
}
コード例 #27
0
void
madara::knowledge::containers::IntegerVector::set_name (
  const std::string & var_name,
  ThreadSafeContext & knowledge, int size)
{
  if (context_ != &knowledge || name_ != var_name)
  {
    context_ = &knowledge;

    ContextGuard context_guard (*context_);
    MADARA_GUARD_TYPE guard (mutex_);

    name_ = var_name;

    vector_.clear ();
    resize (size);
  }
}
コード例 #28
0
void
madara::knowledge::containers::IntegerVector::push_back (type value)
{
  if (context_ && name_ != "")
  {
    ContextGuard context_guard (*context_);
    MADARA_GUARD_TYPE guard (mutex_);

    if (!size_.is_valid ())
    {
      size_ = get_size_ref ();
    }

    size_t i = size ();
    resize ((int)i + 1);
    set (i, value);
  }
}
コード例 #29
0
void
madara::knowledge::containers::NativeDoubleVector::set_quality (
  size_t index,
  uint32_t quality,
  const KnowledgeReferenceSettings & settings)
{
  if (context_)
  {
    ContextGuard context_guard (*context_);
    MADARA_GUARD_TYPE guard (mutex_);

    madara_logger_ptr_log (logger::global_logger.get (),
      logger::LOG_MAJOR,
      "NativeDoubleVector::set: %s: setting quality of knowledge\n",
      this->name_.c_str ());

    context_->set_quality (name_, quality, true, settings);
  }
}
コード例 #30
0
void
madara::knowledge::containers::NativeDoubleVector::push_back (
  type value)
{
  if (context_ && name_ != "")
  {
    madara_logger_ptr_log (logger::global_logger.get (),
      logger::LOG_MAJOR,
      "NativeDoubleVector::push_back: %s: valid context, pushing.\n",
      this->name_.c_str ());

    ContextGuard context_guard (*context_);
    MADARA_GUARD_TYPE guard (mutex_);

    size_t i = size ();
    resize ((int)i + 1);
    set (i, value);
  }
}