Changeset 972 for cpp/frams/_demos/full_props.cpp
- Timestamp:
- 07/03/20 00:32:23 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/_demos/full_props.cpp
r534 r972 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-20 16Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2020 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 47 47 */ 48 48 49 int main(int argc, char*argv[])49 int main(int argc, char*argv[]) 50 50 { 51 StdioFILE::setStdio();//setup VirtFILE::Vstdin/out/err52 LoggerToStdout messages_to_stderr(LoggerBase::Enable | LoggerBase::DontBlock,VirtFILE::Vstderr); //errors -> stderr, don't interfere with stdout51 StdioFILE::setStdio();//setup VirtFILE::Vstdin/out/err 52 LoggerToStdout messages_to_stderr(LoggerBase::Enable | LoggerBase::DontBlock, VirtFILE::Vstderr); //errors -> stderr, don't interfere with stdout 53 53 54 PreconfiguredGenetics genetics;54 PreconfiguredGenetics genetics; 55 55 56 bool reverse=false;57 char* gen_arg=0;58 for(int i=1;i<argc;i++)56 bool reverse = false; 57 char* gen_arg = 0; 58 for (int i = 1; i < argc; i++) 59 59 { 60 char* ar=argv[i];61 if (ar[0]=='-')62 switch(ar[1])60 char* ar = argv[i]; 61 if (ar[0] == '-') 62 switch (ar[1]) 63 63 { 64 case 'r': reverse =true; break;64 case 'r': reverse = true; break; 65 65 case 'h': puts("usage: full_props [-r[everse]] [genotype_or_stdin]\n"); break; 66 66 } 67 else 68 if (!gen_arg) 69 gen_arg = ar; 70 } 71 SString gen; 72 if (gen_arg) 73 gen = gen_arg; 67 74 else 68 if (!gen_arg) 69 gen_arg=ar; 70 } 71 SString gen; 72 if (gen_arg) 73 gen=gen_arg; 74 else 75 loadSString(VirtFILE::Vstdin,gen); 76 Geno g(gen); 77 Model m(g); 75 loadSString(VirtFILE::Vstdin, gen); 76 Geno g(gen); 77 Model m(g, Model::SHAPE_UNKNOWN); 78 78 79 if (!m.isValid())79 if (!m.isValid()) 80 80 { 81 logPrintf("","full_props",LOG_ERROR,"Cannot build Model from the supplied genotype\n");82 return 2;81 logPrintf("", "full_props", LOG_ERROR, "Cannot build Model from the supplied genotype\n"); 82 return 2; 83 83 } 84 84 85 m.open();86 for(int i=0;i<m.getNeuroCount();i++)85 m.open(); 86 for (int i = 0; i < m.getNeuroCount(); i++) 87 87 { 88 Neuro *n=m.getNeuro(i);89 SyntParam p=n->classProperties(reverse);90 p.update();// ...so everyone reading the source can recognize that p was created to update the neuro d field91 // but actually, calling update() here is not necessary, because ~SyntParam() would do it anyway88 Neuro *n = m.getNeuro(i); 89 SyntParam p = n->classProperties(reverse); 90 p.update();// ...so everyone reading the source can recognize that p was created to update the neuro d field 91 // but actually, calling update() here is not necessary, because ~SyntParam() would do it anyway 92 92 } 93 m.close();93 m.close(); 94 94 95 // normal f0 (omitting default values) would be retrieved using m.getF0Geno()96 // the following form allows for more control:97 Geno f0_g;98 m.makeGeno(f0_g,NULL,reverse);//third arg is "handle_defaults" == whether f0 should omit default property values99 puts(f0_g.getGenesAndFormat().c_str());95 // normal f0 (omitting default values) would be retrieved using m.getF0Geno() 96 // the following form allows for more control: 97 Geno f0_g; 98 m.makeGeno(f0_g, NULL, reverse);//third arg is "handle_defaults" == whether f0 should omit default property values 99 puts(f0_g.getGenesAndFormat().c_str()); 100 100 101 return 0;101 return 0; 102 102 } 103 103
Note: See TracChangeset
for help on using the changeset viewer.