예제 #1
0
    void
    Any_Handler::extract_into_any (const Any& desc,
                                   CORBA::Any& toconfig)
    {
      DANCE_TRACE("Any_Handler::extract_into_any");
      try
        {
          DynamicAny::DynAny_var dyn = DYNANY_HANDLER->extract_into_dynany (desc.type (),
                                                                            desc.value ());
          CORBA::Any_var any_safe (dyn->to_any ());
          toconfig = *any_safe;

          dyn->destroy ();
        }
      catch (CORBA::Exception &ex)
        {
          DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, DLINFO
                           ACE_TEXT ("Any_Handler::extract_into_any -")
                           ACE_TEXT (" Caught CORBA Exception while extracting into")
                           ACE_TEXT (" dynany: %C\n"),
                           ex._info ().c_str ()));
          throw Config_Error (ACE_TEXT (""),
                              ACE_TEXT ("CORBA Exception while extracting into dynany\n"));
        }
      catch (Config_Error &ex)
        {
          throw ex;
        }
      catch (...)
        {
          throw Config_Error (ACE_TEXT (""), ACE_TEXT ("Caught error whilst parsing XML into Any\n"));
        }
    }
예제 #2
0
    CORBA::TypeCode_ptr
    DynAlias_Handler::create_typecode (const DataType &type)
    {
      DANCE_TRACE("DynAlias_Handler::create_typecode");

      if (!type.alias_p ())
        {
          DANCE_DEBUG (DANCE_LOG_TERMINAL_ERROR,
            (LM_ERROR, ACE_TEXT ("ERROR: Alias type description required")));
          throw Config_Error (ACE_TEXT (""),
            ACE_TEXT ("Did not find expected alias type description, tk_kind"\
                      "may be wrong."));
        }

      CORBA::TypeCode_var tc =
        DYNANY_HANDLER->orb ()->create_alias_tc
        (ACE_TEXT_ALWAYS_CHAR (type.alias ().typeId ().c_str ()),
         ACE_TEXT_ALWAYS_CHAR (type.alias ().name ().c_str ()),
         DYNANY_HANDLER->create_typecode (type.alias ().elementType ()));

      DYNANY_HANDLER->register_typecode (type.alias ().typeId (),
                                         tc.in ());

      return tc._retn ();
    }
예제 #3
0
    void
    SatisfierProperty_Handler::handle_sat_property (
                                                 const SatisfierProperty& desc,
                                                 Deployment::SatisfierProperty& toconfig)
    {
      DANCE_TRACE("SatisfierProperty_Handler::get_sat_property");

      toconfig.name = ACE_TEXT_ALWAYS_CHAR (desc.name ().c_str ());

      switch (desc.kind ().integral ())
        {
        case SatisfierPropertyKind::Quantity_l:
          toconfig.kind = Deployment::Quantity;
          break;

        case SatisfierPropertyKind::Capacity_l:
          toconfig.kind = Deployment::Capacity;
          break;

        case SatisfierPropertyKind::Minimum_l:
          toconfig.kind = Deployment::Minimum;
          break;

        case SatisfierPropertyKind::Maximum_l:
          toconfig.kind = Deployment::Maximum;
          break;

        case SatisfierPropertyKind::Attribute_l:
          toconfig.kind = Deployment::Attribute;
          break;

        case SatisfierPropertyKind::Selection_l:
          toconfig.kind = Deployment::Selection;
          break;

        default:
          DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
            (LM_ERROR, ACE_TEXT ("Unknown SatisfierPropertyKind\n")));
          throw Config_Error (desc.name (),
            ACE_TEXT ("Unknown SatisfierPropertyKind"));

        }

      toconfig.dynamic = desc.dynamic ();

      try
        {
          Any_Handler::extract_into_any (desc.value (),
                                         toconfig.value);
        }
      catch (Config_Error &ex)
        {
          ex.name_ = desc.name ();
          throw ex;
        }
    }
예제 #4
0
      void
      IDREF_Base<T>::find_ref (const ACE_TString& id, T& val)
      {
        DANCE_TRACE("IDREF_Base<T>::find_ref(C_String, T)");

        int retval =
          idref_map_.find (id, val);

        if (retval < 0)
          throw Config_Error (id.c_str (),
                              ACE_TEXT ("Unable to look up an IDRef."));
      }
예제 #5
0
      void
      IDREF_Base<T>::bind_ref (ACE_TString& id, T value)
      {
        DANCE_TRACE("IDREF_Base<T>::bind_ref");

        int retval =
          idref_map_.bind (id, value);

        pos_map_.bind (value,id);

        if (retval < 0)
          throw Config_Error (id.c_str (),
                              ACE_TEXT ("Failed to bind an IDRef.  This likely indicates a name clash."));
      }
