Beispiel #1
0
OptionalString MetaAlert::get(const std::string &path) const
{
  GlobalLock lock;
  try
  {
    typedef StrFc::Params<StrFc::DefaultHandleMap, CallbackHandle> Params;
    // compute response
    CallbackHandle cb;
    Params         p(StrFc::Path(path), cb);
    StrFc::MainDispatcher::process(node_, p);
    // return computed value, if set
    if(cb.out_.get()!=NULL)
    {
      LOGMSG_DEBUG_S(log_)<<"element '"<<path<<"' of node "<<node_->getMetaAlert()->getID().get()<<" is "<<cb.out_.get();
      return cb.out_;
    }
    // by default return NULL
    LOGMSG_DEBUG_S(log_)<<"element '"<<path<<"' of node "<<node_->getMetaAlert()->getID().get()<<" returns NULL";
    return OptionalString();
  }
  catch(const StrFc::Exception &ex)
  {
    LOGMSG_ERROR_S(log_)<<"facade error accessing element '"<<path<<"': "<<ex.what();
  }
  catch(const std::exception &ex)
  {
    LOGMSG_ERROR_S(log_)<<"generic error accessing element '"<<path<<"': "<<ex.what();
  }
  // on error return empty string
  return OptionalString();
}
Beispiel #2
0
 OptionalString ListAddTokenCommand::getNewStringToken()
 {
     std::string token;
     if(!m_func.getValueA<std::string>(token, m_sharedCache)) {
         LiteralString literal;
         if(m_func.getValueA<LiteralString>(literal, m_sharedCache)) {
             return OptionalString(literal.literal);
         }
     } else {
         auto result = m_sharedCache->getVar<std::string>(token, Type::String);
         if(result) {
             return OptionalString(*result);
         }
     }
     setLastErrorMessage("list_add: problem getting new token");
     return OptionalString();
 }