Ignore:
Timestamp:
03/01/14 22:05:02 (10 years ago)
Author:
sz
Message:

Warn against missing converter, convert() caller can differentiate between conversion failure and missing converter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/genoconv.h

    r145 r150  
    1717class GenoConvManager;
    1818
    19 class GenoConvParam: public Param
     19class GenoConvParam : public Param
    2020{
    21 GenoConvManager *gcm;
    22 std::vector<std::string> gcnames;
    23 char tmp_id[20];
    24 void freetab();
     21        GenoConvManager *gcm;
     22        std::vector<std::string> gcnames;
     23        char tmp_id[20];
     24        void freetab();
    2525public:
    26 GenoConvParam(GenoConvManager *g);
    27 ~GenoConvParam();
    28 void *getTarget(int);
    29 const char* id(int i);
    30 void updatetab();
     26        GenoConvParam(GenoConvManager *g);
     27        ~GenoConvParam();
     28        void *getTarget(int);
     29        const char* id(int i);
     30        void updatetab();
    3131};
    3232
     
    4242{
    4343public:
    44 const char *name;       //< converter name (short)
    45 char in_format,         //< input format, eg. '1'
    46         out_format;     //< output format, eg. '0'
    47 const char *info;       //< detailed info about converter, format or copyright
    48 long enabled;   //< don't touch this! (used by configuration module)
    49 long mapsupport; //< set to 1 if your converter supports genotype mapping
     44        const char *name;       //< converter name (short)
     45        char in_format,         //< input format, eg. '1'
     46                out_format;     //< output format, eg. '0'
     47        const char *info;       //< detailed info about converter, format or copyright
     48        long enabled;   //< don't touch this! (used by configuration module)
     49        long mapsupport; //< set to 1 if your converter supports genotype mapping
    5050
    51 /// You have to reimplement this method.
    52 /// If your converter cannot do its job, return empty string
    53 /// (return SString();), any other return value is assumed
    54 /// to be output genotype.
    55 /// @param map if not null, mapping informaton is requested, converter should add conversion map to this object
    56 virtual SString convert(SString &i,MultiMap *map) {return SString();}
     51        /// You have to reimplement this method.
     52        /// If your converter cannot do its job, return empty string
     53        /// (return SString();), any other return value is assumed
     54        /// to be output genotype.
     55        /// @param map if not null, mapping informaton is requested, converter should add conversion map to this object
     56        virtual SString convert(SString &i, MultiMap *map) { return SString(); }
    5757
    58 virtual ~GenoConverter() {}
    59 /// Don't forget to set public fields in your constructor
    60 GenoConverter():name(""),in_format(-1),out_format('0'),info(""),enabled(1),mapsupport(0) {}
     58        virtual ~GenoConverter() {}
     59        /// Don't forget to set public fields in your constructor
     60        GenoConverter() :name(""), in_format(-1), out_format('0'), info(""), enabled(1), mapsupport(0) {}
    6161};
    6262
     
    7171class GenoConvManager
    7272{
    73 friend class GenoConvParam;
    74 SList converters;
     73        friend class GenoConvParam;
     74        SList converters;
    7575public:
    76 GenoConvManager();
    77 ~GenoConvManager();
    78 class GenoConvParam param;
    79 /// make a genotype in other format. genotype will be invalid
    80 /// if GenoConvManager cannot convert it.
    81 Geno convert(Geno &in,char format,MultiMap *map=0);
    82 /// register GenoConverter, the added object will be automatically deleted when GenoConvManager is destructed (call removeConverter() if this is not desirable)
    83 void addConverter(GenoConverter *conv);
    84 /// unregister GenoConverter
    85 void removeConverter(GenoConverter *conv);
     76        GenoConvManager();
     77        ~GenoConvManager();
     78        class GenoConvParam param;
     79        /// make a genotype in other format. genotype will be invalid
     80        /// if GenoConvManager cannot convert it.
     81        Geno convert(Geno &in, char format, MultiMap *map = 0, bool *converter_missing = NULL);
     82        /// register GenoConverter, the added object will be automatically deleted when GenoConvManager is destructed (call removeConverter() if this is not desirable)
     83        void addConverter(GenoConverter *conv);
     84        /// unregister GenoConverter
     85        void removeConverter(GenoConverter *conv);
    8686
    87 char *getPath(char in,char out,char *path,int maxlen,int *mapavailable=0);
    88 char *getFormatPath(char in,char out,char *path,int maxlen,int *mapavailable=0);
    89 /// returns the list of converters meeting the specified criteria
    90 /// pass result=0 if you only need one result (by return value)
    91 /// default criteria values mean "don't care", pass anything else to narrow your search
    92 GenoConverter *findConverters(SListTempl<GenoConverter*>* result=0,char in=-1,char out=-1,int enabled=-1,char* name=0);
     87        char *getPath(char in, char out, char *path, int maxlen, int *mapavailable = 0);
     88        char *getFormatPath(char in, char out, char *path, int maxlen, int *mapavailable = 0);
     89        /// returns the list of converters meeting the specified criteria
     90        /// pass result=0 if you only need one result (by return value)
     91        /// default criteria values mean "don't care", pass anything else to narrow your search
     92        GenoConverter *findConverters(SListTempl<GenoConverter*>* result = 0, char in = -1, char out = -1, int enabled = -1, char* name = 0);
    9393};
    9494
    9595#endif
    96 
    97 
Note: See TracChangeset for help on using the changeset viewer.