예제 #6
0
파일: CID_Handler.cpp 프로젝트: CCJY/ATCD
    static void handle_ir (const ImplementationRequirement &desc,
                   ::Deployment::ImplementationRequirement &toconfig)
    {
      DANCE_TRACE ("IR_Handler::get_ir");

      if (desc.resourceUsage_p ())
        {
          switch (desc.resourceUsage ().integral ())
        {
        case ResourceUsageKind::None_l:
          toconfig.resourceUsage = Deployment::None;
          break;

        case ResourceUsageKind::InstanceUsesResource_l:
          toconfig.resourceUsage = Deployment::InstanceUsesResource;
          break;

        case ResourceUsageKind::ResourceUsesInstance_l:
          toconfig.resourceUsage = Deployment::ResourceUsesInstance;
          break;

        case ResourceUsageKind::PortUsesResource_l:
          toconfig.resourceUsage = Deployment::PortUsesResource;
          break;

        case ResourceUsageKind::ResourceUsesPort_l:
          toconfig.resourceUsage = Deployment::ResourceUsesPort;
          break;

        default:
          throw Config_Error (desc.name (),
                              ACE_TEXT ("Unknown ResourceUsageKind."));
          break;
        }
        }

      if (desc.resourcePort_p ())
        toconfig.resourcePort = ACE_TEXT_ALWAYS_CHAR ( desc.resourcePort ().c_str ());

      if (desc.componentPort_p  ())
        toconfig.componentPort = ACE_TEXT_ALWAYS_CHAR ( desc.componentPort ().c_str ());

      toconfig.resourceType = ACE_TEXT_ALWAYS_CHAR ( desc.resourceType ().c_str ());
      toconfig.name = ACE_TEXT_ALWAYS_CHAR ( desc.name ().c_str ());

      std::for_each (desc.begin_property (),
             desc.end_property (),
             Property_Functor (toconfig.property ));
    }
예제 #7
0
      void
      IDREF_Base<T>::find_ref (const T& value, ACE_TString& id)
      {
        DANCE_TRACE("IDREF_Base<T>::find_ref (T, CString)");

        int retval =
          pos_map_.find (value, id);

        //      ACE_ERROR ((LM_ERROR, "**** Looking up value %i\n",
        //            value));

        if (retval < 0)
          throw Config_Error (ACE_TEXT ("No location information for reverse IDREF lookup"),
                              id.c_str ());
      }
예제 #8
0
    InstanceResourceDeploymentDescription
    IRDD_Handler::instance_resource_deployment_descr (const Deployment::InstanceResourceDeploymentDescription& src)
    {
      DANCE_TRACE("IRDD_Handler::instance_resource_deployment_descr - reverse");

      XMLSchema::string< ACE_TCHAR > reqname (ACE_TEXT_CHAR_TO_TCHAR (src.requirementName));
      XMLSchema::string< ACE_TCHAR > resname (ACE_TEXT_CHAR_TO_TCHAR (src.resourceName));

      InstanceResourceDeploymentDescription irdd (ResourceUsageKind::None,
                                                  reqname,
                                                  resname);

      switch (src.resourceUsage)
        {
        case Deployment::None:
          irdd.resourceUsage (ResourceUsageKind::None);
          break;

        case Deployment::InstanceUsesResource:
          irdd.resourceUsage (ResourceUsageKind::InstanceUsesResource);
          break;

        case Deployment::ResourceUsesInstance:
          irdd.resourceUsage (ResourceUsageKind::ResourceUsesInstance);
          break;

        case Deployment::PortUsesResource:
          irdd.resourceUsage (ResourceUsageKind::PortUsesResource);
          break;

        case Deployment::ResourceUsesPort:
          irdd.resourceUsage (ResourceUsageKind::ResourceUsesPort);
          break;

        default:
          throw Config_Error (ACE_TEXT_CHAR_TO_TCHAR (src.resourceName.in ()),
                              ACE_TEXT ("Unknown ResourceUsageKind."));
          break;
        }

      for (CORBA::ULong i = 0; i < src.property.length (); ++i)
        {
          //irdd.add_property (Property_Handler::get_property (src.property[i]));
        }


      return irdd;
    }
예제 #9
0
파일: CID_Handler.cpp 프로젝트: CCJY/ATCD
    static ImplementationRequirement
    get_ir (const ::Deployment::ImplementationRequirement &src)
    {
      DANCE_TRACE ("IR_Handler::get_ir - reverse");

      ImplementationRequirement retval (ACE_TEXT_CHAR_TO_TCHAR (src.resourceType.in ()),
                                        ACE_TEXT_CHAR_TO_TCHAR (src.name.in ()));

      if (src.resourceUsage.length () == 1)
        switch (src.resourceUsage[0])
          {
          case Deployment::None:
        retval.resourceUsage (ResourceUsageKind::None);
        break;

          case Deployment::InstanceUsesResource:
        retval.resourceUsage (ResourceUsageKind::InstanceUsesResource);
        break;

          case Deployment::ResourceUsesInstance:
        retval.resourceUsage (ResourceUsageKind::ResourceUsesInstance);
        break;

          case Deployment::PortUsesResource:
        retval.resourceUsage (ResourceUsageKind::PortUsesResource);
        break;

          case Deployment::ResourceUsesPort:
        retval.resourceUsage (ResourceUsageKind::ResourceUsesPort);
        break;

          default:
            throw Config_Error (ACE_TEXT_CHAR_TO_TCHAR (src.name.in ()),
                            ACE_TEXT ("Unknown ResourceUsageKind."));
        break;
          }

      retval.resourcePort (ACE_TEXT_CHAR_TO_TCHAR (src.resourcePort.in ()));

      retval.componentPort (ACE_TEXT_CHAR_TO_TCHAR (src.componentPort.in ()));
#if 0
      for (CORBA::ULong i = 0; i < src.property.length (); ++i)
        retval.add_property (
          Property_Handler::get_property (src.property[i]));
#endif
      return retval;
    }
