Ignore:
Timestamp:
06/25/20 00:34:29 (4 years ago)
Author:
Maciej Komosinski
Message:

Genetic format ID becomes a string (no longer limited to a single character)

File:
1 edited

Legend:

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

    r732 r955  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    3434        SString gen;
    3535        SString name;
    36         char format;
     36        SString format;
    3737        SString txt;
    3838        int isvalid; ///< <0 -> unknown   >=0 -> value for "isValid"
     
    4444        int multiline;
    4545
    46         void init(const SString& genstring, char genformat, const SString& genname, const SString& comment);
     46        void init(const SString& genstring, const SString& genformat, const SString& genname, const SString& comment);
    4747        void validate(void);
    4848
     
    5555
    5656public:
    57         static const char INVALID_FORMAT = '!';
     57        static const SString INVALID_FORMAT;
     58        static const SString UNKNOWN_FORMAT;
    5859        typedef SListTempl<GenoValidator*> Validators;
    5960
     
    6263        /// @param genformat genotype format
    6364        /// @param comment information about genotype (for genetic operators and "history")
    64         Geno(const char *genstring = 0, char genformat = -1, const char *genname = 0, const char *comment = 0);
     65        Geno(const char *genstring = 0, const char* genformat = 0, const char *genname = 0, const char *comment = 0);
     66
     67        Geno(const char *genstring, char genformat, const char *genname = 0, const char *comment = 0); //old style Geno, accepts char genoformat
    6568
    6669        /// create a genotype object from primitives
     
    6972        /// @param name genotype name, new name will generated if needed
    7073        /// @param comment information about genotype (for genetic operators and "history")
    71         Geno(const SString& genstring, char genformat, const SString& genname, const SString& comment);
     74        Geno(const SString& genstring, const SString& genformat, const SString& genname, const SString& comment);
    7275
    7376        /// create object from full string, containing optional format and comment information
     
    8992        void setString(const SString& genewithcomments);
    9093
    91         /** @param genformat=-1 -> detect genotype format from genstring comment (like the constructor does), else specify the valid format in genformat and pure genes in genstring. */
    92         void setGenesAndFormat(const SString& genstring, char genformat = -1);
     94        /** @param genformat="" -> detect genotype format from genstring comment (like the constructor does), else specify the valid format in genformat and pure genes in genstring. */
     95        void setGenesAndFormat(const SString& genstring, const SString& genformat = UNKNOWN_FORMAT);
    9396        /** g must be pure genes, without format. For the standard behavior use setGenesAndFormat() */
    9497        void setGenesAssumingSameFormat(const SString& g);
     
    97100        SString getName(void) const;
    98101        void setName(const SString&);
    99         char getFormat(void) const;
     102        SString getFormat(void) const;
    100103
    101104        SString getComment(void) const;
     
    107110        /// make converted version of the genotype.
    108111        /// @param converter_missing optional output parameter (ignored when NULL). Receives true if the conversion fails because of the lack of appropriate converter(s) (the returned Geno is always invalid in this case). Receives false if the genotype was converted by a converter or a converter chain (the returned Geno can be valid or invalid, depending on the converter's decision).
    109         Geno getConverted(char otherformat, MultiMap *m = 0, bool using_checkpoints = false, bool *converter_missing = NULL);
     112        Geno getConverted(SString otherformat, MultiMap *m = 0, bool using_checkpoints = false, bool *converter_missing = NULL);
    110113
    111114        /// @return -1 = before first char in the string
Note: See TracChangeset for help on using the changeset viewer.