Ejemplo n.º 1
0
bool csSCF::RegisterClass (const char *iClassID, const char *iLibraryName,
  const char *iFactoryClass, const char *iDesc, const char *Dependencies, 
  const char* context)
{
  CS::Threading::RecursiveMutexScopedLock lock (mutex);
  size_t idx;
  csStringID contextID = 
    context ? contexts.Request (context) : csInvalidStringID;

  if (IsVerbose(SCF_VERBOSE_CLASS_REGISTER))
    csPrintfErr("SCF_NOTIFY: registering class %s in context %s (from %s)\n",
      iClassID, CS::Quote::Single (GetContextName(context)), iLibraryName);

  if ((idx = ClassRegistry->FindClass(iClassID)) != (size_t)-1)
  {
    scfFactory *cf = (scfFactory *)ClassRegistry->Get (idx);
    if (ContextClash (cf->classContext, contextID))
    {
      csPrintfErr("SCF_WARNING: class %s (from %s) has already been "
        "registered in the same context %s (in %s)\n",
        iClassID, iLibraryName, CS::Quote::Single (GetContextName(context)),
	get_library_name(cf->LibraryName));
    }
    else
    {
      /*
        The user may want to override a standard CS plugin by putting
	a plugin exhibiting the same class ID into the e.g. app directory.
	In this case a warning is probably not desired. But for debugging
	purposes we emit something.
       */
    #ifdef CS_DEBUG
      // Don't report when the already registered class is static.
      if (cf->classContext != staticContextID)
      {
	// @@@ some way to have this warning in non-debug builds would be nice.
	csPrintfErr("SCF_NOTIFY: class %s (from %s) has already been "
	  "registered in a different context: %s vs. %s (from %s); this "
	  "message appears only in debug builds\n",
	  iClassID, iLibraryName,
	  CS::Quote::Single (GetContextName(context)),
	  CS::Quote::Single (GetContextName(cf->classContext)),
	  get_library_name(cf->LibraryName));
      }
    #endif
    }
    return false;
  }

  scfFactory* factory = new scfFactory (iClassID, iLibraryName, iFactoryClass,
    0, iDesc, Dependencies, contextID);
  ClassRegistry->Push (factory);
  SortClassRegistry = true;
  return true;
}
Ejemplo n.º 2
0
    DDSDataReader *
    DDS_Subscriber_i::create_datareader_with_profile (
                  DDSTopic * topic,
                  const char * qos_profile,
                  DDSDataReaderListener * ccm_dds_drl,
                  ::DDS::StatusMask mask)
    {
      char * lib_name = get_library_name (qos_profile);
      char * prof_name = get_profile_name (qos_profile);

      DDSDataReader * dr = 0;

      if (lib_name != 0 && prof_name != 0)
        {
          dr = this->rti_entity ()->create_datareader_with_profile (topic,
                                                            lib_name,
                                                            prof_name,
                                                            ccm_dds_drl,
                                                            mask);
        }

      ACE_OS::free (lib_name);
      ACE_OS::free (prof_name);
      return dr;
    }
