您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ ACE_TString类代码示例

51自学网 2021-06-03 12:03:15
  C++
这篇教程C++ ACE_TString类代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中ACE_TString的典型用法代码示例。如果您正苦于以下问题:C++ ACE_TString类的具体用法?C++ ACE_TString怎么用?C++ ACE_TString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

在下文中一共展示了ACE_TString类的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: GetStringDefault

std::string GetStringDefault(const char* name, const std::string &def){    ACE_TString val;    return GetValueHelper(name, val) ? val.c_str() : def;};
开发者ID:S-proyect,项目名称:Emu-S,代码行数:5,


示例2: if

  bool  XML_Saver::open(const ACE_TString & base_name, size_t backup_count)  {    this->base_name_ = base_name;    this->backup_count_ = backup_count;    if (base_name ==  ACE_TEXT("cout"))    {      this->output_ = stdout;      this->close_out_ = false;    }    else if (base_name ==  ACE_TEXT("cerr"))    {      this->output_ = stderr;      this->close_out_ = false;    }    else    {      ACE_TString file_name = base_name;      file_name += ACE_TEXT(".new");      this->output_ = ACE_OS::fopen (file_name.c_str(), ACE_TEXT("wb"));      if (this->output_) {        this->close_out_ = true;      } else {        ORBSVCS_ERROR ((LM_ERROR,          ACE_TEXT ("(%P|%t) XML_Saver unable to open %s/n"),            base_name.c_str()));      }    }    if (this->output_ != 0)    {      FILE * const out = this->output_;      ACE_OS::fprintf (out, "<?xml version=/"1.0/"?>/n");      try      {        bool changed = true;        NVPList attrs;        ACE_Time_Value const now = ACE_High_Res_Timer::gettimeofday();        ACE_UINT64 nowus = now.usec();        static const ACE_UINT64 USECSPERSEC = 1000 * 1000;        ACE_UINT64 const tmpus = now.sec();        nowus += tmpus * USECSPERSEC;        ACE_TCHAR nowusstr[128];        ACE_OS::sprintf(nowusstr, ACE_UINT64_FORMAT_SPECIFIER, nowus);        attrs.push_back(NVP("version", "1.0"));        if (this->timestamp_)        {          attrs.push_back(NVP("timestamp", ACE_TEXT_ALWAYS_CHAR(nowusstr)));        }        this->begin_object(0, "notification_service", attrs, changed);      }      catch (const CORBA::Exception& ex)      {        ex._tao_print_exception (          ACE_TEXT (            "(%P|%t) XML_Saver Unknown exception/n"));        if (this->close_out_ && this->output_ != 0)          {            (void) ACE_OS::fclose (this->output_);          }        this->output_ = 0;      }    }    return this->output_ != 0;  }
开发者ID:asdlei00,项目名称:ACE,代码行数:72,


示例3: GetFloatDefault

float GetFloatDefault(const char* name, float def){    ACE_TString val;    return GetValueHelper(name, val) ? (float)atof(val.c_str()) : def;};
开发者ID:S-proyect,项目名称:Emu-S,代码行数:5,


示例4: ACE_TRACE

