atrri

Refractive indices varying with wavelength
git clone git://git.meso-star.fr/atrri.git
Log | Files | Refs | README | LICENSE

atrri.h (3174B)


      1 /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com)
      2  * Copyright (C) 2021 Centre National de la Recherche Scientifique
      3  *
      4  * This program is free software: you can redistribute it and/or modify
      5  * it under the terms of the GNU General Public License as published by
      6  * the Free Software Foundation, either version 3 of the License, or
      7  * (at your option) any later version.
      8  *
      9  * This program is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     12  * GNU General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU General Public License
     15  * along with this program. If not, see <http://www.gnu.org/licenses/>. */
     16 
     17 #ifndef ATRRI_H
     18 #define ATRRI_H
     19 
     20 #include <rsys/rsys.h>
     21 
     22 /* Library symbol management */
     23 #if defined(ATRRI_SHARED_BUILD) /* Build shared library */
     24   #define ATRRI_API extern EXPORT_SYM
     25 #elif defined(ATRRI_STATIC) /* Use/build static library */
     26   #define ATRRI_API extern LOCAL_SYM
     27 #else /* Use shared library */
     28   #define ATRRI_API extern IMPORT_SYM
     29 #endif
     30 
     31 /* Helper macro that asserts if the invocation of the atrri function `Func'
     32  * returns an error. One should use this macro on sth function calls for
     33  * which no explicit error checking is performed */
     34 #ifndef NDEBUG
     35   #define ATRRI(Func) ASSERT(atrri_ ## Func == RES_OK)
     36 #else
     37   #define ATRRI(Func) atrri_ ## Func
     38 #endif
     39 
     40 struct atrri_refractive_index {
     41   double wavelength; /* In nanometer */
     42   double n; /* Real part */
     43   double kappa; /* Imaginary part */
     44 };
     45 #define ATRRI_REFRACTIVE_INDEX_NULL__ {0,0,0}
     46 static const struct atrri_refractive_index ATRRI_REFRACTIVE_INDEX_NULL =
     47   ATRRI_REFRACTIVE_INDEX_NULL__;
     48 
     49 struct atrri_desc {
     50   /* List of indices sorted in ascending order wrt the wavelength */
     51   const struct atrri_refractive_index* indices;
     52   size_t nindices;
     53 };
     54 #define ATRRI_DESC_NULL__ {NULL, 0}
     55 static const struct atrri_desc ATRRI_DESC_NULL = ATRRI_DESC_NULL__;
     56 
     57 /* Forward declaration of external data types */
     58 struct logger;
     59 struct mem_allocator;
     60 
     61 /* Forware declaration of opaque data type */
     62 struct atrri;
     63 
     64 BEGIN_DECLS
     65 
     66 /*******************************************************************************
     67  * AtrRI API
     68  ******************************************************************************/
     69 ATRRI_API res_T
     70 atrri_create
     71   (struct logger* logger, /* NULL <=> use default logger */
     72    struct mem_allocator* allocator, /* NULL <=> use default allocator */
     73    const int verbose, /* Verbosity level */
     74    struct atrri** atrri);
     75 
     76 ATRRI_API res_T
     77 atrri_ref_get
     78   (struct atrri* atrri);
     79 
     80 ATRRI_API res_T
     81 atrri_ref_put
     82   (struct atrri* attrtp);
     83 
     84 ATRRI_API res_T
     85 atrri_load
     86   (struct atrri* atrri,
     87    const char* path);
     88 
     89 ATRRI_API res_T
     90 atrri_load_stream
     91   (struct atrri* atrri,
     92    FILE* stream,
     93    const char* stream_name); /* Can be NULL */
     94 
     95 ATRRI_API res_T
     96 atrri_fetch_refractive_index
     97   (const struct atrri* atrri,
     98    const double wavelength,
     99    struct atrri_refractive_index* refract_id);
    100 
    101 ATRRI_API res_T
    102 atrri_get_desc
    103   (const struct atrri* atrri,
    104    struct atrri_desc* desc);
    105 
    106 END_DECLS
    107 
    108 #endif /* ATRRI_H */