⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 psdl_type_dcl_visitor.cpp

📁 这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用于网络游戏医学图像网关的高qos要求.更详细的内容可阅读相应的材料
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// -*- C++ -*-
// PSDL_Type_Dcl_Visitor.cpp,v 1.1 2002/07/25 15:25:51 pgontla Exp

#include "PSDL_Type_Dcl_Visitor.h"
#include "PSDL_Stream.h"

ACE_RCSID (PSS, PSDL_Type_Dcl_Visitor, "PSDL_Type_Dcl_Visitor.cpp,v 1.1 2002/07/25 15:25:51 pgontla Exp")

TAO_PSDL_Type_Dcl_Visitor::TAO_PSDL_Type_Dcl_Visitor (void)
{
}

TAO_PSDL_Type_Dcl_Visitor::~TAO_PSDL_Type_Dcl_Visitor (void)
{
}

int
TAO_PSDL_Type_Dcl_Visitor::visit_identifier (TAO_PSDL_Identifier *identifier)
{
  if (this->identifiers_.size () == 0)
    {
      this->identifiers_.size (1);
      this->count_ = 0;
    }

  if (this->identifiers_.size () < this->count_ + 1)
    this->identifiers_.size (this->count_ + 1);

  this->identifiers_ [this->count_] = identifier->value ();
  ++this->count_;

  return 0;
}

int
TAO_PSDL_Type_Dcl_Visitor::visit_type_declarator (TAO_PSDL_Type_Declarator *type_declarator)
{
  // Typedefs.
  this->count_ = 0;
  this->identifiers_.size (2);
  this->predefined_type_.size (2);

  this->predefined_type_[this->count_] = 0;

  if (type_declarator->type_spec ()->accept (this) == -1)
    return -1;

  if (type_declarator->declarators ()->accept (this) == -1)
    return -1;

  ACE_CString type;

  // This flag is used to distinguish between the predefined types and
  // types that are typedef'ed before.
  if (this->predefined_type_ [0] == 0)
    {
      if (this->base_type (this->identifiers_[this->count_ -1], type))
        {
          if (ACE_OS::strcmp (type.c_str (), "struct") != 0)
            this->identifiers_[0] = type;
        }
    }

  // If the typedef is for a sequence of something, the very first
  // element is going to be 'sequence' (check visit_predefined_type
  // method in this class). We are basing our selection
  // based on that.
  if (ACE_OS::strcmp (this->identifiers_[0].c_str (), "sequence") != 0)
    {
      this->print_for_simple_typedefs ();
    }
  else
    this->print_for_sequence_typedefs (this->identifiers_[1],
                                       this->identifiers_[2]);

  return 0;
}

/*
  There seems to be a difference with what shoudl be printed adn what
  is printed out as per the method. So commenting it for now. Will keep
  it around for some time nad remove when I am sure its is totally wrong
*/