Ejemplo n.º 3
0
Archivo: scf.cpp Proyecto: garinh/cs
csRef<iDocument> csSCF::GetPluginMetadata (char const *iClassID)
{
  csRef<iDocument> metadata;
  CS::Threading::RecursiveMutexScopedLock lock (mutex);
  size_t idx = ClassRegistry->FindClass(iClassID);
  if (idx != (size_t)-1)
  {
    scfFactory *cf = ClassRegistry->Get (idx);
    if (cf->LibraryName != csInvalidStringID)
      csGetPluginMetadata (get_library_name(cf->LibraryName), metadata);
  }
  return metadata;
}
Ejemplo n.º 4
0
LINEAR_ALGEBRA_CONSTRUCTOR
void init() { 
  const char *library_name = get_library_name();
  if (library_name == NULL) {
    fprintf(stderr, LINALG_NAME ": No Fortran BLAS implementation found.\n");
    return;
  }
  library_handle = dlopen(library_name, RTLD_LAZY);
  if (library_handle == NULL) {
    fprintf(stderr, LINALG_NAME ": %s.\n", dlerror());
  } else {
    init_f77blas();
  }
}
Ejemplo n.º 5
0
Archivo: scf.cpp Proyecto: garinh/cs
scfSharedLibrary::~scfSharedLibrary ()
{
  if (LibraryHandle)
  {
    if (initFunc && finisFunc)
      finisFunc();
    if (PrivateSCF->IsVerbose(SCF_VERBOSE_PLUGIN_LOAD))
      csPrintfErr("SCF_NOTIFY: unloading plugin %s\n",
	get_library_name(LibraryName));
#ifndef LAZY_UNLOAD
    csUnloadLibrary (LibraryHandle);
#else
    PrivateSCF->lazyUnloadLibs.Push (LibraryHandle);
#endif
  }
}
Ejemplo n.º 6
0
    ::DDS::ReturnCode_t
    DDS_DomainParticipantFactory_i::set_default_participant_qos_with_profile (
      const char * qos_profile)
    {
      char * lib_name = get_library_name(qos_profile);
      char * prof_name = get_profile_name(qos_profile);

      ::DDS::ReturnCode_t retcode = ::DDS::RETCODE_ERROR;
      if (lib_name != 0 && prof_name != 0)
        {
          retcode = DDSDomainParticipantFactory::get_instance ()->
            set_default_participant_qos_with_profile (lib_name, prof_name);
        }

      ACE_OS::free (lib_name);
      ACE_OS::free (prof_name);

      return retcode;
    }
Ejemplo n.º 7
0
scfSharedLibrary::scfSharedLibrary (csStringID libraryName, const char *core)
{
  LibraryRegistry->Push (this);

  RefCount = 0;
  LibraryName = libraryName;
  const char* lib = get_library_name(LibraryName);

  if (PrivateSCF->IsVerbose(SCF_VERBOSE_PLUGIN_LOAD))
    csPrintfErr("SCF_NOTIFY: loading plugin %s to satisfy request for %s\n",
      lib, core);

  LibraryHandle = csLoadLibrary (lib);

  if (LibraryHandle != 0)
  {
    csString sym;
    sym << core << "_scfInitialize";
    initFunc = (scfInitFunc)csGetLibrarySymbol(LibraryHandle, sym);
    if (!initFunc)
    {
      csPrintfErr("SCF_ERROR: %s doesn't export %s\n",
		  CS::Quote::Single (lib), CS::Quote::Single (sym.GetData()));
      csPrintLibraryError (sym);
    }
    sym.Clear ();
    sym << core << "_scfFinalize";
    finisFunc = (scfFinisFunc)csGetLibrarySymbol(LibraryHandle, sym);
    if (!finisFunc)
    {
      csPrintfErr("SCF_ERROR: %s doesn't export %s\n",
		  CS::Quote::Single (lib), CS::Quote::Single (sym.GetData()));
      csPrintLibraryError (sym);
    }
    if (initFunc && finisFunc)
      initFunc (PrivateSCF);
  }
  else
    csPrintLibraryError (lib);
}
Ejemplo n.º 8
0
    ::DDS::Topic_ptr
    DDS_DomainParticipant_i::create_topic_with_profile (
        const char *impl_name,
        const char *type_name,
        const char *qos_profile,
        ::DDS::TopicListener_ptr a_listener,
        ::DDS::StatusMask mask)
    {
      DDS4CCM_TRACE ("DDS_DomainParticipant_i::create_topic_with_profile");

      if (impl_name == 0)
        {
          DDS4CCM_ERROR (DDS4CCM_LOG_LEVEL_ERROR, (LM_ERROR, DDS4CCM_INFO
                        "DDS_DomainParticipant_i::create_topic_with_profile <%C> - "
                        "Error: provided nil topic name\n",
                        qos_profile));
          return ::DDS::Topic::_nil ();
        }

      if (type_name == 0)
        {
          DDS4CCM_ERROR (DDS4CCM_LOG_LEVEL_ERROR, (LM_ERROR, DDS4CCM_INFO
                        "DDS_DomainParticipant_i::create_topic_with_profile <%C> - "
                        "Error: provided nil type name\n",
                        qos_profile));
          return ::DDS::Topic::_nil ();
        }

      DDS4CCM_DEBUG (DDS4CCM_LOG_LEVEL_ACTION_STARTING, (LM_DEBUG, DDS4CCM_INFO
                    "DDS_DomainParticipant_i::create_topic_with_profile <%C> - "
                    "Attempting to create topic with name %C and type %C\n",
                    qos_profile,
                    impl_name, type_name));

      DDS_TopicListener_i *ccm_dds_tl = 0;
      if (! ::CORBA::is_nil (a_listener))
        {
          // Topic will be set later (using set_dds_topic)
          ACE_NEW_THROW_EX (ccm_dds_tl,
                            DDS_TopicListener_i (::DDS::Topic::_nil (), a_listener),
                            ::CORBA::NO_MEMORY ());
        }

      DDSTopic * dds_tp = 0;

      char * lib_name = get_library_name(qos_profile);
      char * prof_name = get_profile_name(qos_profile);

      if (lib_name != 0 && prof_name != 0)
        {
          dds_tp = this->rti_entity ()->create_topic_with_profile (
                                                        impl_name,
                                                        type_name,
                                                        lib_name,
                                                        prof_name,
                                                        ccm_dds_tl,
                                                        mask);
        }
      ACE_OS::free (lib_name);
      ACE_OS::free (prof_name);

      if (!dds_tp)
        {
          DDS4CCM_ERROR (DDS4CCM_LOG_LEVEL_DDS_NIL_RETURN, (LM_ERROR, DDS4CCM_INFO
                        "DDS_DomainParticipant_i::create_topic_with_profile <%C> - "
                        "Error: RTI DDS returned a nil topic\n",
                        qos_profile));
          delete ccm_dds_tl;
          return ::DDS::Topic::_nil ();
        }

      ::DDS::Topic_var retval;
      ACE_NEW_THROW_EX (retval,
                        DDS_Topic_i (dds_tp, this),
                        ::CORBA::NO_MEMORY ());

      DDS4CCM_DEBUG (DDS4CCM_LOG_LEVEL_ACTION, (LM_INFO, DDS4CCM_INFO
                    "DDS_DomainParticipant_i::create_topic_with_profile <%C> - "
                    "Successfully created topic with name %C and type %C\n",
                    qos_profile,
                    impl_name, type_name));

      if (ccm_dds_tl)
        {
          ccm_dds_tl->set_dds_topic (retval.in ());
        }
      return retval._retn ();
    }
