Ejemplo n.º 1
0
 static api_bool api_func QueryState( const_action_handle hSender, const void* info )
 {
    try
    {
       return api_bool( reinterpret_cast<const Action*>( hSender )->IsEnabled(
                                           *reinterpret_cast<const ActionInfo*>( info ) ) );
    }
    ERROR_HANDLER
    return api_false;
 }
Ejemplo n.º 2
0
   static api_bool api_func ValidateProcessImageExecution( const_image_handle hImage, const_process_handle hp, char16_type* whyNot, uint32 maxLen )
   {
      try
      {
         uint32 bitsPerSample;
         api_bool isFloat;
         if ( !(*API->SharedImage->GetImageFormat)( hImage, &bitsPerSample, &isFloat ) )
            throw 0;

         ImageVariant image;
         void* h = const_cast<image_handle>( hImage );
         if ( isFloat )
            switch ( bitsPerSample )
            {
            case 32 :
               image = ImageVariant( new pcl::Image( h ) );
               break;
            case 64 :
               image = ImageVariant( new pcl::DImage( h ) );
               break;
            default :
               return api_false; // ?!
            }
         else
            switch ( bitsPerSample )
            {
            case  8 :
               image = ImageVariant( new UInt8Image( h ) );
               break;
            case 16 :
               image = ImageVariant( new UInt16Image( h ) );
               break;
            case 32 :
               image = ImageVariant( new UInt32Image( h ) );
               break;
            default :
               return api_false; // ?!
            }

         image.SetOwnership( true );

         String whyNotStr;
         bool ok = constInstance->CanExecuteOn( image, whyNotStr );

         if ( !ok && !whyNotStr.IsEmpty() && whyNot != 0 && maxLen > 0 )
               whyNotStr.c_copy( whyNot, maxLen );

         return api_bool( ok );
      }
      ERROR_HANDLER
      return api_false;
   }
Ejemplo n.º 3
0
   static api_bool api_func ValidateProcessGlobalExecution( const_process_handle hp, char16_type* whyNot, uint32 maxLen )
   {
      try
      {
         String whyNotStr;
         bool ok = constInstance->CanExecuteGlobal( whyNotStr );

         if ( !ok && !whyNotStr.IsEmpty() && whyNot != 0 && maxLen > 0 )
               whyNotStr.c_copy( whyNot, maxLen );

         return api_bool( ok );
      }
      ERROR_HANDLER
      return api_false;
   }
Ejemplo n.º 4
0
   static api_bool api_func ValidateProcess( process_handle hp, char16_type* info, uint32 maxLen )
   {
      try
      {
         String infoStr;
         bool valid = instance->Validate( infoStr );

         if ( !valid && !infoStr.IsEmpty() && info != 0 && maxLen > 0 )
            infoStr.c_copy( info, maxLen );

         return api_bool( valid );
      }
      ERROR_HANDLER
      return api_false;
   }
Ejemplo n.º 5
0
bool ProcessInstance::SetParameterValue( const Variant& value,
                                         const ProcessParameter& parameter, size_type rowIndex )
{
   if ( !value.IsValid() )
      return false;

   uint32 apiType = (*API->Process->GetParameterType)( parameter.Handle() ) & PTYPE_TYPE_MASK;
   if ( apiType == 0 )
      throw APIFunctionError( "GetParameterType" );

   if ( apiType == PTYPE_TABLE )
      throw Error( "ProcessInstance::SetParameterValue(): Invoked for a table parameter" );

   if ( apiType == PTYPE_STRING )
   {
      String s = value.ToString();
      return (*API->Process->SetParameterValue)( handle, parameter.Handle(), rowIndex, s.c_str(), s.Length() ) != api_false;
   }

   if ( apiType == PTYPE_BLOCK )
   {
      ByteArray a = value.ToByteArray();
      return (*API->Process->SetParameterValue)( handle, parameter.Handle(), rowIndex, a.Begin(), a.Length() ) != api_false;
   }

   union
   {
      uint32   u32;
      int32    i32;
      uint64   u64;
      int64    i64;
      float    f;
      double   d;
      api_bool b;
      api_enum e;
   }
   apiValue;

   switch ( apiType )
   {
   case PTYPE_UINT8:
   case PTYPE_UINT16:
   case PTYPE_UINT32:
      apiValue.u32 = value.ToUInt();
      break;
   case PTYPE_INT8:
   case PTYPE_INT16:
   case PTYPE_INT32:
      apiValue.i32 = value.ToInt();
      break;
   case PTYPE_UINT64:
      apiValue.u64 = value.ToUInt64();
      break;
   case PTYPE_INT64:
      apiValue.i64 = value.ToInt64();
      break;
   case PTYPE_FLOAT:
      apiValue.f = value.ToFloat();
      break;
   case PTYPE_DOUBLE:
      apiValue.d = value.ToDouble();
      break;
   case PTYPE_BOOL:
      apiValue.b = api_bool( value.ToBoolean() );
      break;
   case PTYPE_ENUM:
      apiValue.e = api_enum( value.ToInt() );
      break;
   default:
      throw Error( "ProcessParameter::SetParameterValue(): Internal error: Unknown parameter type" );
   }

   return (*API->Process->SetParameterValue)( handle, parameter.Handle(), rowIndex, &apiValue, 1 ) != api_false;
}
Ejemplo n.º 6
0
bool Console::Show( bool show )
{
   if ( m_thread == 0 )
      return (*API->Global->ShowConsole)( m_handle, api_bool( show ) ) != api_false;
   return false;
}