source: cpp/frams/_demos/geno_test.cpp @ 141

Last change on this file since 141 was 141, checked in by sz, 8 years ago

Improved genotype validation in geno_test and genooper_test (using GenMan?'s genetic operators)

  • Property svn:eol-style set to native
File size: 1.2 KB
Line 
1// This file is a part of the Framsticks GDK.
2// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
3// Refer to http://www.framsticks.com/ for further information.
4
5#include <frams/genetics/geno.h>
6#include <frams/virtfile/stdiofile.h>
7#include <frams/util/sstringutils.h>
8#include <frams/genetics/defgenoconv.h>
9#include <frams/genetics/genman.h>
10
11/**
12 @file
13 Sample code: Testing genotype validity
14
15 \include geno_test.cpp
16*/
17
18DefaultGenoConvManager gcm; //without this object the application would only handle "format 0" genotypes
19
20int main(int argc,char*argv[])
21{
22GenMan gm;
23Geno::validators.insert(0,&gm); //GenMan is available in this application so let's use the extended validity checking!
24// Note: insert() makes it the first validator in the list, this is important for formats that rely on genetic operators to perform reasonable validation,
25// otherwise the default validator (genotype converter) would "win" and most converters are less strict in detecting invalid genotypes.
26if (argc<=1)
27        {
28        puts("no genotype");
29        return 10;
30        }
31SString gen(argv[1]);
32if (!strcmp(gen,"-"))
33        {
34        gen=0;
35        StdioFILEDontClose in(stdin);
36        loadSString(&in,gen);
37        }
38Geno g(gen);
39puts(g.isValid()?"valid":"invalid");
40return !g.isValid();
41}
Note: See TracBrowser for help on using the repository browser.