Ejemplo n.º 9
0
    ::DDS::Publisher_ptr
    DDS_DomainParticipant_i::create_publisher_with_profile (
      const char * qos_profile,
      ::DDS::PublisherListener_ptr a_listener,
      ::DDS::StatusMask mask)
    {
      DDS4CCM_TRACE ("DDS_DomainParticipant_i::create_publisher_with_profile");

      DDS4CCM_DEBUG (DDS4CCM_LOG_LEVEL_ACTION_STARTING, (LM_TRACE, DDS4CCM_INFO
                    "DDS_DomainParticipant_i::create_publisher_with_profile <%C> - "
                    "Start creating Publisher\n",
                    qos_profile));
      DDS_PublisherListener_i *ccm_dds_pl = 0;
      if (! ::CORBA::is_nil (a_listener))
        {
          ACE_NEW_THROW_EX (ccm_dds_pl,
                            DDS_PublisherListener_i (a_listener, this),
                            ::CORBA::NO_MEMORY ());
        }
      char * lib_name = get_library_name(qos_profile);
      char * prof_name = get_profile_name(qos_profile);

      DDSPublisher * ccm_dds_pub = 0;

      if (lib_name != 0 && prof_name != 0)
        {
          ccm_dds_pub = this->rti_entity ()->create_publisher_with_profile (
                                                        lib_name,
                                                        prof_name,
                                                        ccm_dds_pl,
                                                        mask);
        }

      ACE_OS::free (lib_name);
      ACE_OS::free (prof_name);

      if (!ccm_dds_pub)
        {
          DDS4CCM_ERROR (DDS4CCM_LOG_LEVEL_ERROR, (LM_ERROR, DDS4CCM_INFO
                        "DDS_DomainParticipant_i::create_publisher_with_profile <%C> - "
                        "Error: Unable to create Publisher\n",
                        qos_profile));
          delete ccm_dds_pl;
          return ::DDS::Publisher::_nil ();
        }

      ::DDS::Publisher_var retval;
      ACE_NEW_THROW_EX (retval,
                        DDS_Publisher_i (ccm_dds_pub, this),
                        ::CORBA::NO_MEMORY ());

      DDS4CCM_DEBUG (DDS4CCM_LOG_LEVEL_ACTION, (LM_INFO, DDS4CCM_INFO
                    "DDS_DomainParticipant_i::create_publisher_with_profile <%C> - "
                    "Successfully created a DDSPublisher\n",
                    qos_profile));

      DDS_ReturnCode_t retcode = ccm_dds_pub->enable ();
      if (retcode != DDS_RETCODE_OK)
        {
          DDS4CCM_ERROR (DDS4CCM_LOG_LEVEL_ERROR, (LM_ERROR, DDS4CCM_INFO
                       "DDS_DomainParticipant_i"
                       "::create_publisher_with_profile <%C> - "
                       "Error: Unable to create Publisher: <%C>\n",
                       qos_profile,
                       ::CIAO::DDS4CCM::translate_retcode (retcode)));
          delete ccm_dds_pl;
          throw ::CORBA::INTERNAL ();
        }
      return retval._retn ();
    }
