SpiceCel.h
上传用户:center1979
上传日期:2022-07-26
资源大小:50633k
文件大小:20k
源码类别:

OpenGL

开发平台:

Visual C++

  1. /*
  2. -Header_File SpiceCel.h ( CSPICE Cell definitions )
  3. -Abstract
  4.    Perform CSPICE definitions for the SpiceCell data type.
  5.             
  6. -Disclaimer
  7.    THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
  8.    CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
  9.    GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
  10.    ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
  11.    PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
  12.    TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
  13.    WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
  14.    PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
  15.    SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
  16.    SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
  17.    IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
  18.    BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
  19.    LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  20.    INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
  21.    REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
  22.    REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
  23.    RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
  24.    THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
  25.    CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
  26.    ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
  27. -Required_Reading
  28.    CELLS
  29.    
  30. -Particulars
  31.    This header defines structures, macros, and enumerated types that
  32.    may be referenced in application code that calls CSPICE cell
  33.    functions.
  34.  
  35.    CSPICE cells are data structures that implement functionality
  36.    parallel to that of the cell abstract data type in SPICELIB.  In
  37.    CSPICE, a cell is a C structure containing bookkeeping information,
  38.    including a pointer to an associated data array.
  39.  
  40.    For numeric data types, the data array is simply a SPICELIB-style
  41.    cell, including a valid control area.  For character cells, the data
  42.    array has the same number of elements as the corresponding
  43.    SPICELIB-style cell, but the contents of the control area are not
  44.    maintained, and the data elements are null-terminated C-style
  45.    strings.
  46.    CSPICE cells should be declared using the declaration macros
  47.    provided in this header file.  See the table of macros below.
  48.   
  49.       Structures
  50.       ==========
  51.    
  52.          Name                  Description
  53.          ----                  ----------
  54.    
  55.          SpiceCell             Structure containing CSPICE cell metadata.
  56.          
  57.                                The members are:
  58.                                   dtype:     Data type of cell: character,
  59.                                              integer, or double precision.
  60.                                              dtype has type 
  61.                                              SpiceCellDataType.
  62.                                   length:    For character cells, the 
  63.                                              declared length of the 
  64.                                              cell's string array.
  65.  
  66.                                   size:      The maximum number of data
  67.                                              items that can be stored in
  68.                                              the cell's data array.
  69.                                   card:      The cell's "cardinality": the
  70.                                              number of data items currently
  71.                                              present in the cell.
  72.                                   isSet:     Boolean flag indicating whether
  73.                                              the cell is a CSPICE set.  
  74.                                              Sets have no duplicate data 
  75.                                              items, and their data items are
  76.                                              stored in increasing order.
  77.                                   adjust:    Boolean flag indicating whether
  78.                                              the cell's data area has 
  79.                                              adjustable size.  Adjustable
  80.                                              size cell data areas are not 
  81.                                              currently implemented.
  82.                                   init:      Boolean flag indicating whether
  83.                                              the cell has been initialized.
  84.                                   base:      is a void pointer to the 
  85.                                              associated data array.  base
  86.                                              points to the start of the
  87.                                              control area of this array.
  88.                                   data:      is a void pointer to the 
  89.                                              first data slot in the 
  90.                                              associated data array.  This
  91.                                              slot is the element following
  92.                                              the control area.
  93.  
  94.          ConstSpiceCell        A const SpiceCell.
  95.          
  96.   
  97.       Declaration Macros
  98.       ==================      
  99.       Name                                            Description
  100.       ----                                            ----------
  101.       SPICECHAR_CELL ( name, size, length )           Declare a
  102.                                                       character CSPICE
  103.                                                       cell having cell
  104.                                                       name name,
  105.                                                       maximum cell
  106.                                                       cardinality size,
  107.                                                       and string length
  108.                                                       length.  The
  109.                                                       macro declares
  110.                                                       both the cell and
  111.                                                       the associated
  112.                                                       data array. The
  113.                                                       name of the data
  114.                                                       array begins with
  115.                                                       "SPICE_".
  116.  
  117.                                                          
  118.       SPICEDOUBLE_CELL ( name, size )                 Like SPICECHAR_CELL,
  119.                                                       but declares a 
  120.                                                       double precision
  121.                                                       cell.
  122.   
  123.       SPICEINT_CELL ( name, size )                    Like
  124.                                                       SPICECHAR_CELL,
  125.                                                       but declares an
  126.                                                       integer cell.
  127.       Assignment Macros
  128.       =================      
  129.       Name                                            Description
  130.       ----                                            ----------
  131.       SPICE_CELL_SET_C( item, i, cell )               Assign the ith
  132.                                                       element of a
  133.                                                       character cell.
  134.                                                       Arguments cell
  135.                                                       and item are
  136.                                                       pointers.
  137.  
  138.       SPICE_CELL_SET_D( item, i, cell )               Assign the ith
  139.                                                       element of a
  140.                                                       double precision
  141.                                                       cell. Argument
  142.                                                       cell is a
  143.                                                       pointer.
  144.  
  145.       SPICE_CELL_SET_I( item, i, cell )               Assign the ith
  146.                                                       element of an
  147.                                                       integer cell.
  148.                                                       Argument cell is
  149.                                                       a pointer.
  150.  
  151.       Fetch Macros
  152.       ==============      
  153.       Name                                            Description
  154.       ----                                            ----------
  155.       SPICE_CELL_GET_C( cell, i, lenout, item )       Fetch the ith
  156.                                                       element from a
  157.                                                       character cell.
  158.                                                       Arguments cell
  159.                                                       and item are
  160.                                                       pointers.
  161.                                                       Argument lenout
  162.                                                       is the available
  163.                                                       space in item.
  164.  
  165.       SPICE_CELL_GET_D( cell, i, item )               Fetch the ith
  166.                                                       element from a
  167.                                                       double precision
  168.                                                       cell. Arguments
  169.                                                       cell and item are
  170.                                                       pointers.
  171.       SPICE_CELL_GET_I( cell, i, item )               Fetch the ith
  172.                                                       element from an
  173.                                                       integer cell.
  174.                                                       Arguments cell
  175.                                                       and item are
  176.                                                       pointers.
  177.       Element Pointer Macros
  178.       ======================      
  179.       Name                                            Description
  180.       ----                                            ----------
  181.       SPICE_CELL_ELEM_C( cell, i )                    Macro evaluates
  182.                                                       to a SpiceChar
  183.                                                       pointer to the
  184.                                                       ith data element
  185.                                                       of a character
  186.                                                       cell. Argument
  187.                                                       cell is a
  188.                                                       pointer.
  189.       SPICE_CELL_ELEM_D( cell, i )                    Macro evaluates
  190.                                                       to a SpiceDouble
  191.                                                       pointer to the
  192.                                                       ith data element
  193.                                                       of a double
  194.                                                       precision cell.
  195.                                                       Argument cell is
  196.                                                       a pointer.
  197.       SPICE_CELL_ELEM_I( cell, i )                    Macro evaluates
  198.                                                       to a SpiceInt
  199.                                                       pointer to the
  200.                                                       ith data element
  201.                                                       of an integer
  202.                                                       cell. Argument
  203.                                                       cell is a
  204.                                                       pointer.
  205. -Literature_References
  206.    None.
  207. -Author_and_Institution
  208.    N.J. Bachman       (JPL)
  209.    
  210. -Restrictions
  211.    None.
  212.       
  213. -Version
  214.    -CSPICE Version 1.0.0, 22-AUG-2002 (NJB)  
  215. */
  216. #ifndef HAVE_SPICE_CELLS_H
  217.    #define HAVE_SPICE_CELLS_H
  218.       
  219.    /*
  220.    Data type codes:
  221.    */
  222.    typedef enum _SpiceDataType  SpiceCellDataType;
  223.    /*
  224.    Cell structure:
  225.    */
  226.    struct _SpiceCell
  227.    
  228.       {  SpiceCellDataType  dtype;
  229.          SpiceInt           length;
  230.          SpiceInt           size;
  231.          SpiceInt           card;
  232.          SpiceBoolean       isSet;
  233.          SpiceBoolean       adjust;
  234.          SpiceBoolean       init;
  235.          void             * base;
  236.          void             * data;  };     
  237.         
  238.    typedef struct _SpiceCell  SpiceCell;
  239.    typedef const SpiceCell    ConstSpiceCell;
  240.    /*
  241.    SpiceCell control area size: 
  242.    */
  243.    #define SPICE_CELL_CTRLSZ         6
  244.    /*
  245.    Declaration macros: 
  246.    */                   
  247.                                            
  248.    #define SPICECHAR_CELL( name, size, length )                             
  249.                                                                             
  250.       static SpiceChar SPICE_CELL_##name[SPICE_CELL_CTRLSZ + size][length]; 
  251.                                                                             
  252.       static SpiceCell name =                                               
  253.                                                                             
  254.         { SPICE_CHR,                                                        
  255.           length,                                                           
  256.           size,                                                             
  257.           0,                                                                
  258.           SPICETRUE,                                                        
  259.           SPICEFALSE,                                                       
  260.           SPICEFALSE,                                                       
  261.           (void *) &(SPICE_CELL_##name),                                    
  262.           (void *) &(SPICE_CELL_##name[SPICE_CELL_CTRLSZ])  }
  263.         
  264.    #define SPICEDOUBLE_CELL( name, size )                                   
  265.                                                                             
  266.       static SpiceDouble SPICE_CELL_##name [SPICE_CELL_CTRLSZ + size];      
  267.                                                                             
  268.       static SpiceCell name =                                               
  269.                                                                             
  270.         { SPICE_DP,                                                         
  271.           0,                                                                
  272.           size,                                                             
  273.           0,                                                                
  274.           SPICETRUE,                                                        
  275.           SPICEFALSE,                                                       
  276.           SPICEFALSE,                                                       
  277.           (void *) &(SPICE_CELL_##name),                                    
  278.           (void *) &(SPICE_CELL_##name[SPICE_CELL_CTRLSZ])  }
  279.        
  280.    #define SPICEINT_CELL( name, size )                                      
  281.                                                                             
  282.       static SpiceInt SPICE_CELL_##name [SPICE_CELL_CTRLSZ + size];         
  283.                                                                             
  284.       static SpiceCell name =                                               
  285.                                                                             
  286.         { SPICE_INT,                                                        
  287.           0,                                                                
  288.           size,                                                             
  289.           0,                                                                
  290.           SPICETRUE,                                                        
  291.           SPICEFALSE,                                                       
  292.           SPICEFALSE,                                                       
  293.           (void *) &(SPICE_CELL_##name),                                    
  294.           (void *) &(SPICE_CELL_##name[SPICE_CELL_CTRLSZ])  }
  295.            
  296.    /*
  297.    Access macros for individual elements: 
  298.    */
  299.    /*
  300.    Data element pointer macros: 
  301.    */
  302.    #define SPICE_CELL_ELEM_C( cell, i )                                     
  303.                                                                             
  304.        (  ( (SpiceChar    *) (cell)->data ) + (i)*( (cell)->length )  )      
  305.    #define SPICE_CELL_ELEM_D( cell, i )                                     
  306.                                                                             
  307.        (  ( (SpiceDouble  *) (cell)->data )[(i)]  )         
  308.    #define SPICE_CELL_ELEM_I( cell, i )                                     
  309.                                                                             
  310.        (  ( (SpiceInt     *) (cell)->data )[(i)]  )         
  311.    /*
  312.    "Fetch" macros: 
  313.    */
  314.    #define SPICE_CELL_GET_C( cell, i, lenout, item )                        
  315.                                                                             
  316.        {                                                                    
  317.           SpiceInt    nBytes;                                               
  318.                                                                             
  319.           nBytes   =    brckti_c ( (cell)->length,  0, (lenout-1)  )        
  320.                      *  sizeof   ( SpiceChar );                             
  321.                                                                             
  322.           memmove ( (item),  SPICE_CELL_ELEM_C((cell), (i)),  nBytes );     
  323.                                                                             
  324.           item[nBytes] = NULLCHAR;                                          
  325.        }  
  326.    #define SPICE_CELL_GET_D( cell, i, item )                                
  327.                                                                             
  328.        (  (*item) = ( (SpiceDouble *) (cell)->data)[i]  )    
  329.    #define SPICE_CELL_GET_I( cell, i, item )                                
  330.                                                                             
  331.        (  (*item) = ( (SpiceInt    *) (cell)->data)[i]  )         
  332.    /*
  333.    Assignment macros: 
  334.    */
  335.    #define SPICE_CELL_SET_C( item, i, cell )                                
  336.                                                                             
  337.        {                                                                    
  338.           SpiceChar   * sPtr;                                               
  339.           SpiceInt      nBytes;                                             
  340.                                                                             
  341.           nBytes   =    brckti_c ( strlen(item), 0, (cell)->length - 1 )    
  342.                       * sizeof   ( SpiceChar );                             
  343.                                                                             
  344.           sPtr     =    SPICE_CELL_ELEM_C((cell), (i));                     
  345.                                                                             
  346.           memmove ( sPtr,  (item),  nBytes );                               
  347.                                                                             
  348.           sPtr[nBytes] = NULLCHAR;                                          
  349.        }  
  350.    #define SPICE_CELL_SET_D( item, i, cell )                                
  351.                                                                             
  352.        (  ( (SpiceDouble *) (cell)->data)[i]  =  (item) )    
  353.    #define SPICE_CELL_SET_I( item, i, cell )                                
  354.                                                                             
  355.        (  ( (SpiceInt    *) (cell)->data)[i]  =  (item) )         
  356.    /*
  357.    The enum SpiceTransDir is used to indicate language translation
  358.    direction:  C to Fortran or vice versa. 
  359.    */
  360.    enum _SpiceTransDir { C2F = 0, F2C = 1 };
  361.    
  362.    typedef enum  _SpiceTransDir SpiceTransDir;
  363. #endif