Exemple #1
0
void
saj_write_java_statusCondition_address(
    JNIEnv *env,
    gapi_object gapi_obj,
    gapi_statusCondition condition,
    jobject java_object)
{
    saj_userData ud;

    assert(env != NULL);
    assert(java_object != NULL);

    if(gapi_obj != GAPI_OBJECT_NIL){
        ud = saj_userData(gapi_object_get_user_data(gapi_obj));

        if(ud != NULL){
            if(ud->statusConditionUserData != NULL){
                saj_destroy_user_data(env, ud->statusConditionUserData);
            }
            ud->statusConditionUserData = gapi_object_get_user_data(
                                                        (gapi_object)condition);
            gapi_object_set_user_data(gapi_obj, (void*)ud,NULL,NULL);
        }
    }
}
DDS::ErrorInfo::ErrorInfo( void )
{
    DDS::ccpp_UserData_ptr myUD;
    _gapi_self = gapi_errorInfo__alloc();
    if (_gapi_self) {
        myUD = new DDS::ccpp_UserData(this);
        if (myUD) {
            gapi_object_set_user_data(_gapi_self, dynamic_cast<DDS::Object_ptr>(myUD),
                                      ccpp_CallBack_DeleteUserData,NULL);
        } else {
            OS_REPORT(OS_ERROR, "CCPP", 0, "Unable to allocate memory");
        }
    }
}
DDS::TopicDescription_ptr
DDS::DomainParticipant_impl::unprotected_lookup_topicdescription (
  const char * name
)
{
  gapi_topic handle;
  DDS::ccpp_UserData_ptr myUD;
  DDS::TopicDescription_ptr result = NULL;

  handle = gapi_domainParticipant_lookup_topicdescription(_gapi_self, name);

  if (handle)
  {
    myUD = dynamic_cast<DDS::ccpp_UserData_ptr>((DDS::Object *)gapi_object_get_user_data(handle));
    if (myUD)
    {
      result = dynamic_cast<DDS::TopicDescription_impl_ptr>(myUD->ccpp_object);
      if (result)
      {
        DDS::TopicDescription::_duplicate(result);
      }
      else
      {
        OS_REPORT(OS_ERROR, "CCPP", 0, "Invalid Topic Description");
      }
    }
    else
    {
      // If handle is found in GAPI, but has no UserData, then it has to be a builtin Topic.
      // That's how we know that a Topic_impl wrapper needs to be instantiated in this case.
      result = new DDS::Topic_impl(handle);
      if (result)
      {
        DDS::ccpp_UserData_ptr myUD;
        myUD = new DDS::ccpp_UserData(result, NULL);
        if (myUD)
        {
          gapi_object_set_user_data(handle, (DDS::Object *)myUD,
                                    ccpp_CallBack_DeleteUserData,NULL);
        }
        else
        {
          OS_REPORT(OS_ERROR, "CCPP", 0, "Unable to allocate memory");
        }
      }
    }
  }
  return result;
}
/* initially there is no gapi object and therefore no handle */
DDS::GuardCondition::GuardCondition( ) : DDS::Condition_impl(NULL)
{ 
  DDS::ccpp_UserData_ptr myUD;
  _gapi_self = gapi_guardCondition__alloc();
  if (_gapi_self)
  {
    myUD = new DDS::ccpp_UserData(this);
    /* remove the count of the reference to the object 
       such that it is deleted when the user releases it. 
     */
    CORBA::release(this);
    gapi_object_set_user_data(_gapi_self, (CORBA::Object *)myUD,
                              DDS::ccpp_CallBack_DeleteUserData,NULL);
  }
}
/* initially there is no gapi object and therefore no handle */
DDS::GuardCondition::GuardCondition( ) : DDS::Condition_impl(NULL)
{
  DDS::ccpp_UserData_ptr myUD;
  _gapi_self = gapi_guardCondition__alloc();
  if (_gapi_self)
  {
    myUD = new DDS::ccpp_UserData(this, NULL, NULL, true);
    if (myUD)
    {
        CORBA::Object_ptr parent = dynamic_cast<CORBA::Object_ptr>(myUD);
        gapi_object_set_user_data(_gapi_self, static_cast<void *>(parent),
                              ccpp_CallBack_DeleteUserData,NULL);
    }
    else
    {
      OS_REPORT(OS_ERROR, "CCPP", 0, "Unable to allocate memory");
    }
  }
}
Exemple #6
0
void
saj_write_weak_java_address(
    JNIEnv *env,
    gapi_object gapi_obj,
    jobject java_object)
{
    saj_userData ud;

    assert(env != NULL);
    assert(gapi_obj != NULL);
    assert(java_object != NULL);

    ud = os_malloc(C_SIZEOF(saj_userData));
    ud->saj_object = (*env)->NewWeakGlobalRef(env, java_object);
    saj_exceptionCheck(env);
    ud->listenerData = NULL;
    ud->statusConditionUserData = NULL;
    gapi_object_set_user_data(gapi_obj, (void*)ud,NULL,NULL);
}
Exemple #7
0
void
saj_write_java_listener_address(
    JNIEnv *env,
    gapi_object gapi_obj,
    saj_listenerData listenerData)
{
    saj_userData ud;

    assert(env != NULL);
    assert(listenerData != NULL);

    if(gapi_obj != GAPI_OBJECT_NIL){
        ud = saj_userData(gapi_object_get_user_data(gapi_obj));

        if(ud != NULL){
            if(ud->listenerData != NULL){
                saj_listenerDataFree(env, ud->listenerData);
                ud->listenerData = NULL;
            }
            ud->listenerData = listenerData;
            gapi_object_set_user_data(gapi_obj, (void*)ud,NULL,NULL);
        }
    }
}
bool
DDS::DomainParticipant_impl::createBuiltinReader(
    gapi_subscriber subscriber_handle,
    const char *name
)
{
    char *type_name;
    bool status = false;
    gapi_dataReader reader_handle = NULL;
    gapi_topic topic_handle;
    DDS::DataReader_ptr a_reader = NULL;
    DDS::ccpp_UserData_ptr myUD = NULL;
    gapi_typeSupport ts_handle = NULL;

    reader_handle = gapi_subscriber_lookup_datareader(subscriber_handle, name);
    if (reader_handle)
    {
        topic_handle = gapi_dataReader_get_topicdescription(reader_handle);
        if (topic_handle)
        {
            type_name = gapi_topicDescription_get_type_name(topic_handle);
            ts_handle = gapi_domainParticipant_get_typesupport(_gapi_self, type_name);
            gapi_free(type_name);
            if (ts_handle)
            {
                void *tsf = gapi_object_get_user_data(ts_handle);

                if (tsf)
                {
                    DDS::Object_ptr anObject;
                    DDS::TypeSupportFactory_impl_ptr factory;

                    anObject = static_cast<DDS::Object_ptr>(tsf);
                    factory = dynamic_cast<DDS::TypeSupportFactory_impl_ptr>(anObject);
                    if (factory)
                    {
                        a_reader = factory->create_datareader(reader_handle);
                    }

                    if (a_reader)
                    {
                        myUD = new ccpp_UserData(a_reader, NULL);
                        if (myUD)
                        {
                            gapi_object_set_user_data(reader_handle,
                                                      (DDS::Object *)myUD,
                                                      ccpp_CallBack_DeleteUserData,NULL);
                            status = true;
                        }
                    }
                }
            } else {
                OS_REPORT_1(OS_ERROR,
                            "DDS::DomainParticipant_impl::createBuiltinReader",
                            0, "Lookup TypeSupport Failed for DataReader <%s>",
                            name);
            }
        } else {
            OS_REPORT_1(OS_ERROR,
                        "DDS::DomainParticipant_impl::createBuiltinReader",
                        0, "Lookup Topic Failed for DataReader <%s>", name);
        }
    } else if (name) {
        OS_REPORT_1(OS_ERROR,
                    "DDS::DomainParticipant_impl::createBuiltinReader",
                    0, "Lookup DataReader <%s> Failed", name);
    } else {
        OS_REPORT(OS_ERROR,
                  "DDS::DomainParticipant_impl::createBuiltinReader",
                  0, "Lookup DataReader <NULL> Failed");
    }
    return status;
}