intACE_DLL_Handle::open (const ACE_TCHAR *dll_name,                      int open_mode,                      ACE_SHLIB_HANDLE handle,                      ERROR_STACK *errors){  ACE_TRACE ("ACE_DLL_Handle::open");  ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0));  if (this->dll_name_)    {      // Once dll_name_ has been set, it can't be changed..      if (ACE_OS::strcmp (this->dll_name_, dll_name) != 0)        {          if (ACE::debug ())            ACELIB_ERROR ((LM_ERROR,                        ACE_TEXT ("ACE (%P|%t) DLL_Handle::open: error, ")                        ACE_TEXT ("tried to reopen %s with name %s/n"),                        this->dll_name_,                        dll_name));          return -1;        }    }  else    this->dll_name_ = ACE::strnew (dll_name);  if (!this->open_called_)    this->open_called_ = 1;  // If it hasn't been loaded yet, go ahead and do that now.  if (this->handle_ == ACE_SHLIB_INVALID_HANDLE)    {      if (handle)        this->handle_ = handle;      else        {          /*          ** Get the set of names to try loading. We need to do this to          ** properly support the ability for a user to specify a simple,          ** unadorned name (for example, "ACE") that will work across          ** platforms. We apply platform specifics to get a name that will          ** work (e.g. libACE, ACEd.dll, ACE.dll, etc.) We rely on the          ** underlying dlopen() implementation to "Do The Right Thing" in          ** terms of using relative paths, LD_LIBRARY_PATH, system security          ** rules, etc. except when ACE_MUST_HELP_DLOPEN_SEARCH_PATH is set.          ** If it is set, then ACE::ldfind() scans the configured path          ** looking for a match on the name and prefix/suffix applications.          ** NOTE: having ACE scan for a file and then pass a fully-qualified          ** pathname to dlopen() is a potential security hole; therefore,          ** do not use ACE_MUST_HELP_DLOPEN_SEARCH_PATH unless necessary          ** and only after considering the risks.          */          ACE_Array<ACE_TString> dll_names;          dll_names.max_size (10);    // Decent guess to avoid realloc later#if defined (ACE_MUST_HELP_DLOPEN_SEARCH_PATH)          // Find out where the library is          ACE_TCHAR dll_pathname[MAXPATHLEN + 1];          // Transform the pathname into the appropriate dynamic link library          // by searching the ACE_LD_SEARCH_PATH.          ACE::ldfind (dll_name,                       dll_pathname,                       (sizeof dll_pathname / sizeof (ACE_TCHAR)));          ACE_TString dll_str (dll_pathname);          dll_names.size (1);          dll_names.set (dll_str, 0);#else          this->get_dll_names (dll_name, dll_names);#endif          ACE_Array_Iterator<ACE_TString> name_iter (dll_names);          ACE_TString *name = 0;          while (name_iter.next (name))            {              // The ACE_SHLIB_HANDLE object is obtained.              this->handle_ = ACE_OS::dlopen (name->c_str (),                                              open_mode);              if (ACE::debug ())                {                  ACE_TString err;                  ACELIB_DEBUG ((LM_DEBUG,                              ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ")                              ACE_TEXT ("(/"%s/", 0x%x) -> %s: %s/n"),                              name->c_str (),                              open_mode,                              ((this->handle_ != ACE_SHLIB_INVALID_HANDLE)                               ? ACE_TEXT ("succeeded")                               : ACE_TEXT ("failed")),                              this->error (err).c_str()));                }              if (this->handle_ != ACE_SHLIB_INVALID_HANDLE)   // Good one?                break;              // If errno is ENOENT we just skip over this one,              // anything else - like an undefined symbol, for              // instance must be flagged here or the next error will//.........这里部分代码省略.........
开发者ID:INMarkus,项目名称:ATCD,代码行数:101,


示例5: ACE_TEXT

intACE_Ini_ImpExp::export_section (const ACE_Configuration_Section_Key& section,                                const ACE_TString& path,                                FILE* out){    // don't export the root    if (path.length ())    {        // Write out the section header        ACE_TString header = ACE_TEXT ("[");        header += path;        header += ACE_TEXT ("]/n");        if (ACE_OS::fputs (header.fast_rep (), out) < 0)            return -1;        // Write out each value        int index = 0;        ACE_TString name;        ACE_Configuration::VALUETYPE type;        ACE_TString line;        ACE_TCHAR int_value[32];        ACE_TCHAR bin_value[3];        void* binary_data;        size_t binary_length;        ACE_TString string_value;        while (!config_.enumerate_values (section, index, name, type))        {            line = name + ACE_TEXT ("=");            switch (type)            {            case ACE_Configuration::INTEGER:            {                u_int value;                if (config_.get_integer_value (section, name.fast_rep (), value))                    return -2;                ACE_OS::sprintf (int_value, ACE_TEXT ("%08x"), value);                line += int_value;                break;            }            case ACE_Configuration::STRING:            {                if (config_.get_string_value (section,                                              name.fast_rep (),                                              string_value))                    return -2;                line += string_value;                break;            }#ifdef _WIN32            case ACE_Configuration::INVALID:                break;  // JDO added break.  Otherwise INVALID is processed                // like BINARY. If that's correct, please remove the                // break and these comments#endif            case ACE_Configuration::BINARY:            {                // not supported yet - maybe use BASE64 codeing?                if (config_.get_binary_value (section,                                              name.fast_rep (),                                              binary_data,                                              binary_length))                    return -2;                line += ACE_TEXT ("/"");                unsigned char* ptr = (unsigned char*)binary_data;                while (binary_length)                {                    if (ptr != binary_data)                    {                        line += ACE_TEXT (",");                    }                    ACE_OS::sprintf (bin_value, ACE_TEXT ("%02x"), *ptr);                    line += bin_value;                    --binary_length;                    ++ptr;                }                line += ACE_TEXT ("/"");                delete [] (char *) binary_data;                break;            }            default:                return -3;            }// end switch on type            line += ACE_TEXT ("/n");            if (ACE_OS::fputs (line.fast_rep (), out) < 0)                return -4;            ++index;        }// end while enumerating values    }    // Export all sub sections    int index = 0;    ACE_TString name;    ACE_Configuration_Section_Key sub_key;    ACE_TString sub_section;    while (!config_.enumerate_sections (section, index, name))    {        ACE_TString sub_section (path);        if (path.length ())            sub_section += ACE_TEXT ("//");        sub_section += name;        if (config_.open_section (section, name.fast_rep (), 0, sub_key))//.........这里部分代码省略.........
开发者ID:wow4all,项目名称:SkyfireBG,代码行数:101,


示例6: print_context

// Print an context with <name> and <parent>static voidprint_context (ACE_Registry::Naming_Context &parent,               const ACE_TString &name,               u_long indentation){  // Set indentation  indent (indentation);  cout << name << endl;  ACE_Registry::Naming_Context child_context;  // Find child context  int result = parent.resolve_context (name,                                       child_context,                                       KEY_READ);  if (result != 0)    ACE_ERROR ((LM_ERROR, "%s %s/n", "ACE_Registry::Naming_Context::resolve_context failed for:", name.c_str ()));  else    {      // Print contents of the child      result = ::print_naming_context (child_context,                                       indentation + INDENTATION_LEVEL);      if (result != 0)        ACE_ERROR ((LM_ERROR, "%p/n", "print_naming_context failed"));    }}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:26,


示例7: DBG_ENTRY

intSimpleDataWriter::run(SimplePublisher* publisher){  DBG_ENTRY("SimpleDataWriter","run");  VDBG((LM_DEBUG, "(%P|%t) DBG:   "             "Build the DataSampleElementList to contain one element - "             "our 'Hello World' string./n"));  // We just send one message.  // This is what goes in the "Data Block".  ACE_TString data = "Hello World!";  // Now we can create the DataSampleHeader struct and set its fields.  TAO::DCPS::DataSampleHeader header;  // The +1 makes the null terminator ('/0') get placed into the block.  header.message_length_ = data.length() + 1;  header.message_id_ = 1;  header.sequence_ = 0;  // TMB - Compiler no longer likes the next line...  source_timestamp_ is gone.  //header.source_timestamp_ = ACE_OS::gettimeofday().msec();  header.publication_id_ = this->pub_id_;  // The DataSampleHeader is what goes in the "Header Block".  ACE_Message_Block* header_block = new ACE_Message_Block                                                (header.max_marshaled_size());  header_block << header;  // The +1 makes the null terminator ('/0') get placed into the block.  ACE_Message_Block* data_block = new ACE_Message_Block(data.length() + 1);  data_block->copy(data.c_str());  // Chain the "Data Block" to the "Header Block"  header_block->cont(data_block);  // Create the DataSampleListElement now.  TAO::DCPS::DataSampleListElementAllocator allocator(3);  TAO::DCPS::TransportSendElementAllocator trans_allocator(3, sizeof (TAO::DCPS::TransportSendElement));  TAO::DCPS::DataSampleListElement* element;  ACE_NEW_MALLOC_RETURN(element,           static_cast<TAO::DCPS::DataSampleListElement*> (allocator.malloc(sizeof (TAO::DCPS::DataSampleListElement))),           TAO::DCPS::DataSampleListElement(this->pub_id_, this, 0, &trans_allocator),           1);  // The Sample Element will hold on to the chain of blocks (header + data).  element->sample_ = header_block;  // Set up the DataSampleList  TAO::DCPS::DataSampleList samples;  samples.head_ = element;  samples.tail_ = element;  samples.size_ = 1;  VDBG((LM_DEBUG, "(%P|%t) DBG:   "             "Ask the publisher to send the DataSampleList (samples)./n"));  publisher->send_samples(samples);  VDBG((LM_DEBUG, "(%P|%t) DBG:   "             "The Publisher has finished sending the samples./n"));  return 0;}
开发者ID:svn2github,项目名称:OpenDDS,代码行数:67,


示例8: ACE_NEW_RETURN

CORBA::ExtValueDef::ExtFullValueDescription *TAO_ExtValueDef_i::describe_ext_value_i (  ){  CORBA::ExtValueDef::ExtFullValueDescription *fv_desc = 0;  ACE_NEW_RETURN (fv_desc,                  CORBA::ExtValueDef::ExtFullValueDescription,                  0);  CORBA::ExtValueDef::ExtFullValueDescription_var retval = fv_desc;  ACE_TString holder;  this->repo_->config ()->get_string_value (this->section_key_,                                            "name",                                            holder);  fv_desc->name = holder.fast_rep ();  this->repo_->config ()->get_string_value  (this->section_key_,                                             "id",                                             holder);  fv_desc->id = holder.fast_rep ();  CORBA::ULong val = 0;  this->repo_->config ()->get_integer_value (this->section_key_,                                             "is_abstract",                                             val);  fv_desc->is_abstract = static_cast<CORBA::Boolean> (val);  this->repo_->config ()->get_integer_value (this->section_key_,                                             "is_custom",                                             val);  fv_desc->is_custom = static_cast<CORBA::Boolean> (val);  this->repo_->config ()->get_string_value (this->section_key_,                                            "container_id",                                            holder);  fv_desc->defined_in = holder.fast_rep ();  this->repo_->config ()->get_string_value (this->section_key_,                                            "version",                                            holder);  fv_desc->version = holder.fast_rep ();  // Operations.  fv_desc->operations.length (0);  ACE_Configuration_Section_Key ops_key;  int status =    this->repo_->config ()->open_section (this->section_key_,                                          "ops",                                          0,                                          ops_key);  CORBA::ULong count = 0;  CORBA::ULong param_count = 0;  char *stringified = 0;  CORBA::ULong i = 0;  CORBA::ULong j = 0;  TAO_IDLType_i *idl_type = 0;  CORBA::Object_var obj;  ACE_Configuration_Section_Key params_key, excepts_key, except_def_key;  if (status == 0)    {      this->repo_->config ()->get_integer_value (ops_key,                                                 "count",                                                 count);      fv_desc->operations.length (count);      ACE_Configuration_Section_Key op_key, result_key, contexts_key;      for (i = 0; i < count; ++i)        {          stringified = TAO_IFR_Service_Utils::int_to_string (i);          this->repo_->config ()->open_section (ops_key,                                                stringified,                                                0,                                                op_key);          this->repo_->config ()->get_string_value (op_key,                                                    "name",                                                    holder);          fv_desc->operations[i].name = holder.fast_rep ();          this->repo_->config ()->get_string_value (op_key,                                                    "id",                                                    holder);          fv_desc->operations[i].id = holder.fast_rep ();          this->repo_->config ()->get_string_value (this->section_key_,                                                    "id",                                                    holder);          fv_desc->operations[i].defined_in = holder.fast_rep ();          this->repo_->config ()->get_string_value (op_key,                                                    "result",                                                    holder);          idl_type =            TAO_IFR_Service_Utils::path_to_idltype (holder,                                                    this->repo_);          fv_desc->operations[i].result =            idl_type->type_i ();          this->repo_->config ()->get_integer_value (op_key,                                                     "mode",                                                     val);          fv_desc->operations[i].mode = static_cast<CORBA::OperationMode> (val);          CORBA::TCKind kind =            fv_desc->operations[i].result->kind ();//.........这里部分代码省略.........
开发者ID:OspreyHub,项目名称:ATCD,代码行数:101,


示例9: ACE_NEW_RETURN

CORBA::InterfaceAttrExtension::ExtFullInterfaceDescription *TAO_InterfaceAttrExtension_i::describe_ext_interface_i (){    CORBA::InterfaceAttrExtension::ExtFullInterfaceDescription *fifd = 0;    ACE_NEW_RETURN (fifd,                    CORBA::InterfaceAttrExtension::ExtFullInterfaceDescription,                    0);    CORBA::InterfaceAttrExtension::ExtFullInterfaceDescription_var retval =        fifd;    ACE_TString holder;    this->repo_->config ()->get_string_value (this->section_key_,            "name",            holder);    fifd->name = holder.fast_rep ();    this->repo_->config ()->get_string_value (this->section_key_,            "id",            holder);    fifd->id = holder.fast_rep ();    this->repo_->config ()->get_string_value (this->section_key_,            "container_id",            holder);    fifd->defined_in = holder.fast_rep ();    this->repo_->config ()->get_string_value (this->section_key_,            "version",            holder);    fifd->version = holder.fast_rep ();    CORBA::ULong i = 0;    CORBA::ULong j = 0;    ACE_Unbounded_Queue<ACE_Configuration_Section_Key> key_queue;    // Store our section key for later restoration after we have    // traversed entries for inherited interfaces.    ACE_Configuration_Section_Key key_holder = this->section_key_;    // Operations    TAO_InterfaceDef_i iface (this->repo_);    iface.section_key (this->section_key_);    iface.inherited_operations (key_queue);    // Restore our original section key.    //   I am not sure this is needed but it will not hurt.    this->section_key (key_holder);    ACE_Configuration_Section_Key ops_key, op_key;    int status =        this->repo_->config ()->open_section (this->section_key_,                "ops",                0,                ops_key);    CORBA::ULong count = 0;    if (status == 0)    {        this->repo_->config ()->get_integer_value (ops_key,                "count",                count);        for (j = 0; j < count; ++j)        {            char *stringified = TAO_IFR_Service_Utils::int_to_string (j);            status =                this->repo_->config ()->open_section (ops_key,                        stringified,                        0,                        op_key);            if (status == 0)            {                key_queue.enqueue_tail (op_key);            }        }    }    CORBA::ULong size = static_cast<CORBA::ULong> (key_queue.size ());    fifd->operations.length (size);    for (i = 0; i < size; ++i)    {        ACE_Configuration_Section_Key key;        key_queue.dequeue_head (key);        TAO_OperationDef_i op (this->repo_);        op.section_key (key);        op.make_description (fifd->operations[i]);    }    // Restore our original section key.    //   It may have been overwritten by a superclass key as part of the    //   make_description() call.    this->section_key (key_holder);//.........这里部分代码省略.........
开发者ID:svn2github,项目名称:ACE-Middleware,代码行数:101,


示例10: ACE_TRACE

intACE_DLL_Handle::open (const ACE_TCHAR *dll_name,                      int open_mode,                      ACE_SHLIB_HANDLE handle){  ACE_TRACE ("ACE_DLL_Handle::open");  ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0));  //ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("dll_name: %s; open_mode: %d /n"),  //            dll_name,  //            open_mode));  if (this->dll_name_)    {      // Once dll_name_ has been set, it can't be changed..      if (ACE_OS::strcmp (this->dll_name_, dll_name) != 0)        {          if (ACE::debug ())            ACE_ERROR ((LM_ERROR,                        ACE_LIB_TEXT ("ACE_DLL_Handle::open: error, ")                        ACE_LIB_TEXT ("tried to reopen %s with name %s/n"),                        this->dll_name_,                        dll_name));          return -1;        }    }  else    this->dll_name_ = ACE::strnew (dll_name);  if (!this->open_called_)    this->open_called_ = 1;  // If it hasn't been loaded yet, go ahead and do that now.  if (this->handle_ == ACE_SHLIB_INVALID_HANDLE)    {      if (handle)        this->handle_ = handle;      else        {          if (ACE::debug ())            ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("ACE_DLL_Handle::open: calling dlopen on ")                        ACE_LIB_TEXT ("/"%s/"/n"), dll_name));          /*          ** Get the set of names to try loading. We need to do this to          ** properly support the ability for a user to specify a simple,          ** unadorned name (for example, "ACE") that will work across          ** platforms. We apply platform specifics to get a name that will          ** work (e.g. libACE, ACEd.dll, ACE.dll, etc.) We rely on the          ** underlying dlopen() implementation to "Do The Right Thing" in          ** terms of using relative paths, LD_LIBRARY_PATH, system security          ** rules, etc. except when ACE_MUST_HELP_DLOPEN_SEARCH_PATH is set.          ** If it is set, then ACE::ldfind() scans the configured path          ** looking for a match on the name and prefix/suffix applications.          ** NOTE: having ACE scan for a file and then pass a fully-qualified          ** pathname to dlopen() is a potential security hole; therefore,          ** do not use ACE_MUST_HELP_DLOPEN_SEARCH_PATH unless necessary          ** and only after considering the risks.          */          ACE_Array<ACE_TString> dll_names;          dll_names.max_size (10);    // Decent guess to avoid realloc later#if defined (ACE_MUST_HELP_DLOPEN_SEARCH_PATH)          // Find out where the library is          ACE_TCHAR dll_pathname[MAXPATHLEN + 1];          // Transform the pathname into the appropriate dynamic link library          // by searching the ACE_LD_SEARCH_PATH.          ACE::ldfind (dll_name,                       dll_pathname,                       (sizeof dll_pathname / sizeof (ACE_TCHAR)));          ACE_TString dll_str (dll_pathname);          dll_names.size (1);          dll_names.set (dll_str, 0);#else          this->get_dll_names (dll_name, dll_names);#endif          ACE_Array_Iterator<ACE_TString> name_iter (dll_names);          ACE_TString *name = 0;          while (name_iter.next (name))            {              if (ACE::debug ())                ACE_DEBUG ((LM_DEBUG,                            ACE_LIB_TEXT ("ACE_DLL_Handle::open: Trying to open DLL %s with %s name/n"),                            this->dll_name_,                            name->c_str ()));              // The ACE_SHLIB_HANDLE object is obtained.              this->handle_ = ACE_OS::dlopen (name->c_str (),                                              open_mode);              if (this->handle_ != ACE_SHLIB_INVALID_HANDLE)   // Good one                break;#if defined (AIX)              // AIX often puts the shared library file (most often named              // shr.o) inside an archive library. If this is an archive              // library name, then try appending [shr.o] and retry.              if (ACE_TString::npos != name->strstr (ACE_LIB_TEXT (".a")))//.........这里部分代码省略.........
开发者ID:mbert,项目名称:mulberry-lib-jx,代码行数:101,


示例11: base

voidACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name,                               ACE_Array<ACE_TString> &try_names){  // Build the array of DLL names to try on this platform by applying the  // proper prefixes and/or suffixes to the specified dll_name.  ACE_TString base (dll_name);  ACE_TString base_dir, base_file, base_suffix;  // 1. Separate the dll_name into the dir part and the file part. We  // only decorate the file part to determine the names to try loading.  int pos = base.rfind (ACE_DIRECTORY_SEPARATOR_CHAR);  if (pos != ACE_TString::npos)    {      base_dir = base.substr (0, static_cast<ssize_t>(pos) + 1);      base_file = base.substr (static_cast<size_t>(pos) + 1);    }  else    base_file = base;  // 2. Locate the file suffix, if there is one. Move the '.' and the  // suffix to base_suffix.  if ((pos = base_file.rfind (ACE_LIB_TEXT ('.'))) != ACE_TString::npos)    {      base_suffix = base_file.substr (static_cast<size_t>(pos));      base_file = base_file.substr (0, static_cast<ssize_t>(pos));    }  // 3. Build the combinations to try for this platform.  // Try these combinations:  //   - name as originally given  //   - name with decorator and platform's suffix appended (if not supplied)  //   - name with platform's suffix appended (if not supplied)  //   - name with platform's dll prefix (if it has one) and suffix  //   - name with platform's dll prefix, decorator, and suffix.  // So we need room for 5 entries in try_names.  try_names.size (0);  if ((try_names.max_size () - try_names.size ()) < 5)    try_names.max_size (try_names.max_size () + 5);#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)  ACE_TString decorator (ACE_LD_DECORATOR_STR);#endif  ACE_TString suffix (ACE_DLL_SUFFIX);  ACE_TString prefix (ACE_DLL_PREFIX);  for (size_t i = 0; i < 5 && try_names.size () < try_names.max_size (); ++i)    {      ACE_TString try_this;      size_t j = try_names.size ();      switch (i)        {        case 0:          try_this = dll_name;          break;        case 1:        // Name + decorator + suffix        case 2:        // Name + suffix        case 3:        // Prefix + name + decorator + suffix        case 4:        // Prefix + name + suffix          if (              base_suffix.length () > 0#if !(defined(ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK))              || (i == 2 || i == 4)    // No decorator desired; skip#endif              )            break;          try_this = base_dir;          if (i > 2)            try_this += prefix;          try_this += base_file;          if (base_suffix.length () > 0)            try_this += base_suffix;          else            {#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)              try_this += decorator;#endif              try_this += suffix;            }          break;        }      if (try_this.length ())        {          try_names.size (j + 1);          try_names.set (try_this, j);        }    }  return;}
开发者ID:mbert,项目名称:mulberry-lib-jx,代码行数:90,


示例12: add_slash

void Directory::scan_dir(const ACE_TString& relative, DDS_Dirent& dir,                         unsigned int overflow_index){  ACE_TString path = physical_dirname_ + relative;  add_slash(path);  while (DDS_DIRENT* ent = dir.read()) {    if (ent->d_name[0] == ACE_TEXT('.') && (!ent->d_name[1] ||        (ent->d_name[1] == ACE_TEXT('.') && !ent->d_name[2]))) {      continue; // skip '.' and '..'    }    ACE_TString file = path + ent->d_name;    if (is_dir(file.c_str())) {      ACE_TString phys(relative);      add_slash(phys);      phys += ent->d_name;      if (ACE_OS::strncmp(ent->d_name, ACE_TEXT("_overflow."), 10) == 0) {        unsigned int n = ACE_OS::atoi(ent->d_name + 10);        DDS_Dirent overflow(file.c_str());        scan_dir(ent->d_name, overflow, n);      } else if (ACE_OS::strlen(ent->d_name) <= FSS_MAX_FILE_NAME_ENCODED) {        dirs_[b32h_decode(ent->d_name)] = phys;        ++overflow_[overflow_index];      } else {        CwdGuard cg(file);        std::ifstream fn("_fullname");        std::string fullname;        if (!std::getline(fn, fullname)) {          throw std::runtime_error("Can't read .../_fullname");        }        ACE_TString full_t(ACE_TEXT_CHAR_TO_TCHAR(fullname.c_str()));        dirs_[full_t] = phys;        ++overflow_[overflow_index];        String_Index_t idx = phys.rfind(ACE_TEXT('.'));        if (idx == ACE_TString::npos) {          throw std::runtime_error("Badly formatted long dir name");        }        ACE_TString prefix(phys.c_str(), idx);        unsigned int serial = ACE_OS::atoi(&phys[idx + 1]);        unsigned int& counter = long_names_[prefix];        if (serial >= counter) counter = serial + 1;      }    } else { // regular file      if (ent->d_name[0] != ACE_TEXT('_')) {        files_[b32h_decode(ent->d_name)] = ent->d_name;        ++overflow_[overflow_index];      }    }  }}
开发者ID:yanbodiaoweng,项目名称:DDS,代码行数:62,


示例13: GetIntDefault

int GetIntDefault(const char* name, int def){    ACE_TString val;    return GetValueHelper(name, val) ? atoi(val.c_str()) : def;};
开发者ID:S-proyect,项目名称:Emu-S,代码行数:5,


示例14:

voidTAO_Port_Desc_Seq_Utils<T_desc_seq>::port_descriptions (    T_desc_seq &desc_seq,    ACE_Configuration *config,    ACE_Configuration_Section_Key &key,    const char *sub_section  ){  ACE_Configuration_Section_Key sub_key;  int status = config->open_section (key,                                     sub_section,                                     0,                                     sub_key);  if (status != 0)    {      desc_seq.length (0);      return;    }  CORBA::ULong count = 0;  config->get_integer_value (sub_key,                             "count",                             count);  desc_seq.length (count);  ACE_Configuration_Section_Key desc_key;  char *stringified = 0;  ACE_TString holder;  for (CORBA::ULong i = 0; i < count; ++i)    {      stringified = TAO_IFR_Service_Utils::int_to_string (i);      config->open_section (sub_key,                            stringified,                            0,                            desc_key);      config->get_string_value (desc_key,                                "name",                                holder);      desc_seq[i].name = holder.c_str ();      config->get_string_value (desc_key,                                "id",                                holder);      desc_seq[i].id = holder.c_str ();      /// Seems to me that this field should refer to the component      /// where the port is defined - NOT where the base type is defined.      config->get_string_value (key,                                "id",                                holder);      desc_seq[i].defined_in = holder.c_str ();      config->get_string_value (desc_key,                                "version",                                holder);      desc_seq[i].version = holder.c_str ();      config->get_string_value (desc_key,                                "base_type",                                holder);      TAO_Port_Desc_Seq_Utils<T_desc_seq>::port_base_type (desc_seq,                                                           holder,                                                           i);      TAO_Port_Desc_Seq_Utils<T_desc_seq>::get_is_multiple (desc_seq,                                                            config,                                                            desc_key,                                                            i);    }}
开发者ID:binary42,项目名称:OCI,代码行数:72,


示例15: GetIntDefault

int32 Config::GetIntDefault(const char* name, int32 def){    ACE_TString val;    return GetValueHelper(mConf, name, val) ? atoi(val.c_str()) : def;}
开发者ID:Ariathies,项目名称:server,代码行数:5,


示例16: base

voidACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name,                               ACE_Array<ACE_TString> &try_names){  // Build the array of DLL names to try on this platform by applying the  // proper prefixes and/or suffixes to the specified dll_name.  ACE_TString base (dll_name);  ACE_TString base_dir, base_file, base_suffix;  // 1. Separate the dll_name into the dir part and the file part. We  // only decorate the file part to determine the names to try loading.  ACE_TString::size_type pos = base.rfind (ACE_DIRECTORY_SEPARATOR_CHAR);  if (pos != ACE_TString::npos)    {      base_dir = base.substr (0, pos + 1);      base_file = base.substr (pos + 1);    }  else    base_file = base;  // 2. Locate the file suffix, if there is one. Move the '.' and the  // suffix to base_suffix.  if ((pos = base_file.rfind (ACE_TEXT ('.'))) != ACE_TString::npos)    {      base_suffix = base_file.substr (pos);      base_file = base_file.substr (0, pos);    }  // 3. Build the combinations to try for this platform.  // Try these combinations:  //   - name with platform's dll prefix (if it has one) and suffix  //   - name with platform's dll prefix, decorator, and suffix.  //   - name with decorator and platform's suffix appended (if not supplied)  //   - name with platform's suffix appended (if not supplied)  //   - name as originally given  // We first try to find the file using the decorator so that when a  // filename with and without decorator is used, we get the file with  // the same decorator as the ACE dll has and then as last resort  // the one without. For example with msvc, the debug build has a "d"  // decorator, but the release build has none and we really want to get  // the debug version of the library in a debug application instead  // of the release one.  // So we need room for 5 entries in try_names.  try_names.size (0);  if ((try_names.max_size () - try_names.size ()) < 5)    try_names.max_size (try_names.max_size () + 5);#if defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)  ACE_TString decorator (ACE_LD_DECORATOR_STR);#endif  ACE_TString suffix (ACE_DLL_SUFFIX);  ACE_TString prefix (ACE_DLL_PREFIX);  for (size_t i = 0; i < 5 && try_names.size () < try_names.max_size (); ++i)    {      ACE_TString try_this;      size_t const j = try_names.size ();      switch (i)        {        case 0:        // Prefix + name + decorator + suffix        case 1:        // Prefix + name + suffix        case 2:        // Name + decorator + suffix        case 3:        // Name + suffix          if (              base_suffix.length () > 0#if !(defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK))              || (i == 1 || i == 3)    // No decorator desired; skip#endif              )            break;          try_this = base_dir;          if (i < 2)            try_this += prefix;          try_this += base_file;          if (base_suffix.length () > 0)            try_this += base_suffix;          else            {#if defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)              try_this += decorator;#endif              try_this += suffix;            }          break;        case 4:          try_this = dll_name;          break;        }      if (try_this.length ())        {          try_names.size (j + 1);          try_names.set (try_this, j);        }    }  return;}
开发者ID:INMarkus,项目名称:ATCD,代码行数:96,


示例17: GetStringDefault

std::string Config::GetStringDefault(const char* name, const char* def){    ACE_TString val;    return GetValueHelper(mConf, name, val) ? val.c_str() : def;}
开发者ID:Ariathies,项目名称:server,代码行数:5,


示例18: run_main

intrun_main (int argc, ACE_TCHAR *argv[]){  int retval = 0;  MCT_Config config;  retval = config.open (argc, argv);  if (retval != 0)    return 1;  const ACE_TCHAR *temp = ACE_TEXT ("Multicast_Test_IPV6");  ACE_TString test = temp;  u_long role = config.role ();  if (ACE_BIT_DISABLED (role, MCT_Config::PRODUCER)      || ACE_BIT_DISABLED (role, MCT_Config::CONSUMER))    {      if (ACE_BIT_ENABLED (role, MCT_Config::PRODUCER))        test += ACE_TEXT ("-PRODUCER");      else        test += ACE_TEXT ("-CONSUMER");    }  // Start test only if options are valid.  ACE_START_TEST (test.c_str ());#if defined (ACE_HAS_IPV6)# if !defined (ACE_LACKS_UNIX_SIGNALS)  // Register a signal handler to close down application gracefully.  ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT);# endif  // Dump the configuration info to the log if caller passed debug option.  if (config.debug ())    config.dump ();  ACE_Reactor *reactor = ACE_Reactor::instance ();  MCT_Task *task = new MCT_Task (config, reactor);  if (ACE_BIT_ENABLED (role, MCT_Config::CONSUMER))    {      ACE_DEBUG ((LM_INFO, ACE_TEXT ("Starting consumer.../n")));      // Open makes it an active object.      retval += task->open ();    }  // now produce the datagrams...  if (ACE_BIT_ENABLED (role, MCT_Config::PRODUCER))    retval += producer (config);  if (ACE_BIT_ENABLED (role, MCT_Config::CONSUMER))    {      // and wait for everything to finish      ACE_DEBUG ((LM_INFO,                  ACE_TEXT ("start waiting for consumer to finish.../n")));      // Wait for the threads to exit.      // But, wait for a limited time since we could hang if the last udp      // message isn't received.      ACE_Time_Value max_wait ( config.wait ()/* seconds */);      ACE_Time_Value wait_time (ACE_OS::gettimeofday () + max_wait);      ACE_Time_Value *ptime = ACE_BIT_ENABLED (role, MCT_Config::PRODUCER)                                ? &wait_time : 0;      if (ACE_Thread_Manager::instance ()->wait (ptime) == -1)        {          if (errno == ETIME)            ACE_ERROR ((LM_ERROR,                        ACE_TEXT ("maximum wait time of %d msec exceeded/n"),                        max_wait.msec ()));          else            ACE_OS::perror (ACE_TEXT ("wait"));          ++error;        }    }  delete task;#endif /* ACE_HAS_IPV6 */  ACE_END_TEST;  return (retval == 0 && error == 0) ? 0 : 1;}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:81,


示例19: ACE_ERROR_RETURN

int KSGConfig::loadConfig(const std::string& file_name){	ACE_Configuration_Heap config;	if(config.open() == -1)	{		ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);	}	ACE_Ini_ImpExp config_importer(config);	if(config_importer.import_config(file_name.c_str()) == -1)	{		ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);	}	ACE_Configuration_Section_Key section;	if(config.open_section(config.root_section(),ACE_TEXT(KSG_COMMON_SECT)		,0,section) == -1)	{		ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);	}		ACE_TString v;	if(config.get_string_value(section,ACE_TEXT(KSG_MAJOR_VER),v) == -1)	{		ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);	}	_majorVer = ACE_OS::atoi(v.c_str());	if(config.get_string_value(section,KSG_MINOR_VER,v) == -1)	{		ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);	}	_minorVer = ACE_OS::atoi(v.c_str());	if(config.open_section(config.root_section(),ACE_TEXT(KSG_SERVER_SECT)		,0,section) == -1 )		ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);		if(config.get_string_value(section,KSG_SVR_IP,v) == -1)	{		ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);	}	_drtpSvrIP = v.c_str();	if(config.get_string_value(section,KSG_SVR_PORT,v) == -1)		ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);	_drtpSvrPort = ACE_OS::atoi(v.c_str());	if(config.get_string_value(section,KSG_SVR_BRANCE_NO,v) == -1)		ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);	_drtpNo = ACE_OS::atoi(v.c_str());	if(config.get_string_value(section,KSG_SVR_MAINFUNC,v) == -1)		ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);	_drtpMainFunc = ACE_OS::atoi(v.c_str());	if(config.get_string_value(section,KSG_SVR_POOL_CONN,v) == -1)		_drtpPoolMaxCnt = 5;	else		_drtpPoolMaxCnt = ACE_OS::atoi(v.c_str());	if(_drtpPoolMaxCnt < 0)		_drtpPoolMaxCnt = 5;	if(_drtpPoolMaxCnt > 30)		_drtpPoolMaxCnt = 30;	if(config.open_section(config.root_section(),ACE_TEXT(KSG_GATEWAY_SECT)		,0,section) == -1)		ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);	if(config.get_string_value(section,KSG_GW_IP,v) == -1)		ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);	_localIP = v.c_str();	if(config.open_section(config.root_section(),ACE_TEXT(KSG_SCHEDULER_SECT)		,0,section) == -1)		ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);	_runTaskIds = "";	if(config.get_string_value(section,KSG_SCHD_IDS,v) != -1)	{		_runTaskIds = v.c_str();	}	_listenerIds = "";	if(config.get_string_value(section,KSG_LISTENER_IDS,v) != -1)	{		_listenerIds = v.c_str();	}	if(config.open_section(config.root_section(),ACE_TEXT(KSG_LOG_SECT)		,0,section) == -1)		ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取日志配置失败")),-1);	if(config.get_string_value(section,KSG_LOG_LEVEL,v)!=-1)	{		_logLevel = v.c_str();	}	if(config.get_string_value(section,KSG_LOG_APPENDER,v)!=-1)	{		_logOutput = v.c_str();	}	if(config.get_string_value(section,KSG_LOG_FILE,v)!=-1)	{		_logFilePath = v.c_str();//.........这里部分代码省略.........
开发者ID:nykma,项目名称:ykt4sungard,代码行数:101,


