virtual void push_structured_event(CosNotification::StructuredEvent const& event)
    throw(CosEventComm::Disconnected)
  {
    cout << "domain_name: " << event.header.fixed_header.event_type.domain_name
	 << "  type_name: " << event.header.fixed_header.event_type.type_name << " " << flush;

    if (false) {
    Miro::Client client;
    DynamicAny::DynAnyFactory_var daf =
      client.resolveInit<DynamicAny::DynAnyFactory>("DynAnyFactory");
    DynamicAny::DynAny_var da = daf->create_dyn_any(event.remainder_of_body);
    
    CORBA::TypeCode_var tc = da->type();

    if (tc->kind() == CORBA::tk_struct) {
      CORBA::String_var name = tc->name();
      CORBA::String_var id = tc->id();

      DynamicAny::DynStruct_var ds =
	DynamicAny::DynStruct::_narrow(da);

      for (CORBA::ULong i = 0; i < ds->component_count(); ++i) {
	DynamicAny::DynAny_var member = ds->current_component();
	CORBA::String_var name = ds->current_member_name();
	if (std::string("timestamp") == name.in()) {
	  long long int i =  member->get_ulonglong();
	  ACE_Time_Value t;
	  ORBSVCS_Time::Absolute_TimeT_to_Time_Value(t, i);
	  cout << "latency: " << ACE_OS::gettimeofday() - t << endl;
	  break;
	}
	ds->next();
      }
    }
    else {
      cerr << "unknown event layout" << endl;
    }
    }
    ACE_Time_Value t;
    t.set(time_out);
    ACE_OS::sleep(t);

    cout << "waking up after sleep" << endl;
  }
예제 #2
0
void DynAnyAnalyzer::analyze (DynamicAny::DynAny_ptr da)
{
  CORBA::TypeCode_var tc = da->type ();

  CORBA::TCKind kind = tc->kind ();

  CORBA::TypeCode_var dup = CORBA::TypeCode::_duplicate (tc.in ());

  // strip aliases
  while (kind == CORBA::tk_alias)
    {
      dup = dup->content_type ();

      kind = dup->kind ();
    }

  switch (kind)
   {
     case CORBA::tk_struct:
      {
        DynamicAny::DynStruct_var ds
          = DynamicAny::DynStruct::_narrow (da);

        tab (level_);

        if (debug_)
          {
            ACE_DEBUG ((LM_DEBUG,
                      "STRUCT\n"));
          }

        if (da->seek (0) )
          {
            level_++;

            do
              {
                DynamicAny::DynAny_var cc =
                  ds->current_component ();

                DynamicAny::FieldName_var fn =
                  ds->current_member_name ();

                tab(level_);

                if (debug_)
                  {
                    ACE_DEBUG ((LM_DEBUG,
                              "Member = %C\n", fn.in ()));
                  }

                if (!CORBA::is_nil (cc.in ()))
                  {
                    this->analyze (cc.in ());
                  }

              } while (da->next ());

            level_--;
          }
      }
      break; // end tk_struct

    case CORBA::tk_sequence:
      {
        if (TAO_DynCommon::is_basic_type_seq (tc.in ()))
          {
            this->analyze_basic_seq (dup.in (), da);
          }
        else
          {
            DynamicAny::DynSequence_var ds =
              DynamicAny::DynSequence::_narrow (da);

            int i = 0;
            tab(level_);

            if (debug_)
              {
                ACE_DEBUG ((LM_DEBUG,
                            "SEQUENCE\n"));
              }

            if (ds->seek (0UL))
              {
                level_++;

                do
                  {
                    tab(level_);

                    if (debug_)
                      ACE_DEBUG ((LM_DEBUG,
                                  "[%d]\n", i));

                    DynamicAny::DynAny_var cc (ds->current_component ());

                    if (!CORBA::is_nil (cc.in ()))
                      {
                        analyze (cc.in ());
                      }

                    i++;
                  } while (da->next ());

                level_--;
              }
          }
      }
      break; // end tk_sequence

    case CORBA::tk_array:
      {
        tab (level_);

        if (debug_)
          {
            ACE_DEBUG ((LM_DEBUG,
                        "ARRAY\n"));
          }

        level_++;

        CORBA::ULong const len =
          dup->length ();

        for (CORBA::ULong i = 0 ; i < len; ++i)
          {
            tab (level_);

            if (debug_)
              {
                ACE_DEBUG ((LM_DEBUG, "[%d]\n", i));
              }

            DynamicAny::DynAny_var cc = da->current_component();

            if (!CORBA::is_nil (cc.in ()))
              {
                analyze (cc.in ());
              }

            da->next ();
          }
        level_--;
      }
      break;

    case CORBA::tk_union:
      {
        DynamicAny::DynUnion_var value =
          DynamicAny::DynUnion::_narrow (da);

        if (!value->has_no_active_member ())
          {
            DynamicAny::DynAny_var disc = value->member ();

            if (!CORBA::is_nil (disc.in ()))
              {
                this->analyze (disc.in ());
              }
          }
      }
      break;

    case CORBA::tk_any:
      {
        DynamicAny::DynAny_var dynany;
        CORBA::Any_var any = da->get_any ();

        dynany =
          dynany_factory_->create_dyn_any (any.in ());

        if (!CORBA::is_nil (dynany.in ()))
          {
            this->analyze (dynany.in ());
          }

        dynany->destroy ();
      }
      break;

    case CORBA::tk_enum:
      {
        DynamicAny::DynEnum_var value =
          DynamicAny::DynEnum::_narrow (da);

        CORBA::String_var s = value->get_as_string ();
        tab (level_);

        if (debug_)
          {
            ACE_DEBUG ((LM_DEBUG, "  Value (enum) = %C\n", s.in()));
          }
      }
      break;

    CASEE (boolean, Boolean, "  Value (bool) = %d\n");
    CASEE (short, Short, "  Value (short) = %d\n");
    CASEE (ushort, UShort, "  Value (ushort) = %u\n");
    CASEE (long, Long, "  Value (long) = %d\n");
    CASEE (ulong, ULong, "  Value (ulong) = %u\n");
    CASEE (longlong, LongLong, "  Value (longlong) %Ld\n");
    CASEE (ulonglong, ULongLong, "  Value (ulonglong) %Lu\n");
    CASEE (char, Char, "  Value (char) = %c\n");
    CASEE (float, Float, "  Value (float) = %f\n");
    CASEE (double, Double, "  Value (double) = %f\n");
    CASEE (octet, Octet, "  Value (octet) = %c\n");

    case CORBA::tk_string:
      {
        CORBA::String_var b (da->get_string ());
        tab (level_);

        if (debug_)
          {
            ACE_DEBUG ((LM_DEBUG, "  Value (string) = %C\n", b.in ()));
          }
      }
      break;

    case CORBA::tk_TypeCode:
      {
        tab (level_);

        if (debug_)
          {
            CORBA::TCKind const kind =
              da->get_typecode ()->kind ();

            ACE_DEBUG ((LM_DEBUG,
                        "  Value (TypeCode) = %d\n",
                        static_cast<int> (kind)));
          }
      }
      break;

    default:
      {
        tab (level_);

        if (debug_)
          {
            CORBA::TCKind const kind =
              tc->kind ();

            ACE_DEBUG ((LM_DEBUG,
                        "  unhandled typecode = %d\n",
                        static_cast<int> (kind)));
          }
      }
      break;
  }

  if (debug_)
    {
      ACE_DEBUG ((LM_DEBUG, "\n"));
    }
}