예제 #10
0
    void
    IRDD_Handler::handle_irdd (const InstanceResourceDeploymentDescription& desc,
                               Deployment::InstanceResourceDeploymentDescription& toconfig)
    {
      DANCE_TRACE("IRDD_Handler::instance_resource_deployment_descr");

      switch (desc.resourceUsage ().integral ())
        {
        case ResourceUsageKind::None_l:
          toconfig.resourceUsage = Deployment::None;
          break;

        case ResourceUsageKind::InstanceUsesResource_l:
          toconfig.resourceUsage = Deployment::InstanceUsesResource;
          break;

        case ResourceUsageKind::ResourceUsesInstance_l:
          toconfig.resourceUsage = Deployment::ResourceUsesInstance;
          break;

        case ResourceUsageKind::PortUsesResource_l:
          toconfig.resourceUsage = Deployment::PortUsesResource;
          break;

        case ResourceUsageKind::ResourceUsesPort_l:
          toconfig.resourceUsage = Deployment::ResourceUsesPort;
          break;

        default:
          throw Config_Error (desc.requirementName (),
                              ACE_TEXT ("Unknown ResourceUsageKind."));
          break;
        }

      toconfig.requirementName = ACE_TEXT_ALWAYS_CHAR ( desc.requirementName ().c_str ());

      toconfig.resourceName= ACE_TEXT_ALWAYS_CHAR ( desc.resourceName ().c_str ());

      toconfig.property.length (desc.count_property ());
      std::for_each (desc.begin_property (),
                     desc.end_property (),
                     Property_Functor (toconfig.property));
    }
예제 #11
0
      void
      IDREF_Base<T>::bind_next_available (ACE_TString &id)
      {
        // Note:  For this function to compile and work properly,
        // T must have the postincrement operator defined.
        DANCE_TRACE ("IDREF_Base<T>::bind_next_available");
        //      ACE_DEBUG ((LM_DEBUG, "**** Binding %s to %i\n",
        //            id.c_str (),
        //            this->next_));

        int retval = idref_map_.bind (id, this->next_);

        int pos_retval = pos_map_.bind (this->next_, id);

        ++this->next_;

        if (retval < 0 || pos_retval < 0)
          throw Config_Error (id.c_str (),
                              ACE_TEXT ("Failed to bind an IDRef.  This likely indicates a name clash"));

      }
예제 #12
0
    DynAny_Handler::DynAny_Handler (void) :
      orb_ (0),
      daf_ (0)
    {
      DANCE_TRACE("DynAny_Handler::constructor");

      int argc = 0;
      char **argv = 0;

      orb_ = CORBA::ORB_init (argc, argv);

      CORBA::Object_var temp = orb_->resolve_initial_references (
        "DynAnyFactory");
      daf_ = DynamicAny::DynAnyFactory::_narrow (temp.in ());

      if (CORBA::is_nil (daf_.in ()))
        {
          DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
            (LM_ERROR, ACE_TEXT ("Unable to narrow Dynamic Any factory\n")));
          throw Config_Error (
            ACE_TEXT (""), ACE_TEXT ("Unable to narrow DynAny factory"));
        }
    }