Ejemplo n.º 10
0
    ::DDS::DataWriter_ptr
    DDS_Publisher_i::create_datawriter_with_profile (::DDS::Topic_ptr a_topic,
                                        const char* qos_profile,
                                        ::DDS::DataWriterListener_ptr a_listener,
                                        ::DDS::StatusMask mask)
    {
      DDS4CCM_TRACE ("DDS_Publisher_i::create_datawriter_with_profile");

      DDS_Topic_i * topic = dynamic_cast < DDS_Topic_i * > (a_topic);

      if (!topic)
        {
          DDS4CCM_ERROR (DDS4CCM_LOG_LEVEL_CAST_ERROR, (LM_ERROR, DDS4CCM_INFO
                        "DDS_Publisher_i::create_datawriter_with_profile <%C>- "
                        "Error: Unable to cast provided topic to its servant.\n",
                        qos_profile));
          return ::DDS::DataWriter::_nil ();
        }

      DDS_DataWriterListener_i *ccm_dds_dwl = 0;
      if (! ::CORBA::is_nil (a_listener))
        {
          ACE_NEW_THROW_EX (ccm_dds_dwl,
                            DDS_DataWriterListener_i (a_listener, 0),
                            ::CORBA::NO_MEMORY ());
        }

      char * lib_name = get_library_name(qos_profile);
      char * prof_name = get_profile_name(qos_profile);

      DDSDataWriter *ccm_dds_dw = 0;

      if (lib_name != 0 && prof_name != 0)
        {
          ccm_dds_dw = this->rti_entity ()->create_datawriter_with_profile (
                                                                  topic->get_rti_entity (),
                                                                  lib_name,
                                                                  prof_name,
                                                                  ccm_dds_dwl,
                                                                  mask);
        }

      ACE_OS::free (lib_name);
      ACE_OS::free (prof_name);

      if (!ccm_dds_dw)
        {
          DDS4CCM_ERROR (DDS4CCM_LOG_LEVEL_DDS_NIL_RETURN, (LM_ERROR, DDS4CCM_INFO
                        "DDS_Publisher_i::create_datawriter_with_profile <%C> - "
                        "Error: RTI Topic returned a nil datawriter.\n",
                        qos_profile));
          delete ccm_dds_dwl;
          return ::DDS::DataWriter::_nil ();
        }
      else
        {
          DDS4CCM_DEBUG (DDS4CCM_LOG_LEVEL_ACTION, (LM_DEBUG, DDS4CCM_INFO
                        "DDS_Publisher_i::create_datawriter_with_profile - "
                        "Successfully created datawriter with profile <%C>.\n",
                        qos_profile));
        }

      ::DDS::DataWriter_var retval =
        DDS_TypeSupport_i::create_datawriter (ccm_dds_dw,
                                              this->dp_.in (),
                                              this);
      if (ccm_dds_dwl)
        {
          ccm_dds_dwl->set_dds_entity (retval.in ());
        }
      return retval._retn ();
    }
