974 | | #ifndef BDMLIB |
975 | | // MUZEME INTERNE POUZIVAT ENUMY, A KLIDNE MENIT JEJICH PORADI, DIKY TOMUHLE MAKRU SE VZDY NAMAPUJI NA TY SPRAVNE STRINGY |
976 | | #define DEFINED_OPTIONS(...) enum defined_options { __VA_ARGS__ }; const Array<string> logged_options::names( "{"#__VA_ARGS__"}" ) |
977 | | // TODO: ROZPARESUJE TO KONSTRUKTOR ARRAYE NA JEDNOTLIVE STRINGY?? NUTNO OTESTOVAT!! |
978 | | #else |
979 | | #define DEFINED_OPTIONS(...) enum defined_options { __VA_ARGS__ }; |
980 | | #endif |
981 | | |
982 | | enum defined_options; |
983 | | |
984 | | class logged_options : public root |
985 | | // TODO: HA, TADY TO MAME!! POKUD ZDE CHCEME TEZ UZIVAT FROMSETTING A TOSETTING, NEMUZOU BYT LOGOVACI |
986 | | // VECI PRIMO V ROOTU.. RESENIM BUDE ZREJME KOMPOZICE - FUNKCNOST SOUVISEJICI S LOGGERAMA UMISTENA V ROOTU |
987 | | // PREJDE DO TETO TRIDY, A KDO BUDE MIT ZAJEM O NAPOJENI NA LOGGERY MUSI OBSAHOVAT LOGGED_OPTIONS INSTANCI... |
988 | | // TZN. TRIDU LOGGED OPTIONS BUDE JESTE TREBA LEHCE ROZSIRIT.. |
989 | | // KOMPOZICE TAKY UMOZNI NEKOLIK RUZNYCH LOGGERU PRO JEDEN OBJEKT.. PROSTE BUDE OBSHOVAT NEKOLIK RUZNYCH |
990 | | // LOGGED_OPTIONS INSTANCI NAPOJENYCH NA RUZNE LOGGERY.. HMM, ALE TO JE TREBA JESTE DOMYSLET.) |
991 | | { |
992 | | private: |
993 | | bitset<32> values; |
994 | | |
995 | | static const Array<string> names; |
996 | | |
997 | | public: |
998 | | |
999 | | bool operator [] (const defined_options &option ) |
1000 | | { |
1001 | | return values[option]; |
1002 | | } |
1003 | | |
1004 | | void from_setting ( const Setting &set ) |
1005 | | { |
1006 | | values.reset(); |
1007 | | Array<string> true_options; |
1008 | | UI::get( true_options, set ); |
1009 | | for( int i = 0; i < true_options.length(); i++ ) |
1010 | | for( int j = 0; j < names.length(); j++ ) |
1011 | | if( true_options(i) == names(j) ) |
1012 | | { |
1013 | | values[j] = true; |
1014 | | break; |
1015 | | } // TODO kdyz ho to vubec nenajde, nic se nedeje.. coz radeji vyhodit UI vyjimku??! |
1016 | | } |
1017 | | |
1018 | | void to_setting( Setting &set ) const |
1019 | | { |
1020 | | Array<string> true_options( values.count() ); |
1021 | | int true_options_count = 0; |
1022 | | for( unsigned int i = 0; i < values.size(); i++ ) |
1023 | | if( values[i] ) |
1024 | | true_options( true_options_count++ ) = names(i); |
1025 | | UI::save( true_options, set ); |
1026 | | } |
1027 | | }; |
1028 | | UIREGISTER(logged_options); |
1029 | | DEFINED_OPTIONS(bounds,likelyhood,full); |
1030 | | |
1031 | | |
1185 | | UI::save( &posterior()._rv(), set, "rv" ); |
1186 | | UI::save( &logged, set, "logged" ); |
1187 | | } |
1188 | | |
1189 | | virtual void set_options ( const string & ); |
1190 | | |
1191 | | // TODO JEN JAKO UKAZKA POUZIT LOGGED[..], NAKONEC ODSTRANIT CELOU METODU, A TAKY JEJI ORIGINAL VYSE |
1192 | | // jen co zavedeme logged_options i do dalsich objektu, pak se vse muze nastavovat primo |
1193 | | // ve from_settingu, bude to tak ok? |
1194 | | // nejlepsi by bylo, kdyby se options posterioru() nastavovaly v jeho from_settingu, |
1195 | | // aby nevznikala takovahle kaskada zavislosti.. pujde to? domyslet |
1196 | | virtual void SHOWING_ROOM( const string & ) |
1197 | | { |
1198 | | if ( logged[full] ) { |
1199 | | const_cast<epdf&> ( posterior() ).set_log_level ( 10 ) ; |
1200 | | } else { |
1201 | | if ( logged[bounds] ) { |
1202 | | const_cast<epdf&> ( posterior() ).set_log_level ( 2 ) ; |
1203 | | } else { |
1204 | | const_cast<epdf&> ( posterior() ).set_log_level ( 1 ) ; |
1205 | | } |
1206 | | if ( logged[likelyhood] ) { |
1207 | | log_level = 1; |
1208 | | } |
| 1125 | |
| 1126 | string opt; |
| 1127 | switch( posterior()._log_level() ) |
| 1128 | { |
| 1129 | case 2: |
| 1130 | opt = "logbounds "; |
| 1131 | break; |
| 1132 | case 10: |
| 1133 | opt = "logfull "; |
| 1134 | break; |
| 1135 | default: |
| 1136 | opt = ""; |
| 1137 | break; |