예제 #13
0
    bool
    XML_File_Intf::read_process_plan (const ACE_TCHAR *file)
    {
      DANCE_TRACE("XML_File_Intf::read_process_plan");

      try
        {
          if (!XML_Helper_type::XML_HELPER.is_initialized ())
            return false;

          DANCE_DEBUG (DANCE_LOG_EVENT_TRACE,
            (LM_TRACE, DLINFO ACE_TEXT ("XML_File_Intf::read_process_plan - ")
                       ACE_TEXT ("Constructing DOM\n")));
          XERCES_CPP_NAMESPACE::DOMDocument *dom =
            XML_Helper_type::XML_HELPER.create_dom ((file));

          if (dom == 0)
            {
              DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
                (LM_ERROR, DLINFO ACE_TEXT ("XML_File_Intf::read_process_plan - ")
                           ACE_TEXT ("Failed to open file %s\n"), file));
              return false;
            }

          XERCES_CPP_NAMESPACE::DOMElement *foo = dom->getDocumentElement ();
          DANCE_DEBUG (DANCE_LOG_EVENT_TRACE,
            (LM_TRACE, DLINFO ACE_TEXT ("XML_File_Intf::read_process_plan - ")
                       ACE_TEXT ("DOMElement pointer: %u\n"), foo));

          ID_Map::TSS_ID_Map* TSS_ID_Map (ACE_Singleton<ID_Map::TSS_ID_Map, ACE_Null_Mutex>::instance());
          (*TSS_ID_Map)->reset ();

          DANCE_DEBUG (DANCE_LOG_EVENT_TRACE, (LM_TRACE,
            DLINFO ACE_TEXT ("XML_File_Intf::read_process_plan - ")
            ACE_TEXT ("Parsing XML file with XSC\n")));
          deploymentPlan dp =
            DAnCE::Config_Handlers::reader::DeploymentPlan (dom);

          DANCE_DEBUG (DANCE_LOG_EVENT_TRACE, (LM_TRACE,
            DLINFO ACE_TEXT ("XML_File_Intf::read_process_plan - ")
            ACE_TEXT ("Processing using config handlers\n")));
          DP_Handler dp_handler (dp);

          this->idl_dp_.reset (dp_handler.plan ());

          if (this->idl_dp_.get ())
            return true;
        }
      catch (const CORBA::Exception &ex)
        {
          DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
            (LM_ERROR, DLINFO ACE_TEXT ("XML_File_Intf::caught - ")
            ACE_TEXT ("CORBA Exception whilst parsing XML into IDL\n"),
            ex._info ().c_str ()));
          throw Config_Error (this->file_,
                              ex._info ().c_str ());
        }
      catch (const Config_Error &ex)
        {
          throw ex;
        }
      catch (...)
        {
          DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
            (LM_ERROR, DLINFO ACE_TEXT ("XML_File_Intf::caught - ")
            ACE_TEXT ("Unexpected exception whilst parsing XML into IDL.\n")));
          throw Config_Error (this->file_,
            ACE_TEXT ("Unexpected C++ exception whilst parsing XML"));
        }

      return false;
    }
예제 #14
0
DataType
DataType_Handler::data_type (
    const CORBA::TypeCode_ptr&  src)
{
    DANCE_TRACE("DataType_Handler::data_type");
    DataType type;

    switch (src->kind ())
    {
    case ::CORBA::tk_null:
        type.kind (TCKind::tk_null);
        break;
    case CORBA::tk_short:
        type.kind (TCKind::tk_short);
        break;
    case CORBA::tk_long:
        type.kind (TCKind::tk_long);
        break;
    case CORBA::tk_ushort:
        type.kind (TCKind::tk_ushort);
        break;
    case CORBA::tk_ulong:
        type.kind (TCKind::tk_ulong);
        break;
    case CORBA::tk_float:
        type.kind (TCKind::tk_float);
        break;
    case CORBA::tk_double:
        type.kind (TCKind::tk_double);
        break;
    case CORBA::tk_boolean:
        type.kind (TCKind::tk_boolean);
        break;
    case CORBA::tk_char:
        type.kind (TCKind::tk_char);
        break;
    case CORBA::tk_octet:
        type.kind (TCKind::tk_octet);
        break;
    case CORBA::tk_string:
        type.kind (TCKind::tk_string);
        break;
    case CORBA::tk_longlong:
        type.kind (TCKind::tk_longlong);
        break;
    case CORBA::tk_ulonglong:
        type.kind (TCKind::tk_ulonglong);
        break;
    case CORBA::tk_longdouble:
        type.kind (TCKind::tk_longdouble);
        break;
    case CORBA::tk_wchar:
        type.kind (TCKind::tk_wchar);
        break;
    case CORBA::tk_wstring:
        type.kind (TCKind::tk_wstring);
        break;
    case CORBA::tk_any:
        type.kind (TCKind::tk_any);
        break;
    case CORBA::tk_TypeCode:
        type.kind (TCKind::tk_TypeCode);
    default:
        DANCE_DEBUG (DANCE_LOG_TERMINAL_ERROR,
                     (LM_ERROR, "DataType_Handler::data_type - Invalid typecode\n"));
        throw Config_Error ("", "Invalid typecode");
    }
    return type;
}
예제 #15
0
///This method takes a CIAO::Config_Handlers::DataType
///and returns the corresponding CORBA::TypeCode.
CORBA::TypeCode_ptr
DataType_Handler::data_type (const DataType& desc)
{
    DANCE_TRACE("DataType_Handler::destructor");

    TCKind kind (desc.kind ());

    switch (kind.integral ())
    {
    case  TCKind::tk_null_l:
        return CORBA::TypeCode::_duplicate (CORBA::_tc_null);

    case  TCKind::tk_short_l:
        return CORBA::TypeCode::_duplicate (CORBA::_tc_short);

    case  TCKind::tk_long_l:
        return CORBA::TypeCode::_duplicate (CORBA::_tc_long);

    case  TCKind::tk_ushort_l:
        return CORBA::TypeCode::_duplicate (CORBA::_tc_ushort);

    case  TCKind::tk_ulong_l:
        return CORBA::TypeCode::_duplicate (CORBA::_tc_ulong);

    case  TCKind::tk_float_l:
        return CORBA::TypeCode::_duplicate (CORBA::_tc_float);

    case  TCKind::tk_double_l:
        return CORBA::TypeCode::_duplicate (CORBA::_tc_double);

    case  TCKind::tk_boolean_l:
        return CORBA::TypeCode::_duplicate (CORBA::_tc_boolean);

    case  TCKind::tk_char_l:
        return CORBA::TypeCode::_duplicate (CORBA::_tc_char);

    case  TCKind::tk_octet_l:
        return CORBA::TypeCode::_duplicate (CORBA::_tc_octet);

    case  TCKind::tk_string_l:
        return CORBA::TypeCode::_duplicate (CORBA::_tc_string);

    case  TCKind::tk_longlong_l:
        return CORBA::TypeCode::_duplicate (CORBA::_tc_longlong);

    case  TCKind::tk_ulonglong_l:
        return CORBA::TypeCode::_duplicate (CORBA::_tc_ulonglong);

    case  TCKind::tk_longdouble_l:
        return CORBA::TypeCode::_duplicate (CORBA::_tc_longdouble);

    case  TCKind::tk_wchar_l:
        return CORBA::TypeCode::_duplicate (CORBA::_tc_wchar);

    case  TCKind::tk_wstring_l:
        return CORBA::TypeCode::_duplicate (CORBA::_tc_wstring);

    case  TCKind::tk_any_l:
        return CORBA::TypeCode::_duplicate (CORBA::_tc_any);

    case  TCKind::tk_TypeCode_l:
        return CORBA::TypeCode::_duplicate (CORBA::_tc_TypeCode);

    default:
        DANCE_DEBUG (DANCE_LOG_TERMINAL_ERROR,
                     (LM_ERROR, "DataType_Handler::data_type - Invalid typecode in any\n"));
        throw Config_Error ("", "Invalid typecode");
    }

    //   This case used to be supported...is it not in the schema?
    //    case  TCKind::tk_Object)
    //      return CORBA::TypeCode::_duplicate (CORBA::_tc_Object);*/

}
예제 #16
0
    DynamicAny::DynAny_ptr
    DynAny_Handler::extract_into_dynany (const DataType &type,
                                         const DataValue &value,
                                         CORBA::TypeCode_ptr req_tc)
    {
      DANCE_TRACE("DynAny_Handler::extract_into_dynany");

      DynamicAny::DynAny_var retval;

      if (req_tc)
        retval = this->daf_->create_dyn_any_from_type_code (req_tc);

      TCKind::Value tkind = type.kind ().integral ();

      if ((value.count_short () && tkind != TCKind::tk_short_l) ||
          (value.count_long () && tkind != TCKind::tk_long_l) ||
          (value.count_ushort () && tkind != TCKind::tk_ushort_l ) ||
          (value.count_ulong () && tkind != TCKind::tk_ulong_l) ||
          (value.count_float () && tkind != TCKind::tk_float_l) ||
          (value.count_double () && tkind != TCKind::tk_double_l) ||
          (value.count_boolean () && tkind != TCKind::tk_boolean_l) ||
          (value.count_octet () && tkind != TCKind::tk_octet_l) ||
          (value.count_longlong () && tkind != TCKind::tk_longlong_l) ||
          (value.count_ulonglong () && tkind != TCKind::tk_ulonglong_l) ||
          (value.count_string () && !(tkind == TCKind::tk_string_l ||
                                      tkind == TCKind::tk_char_l ||
                                      tkind == TCKind::tk_wchar_l)))
        {
          throw Config_Error (ACE_TEXT (""), ACE_TEXT ("Wrong value type for data type"));
        }

      switch (tkind)
        {
          // ========== BASIC TYPES
        case TCKind::tk_null_l:
        case TCKind::tk_void_l:
          DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
            (LM_ERROR,
            ACE_TEXT ("DynAny_Handler::extract_into_dynany - Don't know how to handle null or void types\n")));
          throw Config_Error (ACE_TEXT (""),
            ACE_TEXT ("Null or void types not supported"));
          break;

        case TCKind::tk_short_l:
          {
            if (!req_tc)
              {
                retval = this->daf_->create_dyn_any_from_type_code (CORBA::_tc_short);
              }
            CORBA::Short s = 0;
            if (value.count_short ())
              {
                s = *(*value.begin_short ());
              }
            retval->insert_short (s);
          }
          break;

        case TCKind::tk_long_l:
          {
            if (!req_tc)
              {
                retval = this->daf_->create_dyn_any_from_type_code (CORBA::_tc_long);
              }
            CORBA::Long l = 0;
            if (value.count_long ())
              {
                l = *(*value.begin_long ());
              }
            retval->insert_long (l);
          }
          break;

        case TCKind::tk_ushort_l:
          {
            if (!req_tc)
              {
                retval = this->daf_->create_dyn_any_from_type_code (CORBA::_tc_ushort);
              }
            CORBA::UShort us = 0;
            if (value.count_ushort ())
              {
                us = *(*value.begin_ushort ());
              }
            retval->insert_ushort (us);
          }
          break;

        case TCKind::tk_ulong_l:
          {
            if (!req_tc)
              {
                retval = this->daf_->create_dyn_any_from_type_code (CORBA::_tc_ulong);
              }
            CORBA::ULong ul = 0;
            if (value.count_ulong ())
              {
                ul = *(*value.begin_ulong ());
              }
            retval->insert_ulong (ul);
          }
          break;

        case TCKind::tk_float_l:
          {
            if (!req_tc)
              {
                retval = this->daf_->create_dyn_any_from_type_code (CORBA::_tc_float);
              }
            CORBA::Float f = 0.0f;
            if (value.count_float ())
              {
                f = *(*value.begin_float ());
              }
            retval->insert_float (f);
          }
          break;

        case TCKind::tk_double_l:
          {
            if (!req_tc)
              {
                retval = this->daf_->create_dyn_any_from_type_code (CORBA::_tc_double);
              }
            CORBA::Double d = 0.0;
            if (value.count_double ())
              {
                d = *(*value.begin_double ());
              }
            retval->insert_double (d);
          }
          break;

        case TCKind::tk_boolean_l:
          {
            if (!req_tc)
              {
                retval = this->daf_->create_dyn_any_from_type_code (CORBA::_tc_boolean);
              }
            CORBA::Boolean b = false;
            if (value.count_boolean ())
              {
                b = *(*value.begin_boolean ());
              }
            retval->insert_boolean (b);
          }
          break;

        case TCKind::tk_octet_l:
          {
            if (!req_tc)
              {
                retval = this->daf_->create_dyn_any_from_type_code (CORBA::_tc_octet);
              }
            CORBA::Octet o = 0;
            if (value.count_octet ())
              {
                o = *(*(value.begin_octet ()));
              }
            retval->insert_octet (o);
          }
          break;

        case TCKind::tk_longlong_l:
          {
            if (!req_tc)
              {
                retval = this->daf_->create_dyn_any_from_type_code (CORBA::_tc_longlong);
              }
            CORBA::LongLong ll = 0;
            if (value.count_longlong ())
              {
                ll = *(*value.begin_longlong ());
              }
            retval->insert_longlong (ll);
          }
          break;

        case TCKind::tk_ulonglong_l:
          {
            if (!req_tc)
              {
                retval = this->daf_->create_dyn_any_from_type_code (CORBA::_tc_ulonglong);
              }
            CORBA::ULongLong ull = 0;
            if (value.count_ulonglong ())
              {
                ull = *(*value.begin_ulonglong ());
              }
            retval->insert_ulonglong (ull);
          }
          break;

        case TCKind::tk_string_l:
          return DynString_Handler::extract_into_dynany (type, value, req_tc);

        case TCKind::tk_char_l:
          {
            if (!req_tc)
              {
                retval = this->daf_->create_dyn_any_from_type_code (CORBA::_tc_char);
              }
            CORBA::Char c = 0;
            if (value.count_string ())
              {
                c = *(*value.begin_string ())->c_str ();
              }
            retval->insert_char (c);
          }
          break;

        case TCKind::tk_wchar_l:
          {
            if (!req_tc)
              {
                retval = this->daf_->create_dyn_any_from_type_code (CORBA::_tc_wchar);
              }
            CORBA::WChar wc = 0;
            if (value.count_string ())
              {
                wc = *(*value.begin_string ())->c_str ();
              }
            retval->insert_wchar (wc);
          }
          break;

        case TCKind::tk_enum_l:
          return DynEnum_Handler::extract_into_dynany (type, value, req_tc);

        case TCKind::tk_sequence_l:
          return DynSequence_Handler::extract_into_dynany (type, value, req_tc);

        case TCKind::tk_struct_l:
          return DynStruct_Handler::extract_into_dynany (type, value, req_tc);

        case TCKind::tk_alias_l:
          return DynAlias_Handler::extract_into_dynany (type, value, req_tc);

        case TCKind::tk_array_l:
          return DynArray_Handler::extract_into_dynany (type, value, req_tc);

        case TCKind::tk_longdouble_l:
          // Not supported since a longdouble is defined in the xsd as double.
          // We are then creating a long double initialized with a regular
          // double. This is a very tricky conversion and doesn't work in
          // combination with certain (versions of) compilers.
        case TCKind::tk_wstring_l:
        case TCKind::tk_fixed_l:
        case TCKind::tk_any_l:
        case TCKind::tk_TypeCode_l:
        case TCKind::tk_Principal_l:
        case TCKind::tk_objref_l:
        case TCKind::tk_union_l:
        case TCKind::tk_except_l:
        case TCKind::tk_value_l:
        case TCKind::tk_value_box_l:
        case TCKind::tk_native_l:
        case TCKind::tk_abstract_interface_l:
        case TCKind::tk_local_interface_l:
        case TCKind::tk_component_l:
        case TCKind::tk_home_l:
        case TCKind::tk_event_l:
          DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR,
            DLINFO ACE_TEXT ("DynAny_Handler::extract_into_dynany - Type not supported\n")));
          throw Config_Error (ACE_TEXT (""), ACE_TEXT ("Type not supported"));
        }

      return retval._retn ();
    }
예제 #17
0
    CORBA::TypeCode_ptr
    DynAny_Handler::create_typecode (const DataType &type)
    {
      DANCE_TRACE("DynAny_Handler::create_typecode");

      switch (type.kind ().integral ())
        {
          // ========== BASIC TYPES
        case TCKind::tk_null_l:
        case TCKind::tk_void_l:
          DANCE_DEBUG (DANCE_LOG_TERMINAL_ERROR, (LM_WARNING,
            ACE_TEXT ("I don't know how to handle null or void types\n")));
          throw Config_Error (ACE_TEXT (""),
            ACE_TEXT ("Null or void types not supported"));
          break;

        case TCKind::tk_short_l:
          return CORBA::_tc_short;

        case TCKind::tk_long_l:
          return CORBA::_tc_long;

        case TCKind::tk_ushort_l:
          return CORBA::_tc_ushort;

        case TCKind::tk_ulong_l:
          return CORBA::_tc_ulong;

        case TCKind::tk_float_l:
          return CORBA::_tc_float;

        case TCKind::tk_double_l:
          return CORBA::_tc_double;

        case TCKind::tk_boolean_l:
          return CORBA::_tc_boolean;

        case TCKind::tk_char_l:
          return CORBA::_tc_char;

        case TCKind::tk_octet_l:
          return CORBA::_tc_octet;

        case TCKind::tk_string_l:
          return DynString_Handler::create_typecode (type);

        case TCKind::tk_longlong_l:
          return CORBA::_tc_longlong;

        case TCKind::tk_ulonglong_l:
          return CORBA::_tc_ulonglong;

        case TCKind::tk_longdouble_l:
          // Disabled since a longdouble is defined in the xsd as double.
          // We are then creating a long double initialized from a regular
          // double. This is a very tricky conversion and doesn't work in
          // combination with certain (versions of) compilers.
          break;

        case TCKind::tk_wchar_l:
          return CORBA::_tc_wchar;

        case TCKind::tk_wstring_l:
          break;

        case TCKind::tk_enum_l:
          return DynEnum_Handler::create_typecode (type);

        case TCKind::tk_struct_l:
          return DynStruct_Handler::create_typecode (type);

        case TCKind::tk_sequence_l:
          return DynSequence_Handler::create_typecode (type);

        case TCKind::tk_alias_l:
          return DynAlias_Handler::create_typecode (type);

        case TCKind::tk_array_l:
          return DynArray_Handler::create_typecode (type);

        case TCKind::tk_fixed_l:
        case TCKind::tk_any_l:
        case TCKind::tk_TypeCode_l:
        case TCKind::tk_Principal_l:
        case TCKind::tk_objref_l:
        case TCKind::tk_union_l:
        case TCKind::tk_except_l:
        case TCKind::tk_value_l:
        case TCKind::tk_value_box_l:
        case TCKind::tk_native_l:
        case TCKind::tk_abstract_interface_l:
        case TCKind::tk_local_interface_l:
        case TCKind::tk_component_l:
        case TCKind::tk_home_l:
        case TCKind::tk_event_l:
          DANCE_DEBUG (DANCE_LOG_TERMINAL_ERROR,
            (LM_ERROR, DLINFO ACE_TEXT ("DynAny_Handler::create_typecode - Type not supported\n")));
          throw Config_Error (ACE_TEXT (""), ACE_TEXT ("Type not supported"));
        }

      return 0;
    }