Ejemplo n.º 11
0
    ::DDS::DomainParticipant_ptr
    DDS_DomainParticipantFactory_i::create_participant_with_profile (
      ::DDS::DomainId_t domain_id,
      const char * qos_profile,
      ::DDS::DomainParticipantListener_ptr a_listener,
      ::DDS::StatusMask mask)
    {
      DDS4CCM_TRACE ("DDS_DomainParticipantFactory_i::"
                     "create_participant_with_profile");

      DDS4CCM_DEBUG (DDS4CCM_LOG_LEVEL_ACTION_STARTING, (LM_TRACE, DDS4CCM_INFO
                    "DDS_DomainParticipantFactory_i::create_participant_with_profile - "
                    "Start creating domain participant: "
                    "profile <%C> - domain <%d>\n",
                    qos_profile, domain_id));
      DDS_DomainParticipantListener_i *ccm_dds_dpl = 0;
      if (! ::CORBA::is_nil (a_listener))
        {
          ACE_NEW_THROW_EX (ccm_dds_dpl,
                            DDS_DomainParticipantListener_i (a_listener),
                            ::CORBA::NO_MEMORY ());
        }

      DDS4CCM_DEBUG (DDS4CCM_LOG_LEVEL_ACTION, (LM_DEBUG, DDS4CCM_INFO
                    "DDS_DomainParticipantFactory_i::create_participant_with_profile - "
                    "Creating participant: profile <%C> - domain <%d>\n",
                    qos_profile,
                    domain_id));

      char * lib_name = get_library_name(qos_profile);
      char * prof_name = get_profile_name(qos_profile);

      DDSDomainParticipant * dds_dp = 0;
      if (lib_name != 0 && prof_name != 0)
        {
          dds_dp = DDSDomainParticipantFactory::get_instance ()->
                            create_participant_with_profile (domain_id,
                                                            lib_name,
                                                            prof_name,
                                                            ccm_dds_dpl,
                                                            mask);
        }

      ACE_OS::free (lib_name);
      ACE_OS::free (prof_name);

      if (!dds_dp)
        {
          DDS4CCM_ERROR (DDS4CCM_LOG_LEVEL_ERROR, (LM_ERROR, DDS4CCM_INFO
                        "DDS_DomainParticipantFactory_i::create_participant_with_profile <%C> - "
                        "Error: Unable to create DomainParticipant for domain <%d>\n",
                        qos_profile,
                        domain_id));
          delete ccm_dds_dpl;
          return ::DDS::DomainParticipant::_nil ();
        }
      ::DDS::DomainParticipant_var retval;
      ACE_NEW_THROW_EX (retval,
                        DDS_DomainParticipant_i (dds_dp),
                        ::CORBA::NO_MEMORY ());
      DDS_ReturnCode_t retcode = dds_dp->enable ();
      if (retcode != DDS_RETCODE_OK)
        {
          DDS4CCM_ERROR (DDS4CCM_LOG_LEVEL_ERROR, (LM_ERROR, DDS4CCM_INFO
                        "DDS_DomainParticipantFactory_i::create_participant_with_profile <%C> - "
                        "Error: Unable to enable DomainParticipant for domain <%d>: <%C>\n",
                        qos_profile,
                        domain_id,
                        ::CIAO::DDS4CCM::translate_retcode (retcode)));
          delete ccm_dds_dpl;
          throw ::CORBA::INTERNAL ();
        }

      if (ccm_dds_dpl)
        {
          ccm_dds_dpl->set_dds_dp (retval.in ());
        }
      DDS_DomainParticipant_i * typed_dp =
        dynamic_cast < DDS_DomainParticipant_i *>
        (retval.in ());

      if (typed_dp)
        {
          typed_dp->set_rti_entity (dds_dp);
        }

      return retval._retn ();
    }