File indexing completed on 2026-04-09 07:49:20
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "ssys.h"
0011 #include "SRecord.h"
0012 #include "NPFold.h"
0013
0014 struct SRecord_test
0015 {
0016 static int Load();
0017 static int LoadSlice();
0018 static int LoadNonExisting();
0019 static int getPhotonAtTime();
0020 static int Main();
0021 };
0022
0023
0024 inline int SRecord_test::Load()
0025 {
0026 std::cout << "[SRecord_test::Load" << std::endl ;
0027 SRecord* sr= SRecord::Load("$SRECORD_FOLD") ;
0028 std::cout << sr->desc() ;
0029 std::cout << "]SRecord_test::Load" << std::endl ;
0030 return 0 ;
0031 }
0032
0033 inline int SRecord_test::LoadSlice()
0034 {
0035 std::cout << "[SRecord_test::LoadSlice" << std::endl ;
0036 SRecord* ar = SRecord::Load("$AFOLD", "$AFOLD_RECORD_SLICE" ) ;
0037 std::cout << ar->desc();
0038 std::cout << "]SRecord_test::LoadSlice" << std::endl ;
0039 return 0 ;
0040 }
0041
0042 inline int SRecord_test::LoadNonExisting()
0043 {
0044 std::cout << "[SRecord_test::LoadNonExisting" << std::endl ;
0045 SRecord* sr= SRecord::Load("$SRECORD_FOLD_NON_EXISTING") ;
0046 assert( sr == nullptr );
0047 std::cout << "]SRecord_test::LoadNonExisting" << std::endl ;
0048 return 0 ;
0049 }
0050
0051 inline int SRecord_test::getPhotonAtTime()
0052 {
0053 SRecord* ar = SRecord::Load("$AFOLD", "$AFOLD_RECORD_SLICE" ) ;
0054 std::cout << ar->desc();
0055
0056 float t = ssys::getenvfloat("AFOLD_RECORD_TIME", 1.0 );
0057
0058 NP* ph = ar->getPhotonAtTime(t);
0059
0060 std::cout
0061 << "SRecord_test::getPhotonAtTime"
0062 << " t " << std::setw(7) << std::fixed << std::setprecision(3) << t
0063 << " ph " << ( ph ? ph->sstr() : "-" )
0064 << "\n"
0065 ;
0066
0067 NPFold* sub = new NPFold ;
0068 sub->add("record", ar->record );
0069 sub->add("ph", ph );
0070
0071 NPFold* top = new NPFold ;
0072 top->add_subfold( "getPhotonAtTime", sub );
0073 top->save("$FOLD");
0074
0075 return 0 ;
0076 }
0077
0078 inline int SRecord_test::Main()
0079 {
0080 int rc(0) ;
0081 const char* test = "getPhotonAtTime" ;
0082 const char* TEST = ssys::getenvvar("TEST", test );
0083 bool ALL = strcmp(TEST, "ALL") == 0 ;
0084
0085 if(ALL||strcmp(TEST,"Load") == 0 ) rc += Load() ;
0086 if(ALL||strcmp(TEST,"LoadSlice") == 0 ) rc += LoadSlice() ;
0087 if(ALL||strcmp(TEST,"LoadNonExisting") == 0 ) rc += LoadNonExisting() ;
0088 if(ALL||strcmp(TEST,"getPhotonAtTime") == 0 ) rc += getPhotonAtTime() ;
0089
0090 return rc ;
0091 }
0092
0093 int main()
0094 {
0095 return SRecord_test::Main();
0096 }
0097