void
TAO_PSDL_Type_Dcl_Visitor::print_for_sequence_typedefs (ACE_CString identifier_type,
                                                        ACE_CString identifier)
{
  ACE_CString name_space = TAO_PSDL_Scope::instance ()->get_name_space ();

  // Get a pointer to PSDL_Stream of the stub header.
  TAO_PSDL_Stream *ps_sh = TAO_PSDL_Scope::instance ()->get_sh ();

  ps_sh->nl ();
  *ps_sh << "#if !defined (TAO_USE_SEQUENCE_TEMPLATES)";
  ps_sh->nl ();
  *ps_sh << "#if !defined (__TAO_UNBOUNDED_SEQUENCE_" << name_space.c_str ()
         << "_" << identifier.c_str () << "_CH_)";
  ps_sh->nl ();
  *ps_sh << "#define __TAO_UNBOUNDED_SEQUENCE_" << name_space.c_str ()
         << "_" << identifier.c_str () << "_CH_";
  ps_sh->nl ();
  *ps_sh << "class TAO_EXPORT_MACRO _TAO_Unbounded_Sequence_CosNaming_"
         << identifier.c_str ();
  ps_sh->nl ();
  *ps_sh << ": public TAO_Unbounded_Base_Sequence";
  ps_sh->nl ();
  *ps_sh << "{";
  ps_sh->incr_indent ();
  ps_sh->nl ();
  *ps_sh << "public:";
  ps_sh->nl ();
  *ps_sh << "// = Initialization and termination methods.";
  ps_sh->nl ();
  *ps_sh << "_TAO_Unbounded_Sequence_" << name_space.c_str ()
         << "_" << identifier.c_str () << " (void);";
  ps_sh->nl ();
  *ps_sh << "_TAO_Unbounded_Sequence_" << name_space.c_str ()
         << "_" << identifier.c_str () << " (CORBA::ULong maximum);";
  ps_sh->nl ();
  *ps_sh << "_TAO_Unbounded_Sequence_" << name_space.c_str () << "_"
         << identifier.c_str () << " (";
  ps_sh->nl ();
  *ps_sh << "CORBA::ULong maximum,";
  ps_sh->nl ();
  *ps_sh << "CORBA::ULong length,";
  ps_sh->nl ();
  *ps_sh << identifier_type << " *data,";
  ps_sh->nl ();
  *ps_sh << "CORBA::Boolean release = 0";
  ps_sh->nl ();
  *ps_sh << ");";
  ps_sh->nl ();
  *ps_sh << "_TAO_Unbounded_Sequence_" << name_space.c_str () << "_" << identifier.c_str () << " (";
  ps_sh->nl ();
  *ps_sh << "const _TAO_Unbounded_Sequence_" << name_space.c_str () << "_" << identifier.c_str () << " &rhs\n";
  *ps_sh << ");\n";
  *ps_sh << "_TAO_Unbounded_Sequence_" << name_space.c_str () << "_" << identifier.c_str () << " &operator= (\n";
  *ps_sh << "const _TAO_Unbounded_Sequence_" << name_space.c_str () << "_" << identifier.c_str () << " &rhs\n";
  *ps_sh << ");\n";
  *ps_sh << "virtual ~_TAO_Unbounded_Sequence_" << name_space << "_" << identifier << " (void);";
  ps_sh->nl ();
  ps_sh->nl ();
  *ps_sh << "// = Accessors.\n";
  *ps_sh << identifier_type << " &operator[] (CORBA::ULong i);\n";
  *ps_sh << "const " << identifier_type << " &operator[] (CORBA::ULong i) const;\n";
  ps_sh->nl ();
  *ps_sh << "// = Static operations.\n";
  *ps_sh << "static " << identifier_type << " *allocbuf (CORBA::ULong size);\n";
  *ps_sh << "static void freebuf (" << identifier_type << " *buffer);\n";
  ps_sh->nl ();
  *ps_sh << "// Implement the TAO_Base_Sequence methods (see Sequence.h)";   ps_sh->nl ();
  *ps_sh << "virtual void _allocate_buffer (CORBA::ULong length);";   ps_sh->nl ();
  *ps_sh << "virtual void _deallocate_buffer (void);";   ps_sh->nl ();
  *ps_sh << identifier_type << " *get_buffer (CORBA::Boolean orphan = 0);";   ps_sh->nl ();
  *ps_sh << "const " << identifier_type << " *get_buffer (void) const;";   ps_sh->nl ();
  *ps_sh << "void replace (";   ps_sh->nl ();
  *ps_sh << "  CORBA::ULong max,";   ps_sh->nl ();
  *ps_sh << "  CORBA::ULong length,";   ps_sh->nl ();
  *ps_sh << identifier_type << " *data,";   ps_sh->nl ();
  *ps_sh << "CORBA::Boolean release";   ps_sh->nl ();
  *ps_sh << ");";   ps_sh->nl ();
  ps_sh->decr_indent ();
  *ps_sh << "};";   ps_sh->nl ();
  ps_sh->decr_indent ();
  ps_sh->nl ();
  *ps_sh << "#endif /* end #if !defined */";   ps_sh->nl ();
  ps_sh->nl ();
  ps_sh->nl ();
  *ps_sh << "#endif /* !TAO_USE_SEQUENCE_TEMPLATES */ ";   ps_sh->nl ();

  ps_sh->nl ();
  ps_sh->nl ();

  *ps_sh << "#if !defined (_" << name_space.c_str () << "_" << identifier.c_str () << "_CH_)";   ps_sh->nl ();
  *ps_sh << "#define _" << name_space.c_str () << "_" << identifier.c_str () << "_CH_";   ps_sh->nl ();
  ps_sh->nl ();

  *ps_sh << "class " << identifier.c_str () << ";";   ps_sh->nl ();
  *ps_sh << "class " << identifier.c_str () << "_var;";   ps_sh->nl ();
  ps_sh->nl ();

  *ps_sh << "// *************************************************************";   ps_sh->nl ();
  *ps_sh << "// " << identifier.c_str () ;   ps_sh->nl ();
  *ps_sh << "// *************************************************************";   ps_sh->nl ();

  ps_sh->nl ();

  *ps_sh << "class  " << identifier.c_str () << " : public";   ps_sh->nl ();

  ps_sh->nl ();

  *ps_sh << "#if !defined (TAO_USE_SEQUENCE_TEMPLATES)";   ps_sh->nl ();
  *ps_sh << "_TAO_Unbounded_Sequence_" << name_space.c_str () << "_" << identifier.c_str () ;   ps_sh->nl ();
  *ps_sh << "#else /* TAO_USE_SEQUENCE_TEMPLATES */";   ps_sh->nl ();
  *ps_sh << "TAO_Unbounded_Sequence<" << identifier.c_str () << "Component>";   ps_sh->nl ();
  *ps_sh << "#endif /* !TAO_USE_SEQUENCE_TEMPLATES */ ";   ps_sh->nl ();
  *ps_sh << "{";   ps_sh->nl ();
  ps_sh->incr_indent ();
  *ps_sh << "public:";   ps_sh->nl ();
  *ps_sh << identifier.c_str () << " (void); // default ctor";   ps_sh->nl ();
  *ps_sh << identifier.c_str () << " (CORBA::ULong max); // uses max size";   ps_sh->nl ();
  *ps_sh << identifier.c_str () << " (";   ps_sh->nl ();
  *ps_sh << "CORBA::ULong max, ";   ps_sh->nl ();
  *ps_sh << "CORBA::ULong length, ";   ps_sh->nl ();
  *ps_sh << identifier.c_str () << "Component *buffer, ";   ps_sh->nl ();
  *ps_sh << "CORBA::Boolean release = 0";   ps_sh->nl ();
  *ps_sh << ");";   ps_sh->nl ();

  *ps_sh  << identifier.c_str () << " (const " << identifier.c_str () << " &); // copy ctor";   ps_sh->nl ();
  *ps_sh << "~" << identifier.c_str () << " (void);";   ps_sh->nl ();
  *ps_sh << "static void _tao_any_destructor (void*);";   ps_sh->nl ();
  ps_sh->nl ();
  *ps_sh << "#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)";   ps_sh->nl ();
  *ps_sh << "typedef " << identifier.c_str () << "_var _var_type;";   ps_sh->nl ();
  *ps_sh << "#endif /* ! __GNUC__ || g++ >= 2.8 */";   ps_sh->nl ();
  ps_sh->nl ();
  ps_sh->nl ();
  *ps_sh << "};";   ps_sh->nl ();
  ps_sh->decr_indent ();
  ps_sh->nl ();
  *ps_sh << "#endif /* end #if !defined */";   ps_sh->nl ();
  ps_sh->nl ();
  ps_sh->nl ();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -