Changeset 11084
- Timestamp:
- 06/20/11 21:37:19 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/gui/FactGui.h
r11066 r11084 736 736 const T &ref(uint32_t offset=0) const { return *reinterpret_cast<const T*>(data.data()+offset); } 737 737 738 739 740 741 742 743 744 745 746 747 748 int size() const { return data.size(); }738 vector<char> vec(int b) const { return vector<char>(data.begin()+b, data.end()); } 739 string str(unsigned int b) const { return b>=data.size()?string():string(data.data()+b, data.size()-b); } 740 const char *c_str() const { return (char*)data.data(); } 741 742 vector<boost::any> any() const 743 { 744 const Converter conv(format); 745 conv.Print(); 746 return conv.GetAny(data.data(), data.size()); 747 } 748 size_t size() const { return data.size(); } 749 749 }; 750 750 … … 902 902 } 903 903 904 905 // ===================== All ============================================ 906 907 bool CheckSize(const DimData &d, size_t sz) const 908 { 909 if (d.size()==0) 910 return false; 911 912 if (d.size()!=sz) 913 { 914 cout << "Size mismatch in " << d.name << ": Found=" << d.size() << " Expected=" << sz << endl; 915 return false; 916 } 917 918 return true; 919 } 920 904 921 // ===================== FAD ============================================ 905 922 906 923 void handleFadFiles(const DimData &d) 907 924 { 908 if (d.size()==0) 909 return; 910 911 if (d.size()!=8) 912 { 913 cout << "Size mismatch: " << d.size() << " " << 8 << endl; 914 return; 915 } 925 if (!CheckSize(d, 8)) 926 return; 916 927 917 928 fEvtBuilderOpenFiles->setValue(d.get<uint64_t>()); … … 920 931 void handleFadRuns(const DimData &d) 921 932 { 922 if (d.size()==0) 923 return; 924 925 if (d.size()!=4) 926 { 927 cout << "Size mismatch: " << d.size() << " " << 8 << endl; 928 return; 929 } 933 if (!CheckSize(d, 4)) 934 return; 930 935 931 936 fEvtsRunMax->setValue(d.get<uint32_t>()); … … 934 939 void handleFadEvents(const DimData &d) 935 940 { 936 if (d.size()==0) 937 return; 938 939 if (d.size()!=8) 940 { 941 cout << "Size mismatch: " << d.size() << " " << 8 << endl; 942 return; 943 } 941 if (!CheckSize(d, 8)) 942 return; 944 943 945 944 const uint32_t *ptr = d.ptr<uint32_t>(); … … 951 950 void handleFadCurrentEvent(const DimData &d) 952 951 { 953 if (d.size()==0) 954 return; 955 956 if (d.size()!=4) 957 { 958 cout << "Size mismatch: " << d.size() << " " << 4 << endl; 959 return; 960 } 952 if (!CheckSize(d, 4)) 953 return; 961 954 962 955 fEvtsTriggerId->setValue(d.get<uint32_t>()); … … 965 958 void handleFadConnections(const DimData &d) 966 959 { 967 if (d.size()==0) 968 return; 969 970 if (d.size()!=40) 971 { 972 cout << "Size mismatch: " << d.size() << " " << 40 << endl; 973 return; 974 } 960 if (!CheckSize(d, 40)) 961 return; 975 962 976 963 const uint8_t *ptr = d.ptr<uint8_t>(); … … 1034 1021 void handleFtmTriggerCounter(const DimData &d) 1035 1022 { 1036 if (d.size()==0) 1037 return; 1038 1039 if (d.size()!=sizeof(FTM::DimTriggerCounter)) 1040 { 1041 cout << "Size mismatch: " << d.size() << " " << sizeof(FTM::DimTriggerCounter) << endl; 1042 return; 1043 } 1023 if (!CheckSize(d, sizeof(FTM::DimTriggerCounter))) 1024 return; 1044 1025 1045 1026 const FTM::DimTriggerCounter &sdata = d.ref<FTM::DimTriggerCounter>(); … … 1118 1099 void handleFtmCounter(const DimData &d) 1119 1100 { 1120 if (d.size()==0) 1121 return; 1122 1123 if (d.size()!=sizeof(uint32_t)*6) 1124 { 1125 cout << "Size mismatch: " << d.size() << " " << sizeof(uint32_t)*6 << endl; 1126 return; 1127 } 1101 if (!CheckSize(d, sizeof(uint32_t)*6)) 1102 return; 1128 1103 1129 1104 const uint32_t *sdata = d.ptr<uint32_t>(); … … 1142 1117 void handleFtmDynamicData(const DimData &d) 1143 1118 { 1144 if (d.size()==0) 1145 return; 1146 1147 if (d.size()!=sizeof(FTM::DimDynamicData)) 1148 { 1149 cout << "Size mismatch: " << d.size() << " " << sizeof(FTM::DimDynamicData) << endl; 1150 return; 1151 } 1119 if (!CheckSize(d, sizeof(FTM::DimDynamicData))) 1120 return; 1152 1121 1153 1122 const FTM::DimDynamicData &sdata = d.ref<FTM::DimDynamicData>(); … … 1335 1304 void handleFtmStaticData(const DimData &d) 1336 1305 { 1337 if (d.size()==0) 1338 return; 1339 1340 if (d.size()!=sizeof(FTM::DimStaticData)) 1341 { 1342 cout << "Size mismatch: " << d.size() << " " << sizeof(FTM::DimStaticData) << endl; 1343 return; 1344 } 1306 if (!CheckSize(d, sizeof(FTM::DimStaticData))) 1307 return; 1345 1308 1346 1309 const FTM::DimStaticData &sdata = d.ref<FTM::DimStaticData>(); … … 1421 1384 void handleFtmPassport(const DimData &d) 1422 1385 { 1423 if (d.size()==0) 1424 return; 1425 1426 if (d.size()!=sizeof(FTM::DimPassport)) 1427 { 1428 cout << "Size mismatch: " << d.size() << " " << sizeof(FTM::DimPassport) << endl; 1429 return; 1430 } 1386 if (!CheckSize(d, sizeof(FTM::DimPassport))) 1387 return; 1431 1388 1432 1389 const FTM::DimPassport &sdata = d.ref<FTM::DimPassport>(); … … 1442 1399 void handleFtmFtuList(const DimData &d) 1443 1400 { 1444 if (d.size()==0) 1445 return; 1446 1447 if (d.size()!=sizeof(FTM::DimFtuList)) 1448 { 1449 cout << "Size mismatch: " << d.size() << " " << sizeof(FTM::DimFtuList) << endl; 1450 return; 1451 } 1401 if (!CheckSize(d, sizeof(FTM::DimFtuList))) 1402 return; 1452 1403 1453 1404 fFtuPing->setChecked(false); … … 1486 1437 void handleFtmError(const DimData &d) 1487 1438 { 1488 if ( d.size()==0)1439 if (!CheckSize(d, sizeof(FTM::DimError))) 1489 1440 return; 1490 1441
Note:
See TracChangeset
for help on using the changeset viewer.