예제 #18
0
    DynamicAny::DynAny_ptr
    DynAlias_Handler::extract_into_dynany (const DataType &type,
                                           const DataValue &value,
                                           CORBA::TypeCode_ptr req_tc)
    {
      DANCE_TRACE("DynAlias_Handler::extract_into_dynany");

      try
        {
          CORBA::TypeCode_var tc;

          if (req_tc)
            tc = req_tc;
          else
            tc = DynAlias_Handler::create_typecode (type);

          // Make the actual DynAlias
          //          DynamicAny::DynAny_var retval =
          //DYNANY_HANDLER->daf ()->create_dyn_any_from_type_code (tc);
          //          DynamicAny::DynAlias_var retval =
          //            DynamicAny::DynAlias::_narrow (temp.in ());

          DynamicAny::DynAny_var alias = DYNANY_HANDLER->extract_into_dynany (
            type.alias ().elementType (), value, tc);
          return alias._retn ();
          /*
          switch (type.kind ().integral ())
            {
              // ========== BASIC TYPES
            case TCKind::tk_null_l:
            case TCKind::tk_void_l:
              DANCE_DEBUG (DANCE_LOG_TERMINAL_ERROR,
                (LM_WARNING, "I don't know how to handle null or
              void types\n"));

            case TCKind::tk_short_l:
              retval->insert_short (CORBA::Short (static_cast <
                ::XMLSchema::short_ const & > (*value.begin_short ())));
              break;

            case TCKind::tk_long_l:
              retval->insert_long (CORBA::Long (static_cast <
                ::XMLSchema::int_ const& > (*value.begin_long ())));
              break;

            case TCKind::tk_ushort_l:
              retval->insert_ushort (CORBA::UShort (static_cast<
                ::XMLSchema::unsignedShort const & > (*value.begin_ushort ())));
              break;

            case TCKind::tk_ulong_l:
              retval->insert_ulong (CORBA::ULong (static_cast <
                ::XMLSchema::unsignedInt const& > (*value.begin_ulong ())));
              break;

            case TCKind::tk_float_l:
              retval->insert_float (CORBA::Float (*value.begin_float ()));
              break;

            case TCKind::tk_double_l:
              retval->insert_double (CORBA::Double (*value.begin_double ()));
              break;

            case TCKind::tk_boolean_l:
              retval->insert_boolean (static_cast <
                ::XMLSchema::boolean const& > (*value.begin_boolean ()));
              break;

            case TCKind::tk_char_l:
              retval->insert_char (CORBA::Char (
                *value.begin_string ()->c_str ()));
              break;

            case TCKind::tk_octet_l:
              retval->insert_octet (static_cast <
                const unsigned char &> (*value.begin_octet ()));
              break;

            case TCKind::tk_string_l:
              retval->insert_string (value.begin_string ()->c_str ());
              break;

            case TCKind::tk_longlong_l:
              retval->insert_longlong (CORBA::LongLong (static_cast <
                ::XMLSchema::long_ const& > (*value.begin_longlong ())));
              break;

            case TCKind::tk_ulonglong_l:
              retval->insert_ulonglong (CORBA::ULongLong (static_cast <
                ::XMLSchema::unsignedLong const& > (
                  *value.begin_ulonglong ())));
              break;

            case TCKind::tk_wchar_l:
              retval->insert_wchar (CORBA::WChar (
                *value.begin_string ()->c_str ()));
              break;

        case TCKind::tk_enum_l:
          return DynEnum_Handler::extract_into_dynany (type, value);

        case TCKind::tk_sequence_l:
          return DynSequence_Handler::extract_into_dynany (type, value);

        case TCKind::tk_struct_l:
          return DynStruct_Handler::extract_into_dynany (type, value);

        case TCKind::tk_alias_l:
          return DynAlias_Handler::extract_into_dynany (type, value);

        case TCKind::tk_longdouble_l:
        case TCKind::tk_wstring_l:
        case TCKind::tk_wfixed_l:
        case TCKind::tk_any_l:
        case TCKind::tk_TypeCode_l:
        case TCKind::tk_Principal_l:
        case TCKind::tk_objref_l:
        case TCKind::tk_union_l:
        case TCKind::tk_array_l:
        case TCKind::tk_except_l:
        case TCKind::tk_value_l:
        case TCKind::tk_value_box_l:
        case TCKind::tk_native_l:
        case TCKind::tk_abstract_interface_l:
        case TCKind::tk_local_interface_l:
        case TCKind::tk_component_l:
        case TCKind::tk_home_l:
        case TCKind::tk_event_l:
          DANCE_DEBUG (DANCE_LOG_TERMINAL_ERROR,
          (LM_ERROR, "Type not supported\n"));
          throw Config_Error ("", "Type not supported");
        }
          */
          //          retval->assign (alias);

          //          return retval._retn ();
        }
      catch (const DynamicAny::DynAny::InvalidValue&)
        {
          DANCE_DEBUG (DANCE_LOG_TERMINAL_ERROR,
            (LM_ERROR,
              ACE_TEXT ("Invalid value provided in XML when trying to ")
              ACE_TEXT ("initialize an instance of enumerated type %s\n"),
              type.alias ().typeId ().c_str ()));
          throw Config_Error (type.alias ().typeId (),
              ACE_TEXT ("Invalid value provided in XML"));
        }
      catch (Config_Error &ex)
        {
          DANCE_DEBUG (DANCE_LOG_TERMINAL_ERROR,
            (LM_ERROR, ACE_TEXT ("DynAlias_Handler caught Config_Error\n")));
          if (type.alias_p ())
            ex.add_name (type.alias ().typeId ());

          throw ex;
        }
      catch (...)
        {
          DANCE_DEBUG (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR,
            ACE_TEXT ("DynAlias_Handler caught unknown exception\n")));
          throw Config_Error (type.alias ().typeId (),
                              ACE_TEXT ("Unknown exception"));
        }
    }