sinfo_dump.c

00001 /*                                                                           *
00002  *   This file is part of the SINFONI   Pipeline                             *
00003  *   Copyright (C) 2002,2003 European Southern Observatory                   *
00004  *                                                                           *
00005  *   This library is free software; you can redistribute it and/or modify    *
00006  *   it under the terms of the GNU General Public License as published by    *
00007  *   the Free Software Foundation; either version 2 of the License, or       *
00008  *   (at your option) any later version.                                     *
00009  *                                                                           *
00010  *   This program is distributed in the hope that it will be useful,         *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
00013  *   GNU General Public License for more details.                            *
00014  *                                                                           *
00015  *   You should have received a copy of the GNU General Public License       *
00016  *   along with this program; if not, write to the Free Software             *
00017  *   Foundation, 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA    *
00018  *                                                                           */
00019 
00020 /*
00021  * $Author: amodigli $
00022  * $Date: 2012/03/02 08:42:20 $
00023  * $Revision: 1.8 $
00024  * $Name: sinfo-2_3_0 $
00025  * $Log: sinfo_dump.c,v $
00026  * Revision 1.8  2012/03/02 08:42:20  amodigli
00027  * fixed some typos on doxygen
00028  *
00029  * Revision 1.7  2011/11/23 17:29:19  amodigli
00030  * fix warning with cpl6
00031  *
00032  * Revision 1.6  2008/01/17 07:54:04  amodigli
00033  * shorten long lines
00034  *
00035  * Revision 1.5  2007/08/11 10:45:47  amodigli
00036  * upgrade to CPL4, fixed compil warnings
00037  *
00038  * Revision 1.4  2007/06/06 07:10:45  amodigli
00039  * replaced tab with 4 spaces
00040  *
00041  * Revision 1.3  2006/10/20 08:07:05  amodigli
00042  * using prefix sinfo_ in place of sinfoni_ for includes
00043  *
00044  * Revision 1.2  2006/10/16 07:26:23  amodigli
00045  * shortened line length
00046  *
00047  * Revision 1.1  2006/08/09 12:20:11  amodigli
00048  * added sinfo_dump.h sinfo_dump.c
00049  *
00050  * Revision 1.7  2006/05/12 15:02:05  jmlarsen
00051  * Support NULL tags
00052  *
00053  * Revision 1.6  2006/02/28 09:15:22  jmlarsen
00054  * Minor update
00055  *
00056  * Revision 1.5  2006/02/15 13:19:15  jmlarsen
00057  * Reduced source code max. line length
00058  *
00059  * Revision 1.4  2005/12/19 16:17:56  jmlarsen
00060  * Replaced bool -> int
00061  *
00062  */
00063 
00064 #ifdef HAVE_CONFIG_H
00065 #  include <config.h>
00066 #endif
00067 
00070 /*----------------------------------------------------------------------------*/
00077 /*----------------------------------------------------------------------------*/
00078 
00079 
00080 #include <sinfo_dump.h>
00081 #include <sinfo_utils.h>
00082 #include <sinfo_error.h>
00083 #include <sinfo_msg.h>
00084 #include <cpl.h>
00085 
00086 /*----------------------------------------------------------------*/
00098 /*----------------------------------------------------------------*/
00099 cpl_error_code
00100 sinfo_print_cpl_propertylist(const cpl_propertylist *pl, long low, long high)
00101 {
00102     cpl_property *prop;
00103     long i = 0;
00104     
00105     assure (0 <= low && high <= cpl_propertylist_get_size(pl) && low <= high,
00106         CPL_ERROR_ILLEGAL_INPUT, "Illegal range");
00107     /* Printing an empty range is allowed but only when low == high */
00108 
00109     if (pl == NULL){
00110     sinfo_msg("NULL");
00111     }
00112     else if (cpl_propertylist_is_empty(pl))  {
00113     sinfo_msg("[Empty property list]");
00114     }
00115     else    
00116     for (i = low; i < high; i++)
00117         {
00118         /* bug workaround: remove const cast when declaration 
00119            of cpl_propertylist_get() is changed */
00120         prop = cpl_propertylist_get((cpl_propertylist *)pl, i);
00121         check (sinfo_print_cpl_property(prop), 
00122                 "Error printing property");
00123         }
00124     
00125   cleanup:
00126     return cpl_error_get_code();
00127 }
00128 /*----------------------------------------------------------------*/
00136 /*----------------------------------------------------------------*/
00137 
00138 cpl_error_code
00139 sinfo_print_cpl_property(const cpl_property *prop)
00140 {
00141     cpl_type t;
00142 
00143     if (prop == NULL)
00144     {
00145         sinfo_msg("NULL");
00146     }
00147     else
00148     {   
00149         /* print property with this formatting
00150            NAME =
00151              VALUE
00152            COMMENT
00153         */
00154 
00155         /* print name */
00156         
00157         sinfo_msg("%s =", cpl_property_get_name(prop));
00158 
00159         /* print value */
00160         
00161         check( t = cpl_property_get_type(prop), 
00162                   "Could not read property type");
00163         
00164         switch(t & (~CPL_TYPE_FLAG_ARRAY))
00165         {
00166         case CPL_TYPE_CHAR:
00167             if (t & CPL_TYPE_FLAG_ARRAY)  /* if type is string */
00168             {
00169                 sinfo_msg("  '%s'", cpl_property_get_string(prop));
00170             }
00171             else                          /* an ordinary char */
00172             {
00173                 sinfo_msg("  %c", cpl_property_get_char(prop));
00174             }
00175             break;
00176         case CPL_TYPE_BOOL:    if (cpl_property_get_bool(prop))
00177             {sinfo_msg("  true");}
00178         else
00179             {sinfo_msg("  false");}
00180             break;
00181         case CPL_TYPE_UCHAR: 
00182       sinfo_msg("%c",cpl_property_get_char(prop)); 
00183           break;
00184         case CPL_TYPE_INT:   
00185       sinfo_msg("%d",cpl_property_get_int(prop)); 
00186           break;
00187         case CPL_TYPE_UINT:  
00188           sinfo_msg("%d",cpl_property_get_int(prop)); 
00189           break;
00190         case CPL_TYPE_LONG: 
00191           sinfo_msg("%ld",cpl_property_get_long(prop)); 
00192           break;
00193         case CPL_TYPE_ULONG: 
00194           sinfo_msg("%ld",cpl_property_get_long(prop)); 
00195           break;
00196         case CPL_TYPE_FLOAT: 
00197           sinfo_msg("%f",cpl_property_get_float(prop)); 
00198           break;
00199         case CPL_TYPE_DOUBLE: 
00200           sinfo_msg("%f",cpl_property_get_double(prop)); 
00201           break;
00202         case CPL_TYPE_POINTER: 
00203           sinfo_msg("POINTER");    
00204           break;
00205         case CPL_TYPE_INVALID: 
00206           sinfo_msg("INVALID");    
00207           break;
00208         default: 
00209           sinfo_msg("  unrecognized property");  
00210           break;
00211         }
00212         
00213         /* Is this property an array? */
00214         if (t & CPL_TYPE_FLAG_ARRAY){
00215            cpl_msg_info(cpl_func,"  (array size = %" CPL_SIZE_FORMAT " )", 
00216               cpl_property_get_size(prop));
00217         }
00218 
00219         /* Print comment */
00220         if (cpl_property_get_comment(prop) != NULL){
00221         sinfo_msg("    %s", cpl_property_get_comment(prop));
00222         }
00223     }
00224 
00225   cleanup:
00226     return cpl_error_get_code();
00227 }
00228 
00229 /*----------------------------------------------------------------*/
00237 /*----------------------------------------------------------------*/
00238 cpl_error_code
00239 sinfo_print_cpl_frameset(const cpl_frameset *frames)
00240 {
00241     /* Two special cases: a NULL frame set and an empty frame set */
00242 
00243     if (frames == NULL)
00244     {
00245         sinfo_msg("NULL");
00246     }
00247     else
00248     {
00249         const cpl_frame *f = NULL;
00250         check( f = cpl_frameset_get_first_const(frames), 
00251                    "Error reading frameset");
00252         
00253         if (f == NULL)
00254         {
00255             sinfo_msg("[Empty frame set]");
00256         }
00257         else
00258         {
00259             while(f != NULL)
00260             {
00261                 check( sinfo_print_cpl_frame(f), 
00262                                   "Could not print frame");
00263                 check( f = cpl_frameset_get_next_const(frames), 
00264                                   "Error reading frameset");
00265             }
00266         }
00267     }
00268     
00269   cleanup:
00270     return cpl_error_get_code();
00271 }
00272 
00273 /*----------------------------------------------------------------*/
00281 /*----------------------------------------------------------------*/
00282 cpl_error_code
00283 sinfo_print_cpl_frame(const cpl_frame *f)
00284 {
00285     if (f == NULL)
00286     {
00287         sinfo_msg("NULL");
00288     }
00289     else
00290     {
00291         sinfo_msg("%-7s %-20s '%s'", 
00292              sinfo_tostring_cpl_frame_group(cpl_frame_get_group(f)),
00293              cpl_frame_get_tag(f) != NULL ? 
00294                      cpl_frame_get_tag(f) : "Null",
00295              cpl_frame_get_filename(f));
00296         
00297         sinfo_msg_debug("type \t= %s",   
00298             sinfo_tostring_cpl_frame_type (cpl_frame_get_type (f)));
00299         sinfo_msg_debug("group \t= %s",  
00300             sinfo_tostring_cpl_frame_group(cpl_frame_get_group(f)));
00301         sinfo_msg_debug("level \t= %s",  
00302             sinfo_tostring_cpl_frame_level(cpl_frame_get_level(f)));
00303     }
00304 
00305     return cpl_error_get_code();
00306 }
00307 
00308 /*----------------------------------------------------------------*/
00314 /*----------------------------------------------------------------*/
00315 const char *
00316 sinfo_tostring_cpl_frame_type(cpl_frame_type ft)
00317 {    
00318     switch(ft)
00319     {
00320     case CPL_FRAME_TYPE_NONE:   return "NONE";      break;
00321     case CPL_FRAME_TYPE_IMAGE:  return "IMAGE";     break;
00322     case CPL_FRAME_TYPE_MATRIX: return "MATRIX";    break;
00323     case CPL_FRAME_TYPE_TABLE:  return "TABLE";     break;
00324     default: return "unrecognized frame type";
00325     }
00326 }
00327 
00328 /*----------------------------------------------------------------*/
00334 /*----------------------------------------------------------------*/
00335 const char *
00336 sinfo_tostring_cpl_frame_group(cpl_frame_group fg)
00337 {
00338     switch(fg)
00339     {
00340     case CPL_FRAME_GROUP_NONE:    return "NONE";                    break;
00341     case CPL_FRAME_GROUP_RAW:     return CPL_FRAME_GROUP_RAW_ID;    break;
00342     case CPL_FRAME_GROUP_CALIB:   return CPL_FRAME_GROUP_CALIB_ID;  break;
00343     case CPL_FRAME_GROUP_PRODUCT: return CPL_FRAME_GROUP_PRODUCT_ID;break;
00344     default:
00345         return "unrecognized frame group";
00346     }
00347 }
00348 
00349 /*----------------------------------------------------------------*/
00355 /*----------------------------------------------------------------*/
00356 const char *
00357 sinfo_tostring_cpl_frame_level(cpl_frame_level fl)
00358 {
00359     
00360     switch(fl)
00361     {
00362     case CPL_FRAME_LEVEL_NONE:        return "NONE";        break;
00363     case CPL_FRAME_LEVEL_TEMPORARY:   return "TEMPORARY";   break;
00364     case CPL_FRAME_LEVEL_INTERMEDIATE:return "INTERMEDIATE";break;
00365     case CPL_FRAME_LEVEL_FINAL:       return "FINAL";       break;
00366     default: return "unrecognized frame level";
00367     }
00368 }
00369 
00370 
00371 /*----------------------------------------------------------------*/
00377 /*----------------------------------------------------------------*/
00378 const char *
00379 sinfo_tostring_cpl_type(cpl_type t)
00380 {
00381 
00382     /* Note that CPL_TYPE_STRING is shorthand
00383        for CPL_TYPE_CHAR | CPL_TYPE_FLAG_ARRAY . */
00384 
00385     if (!(t & CPL_TYPE_FLAG_ARRAY))
00386     switch(t & (~CPL_TYPE_FLAG_ARRAY))
00387         {
00388         case CPL_TYPE_CHAR:       return "char";    break;
00389         case CPL_TYPE_UCHAR:      return "uchar";   break;
00390         case CPL_TYPE_BOOL:       return "boolean"; break;
00391         case CPL_TYPE_INT:        return "int";     break;
00392         case CPL_TYPE_UINT:       return "uint";    break;
00393         case CPL_TYPE_LONG:       return "long";    break;
00394         case CPL_TYPE_ULONG:      return "ulong";   break;
00395         case CPL_TYPE_FLOAT:      return "float";   break;
00396         case CPL_TYPE_DOUBLE:     return "double";  break;
00397         case CPL_TYPE_POINTER:    return "pointer"; break;
00398 /* not in CPL3.0: case CPL_TYPE_COMPLEX:    return "complex"; break; */
00399         case CPL_TYPE_INVALID:    return "invalid"; break;
00400         default:
00401         return "unrecognized type";
00402         }
00403     else
00404     switch(t & (~CPL_TYPE_FLAG_ARRAY))
00405         {
00406         case CPL_TYPE_CHAR:       return "string (char array)"; break;
00407         case CPL_TYPE_UCHAR:      return "uchar array";         break;
00408         case CPL_TYPE_BOOL:       return "boolean array";       break;
00409         case CPL_TYPE_INT:        return "int array";           break;
00410         case CPL_TYPE_UINT:       return "uint array";          break;
00411         case CPL_TYPE_LONG:       return "long array";          break;
00412         case CPL_TYPE_ULONG:      return "ulong array";         break;
00413         case CPL_TYPE_FLOAT:      return "float array";         break;
00414         case CPL_TYPE_DOUBLE:     return "double array";        break;
00415         case CPL_TYPE_POINTER:    return "pointer array";       break;
00416 /* not in CPL3.0: case CPL_TYPE_COMPLEX:    return "complex array"; break; */
00417         case CPL_TYPE_INVALID:    return "invalid (array)";     break;
00418         default:
00419         return "unrecognized type";
00420         }
00421 }

Generated on 26 Mar 2012 for SINFONI Pipeline Reference Manual by  doxygen 1.6.1