示例20: ExtractProperties

    int ExtractProperties(const ACE_TString& input, mstrings_t& properties)    {        TTASSERT(input.find('/n') == input.rfind('/n'));        bool bSyntaxError = false;        if( input.length() == 0 )            bSyntaxError = true;        size_t offset = input.find(' ');//past command        if(offset == ACE_TString::npos)            return 0;        while(offset < input.length() && !bSyntaxError)        {            //past any spaces            offset = pastBlanks(offset, input);            if(offset == input.length())            {                break;            }            size_t propBegin = offset;            ACE_TString prop;            ACE_TString value;            while(offset < input.length()) //extract property name            {                if( input[offset] != ' ' && input[offset] != '=') offset ++;                else break;            }            if(offset == input.length())            {                bSyntaxError = true; //no properties in ACE_TString                break;            }            prop = input.substr(propBegin, offset-propBegin); //set propertyname            TTASSERT(properties.find(prop) == properties.end());            offset = pastBlanks(offset, input); //past spaces            if(offset == input.length())            {                bSyntaxError = true;                break;            }            if(input[offset] != '=')            {                bSyntaxError = true;                break;            }            else offset ++; //past =            offset = pastBlanks(offset, input); //past spaces            if(offset == input.length())            {                bSyntaxError = true;                break;            }            //determine whether it's a string or an integer            if(input[offset] == '"') //a ACE_TString            {                bool found = false;                size_t strBegin = ++offset; //past "                while(!found && offset<input.length())                {                    /*                    if(input[offset]==ACE_TEXT('/"') && input[offset-1] != ACE_TEXT('//')) found = true;                    offset++;                    */                    if(input[offset] == '//')                        offset += 2;                    else if(input[offset] == '"')                    {                        found = true;                        offset++;                    }                    else                        offset++;                }                if(!found)                {                    bSyntaxError = true;                    break;                }                value = input.substr(strBegin, offset-strBegin-1);                offset ++; //past /"                properties[prop] = RebuildString(value);                //properties.SetAt(prop, RebuildString(value));            }            else if(input[offset] == '[') // an int list            {                bool found = false;                size_t listBegin = ++offset; //past "                while(!found && offset<input.length())                {                    if(input[offset] == ']') found = true;                    offset++;                }//.........这里部分代码省略.........
开发者ID:BearWare,项目名称:TeamTalk5,代码行数:101,


示例21: mutex

static voidwriter (void){  ACE_RW_Process_Mutex mutex (mutex_name.c_str ());  // Make sure the constructor succeeded  if (ACE_LOG_MSG->op_status () != 0)    {      ACE_ERROR ((LM_ERROR,                  ACE_TEXT ("Writer, mutex %s %p/n"),                  mutex_name.c_str (),                  ACE_TEXT ("ctor")));      return;    }  ACE_SOCK_Dgram sock;  ACE_INET_Addr parent;  parent.set (reporting_port, ACE_LOCALHOST, 1, AF_INET);  ACE_TCHAR me_str[80];  parent.addr_to_string (me_str, 80);  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Sending reports to %s/n"), me_str));  if (sock.open (ACE_Addr::sap_any, PF_INET) == -1)    ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p/n"), ACE_TEXT ("UDP open")));  Range_Report report;  report.child_ = 0;   // We're the writer  ACE_Time_Value start (ACE_Time_Value::zero), stop (ACE_Time_Value::zero);  // Grab the lock  if (-1 == mutex.acquire_write ())    ACE_ERROR ((LM_ERROR,                ACE_TEXT ("Writer first %p/n"),                ACE_TEXT ("acquire_write")));  else    {      start = ACE_OS::gettimeofday ();      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Writer acquired first time/n")));    }  // Now sleep, making the readers wait for the lock. Then release the lock,  // sleep, and reacquire the lock.  ACE_OS::sleep (2);  stop = ACE_OS::gettimeofday ();  if (-1 == mutex.release ())    ACE_ERROR ((LM_ERROR,                ACE_TEXT ("Writer %p/n"),                ACE_TEXT ("first release")));  else    ACE_DEBUG ((LM_DEBUG,                ACE_TEXT ("Writer released first time/n")));  report.range_.set (start, stop);  ssize_t bytes = sock.send (&report, sizeof (report), parent);  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Writer sent %b byte report/n"), bytes));  ACE_OS::sleep (1);   // Ensure we don't immediately grab the lock back  start = stop = ACE_Time_Value::zero;  if (-1 == mutex.acquire_write ())    ACE_ERROR ((LM_ERROR,                ACE_TEXT ("Writer second %p/n"),                ACE_TEXT ("acquire_write")));  else    {      start = ACE_OS::gettimeofday ();      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Writer acquired second time/n")));    }  ACE_OS::sleep (2);  stop = ACE_OS::gettimeofday ();  if (-1 == mutex.release ())    ACE_ERROR ((LM_ERROR,                ACE_TEXT ("Writer %p/n"),                ACE_TEXT ("second release")));  else    ACE_DEBUG ((LM_DEBUG,                ACE_TEXT ("Writer released second time/n")));  report.range_.set (start, stop);  bytes = sock.send (&report, sizeof (report), parent);  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Writer sent %b byte report/n"), bytes));  sock.close ();  return;}
开发者ID:asdlei00,项目名称:ACE,代码行数:84,


示例22: return

intACE_TMAIN(int argc, ACE_TCHAR *argv[]){  CORBA::ORB_var orb;  test_var server;  RTScheduling::Scheduler_var safe_scheduler;  try    {      try        {          orb = CORBA::ORB_init (argc, argv);          if (parse_args (argc, argv) == -1)            return (-1);          CORBA::Object_var manager_obj = orb->resolve_initial_references ("RTSchedulerManager");          TAO_RTScheduler_Manager_var manager = TAO_RTScheduler_Manager::_narrow (manager_obj.in ());          TAO_Scheduler* scheduler = 0;          ACE_NEW_RETURN (scheduler,                          TAO_Scheduler (orb.in ()),                          -1);          safe_scheduler = scheduler;          manager->rtscheduler (scheduler);          CORBA::Object_var object =            orb->string_to_object (ior.c_str ());          server = test::_narrow (object.in ());          if (CORBA::is_nil (server.in ()))            {              ACE_ERROR_RETURN ((LM_ERROR,                                "ERROR: Object reference <%s> is nil/n",                                ior.c_str ()),                                1);            }          CORBA::Object_var current_obj = orb->resolve_initial_references ("RTScheduler_Current");          RTScheduling::Current_var current = RTScheduling::Current::_narrow (current_obj.in ());          const char * name = 0;          CORBA::Policy_ptr sched_param = 0;          CORBA::Policy_ptr implicit_sched_param = 0;          current->begin_scheduling_segment (name,                                            sched_param,                                            implicit_sched_param);          ACE_DEBUG ((LM_DEBUG,                      "Making a one-way request/n"));          server->one_way (ACE_TEXT_ALWAYS_CHAR(ior.c_str ()));          ACE_DEBUG ((LM_DEBUG,                      "Making a two-way request/n"));          server->two_way (ACE_TEXT_ALWAYS_CHAR(ior.c_str ()));          current->end_scheduling_segment (name);        }      catch (const CORBA::THREAD_CANCELLED& )        {          ACE_DEBUG ((LM_DEBUG,            "Distributable Thread Cancelled - Expected Exception/n"));          server->shutdown ();        }      catch (const CORBA::Exception& ex)        {          ex._tao_print_exception ("Caught exception:");          return 0;        }      orb->destroy ();    }  catch (const CORBA::Exception& ex)    {      ex._tao_print_exception ("Caught unexpected exception:");      return 1;    }  return 0;}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:90,


示例23: start

/* * The set of readers and the writer will operate in a staggered sequence * of acquiring and releasing the lock. The sequence is designed to exercise * waiting behavior of both readers and writer, as well as allowing multiple * readers in, without getting tripped up by any differences in ordering * on different platforms which may favor writers, or vice-versa. * In this timeline, time on seconds is on the left, time holding the lock * is solid, time waiting is dots, acquire/release point is a dash, and * time without the lock is blank. * *   TIME        WRITER    READER1    READER2    READER3 *     0            | *                  | *     1            |         . *                  |         . *     2            -         -          - *                            |          | *     3                      |          |          - *                            |          |          | *     4                      -          |          | *                                       |          | *     5                                 -          | *                                                  | *     6            -                               - *                  | *     7            |         .          .          . *                  |         .          .          . *     8            -         -          -          - *                            |          |          | *     9                      |          |          | * * A file is used to test the sequencing. When the writer first gets the * lock, it will ensure the file is not present. At the end of its time * holding the lock the first time, it will write a "writer 1" string to * the file. When it gets the lock the second time, it will write a * different string to the file, and just before releasing the second time * write a "writer 2" string to the file. The readers all check to be sure * that the file is present and says "writer 1" at the start and end of * their periods of holding the reader lock and, similarly, check for * "writer 2" the second time they hold the lock. */static voidreader (int num){  // Let the writer get there first.  ACE_OS::sleep (1);  ACE_SOCK_Dgram sock;  ACE_INET_Addr parent;  parent.set (reporting_port, ACE_LOCALHOST, 1, AF_INET);  ACE_TCHAR me_str[80];  parent.addr_to_string (me_str, 80);  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Sending reports to %s/n"), me_str));  if (sock.open (ACE_Addr::sap_any, PF_INET) == -1)    ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p/n"), ACE_TEXT ("UDP open")));  Range_Report report;  report.child_ = num;  ACE_Time_Value start (ACE_Time_Value::zero), stop (ACE_Time_Value::zero);  ACE_RW_Process_Mutex mutex (mutex_name.c_str ());  // Make sure the constructor succeeded  if (ACE_LOG_MSG->op_status () != 0)    {      ACE_ERROR ((LM_ERROR,                  ACE_TEXT ("Reader %d, mutex %s %p/n"),                  num,                  mutex_name.c_str (),                  ACE_TEXT ("ctor")));      return;    }  ACE_OS::sleep (num);  // Grab the lock  if (-1 == mutex.acquire_read ())    ACE_ERROR ((LM_ERROR,                ACE_TEXT ("Reader %d %p/n"),                num,                ACE_TEXT ("first acquire_read")));  else    {      start = ACE_OS::gettimeofday ();      ACE_DEBUG ((LM_DEBUG,                  ACE_TEXT ("Reader %d acquired first time/n"),                  num));    }  // Wait a bit, then release and report the range held.  ACE_OS::sleep (num);  // Release the lock then wait; in the interim, the writer should change  // the file.  stop = ACE_OS::gettimeofday ();  if (-1 == mutex.release ())    ACE_ERROR ((LM_ERROR,                ACE_TEXT ("Reader %d %p/n"),                num,                ACE_TEXT ("first release")));//.........这里部分代码省略.........
开发者ID:asdlei00,项目名称:ACE,代码行数:101,


示例24: mypid

intrun_main (int argc, ACE_TCHAR *argv[]){  parse_args (argc, argv);  // Child process code.  if (child_nr >= 0)    {      ACE_TCHAR lognm[MAXPATHLEN];      int mypid (ACE_OS::getpid ());      ACE_OS::sprintf(lognm,                      ACE_TEXT ("RW_Process_Mutex_Test-child-%d"),                      (int)mypid);      ACE_START_TEST (lognm);      if (child_nr == 0)        writer ();      else        reader (child_nr);      ACE_END_LOG;    }  else    {      ACE_START_TEST (ACE_TEXT ("RW_Process_Mutex_Test"));      // Although it should be safe for each process to construct and      // destruct the rw lock, this can disturb other process still      // using the lock. This is not really correct, and should be      // looked at, but it gets things moving.      // Also see Process_Mutex_Test.cpp for similar issue.      ACE_RW_Process_Mutex mutex (mutex_name.c_str ());      // Make sure the constructor succeeded      if (ACE_LOG_MSG->op_status () != 0)        {          ACE_ERROR ((LM_ERROR,                      ACE_TEXT ("Parent, mutex %s %p/n"),                      mutex_name.c_str (),                      ACE_TEXT ("ctor")));        }#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)      static const ACE_TCHAR* format = ACE_TEXT ("%ls -c %d -p %u -n %ls");#else      static const ACE_TCHAR* format = ACE_TEXT ("%s -c %d -p %u -n %s");#endif /* !ACE_WIN32 && ACE_USES_WCHAR */      // The parent process reads time ranges sent from the children via      // UDP. Grab an unused UDP port to tell the children to send to.      ACE_INET_Addr me;      ACE_SOCK_Dgram sock;      if (sock.open (ACE_Addr::sap_any, PF_INET) == -1)        ACE_ERROR_RETURN ((LM_ERROR,                           ACE_TEXT ("Socket %p/n"),                           ACE_TEXT ("open")),                          -1);      sock.get_local_addr (me);      ACE_TCHAR me_str[80];      me.addr_to_string (me_str, 80);      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Receiving on %s/n"), me_str));      // Spawn 1 writer and 3 reader processes that will contend for the      // lock.      Child writer;      Child readers[Nr_Processes - 1];      int i;      for (i = 0; i < Nr_Processes; i++)        {          Child *child = (i == 0 ? &writer : &readers[i-1]);          ACE_Process_Options options;          options.command_line (format,                                argc > 0 ? argv[0] : ACE_TEXT ("RW_Process_Mutex_Test"),                                i,                                (unsigned int)me.get_port_number (),                                mutex_name.c_str ());          if (child->spawn (options) == -1)            {              ACE_ERROR_RETURN ((LM_ERROR,                                 ACE_TEXT ("spawn of child %d %p/n"),                                 i,                                 ACE_TEXT ("failed")),                                -1);            }          else            {              ACE_DEBUG ((LM_DEBUG,                          ACE_TEXT ("Child process %d has pid = %d./n"),                          i,                          (int)(child->getpid ())));            }        }      // Keep reading time ranges reported from the children until all the      // children have exited. Alternate between checking for a range and      // checking for exits.      int processes = Nr_Processes;      Child *children[Nr_Processes];      for (i = 0; i < Nr_Processes; i++)        children[i] = (i == 0 ? &writer : &readers[i-1]);      Range_Report report;      ACE_Time_Value poll (0);      ACE_INET_Addr from;//.........这里部分代码省略.........
开发者ID:asdlei00,项目名称:ACE,代码行数:101,


示例25: init_tranport

int init_tranport (){  int status = 0;  if (sub_using_udp)    {      reader_transport_impl        = TheTransportFactory->create_transport_impl (SUB_TRAFFIC,                                                      ACE_TEXT("udp"),                                                      OpenDDS::DCPS::DONT_AUTO_CONFIG);      OpenDDS::DCPS::TransportConfiguration_rch reader_config        = TheTransportFactory->create_configuration (SUB_TRAFFIC, ACE_TEXT("udp"));      OpenDDS::DCPS::UdpConfiguration* reader_udp_config        = static_cast <OpenDDS::DCPS::UdpConfiguration*> (reader_config.in ());      if (!reader_address_given)        {          ACE_ERROR((LM_ERROR,                    ACE_TEXT("(%P|%t) init_transport: sub UDP")                    ACE_TEXT(" Must specify an address for UDP./n")));          return 11;        }      ACE_INET_Addr reader_address (reader_address_str.c_str ());      reader_udp_config->local_address_ = reader_address;      if (reader_transport_impl->configure(reader_config.in()) != 0)        {          ACE_ERROR((LM_ERROR,                    ACE_TEXT("(%P|%t) init_transport: sub UDP")                    ACE_TEXT(" Failed to configure the transport./n")));          status = 1;        }    }  else    {      reader_transport_impl        = TheTransportFactory->create_transport_impl (SUB_TRAFFIC,                                                      ACE_TEXT("SimpleTcp"),                                                      OpenDDS::DCPS::DONT_AUTO_CONFIG);      OpenDDS::DCPS::TransportConfiguration_rch reader_config        = TheTransportFactory->create_configuration (SUB_TRAFFIC, ACE_TEXT("SimpleTcp"));      OpenDDS::DCPS::SimpleTcpConfiguration* reader_tcp_config        = static_cast <OpenDDS::DCPS::SimpleTcpConfiguration*> (reader_config.in ());      if (reader_address_given)        {          ACE_INET_Addr reader_address (reader_address_str.c_str ());          reader_tcp_config->local_address_ = reader_address;          reader_tcp_config->local_address_str_ = reader_address_str;        }        // else use default address - OS assigned.      if (reader_transport_impl->configure(reader_config.in()) != 0)        {          ACE_ERROR((LM_ERROR,                    ACE_TEXT("(%P|%t) init_transport: sub TCP ")                    ACE_TEXT(" Failed to configure the transport./n")));          status = 1;        }    }  if (pub_using_udp)    {      writer_transport_impl         = TheTransportFactory->create_transport_impl (PUB_TRAFFIC,                                                       ACE_TEXT("udp"),                                                       OpenDDS::DCPS::DONT_AUTO_CONFIG);      OpenDDS::DCPS::TransportConfiguration_rch writer_config        = TheTransportFactory->create_configuration (PUB_TRAFFIC, ACE_TEXT("udp"));      OpenDDS::DCPS::UdpConfiguration* writer_udp_config        = static_cast <OpenDDS::DCPS::UdpConfiguration*> (writer_config.in ());      if (!writer_address_given)        {          ACE_ERROR((LM_ERROR,                    ACE_TEXT("(%P|%t) init_transport: pub UDP")                    ACE_TEXT(" Must specify an address for UDP./n")));          return 12;        }      ACE_INET_Addr writer_address (writer_address_str.c_str ());      writer_udp_config->local_address_ = writer_address;      if (writer_transport_impl->configure(writer_config.in()) != 0)        {          ACE_ERROR((LM_ERROR,                    ACE_TEXT("(%P|%t) init_transport: sub UDP")                    ACE_TEXT(" Failed to configure the transport./n")));          status = 1;        }    }  else//.........这里部分代码省略.........
开发者ID:svn2github,项目名称:OpenDDS,代码行数:101,



注:本文中的ACE_TString类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ ACE_Time_Value类代码示例
C++ ACE_Sig_Handler类代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。