From 4a21b2db54cf96384b2add137265a298cdf30799 Mon Sep 17 00:00:00 2001 From: "J. Daniel Smith" Date: Thu, 15 Jun 2023 15:36:28 -0400 Subject: [PATCH] Allow code to work with our own complex type (#663) * Squashed commit of the following: commit bb2bb5aaf944040ea5bc42168b846324287dcad8 Merge: bbba5a210 4c146e7d0 Author: Dan Smith Date: Mon Jun 12 13:04:09 2023 -0400 Merge commit '4c146e7d01b14cf408b0e398cba96705df69090c' into develop/sync_externals commit 4c146e7d01b14cf408b0e398cba96705df69090c Author: Dan Smith Date: Mon Jun 12 13:04:09 2023 -0400 Squashed 'externals/coda-oss/' changes from aeec0131c..c88b9c053 c88b9c053 types::complex (#681) d1244a080 don't need our own make_unique in C++14 (#680) git-subtree-dir: externals/coda-oss git-subtree-split: c88b9c05325c802f88a85ddcebb498be4afacad0 commit bbba5a210c0257f622781914e9d228eeca23341c Author: Dan Smith Date: Mon Jun 12 13:04:06 2023 -0400 latest from CODA-OSS commit 370dd8876136755230624ebc955bc67642b1482b Merge: 58ff5a537 ffe1caafd Author: Dan Smith Date: Mon Jun 12 13:03:25 2023 -0400 Merge branch 'main' into develop/sync_externals commit 58ff5a5371d9158910e99613f4ce6e6fc36e543e Author: Dan Smith Date: Thu Jun 8 16:23:08 2023 -0400 latest from CODA-OSS commit 3bfc33a40274fa7a073983d4e4ddd907e45730d2 Author: Dan Smith Date: Thu Jun 8 14:34:45 2023 -0400 latest from CODA-OSS and NITRO commit 389417a983778ba2a07af9c6dbfea80484324b97 Merge: bce7ba0b1 4ad490fe4 Author: Dan Smith Date: Thu Jun 8 14:34:28 2023 -0400 latest from CODA-OSS and NITRO commit 4ad490fe4224df18ce4a437c40a257af0686140e Author: Dan Smith Date: Thu Jun 8 14:34:22 2023 -0400 Squashed 'externals/nitro/' changes from c8ecbe9ae..05dae18a3 05dae18a3 patch to build other projects 8f974e995 NITRO-2.11.3 (#554) 870aa6afd update to coda-oss 2023-06-05 (#553) 2fd7a0bfa latest from coda-oss (#552) 0eecce004 invoke() utility to reduce code duplication (#550) 59fb02fe9 latest from coda-oss (#551) 9fbf2b7b8 Fill out adapter free block which is used for nitf decompression (#549) 089ba0b5b latest from coda-oss 3b52f0025 latest from coda-oss (#547) 90c6263e2 latest from coda-oss (#544) 90d513ac5 latest from coda-oss (#543) git-subtree-dir: externals/nitro git-subtree-split: 05dae18a3a9c5ad70e1ce814c21ca8ec278829be commit 86929db19a438630d531ca0c34bdcd8e8c527ae9 Author: Dan Smith Date: Thu Jun 8 14:34:18 2023 -0400 Squashed 'externals/coda-oss/' changes from e87c32b4d..aeec0131c aeec0131c assert()s for mem::CopyablePtr (#679) 72b0ebd60 add types::complex_short (#678) 932130a58 patch to build other projects c00c1f203 coda-oss release 2023-06-06 (#677) ef54bbcd5 remove more compiler warnings (#676) dadfc5ce6 distinguish between byte-swapping a buffer and single value (#674) 90187f6cd more xml.lite tweaks for SIDD-3.0/ISM (#675) eb9960772 stronger type-checking for byteSwap() (#673) ff4f820ed xml.lite tweaks to support SIDD 3.0 ISM (#672) b1de8c0e5 std::byte should be a unique type (#671) c05bf9a02 allow enums to be byte-swapped too 1f9fd88d6 remove spurious 47684c45b byteSwap now uses byte buffers (#670) cbc659db2 add swapBytes() utility from SIX (#669) 891481b64 simplify byte-swapping (#668) 540ae763e more byteSwap() tweaks 0774c03c4 threaded byteSwap() (#667) d156370d3 swapping a single-byte value makes no sense c120e3255 be sure parameter is used to avoid compiler warning e85ec9331 --output-on-failure for CTest (#666) e80376197 turn off "there is no warning number" warning c5f0a5d15 A C-string may not be NULL-terminated (#665) 0c5eb29ae use platform-specific routines for byteSwap() (#664) 0b7d581fa remove transform_async() (#663) f6489b6be Merge branch 'main' into feature/xml.lite_tweaks 836c426a2 use function-pointers so that isConsoleOutput is only checked once 56e3c45b1 move depthPrint() functionality into non-member function in preparation for future changes ddcd26d97 Merge branch 'main' into feature/xml.lite_tweaks 69cc0e506 use the more rigorous create_and_check_datatype() 9efb87558 Merge branch 'main' into feature/hdf5 4d2f2f417 more HighFive unittests (#662) 14191a844 HighFive::create_datatype() goes from C++ to HighFive 98583473f utility routines to read string attributes 1fa75ce81 use the C API to read a string attribute 71e7b69f5 still can't figure out how to read a string attribute :-( e96f37a69 test reading the file attributes a25244519 getAttribute() unittest 8f12a3000 getDataType() unittest 857ff0af3 HighFive utility routines (#661) 1d687db57 writeDataSet() utility overload 106aa6894 sigh ... H5Easy::dump() fill fails on Windows/WAF :-( 2641b60b2 Merge branch 'main' into feature/hdf5 35c19e7e8 change actions to @v3 (#660) 212bbd3a3 works on local machine, but not build server ... ? 7125118b0 dump of 1D vector doesn't work :-( c704db435 sigh ... WAF build still failing :-( 01aae4616 does dump() of a 1D vector work? 76a53c813 comment-out H5 writing :-( 0f0e19aff test_highfive_dump() cb8f73795 trying to get highfive_dump() unittest working w/Windows-WAF 6584a264a does test_highfive_create() work? cde6147ce tweak HighFive wrappers (#659) 316566854 Revert "trying HighFive "write" unittests again" a9ec24ca4 trying HighFive "write" unittests again 585ad49a5 tweak names of utility routines 4c91a4d97 make it easier to read a std::vector and std::vecotr 0217ffa26 readDataSet() now works for 1D data 95e8973f2 trying to get hdf5::lite::load() working 4d294611d "const" correctness 5e6305c3f fix load_complex() 4a134dc5f start work on utility routines to read complex data from HDF5 9d76a7f41 Merge branch 'main' into feature/hdf5 8f9667a24 whitepsace ebd3fc99e Merge branch 'main' into feature/hdf5 40091b069 comment-out writing tests for now ... need to figure our WAF bulid failure 935aa3459 be sure the dataset has real data 114b9bf33 update release notes bd9c0b26c tweak HighFive utility routines acda1ef57 turn off diagnostics around expected failures 22a748840 readDataSet() utility routine for HighFive bd88a8c25 HighFive writeDataSet() utility to work with our SpanRC 6142f5b33 use HighFive routines to write a HDF5 file 5bbf1abaf Use HiveFive routines to get info about the file 84fbc8378 duplicate unittests with H5Easy f1f054c03 Merge branch 'main' into feature/hdf5 9b63ca470 fix directory names f6f826689 fix directory names 7aeb82c33 Merge branch 'main' into feature/hdf5 d028baaeb hook up HighFive header-only library (#653) 3083b0a31 Revert "HighFive 2.6.2" 246985a7f Revert ""build" HighFive HDF5 library" a8b75a586 Revert "turn off HighFive Boost support" ec68d5f83 Revert "Add HighFive unittests" f1f85b9e7 Revert "get test_high_five_base more-or-less compiling" 5ea634ee1 Revert "more work on getting HighFive unittests to build" ecc45433c more work on getting HighFive unittests to build bb194788a get test_high_five_base more-or-less compiling d42bde000 Add HighFive unittests ddc86bb32 turn off HighFive Boost support b255122d4 "build" HighFive HDF5 library 396cc3ef2 HighFive 2.6.2 5e5f9d9c0 Merge branch 'main' into feature/hdf5 ee938b4a5 changes from SIX bb764df90 Merge branch 'main' into feature/xml.lite_tweaks de2a24380 make derived classes 'final' if possible 14e19bcd2 Change xml lite function to virtual (#645) 8f42ac8e9 Merge branch 'main' into feature/xml.lite_tweaks 18ad90645 hdf5Write unittest 3462e1179 createFile() and writeFile() overloads ecee81d53 fix typos 197eecfa6 sketch-out hdf5::lite::writeFile() bd2311795 use SpanRC for writeFile(), not yet implemented ea9af7510 simple SpanRC to hold a 2D-size and pointer 027c19ee8 createFile() unittest 1f9d07ecb hook up createFile() 8c7e4473f start hooking up HDF5 writing 146e0bea3 Merge branch 'main' into feature/hdf5 88ca9fcb7 Merge branch 'main' into feature/hdf5 42b604b46 Squashed commit of the following: 10ee602c2 Merge branch 'main' into feature/hdf5 67aa42b69 restore changes from "main" 8bbfcbfbf unittests can be simplified to match fewer "view" classes 126bb802e Merge branch 'main' into feature/hdf5 3f8ba7a42 again, don't need a class just to convert from std::vector<> to std::span<> 24c2b489c Squashed commit of the following: 2703c119d Squashed commit of the following: 9d5228a2b don't need an entire class just to convert a std::vector<> into std::span<> 51bc931dc Merge branch 'main' into feature/hdf5 a84f25816 Squashed commit of the following: c4d2ed696 add missing #include guards, fix type in existing #include guard d541525a0 use a single ComplexViewConstIterator for all views 86e6a459f CODA_OSS_disable_warning causes GCC errors :-( 5d4b9c2cb only need an custom iterator for ComplexSpansView d9f0fb128 hook up iterators b9329e4db initial pass at a ComplexViewConstIterator 635238873 remove compiler warning about unused "constexpr" variables b39f6096f use the casing from H5 to make copy/pasting code slightly easier 0887b13eb Merge branch 'main' into feature/hdf5 bd07df1ca Consistent casing for Dataset, Datatype, Dataspace 7acd30ee2 tweak hdf5.lite dependencies 38ab914df Jupyter notebook for creating H5 files 95a040e0b _small.h5 is now (correctly) FLOAT32 107e7c487 make a simple values() member function to avoid template magic e1feca919 use TEST_SPECIFIC_EXCEPTION macro instead of try/catch 738333688 readDatasetT() now throws for the wrong buffer type 6b2cc2529 Merge branch 'feature/hdf5' of github.com:mdaus/coda-oss into feature/hdf5 310f8fd3d can't get template magic right for copy_axis() 86b306d59 stepping through copy ctors in the debugger is annoying f243e92d6 trying to make wrong type of buffer fail 2b10d9652 read in new sample file a28e59d8c help the compiler with type deduction 49bf5e9bc nested_complex_float_data_small.h5 e029325fc utility routines to "deconstruct" and array of std::complex dede3bd39 Merge branch 'main' into feature/hdf5 904b1ef5e tweak class names, make_() and copy() utility routines 8237b9efb make it harder to pass the wrong types to ComplexViews 4d9aeda2c ComplexArrayView and ComplexParallelView utility classes f5e367dfa test std::span> a4a2844f2 read in the nested "i" and "r" data 115615265 sample file has subgroups 8e1b7869a Merge branch 'feature/hdf5' of github.com:mdaus/coda-oss into feature/hdf5 9f4232a1d update sample H5 file 8c55db73a walk through HDF5 sub-groups 7775ed9c4 Update 123_barfoo_catdog_cx.h5 677975d7c Matlab code to create sample H5 file a0e7dfe07 Update test_hdf5info.cpp 0b67e1602 pass __FILE__ and __LINE__ from calling site for a more accurate exception message 86a677321 skeleton for more sample data 85f79b099 Merge branch 'main' into feature/hdf5 18088e942 Merge branch 'main' into feature/hdf5 3a1d17692 Merge branch 'main' into feature/hdf5 1755c69d7 Merge branch 'main' into feature/hdf5 9ad015432 No more "11" suffix on exception names c20d96251 Squashed commit of the following: c88cee999 other values to be filled-in bca4a4ecd incorporation NamedObject from HDF5 docs 61fa68f72 groupInfo() 460e7d766 datasetInfo() 14eb9b764 start filling in DatasetInfo afe5f1c3a start to fill in DatasetInfo 77a968c72 start filling in GroupInfo d81bcdfd9 openGroup() to open groups (loc) a0cd29469 comment-out "dataset" unittest for now 86e006024 begin filling in FileInfo 366dda6ab a return_type_of utility is needed to deduce the return type e21928263 explicitly pass return type to template 4937ccd11 template to reduce boilerplate when calling try_catch_H5Exceptions b3b5ebde7 use new exception utility routines ea1c03ef0 put exception handling/conversion in a utility routine 819a99d39 utility routine for exception handling 6f34eea97 put utilities in a separate file for easier reuse fcbde4f24 break utility routines into smaller pieces for easier reuse 52358ea8a WIN32 no longer automatically defined? 5a4286472 Revert "build HDF5 with C89" 680e599e9 build HDF5 with C89 a87a07121 Merge branch 'main' into feature/hdf5 8447c1a90 Revert "sym-links instead of copying files" db3b5e12b Merge branch 'main' into feature/xml.lite_tweaks fb60b5696 Merge branch 'main' into feature/hdf5 5110a5cc8 Comments about _u and _q 1a937d32c Merge branch 'main' into feature/xml.lite_tweaks fa06f04d7 get ready for hdf5.lite enhancdements b040c7c43 sym-links instead of copying files aa431bb47 use _u for xml::lite::Uri 3d0c6d58c fix case-sensitive #include filename 93dcd0e52 operator() for getElementByName() 75a93af85 more operator[] overloads to make attribute management easier 4ab8216f8 user-defined string literals to remove some noise around xml::lite::QName f82f0b0fc Merge branch 'main' into feature/xml.lite_tweaks ae30e3644 Merge branch 'feature/xml.lite_tweaks' of github.com:mdaus/coda-oss into feature/xml.lite_tweaks ffdd9beb0 simplify attribute creation 9bf5414f5 simplify attribute creation 82d7a4e95 SWIG gets confused about namespaces 7a61d0741 fix bug on Element ctor uncovered by unittest fdd7e58c1 QName is also in the xerces namespace which confuses SWIG bindings a325b7053 operator+=() overload for addChild daf30e6c0 Merge branch 'feature/xml.lite_tweaks' of github.com:mdaus/coda-oss into feature/xml.lite_tweaks b887d2b47 provide overloads for Element& rather than creating new "reference" types 1fa6bba38 rename test_xmleasy.cpp 7c8c9e0f1 += overload 850da6f63 overload for std::string 4547fc5a7 use UIT-8 strings for characterData 4723462a3 convenient addChild() overloads e48720753 copy over ElementReference from xml.easy a4ca30a0d Merge branch 'main' into feature/xml.lite_tweaks 6ae9f0b71 Revert "check-in of new xml.easy (to move code between computers)" f7466a6d7 Revert "simple routines for single element" a5490230d Revert "make some operators simplier ways of calling functions" c9a25630a Revert "get document creation working" 8af8710b0 Revert "free functions instead of member functions" 16c3847cb Revert "ElementReference distinct from Element" 7d68e156f Revert "ElementMutableReference" 00eb2a282 Merge branch 'main' into feature/xml.lite_tweaks a42969c1f ElementMutableReference a20ae9355 ElementReference distinct from Element 14eeeea0b free functions instead of member functions 4aae014b3 get document creation working 883569269 make some operators simplier ways of calling functions 053bd1212 simple routines for single element 8bf701a2e check-in of new xml.easy (to move code between computers) 41f959051 unittests for creating XML documents from scratch 9752d50ae Merge branch 'main' into feature/xml.lite_tweaks 1531d5709 by default, don't validate strings passed to Uri() 46d13d4bf Merge branch 'master' into feature/xml.lite_tweaks 39b547d32 remove more vestiges of Expat and LibXML ec8274d52 remove LibXML and Expat as they're no longer used/supported. 20eeefeef Merge branch 'master' into feature/xml.lite_tweaks 95074b9b1 update for newer Intel compiler 7024f71e1 Merge branch 'master' into feature/xml.lite_tweaks 57b1cbc83 Merge branch 'master' into feature/xml.lite_tweaks 4b67561c3 remove validate() overload that nobody is using fa15f1e5d Squashed commit of the following: 1484a9090 test the new validate() API 470da70fb hookup StringStreamT routines 2cddf2504 begin hooking up validate() overloads 1b5d910f3 overload validate() for UTF-8 and Windows-1252 03309b8c9 Squashed commit of the following: b72c6c5bf older compiler doesn't like our make_unique af8f00307 validate UTF-8 XML on Linux 211188613 unit-test for LEGACY XML validation 3c1169d2b Squashed commit of the following: 3afff19ca std::filesystem::path for FileInputStreamOS 908d452f8 WIP: validate all of our sample XML files 00f9bb16b validate against a XML schema 243d8c356 Merge branch 'master' into feature/xml.lite_tweaks 2815d707d fix to work with SWIG bindings. :-( 460862132 trying (again) to remove vestiages of old code e3c83a858 Revert "new code should use UTF-8" 811207c92 new code should use UTF-8 0ffd835f9 Squashed commit of the following: 1e7e03ded Merge branch 'master' into feature/xml.lite_tweaks c1d806aff Merge branch 'master' into feature/xml.lite_tweaks 850d3c811 str::strip() that can be easier to use than str::trim() 580ba9c8c explicitly =delete move 2b39831a8 Squashed commit of the following: 39eebdc23 Merge branch 'master' into feature/xml.lite_tweaks 9adf86cba force calling new UTF-8 write() routines ea61b6204 Merge branch 'master' into feature/xml.lite_tweaks 8a34583fa overload to take schemaPaths as filesystem::path 8671b442f parse XML embedded in a binary file ec4a902f1 updates from xerces.lite 80dc4d963 updates from xerces.lite 549766d6c Attributes::contains() no longer catches an exception 8a645ceac need "sys/" when building in other environments 36af08269 super-simple URI validation 78ef28a3e SWIG bindings are a PITA! :-( e9cba8491 SWIG needs help with Uri 8a8d8dc07 another routines used by pre-build SWIG bindings 818e1ec5d pre-build SWIG bindings use getElementByTagName() member function 067cac5d8 old compiler gets confused on unadorned QName ba92c0ae7 more use of Uri and QName 446c7d17a use QName in new code d6f8b0c83 more direct use of QName 90fff1c73 use xml::lite::QName instead of tuple 646cbb5ed more direct use of QName and Uri ba589ea3b make QName more robust bab0ee8b5 createElement() -> addNewElement() e3a145747 grab changes from six-library 32285e95c Merge branch 'master' into feature/xml.lite_tweaks 9f79f0bf6 Merge branch 'master' into feature/xml.lite_tweaks a12bbc32c make it easier to create new Elements with a value fc9967f98 make it easy for callers to addChild() keep a reference to the Element 4627766b7 be sure test_xmlparser works in "externals" of other projects bf2276396 "private" is part of the name-mangling fad92bcc8 making sure copy-ctor is implemented f90fdcead consolidate common XML test code 9fc53f2d5 use str:: utility for casting 6da6f794b still trying to find the right macro for SWIG 0c1b86c56 still trying to fix SWIG fdc6fc9bd trying to fix SWIG build error 7835e8c27 SWIG needs copy-ctor 585695942 disable copy/assignment for Element, it's probably almost always wrong 391fed613 fix double-delete caused by copying 61790fe69 retry parsing XML with Windows-1252 if first parse() fails 63cffac59 change string_encoding to match coda-oss style of PascalCase 010479bbe read an XML file we know is wrongly encoded as Windows-1252 9a0505062 more references instead of pointers 2d44b6951 Reading Windows-1252 w/o "encoding" fails 63dc7b076 read Windows-1252 too c9434c9cb test as UIT-8 too f310ccf0c get reading from UTF-8 XML working on Windows 1fa39c2be get testReadUtf8XmlFile working on Linux 1a83cd815 sys::Path is too much trouble right now ed60aa22c unit-test to read XML from a file a9336db7c Squashed commit of the following: 0825beb0d Merge branch 'master' into feature/xml.lite_tweaks c618489be Merge branch 'master' into feature/xml.lite_tweaks e8e4b8fe1 determine string_encoding based on platform 1f43bcfc2 create a new Element by using the platform to determine "characterData" encoding 961bef66b Merge branch 'master' into feature/xml.lite_tweaks e9798a5cb fix static_assert() 6f7772874 Merge branch 'master' into feature/xml.lite_tweaks b98d4f5a9 Merge branch 'master' into feature/xml.lite_tweaks 1b5abba2a The (old) version of SWIG we're using doesn't like certain C++11 features. 53bdeabaf Merge branch 'master' into feature/xml.lite_tweaks 60cf8ae80 "" doesn't work with decltype() in older C++ 97e72477a reduce getValue() overloads by making "key" a template argument 5e6373e55 reduce code duplication f9e7cfeee provide castValue instead of getValue(T&) cbd0bd8f2 castValue throws instead of returning a bool like getValue(T&) 87c7514fc Merge branch 'master' into feature/xml.lite_tweaks 10cc61223 make getElement*() consistent for zero or >1 results f5b137e3c Merge branch 'master' into feature/xml.lite_tweaks 1765efc62 allow clients to specify toType() and toString() for getValue() and setValue() df8b746e1 allow clients to specify their own toType/toString routines 66702726a Merge branch 'master' into feature/xml.lite_tweaks 6956311f1 Merge branch 'master' into feature/xml.lite_tweaks d505f3593 Merge branch 'master' into feature/xml.lite_tweaks fbd106115 catch a BadCastException and return false from getValue() 3a78377b5 use a template to reduce duplicated code 0ad4b8606 Merge branch 'master' into feature/xml.lite_tweaks a848aa3a2 get & set the characer data as a type f3ee1ee12 utility routines to set an attribute value 595227683 templates to get an attribute value convert to a specific type 06639227b miised a change in last commit 1aa458ef8 add getValue() overloads that return true/false rather than throwing faa6d3075 added getElementByTagName() overloads as that's a very common use-case git-subtree-dir: externals/coda-oss git-subtree-split: aeec0131c51497c5d448a39be0d2df608d93bc15 commit bce7ba0b1ae40e9ddcb4f24610e7e4d702272d54 Merge: 646b70e8d 86929db19 Author: Dan Smith Date: Thu Jun 8 14:34:18 2023 -0400 Merge commit '86929db19a438630d531ca0c34bdcd8e8c527ae9' into develop/sync_externals commit 646b70e8d47438211451493837e6b2d76db4e896 Author: Dan Smith Date: Thu Jun 8 14:34:13 2023 -0400 latest from CODA-OSS and NITRO * aliases for std::complex and std::complex * std::complex -> zfloat * std::complex -> zfloat * turn off _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING * begin switching to types::complex for integral T * use types::z* aliases for complex * latest from coda-oss * CPHD aliaes for std::complex * use types::complex for TInteger * Update test_dump_images.cpp * latest from coda-oss * types::complex is std::complex for now * finish (almost) switching to types::complex for integers * std::complex -> six::zfloat * move is implicitly deleted because of =delete for copy * latest from coda-oss * fix Parameter::setValue() overloads * latest from CODA-OSS * use our own type for complex * more progress on types::complex * pass the entire complex type and use value_type * getComplex() overloads * const& for Parameter arguments * findComplex() utility * restore types::z* overloads * Update PVPBlock.cpp * pass entire complex type as template parameter * pass entire complex type as template parameter * pass the entire complex type and use value_type * latest from CODA-OSS * no more types::complex * more changes from CODA-OSS * unittest changes from develop/complex_short branch * latest from CODA-OSS * use CODA_OSS_types_unique_zinteger * no more types::complex * more passing the entire complex type as a template parameter * restore CODA-OSS changes to minimize merge differences * build against "old" CODA-OSS * latest from CODA-OSS * keep using std::complex<> everywhere * restore "old" CODA-OSS to minimize differences --- six/modules/c++/cphd/include/cphd/PVPBlock.h | 14 ++- six/modules/c++/cphd/include/cphd/Types.h | 8 +- six/modules/c++/cphd/source/ByteSwap.cpp | 51 +++++---- six/modules/c++/cphd/source/PVPBlock.cpp | 21 ++-- six/modules/c++/cphd/source/Wideband.cpp | 52 ++++----- .../cphd/unittests/test_pvp_block_round.cpp | 30 +++--- .../unittests/test_signal_block_round.cpp | 43 ++++---- .../unittests/test_cphd_read_unscaled_int.cpp | 51 ++++----- six/modules/c++/samples/round_trip_six.cpp | 12 +-- six/modules/c++/samples/test_dump_images.cpp | 2 +- .../c++/six.sicd/tests/TestUtilities.h | 5 +- .../tests/test_sicd_byte_provider.cpp | 43 ++++---- .../six.sicd/tests/test_streaming_write.cpp | 36 ++++--- .../unittests/test_CollectionInfo.cpp | 6 +- six/modules/c++/six/include/six/Adapters.h | 2 +- .../c++/six/include/six/AmplitudeTable.h | 4 +- .../c++/six/include/six/NITFWriteControl.h | 2 +- six/modules/c++/six/include/six/Parameter.h | 100 +++++++++++------- six/modules/c++/six/include/six/Types.h | 3 +- six/modules/c++/six/source/Adapters.cpp | 2 +- .../c++/six/source/NITFWriteControl.cpp | 2 +- .../c++/six/source/SICommonXMLParser.cpp | 2 +- 22 files changed, 267 insertions(+), 224 deletions(-) diff --git a/six/modules/c++/cphd/include/cphd/PVPBlock.h b/six/modules/c++/cphd/include/cphd/PVPBlock.h index 7981e33123..e65da144ad 100644 --- a/six/modules/c++/cphd/include/cphd/PVPBlock.h +++ b/six/modules/c++/cphd/include/cphd/PVPBlock.h @@ -61,13 +61,23 @@ struct AddedPVP } }; template -struct AddedPVP > +struct AddedPVP> { - types::complex getAddedPVP(const six::Parameter& val) const + auto getAddedPVP(const six::Parameter& val) const { return val.getComplex(); } }; +//#if CODA_OSS_types_unique_zinteger +//template +//struct AddedPVP > +//{ +// auto getAddedPVP(const six::Parameter& val) const +// { +// return val.getComplex(); +// } +//}; +//#endif template<> struct AddedPVP { diff --git a/six/modules/c++/cphd/include/cphd/Types.h b/six/modules/c++/cphd/include/cphd/Types.h index 81873ffcb6..042d0485cf 100644 --- a/six/modules/c++/cphd/include/cphd/Types.h +++ b/six/modules/c++/cphd/include/cphd/Types.h @@ -42,11 +42,11 @@ namespace cphd using zfloat = six::zfloat; using zdouble = six::zdouble; +using zint16_t = six::zint16_t; -using zint8_t = types::zint8_t; -using zint16_t = types::zint16_t; -using zint32_t = types::zint32_t; -using zint64_t = types::zint64_t; +using zint8_t = std::complex; // TODO: types::zint8_t; +using zint32_t = std::complex; // TODO: types::zint32_t; +using zint64_t = std::complex; // TODO: types::zint64_t; typedef six::Vector2 Vector2; diff --git a/six/modules/c++/cphd/source/ByteSwap.cpp b/six/modules/c++/cphd/source/ByteSwap.cpp index 978e1c98dd..642c9a7750 100644 --- a/six/modules/c++/cphd/source/ByteSwap.cpp +++ b/six/modules/c++/cphd/source/ByteSwap.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -41,6 +42,8 @@ #include #include +#include + namespace { template @@ -56,7 +59,7 @@ inline const std::byte* calc_offset(const void* input_, size_t offset) return input + offset; } -template +template struct ByteSwapAndPromoteRunnable final : public sys::Runnable { ByteSwapAndPromoteRunnable(const void* input, @@ -64,7 +67,7 @@ struct ByteSwapAndPromoteRunnable final : public sys::Runnable size_t numRows, size_t numCols, cphd::zfloat* output) : - mInput(calc_offset(input, startRow * numCols * sizeof(types::complex))), + mInput(calc_offset(input, startRow * numCols * sizeof(ComplexInT))), mDims(numRows, numCols), mOutput(output + startRow * numCols) { @@ -72,19 +75,20 @@ struct ByteSwapAndPromoteRunnable final : public sys::Runnable void run() override { - InT real(0); - InT imag(0); + using value_type = typename ComplexInT::value_type; + value_type real(0); + value_type imag(0); for (size_t row = 0, inIdx = 0, outIdx = 0; row < mDims.row; ++row) { - for (size_t col = 0; col < mDims.col; ++col, inIdx += sizeof(types::complex), ++outIdx) + for (size_t col = 0; col < mDims.col; ++col, inIdx += sizeof(ComplexInT), ++outIdx) { // Have to be careful here - can't treat mInput as a - // types::complex directly in case InT is a float (see + // std::complex_t directly in case InT is a float (see // explanation in byteSwap() comments) const auto input = calc_offset(mInput, inIdx); byteSwap(input, real); - byteSwap(calc_offset(input, sizeof(InT)), imag); + byteSwap(calc_offset(input, sizeof(value_type)), imag); mOutput[outIdx] = cphd::zfloat(real, imag); } @@ -98,7 +102,7 @@ struct ByteSwapAndPromoteRunnable final : public sys::Runnable }; -template +template struct ByteSwapAndScaleRunnable final : public sys::Runnable { ByteSwapAndScaleRunnable(const void* input, @@ -107,7 +111,7 @@ struct ByteSwapAndScaleRunnable final : public sys::Runnable size_t numCols, const double* scaleFactors, cphd::zfloat* output) : - mInput(calc_offset(input, startRow * numCols * sizeof(types::complex))), + mInput(calc_offset(input, startRow * numCols * sizeof(ComplexInT))), mDims(numRows, numCols), mScaleFactors(scaleFactors + startRow), mOutput(output + startRow * numCols) @@ -116,8 +120,9 @@ struct ByteSwapAndScaleRunnable final : public sys::Runnable void run() override { - InT real(0); - InT imag(0); + using value_type = typename ComplexInT::value_type; + value_type real(0); + value_type imag(0); for (size_t row = 0, inIdx = 0, outIdx = 0; row < mDims.row; ++row) { @@ -125,14 +130,14 @@ struct ByteSwapAndScaleRunnable final : public sys::Runnable for (size_t col = 0; col < mDims.col; - ++col, inIdx += sizeof(types::complex), ++outIdx) + ++col, inIdx += sizeof(ComplexInT), ++outIdx) { // Have to be careful here - can't treat mInput as a - // types::complex directly in case InT is a float (see + // std::ComplexInT directly in case InT is a float (see // explanation in byteSwap() comments) const auto input = calc_offset(mInput, inIdx); byteSwap(input, real); - byteSwap(calc_offset(input, sizeof(InT)), imag); + byteSwap(calc_offset(input, sizeof(value_type)), imag); mOutput[outIdx] = cphd::zfloat( static_cast(real * scaleFactor), @@ -148,7 +153,7 @@ struct ByteSwapAndScaleRunnable final : public sys::Runnable cphd::zfloat* const mOutput; }; -template +template void byteSwapAndPromote(const void* input, const types::RowCol& dims, size_t numThreads, @@ -156,7 +161,7 @@ void byteSwapAndPromote(const void* input, { if (numThreads <= 1) { - ByteSwapAndPromoteRunnable(input, 0, dims.row, dims.col,output).run(); + ByteSwapAndPromoteRunnable(input, 0, dims.row, dims.col,output).run(); } else { @@ -170,7 +175,7 @@ void byteSwapAndPromote(const void* input, startRow, numRowsThisThread)) { - auto scaler = std::make_unique>( + auto scaler = std::make_unique>( input, startRow, numRowsThisThread, @@ -238,13 +243,13 @@ void byteSwapAndPromote(const void* input, switch (elementSize) { case 2: - ::byteSwapAndPromote(input, dims, numThreads, output); + ::byteSwapAndPromote(input, dims, numThreads, output); break; case 4: - ::byteSwapAndPromote(input, dims, numThreads, output); + ::byteSwapAndPromote(input, dims, numThreads, output); break; case 8: - ::byteSwapAndPromote(input, dims, numThreads, output); + ::byteSwapAndPromote(input, dims, numThreads, output); break; default: throw except::Exception(Ctxt( @@ -262,15 +267,15 @@ void byteSwapAndScale(const void* input, switch (elementSize) { case 2: - ::byteSwapAndScale(input, dims, scaleFactors, numThreads, + ::byteSwapAndScale(input, dims, scaleFactors, numThreads, output); break; case 4: - ::byteSwapAndScale(input, dims, scaleFactors, numThreads, + ::byteSwapAndScale(input, dims, scaleFactors, numThreads, output); break; case 8: - ::byteSwapAndScale(input, dims, scaleFactors, numThreads, + ::byteSwapAndScale(input, dims, scaleFactors, numThreads, output); break; default: diff --git a/six/modules/c++/cphd/source/PVPBlock.cpp b/six/modules/c++/cphd/source/PVPBlock.cpp index c94677ab5b..fdae548e8f 100644 --- a/six/modules/c++/cphd/source/PVPBlock.cpp +++ b/six/modules/c++/cphd/source/PVPBlock.cpp @@ -309,6 +309,15 @@ void PVPBlock::PVPSet::write(const PVPBlock& pvpBlock, const Pvp& p, const sys:: } } +template +auto findComplex(const std::unordered_map& addedPVP, std::map::const_iterator it) +{ + using value_type = typename TComplex::value_type; // help the compiler find the right overload + TComplex retval; + addedPVP.find(it->first)->second.getComplex(retval); + return retval; +} + void PVPBlock::PVPSet::read(const Pvp& p, sys::ubyte* dest_) const { auto dest = reinterpret_cast(dest_); @@ -407,27 +416,27 @@ void PVPBlock::PVPSet::read(const Pvp& p, sys::ubyte* dest_) const } else if (it->second.getFormat() == "CI2") { - ::getData(dest + it->second.getByteOffset(), addedPVP.find(it->first)->second.getComplex()); + ::getData(dest + it->second.getByteOffset(), findComplex(addedPVP, it)); } else if (it->second.getFormat() == "CI4") { - ::getData(dest + it->second.getByteOffset(), addedPVP.find(it->first)->second.getComplex()); + ::getData(dest + it->second.getByteOffset(), findComplex(addedPVP, it)); } else if (it->second.getFormat() == "CI8") { - ::getData(dest + it->second.getByteOffset(), addedPVP.find(it->first)->second.getComplex()); + ::getData(dest + it->second.getByteOffset(), findComplex(addedPVP, it)); } else if (it->second.getFormat() == "CI16") { - ::getData(dest + it->second.getByteOffset(), addedPVP.find(it->first)->second.getComplex()); + ::getData(dest + it->second.getByteOffset(), findComplex(addedPVP, it)); } else if (it->second.getFormat() == "CF8") { - ::getData(dest + it->second.getByteOffset(), addedPVP.find(it->first)->second.getComplex()); + ::getData(dest + it->second.getByteOffset(), findComplex(addedPVP, it)); } else if (it->second.getFormat() == "CF16") { - ::getData(dest + it->second.getByteOffset(), addedPVP.find(it->first)->second.getComplex()); + ::getData(dest + it->second.getByteOffset(), findComplex(addedPVP, it)); } else { diff --git a/six/modules/c++/cphd/source/Wideband.cpp b/six/modules/c++/cphd/source/Wideband.cpp index a2a50d48b6..adfe8e46f3 100644 --- a/six/modules/c++/cphd/source/Wideband.cpp +++ b/six/modules/c++/cphd/source/Wideband.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -38,17 +39,17 @@ #include #include #include +#include #undef min #undef max namespace { -template -class PromoteRunnable : public sys::Runnable +template +struct PromoteRunnable final : public sys::Runnable { -public: - PromoteRunnable(const types::complex* input, + PromoteRunnable(const ComplexInT* input, size_t startRow, size_t numRows, size_t numCols, @@ -65,23 +66,22 @@ class PromoteRunnable : public sys::Runnable { for (size_t col = 0; col < mDims.col; ++col, ++idx) { - const types::complex& input(mInput[idx]); + const ComplexInT& input(mInput[idx]); mOutput[idx] = cphd::zfloat(input.real(), input.imag()); } } } private: - const types::complex* const mInput; + const ComplexInT* const mInput; const types::RowCol mDims; cphd::zfloat* const mOutput; }; -template -class ScaleRunnable : public sys::Runnable +template +struct ScaleRunnable final : public sys::Runnable { -public: - ScaleRunnable(const types::complex* input, + ScaleRunnable(const ComplexInT* input, size_t startRow, size_t numRows, size_t numCols, @@ -101,7 +101,7 @@ class ScaleRunnable : public sys::Runnable const double scaleFactor(mScaleFactors[row]); for (size_t col = 0; col < mDims.col; ++col, ++idx) { - const types::complex& input(mInput[idx]); + auto&& input(mInput[idx]); mOutput[idx] = cphd::zfloat(static_cast(input.real() * scaleFactor), static_cast(input.imag() * scaleFactor)); } @@ -109,13 +109,13 @@ class ScaleRunnable : public sys::Runnable } private: - const types::complex* const mInput; + const ComplexInT* const mInput; const types::RowCol mDims; const double* const mScaleFactors; cphd::zfloat* const mOutput; }; -template +template void promote(const void* input, const types::RowCol& dims, size_t numThreads, @@ -123,7 +123,7 @@ void promote(const void* input, { if (numThreads <= 1) { - PromoteRunnable(static_cast*>(input), + PromoteRunnable(static_cast(input), 0, dims.row, dims.col, @@ -140,8 +140,8 @@ void promote(const void* input, size_t numRowsThisThread(0); while (planner.getThreadInfo(threadNum++, startRow, numRowsThisThread)) { - auto scaler = std::make_unique>( - static_cast*>(input), + auto scaler = std::make_unique>( + static_cast(input), startRow, numRowsThisThread, dims.col, @@ -162,20 +162,20 @@ void promote(const void* input, switch (elementSize) { case 2: - promote(input, dims, numThreads, output); + promote(input, dims, numThreads, output); break; case 4: - promote(input, dims, numThreads, output); + promote(input, dims, numThreads, output); break; case 8: - promote(input, dims, numThreads, output); + promote(input, dims, numThreads, output); break; default: throw except::Exception( Ctxt("Unexpected element size " + std::to_string(elementSize))); } } -template +template void scale(const void* input, const types::RowCol& dims, const double* scaleFactors, @@ -184,7 +184,7 @@ void scale(const void* input, { if (numThreads <= 1) { - ScaleRunnable(static_cast*>(input), + ScaleRunnable(static_cast(input), 0, dims.row, dims.col, @@ -202,8 +202,8 @@ void scale(const void* input, size_t numRowsThisThread(0); while (planner.getThreadInfo(threadNum++, startRow, numRowsThisThread)) { - auto scaler = std::make_unique>( - static_cast*>(input), + auto scaler = std::make_unique>( + static_cast(input), startRow, numRowsThisThread, dims.col, @@ -226,13 +226,13 @@ void scale(const void* input, switch (elementSize) { case 2: - scale(input, dims, scaleFactors, numThreads, output); + scale(input, dims, scaleFactors, numThreads, output); break; case 4: - scale(input, dims, scaleFactors, numThreads, output); + scale(input, dims, scaleFactors, numThreads, output); break; case 8: - scale(input, dims, scaleFactors, numThreads, output); + scale(input, dims, scaleFactors, numThreads, output); break; default: throw except::Exception( diff --git a/six/modules/c++/cphd/unittests/test_pvp_block_round.cpp b/six/modules/c++/cphd/unittests/test_pvp_block_round.cpp index 026f6c3511..3bb70ad502 100644 --- a/six/modules/c++/cphd/unittests/test_pvp_block_round.cpp +++ b/six/modules/c++/cphd/unittests/test_pvp_block_round.cpp @@ -42,16 +42,17 @@ #include #include -template -std::vector> generateComplexData(size_t length) +template +auto generateComplexData(size_t length) { - std::vector> data(length); + using value_type = typename TComplex::value_type; + std::vector data(length); srand(0); for (size_t ii = 0; ii < data.size(); ++ii) { - float real = static_cast(rand() / 100); - float imag = static_cast(rand() / 100); - data[ii] = types::complex(real, imag); + auto real = static_cast(rand() / 100); + auto imag = static_cast(rand() / 100); + data[ii] = TComplex(real, imag); } return data; } @@ -115,11 +116,11 @@ void setPVPBlock(const types::RowCol dims, } } -template +template void writeCPHD(const std::string& outPathname, size_t numThreads, const types::RowCol dims, - const std::vector>& writeData, + const TCxVector& writeData, cphd::Metadata& metadata, cphd::PVPBlock& pvpBlock) { @@ -155,9 +156,9 @@ bool checkData(const std::string& pathname, return true; } -template +template bool runTest(bool /*scale*/, - const std::vector>& writeData, + const TCxVector& writeData, cphd::Metadata& meta, cphd::PVPBlock& pvpBlock, const types::RowCol dims) @@ -171,8 +172,7 @@ bool runTest(bool /*scale*/, TEST_CASE(testPVPBlockSimple) { const types::RowCol dims(128, 256); - const std::vector writeData = - generateComplexData(dims.area()); + const auto writeData = generateComplexData(dims.area()); const bool scale = false; cphd::Metadata meta = cphd::Metadata(); cphd::setUpData(meta, dims, writeData); @@ -195,8 +195,7 @@ TEST_CASE(testPVPBlockSimple) TEST_CASE(testPVPBlockOptional) { const types::RowCol dims(128, 256); - const std::vector writeData = - generateComplexData(dims.area()); + const auto writeData = generateComplexData(dims.area()); const bool scale = false; cphd::Metadata meta = cphd::Metadata(); cphd::setUpData(meta, dims, writeData); @@ -222,8 +221,7 @@ TEST_CASE(testPVPBlockOptional) TEST_CASE(testPVPBlockAdditional) { const types::RowCol dims(128, 256); - const std::vector writeData = - generateComplexData(dims.area()); + const auto writeData = generateComplexData(dims.area()); const bool scale = false; cphd::Metadata meta = cphd::Metadata(); cphd::setUpData(meta, dims, writeData); diff --git a/six/modules/c++/cphd/unittests/test_signal_block_round.cpp b/six/modules/c++/cphd/unittests/test_signal_block_round.cpp index 5eaeb9fd70..197bc10698 100644 --- a/six/modules/c++/cphd/unittests/test_signal_block_round.cpp +++ b/six/modules/c++/cphd/unittests/test_signal_block_round.cpp @@ -46,16 +46,17 @@ * Fails if values don't match */ -template -std::vector > generateData(size_t length) +template +auto generateData(size_t length) { - std::vector > data(length); + using value_type = typename TComplex::value_type; + std::vector data(length); srand(0); for (size_t ii = 0; ii < data.size(); ++ii) { - auto real = static_cast(rand() / 100); - auto imag = static_cast(rand() / 100); - data[ii] = types::complex(real, imag); + auto real = static_cast(rand() / 100); + auto imag = static_cast(rand() / 100); + data[ii] = TComplex(real, imag); } return data; } @@ -73,10 +74,10 @@ inline std::vector generateScaleFactors(size_t length, bool scale) return scaleFactors; } -template +template void writeCPHD(const std::string& outPathname, size_t /*numThreads*/, const types::RowCol dims, - const std::vector >& writeData, + const TCxVector& writeData, cphd::Metadata& metadata, cphd::PVPBlock& pvpBlock) { @@ -120,9 +121,9 @@ std::vector checkData(const std::string& pathname, return readData; } -template +template bool compareVectors(const std::vector& readData, - const std::vector >& writeData, + const TCxVector& writeData, const std::vector& scaleFactors, bool scale) { @@ -144,8 +145,8 @@ bool compareVectors(const std::vector& readData, return true; } -template -bool runTest(bool scale, const std::vector >& writeData) +template +bool runTest(bool scale, const TCxVector& writeData) { io::TempFile tempfile; const size_t numThreads = std::thread::hardware_concurrency(); @@ -168,8 +169,7 @@ bool runTest(bool scale, const std::vector >& writeData) TEST_CASE(testUnscaledInt8) { const types::RowCol dims(128, 128); - const std::vector writeData = - generateData(dims.area()); + const auto writeData = generateData(dims.area()); const bool scale = false; TEST_ASSERT_TRUE(runTest(scale, writeData)); } @@ -177,8 +177,7 @@ TEST_CASE(testUnscaledInt8) TEST_CASE(testScaledInt8) { const types::RowCol dims(128, 128); - const std::vector writeData = - generateData(dims.area()); + const auto writeData = generateData(dims.area()); const bool scale = true; TEST_ASSERT_TRUE(runTest(scale, writeData)); } @@ -186,8 +185,7 @@ TEST_CASE(testScaledInt8) TEST_CASE(testUnscaledInt16) { const types::RowCol dims(128, 128); - const std::vector writeData = - generateData(dims.area()); + const auto writeData = generateData(dims.area()); const bool scale = false; TEST_ASSERT_TRUE(runTest(scale, writeData)); } @@ -195,8 +193,7 @@ TEST_CASE(testUnscaledInt16) TEST_CASE(testScaledInt16) { const types::RowCol dims(128, 128); - const std::vector writeData = - generateData(dims.area()); + const auto writeData = generateData(dims.area()); const bool scale = true; TEST_ASSERT_TRUE(runTest(scale, writeData)); } @@ -204,8 +201,7 @@ TEST_CASE(testScaledInt16) TEST_CASE(testUnscaledFloat) { const types::RowCol dims(128, 128); - const std::vector writeData = - generateData(dims.area()); + const auto writeData = generateData(dims.area()); const bool scale = false; TEST_ASSERT_TRUE(runTest(scale, writeData)); } @@ -213,8 +209,7 @@ TEST_CASE(testUnscaledFloat) TEST_CASE(testScaledFloat) { const types::RowCol dims(128, 128); - const std::vector writeData = - generateData(dims.area()); + const auto writeData = generateData(dims.area()); const bool scale = true; TEST_ASSERT_TRUE(runTest(scale, writeData)); } diff --git a/six/modules/c++/cphd03/unittests/test_cphd_read_unscaled_int.cpp b/six/modules/c++/cphd03/unittests/test_cphd_read_unscaled_int.cpp index 704517da68..55ba575540 100644 --- a/six/modules/c++/cphd03/unittests/test_cphd_read_unscaled_int.cpp +++ b/six/modules/c++/cphd03/unittests/test_cphd_read_unscaled_int.cpp @@ -37,16 +37,17 @@ #include "TestCase.h" -template -std::vector > generateData(size_t length) +template +auto generateData(size_t length) { - std::vector > data(length); + using value_type = typename TComplex::value_type; + std::vector data(length); srand(0); for (size_t ii = 0; ii < data.size(); ++ii) { - float real = static_cast(rand() / 100); - float imag = static_cast(rand() / 100); - data[ii] = types::complex(real, imag); + auto real = static_cast(rand() / 100); + auto imag = static_cast(rand() / 100); + data[ii] = TComplex(real, imag); } return data; } @@ -84,10 +85,10 @@ inline cphd::SampleType getSampleType(size_t writeDataSize) throw std::invalid_argument("Unespced writeDataSize"); } -template +template void writeCPHD(const std::string& outPathname, size_t numThreads, const types::RowCol dims, - const std::vector >& writeData) + const TCxVector& writeData) { const size_t numChannels = 1; const std::vector numVectors(numChannels, dims.row); @@ -164,9 +165,9 @@ std::vector checkData(const std::string& pathname, return readData; } -template +template bool compareVectors(const std::vector& readData, - const std::vector >& writeData, + const TCxVector& writeData, const std::vector& scaleFactors, bool scale) { @@ -188,26 +189,23 @@ bool compareVectors(const std::vector& readData, return true; } -template -bool runTest(bool scale, const std::vector >& writeData) +template +bool runTest(bool scale, const TCxVector& writeData) { io::TempFile tempfile; const size_t numThreads = std::thread::hardware_concurrency(); const types::RowCol dims(128, 128); - const std::vector scaleFactors = - generateScaleFactors(dims.row, scale); writeCPHD(tempfile.pathname(), numThreads, dims, writeData); - const std::vector readData = - checkData(tempfile.pathname(), numThreads, scaleFactors, - scale, dims); + + const auto scaleFactors = generateScaleFactors(dims.row, scale); + const auto readData = checkData(tempfile.pathname(), numThreads, scaleFactors, scale, dims); return compareVectors(readData, writeData, scaleFactors, scale); } TEST_CASE(testUnscaledInt8) { const types::RowCol dims(128, 128); - const std::vector writeData = - generateData(dims.area()); + const auto writeData = generateData(dims.area()); const bool scale = false; TEST_ASSERT(runTest(scale, writeData)); } @@ -215,16 +213,14 @@ TEST_CASE(testUnscaledInt8) TEST_CASE(testScaledInt8) { const types::RowCol dims(128, 128); - const std::vector writeData = - generateData(dims.area()); + const auto writeData = generateData(dims.area()); const bool scale = true; TEST_ASSERT(runTest(scale, writeData)); } TEST_CASE(testUnscaledInt16) { const types::RowCol dims(128, 128); - const std::vector writeData = - generateData(dims.area()); + const auto writeData = generateData(dims.area()); const bool scale = false; TEST_ASSERT(runTest(scale, writeData)); } @@ -232,8 +228,7 @@ TEST_CASE(testUnscaledInt16) TEST_CASE(testScaledInt16) { const types::RowCol dims(128, 128); - const std::vector writeData = - generateData(dims.area()); + const auto writeData = generateData(dims.area()); const bool scale = true; TEST_ASSERT(runTest(scale, writeData)); } @@ -241,8 +236,7 @@ TEST_CASE(testScaledInt16) TEST_CASE(testUnscaledFloat) { const types::RowCol dims(128, 128); - const std::vector writeData = - generateData(dims.area()); + const auto writeData = generateData(dims.area()); const bool scale = false; TEST_ASSERT(runTest(scale, writeData)); } @@ -250,8 +244,7 @@ TEST_CASE(testUnscaledFloat) TEST_CASE(testScaledFloat) { const types::RowCol dims(128, 128); - const std::vector writeData = - generateData(dims.area()); + const auto writeData = generateData(dims.area()); const bool scale = true; TEST_ASSERT(runTest(scale, writeData)); } diff --git a/six/modules/c++/samples/round_trip_six.cpp b/six/modules/c++/samples/round_trip_six.cpp index c28844a373..83e8f28da4 100644 --- a/six/modules/c++/samples/round_trip_six.cpp +++ b/six/modules/c++/samples/round_trip_six.cpp @@ -96,9 +96,9 @@ struct Buffers final // We'll expand to complex starting in the first half of the buffer void expandComplex(size_t numPixels, std::byte* buffer) { - const types::zint16_t* const input = - reinterpret_cast( - buffer + numPixels * sizeof(types::zint16_t)); + const six::zint16_t* const input = + reinterpret_cast( + buffer + numPixels * sizeof(six::zint16_t)); six::zfloat* const output = reinterpret_cast(buffer); @@ -137,7 +137,7 @@ void compressInteger(size_t numPixels, std::byte* buffer) } auto const input = reinterpret_cast(buffer); - auto const output = reinterpret_cast(buffer); + auto const output = reinterpret_cast(buffer); const float diff = max - min; // If diff ends up being zero, we will get a division by 0 error. @@ -145,14 +145,14 @@ void compressInteger(size_t numPixels, std::byte* buffer) // fill it with 0s. if (diff == 0.0f) { - std::fill_n(output, numPixels, types::zint16_t(0, 0)); + std::fill_n(output, numPixels, six::zint16_t(0, 0)); return; } const CompressFloat compressFloat(min, diff); for (size_t ii = 0; ii < numPixels; ++ii) { - output[ii] = types::zint16_t( + output[ii] = six::zint16_t( compressFloat(input[ii].real()), compressFloat(input[ii].imag())); } diff --git a/six/modules/c++/samples/test_dump_images.cpp b/six/modules/c++/samples/test_dump_images.cpp index 8b279e4b72..918a5ea232 100644 --- a/six/modules/c++/samples/test_dump_images.cpp +++ b/six/modules/c++/samples/test_dump_images.cpp @@ -53,7 +53,7 @@ void writeSIOFileHeader(size_t numRows, elementType = sio::lite::FileHeader::COMPLEX_FLOAT; break; case six::PixelType::RE16I_IM16I: - elementSize = sizeof(types::zint16_t); + elementSize = sizeof(six::zint16_t); elementType = sio::lite::FileHeader::COMPLEX_SIGNED; break; case six::PixelType::MONO8I: diff --git a/six/modules/c++/six.sicd/tests/TestUtilities.h b/six/modules/c++/six.sicd/tests/TestUtilities.h index 056ee0ba3f..7100bfa61a 100644 --- a/six/modules/c++/six.sicd/tests/TestUtilities.h +++ b/six/modules/c++/six.sicd/tests/TestUtilities.h @@ -55,14 +55,15 @@ struct GetPixelType }; // Create dummy SICD data -template +template std::unique_ptr createData(const types::RowCol& dims) { std::unique_ptr data = six::sicd::Utilities::createFakeComplexData(); setExtent(*data, dims); - data->setPixelType(GetPixelType::getPixelType()); + using value_type = typename CxDataTypeT::value_type; + data->setPixelType(GetPixelType::getPixelType()); return data; } diff --git a/six/modules/c++/six.sicd/tests/test_sicd_byte_provider.cpp b/six/modules/c++/six.sicd/tests/test_sicd_byte_provider.cpp index 86b94a1e14..29613f5730 100644 --- a/six/modules/c++/six.sicd/tests/test_sicd_byte_provider.cpp +++ b/six/modules/c++/six.sicd/tests/test_sicd_byte_provider.cpp @@ -39,7 +39,7 @@ namespace { // Main test class -template +template struct Tester final { Tester(const std::vector& schemaPaths, @@ -50,7 +50,7 @@ struct Tester final mDims(123, 456), // Have to release() here to prevent nasty runtime error // with Solaris - mData(createData(mDims).release()), + mData(createData(mDims).release()), mImage(mDims.area()), mTestPathname("streaming_write.nitf"), mSchemaPaths(schemaPaths), @@ -60,16 +60,17 @@ struct Tester final { for (size_t ii = 0; ii < mImage.size(); ++ii) { - mImage[ii] = types::complex( - static_cast(ii), - static_cast(ii * 10)); + using value_type = typename CxDataTypeT::value_type; + mImage[ii] = CxDataTypeT( + static_cast(ii), + static_cast(ii * 10)); } mBigEndianImage = mImage; if (sys::isLittleEndianSystem()) { void* const buffer = mBigEndianImage.data(); - constexpr auto elemSize = sizeof(DataTypeT); + constexpr auto elemSize = sizeof(CxDataTypeT); const auto numElems = mBigEndianImage.size() * 2; // real and imag sys::byteSwap(buffer, elemSize, numElems); } @@ -148,8 +149,8 @@ struct Tester final const types::RowCol mDims; std::unique_ptr mData; - std::vector > mImage; - std::vector > mBigEndianImage; + std::vector mImage; + std::vector mBigEndianImage; std::unique_ptr mCompareFiles; const std::string mTestPathname; @@ -161,8 +162,8 @@ struct Tester final bool mSuccess; }; -template -void Tester::normalWrite() +template +void Tester::normalWrite() { mem::SharedPtr container( new six::Container(six::DataType::COMPLEX)); @@ -183,8 +184,8 @@ void Tester::normalWrite() mCompareFiles.reset(new CompareFiles(mNormalPathname)); } -template -void Tester::testSingleWrite() +template +void Tester::testSingleWrite() { const EnsureFileCleanup ensureFileCleanup(mTestPathname); @@ -206,8 +207,8 @@ void Tester::testSingleWrite() compare("Single write"); } -template -void Tester::testMultipleWrites() +template +void Tester::testMultipleWrites() { const EnsureFileCleanup ensureFileCleanup(mTestPathname); @@ -291,8 +292,8 @@ void Tester::testMultipleWrites() compare("Multiple writes"); } -template -void Tester::testOneWritePerRow() +template +void Tester::testOneWritePerRow() { const EnsureFileCleanup ensureFileCleanup(mTestPathname); @@ -323,7 +324,7 @@ void Tester::testOneWritePerRow() compare("One write per row"); } -template +template bool doTests(const std::vector& schemaPaths, bool setMaxProductSize, size_t numRowsPerSeg) @@ -334,11 +335,11 @@ bool doTests(const std::vector& schemaPaths, // It would be better to get the logic fixed that forces // segmentation on the number of rows via OPT_MAX_ILOC_ROWS static const size_t APPROX_HEADER_SIZE = 2 * 1024; - const size_t numBytesPerRow = 456 * sizeof(types::complex); + const size_t numBytesPerRow = 456 * sizeof(CxDataTypeT); const size_t maxProductSize = numRowsPerSeg * numBytesPerRow + APPROX_HEADER_SIZE; - Tester tester(schemaPaths, setMaxProductSize, maxProductSize); + Tester tester(schemaPaths, setMaxProductSize, maxProductSize); tester.testSingleWrite(); tester.testMultipleWrites(); tester.testOneWritePerRow(); @@ -351,12 +352,12 @@ bool doTestsBothDataTypes(const std::vector& schemaPaths, size_t numRowsPerSeg = 0) { bool success = true; - if (!doTests(schemaPaths, setMaxProductSize, numRowsPerSeg)) + if (!doTests(schemaPaths, setMaxProductSize, numRowsPerSeg)) { success = false; } - if (!doTests(schemaPaths, setMaxProductSize, numRowsPerSeg)) + if (!doTests(schemaPaths, setMaxProductSize, numRowsPerSeg)) { success = false; } diff --git a/six/modules/c++/six.sicd/tests/test_streaming_write.cpp b/six/modules/c++/six.sicd/tests/test_streaming_write.cpp index 4c61691474..429e32e5de 100644 --- a/six/modules/c++/six.sicd/tests/test_streaming_write.cpp +++ b/six/modules/c++/six.sicd/tests/test_streaming_write.cpp @@ -103,13 +103,15 @@ struct GetPixelType }; // Create dummy SICD data -template +template std::unique_ptr createData(const types::RowCol& dims) { + using value_type = typename CxDataTypeT::value_type; + six::sicd::ComplexData* data(new six::sicd::ComplexData()); std::unique_ptr scopedData(data); - data->setPixelType(GetPixelType::getPixelType()); + data->setPixelType(GetPixelType::getPixelType()); setExtent(*data, dims); data->setName("corename"); data->setSource("sensorname"); @@ -215,7 +217,7 @@ void subsetData(const T* orig, } // Main test class -template +template struct Tester final { Tester(const std::vector& schemaPaths, @@ -233,11 +235,13 @@ struct Tester final mMaxProductSize(maxProductSize), mSuccess(true) { + using value_type = typename CxDataTypeT::value_type; + for (size_t ii = 0; ii < mImage.size(); ++ii) { - mImage[ii] = types::complex( - static_cast(ii), - static_cast(ii * 10)); + mImage[ii] = CxDataTypeT( + static_cast(ii), + static_cast(ii * 10)); } normalWrite(); @@ -291,8 +295,8 @@ struct Tester final mem::SharedPtr mContainer; const types::RowCol mDims; - std::vector > mImage; - types::complex* const mImagePtr; + std::vector mImage; + CxDataTypeT* const mImagePtr; std::unique_ptr mCompareFiles; const std::string mTestPathname; @@ -388,8 +392,8 @@ void Tester::testMultipleWritesOfFullRows() compare("Multiple writes of full rows"); } -template -void Tester::testMultipleWritesOfPartialRows() +template +void Tester::testMultipleWritesOfPartialRows() { const EnsureFileCleanup ensureFileCleanup(mTestPathname); @@ -402,7 +406,7 @@ void Tester::testMultipleWritesOfPartialRows() // Rows [40, 60) // Cols [400, 456) types::RowCol offset(40, 400); - std::vector > subset; + std::vector subset; types::RowCol subsetDims(20, 56); subsetData(mImagePtr, mDims.col, offset, subsetDims, subset); sicdWriter.save(subset.data(), offset, subsetDims); @@ -446,7 +450,7 @@ void Tester::testMultipleWritesOfPartialRows() compare("Multiple writes of partial rows"); } -template +template bool doTests(const std::vector& schemaPaths, bool setMaxProductSize, size_t numRowsPerSeg) @@ -457,11 +461,11 @@ bool doTests(const std::vector& schemaPaths, // It would be better to get the logic fixed that forces // segmentation on the number of rows via OPT_MAX_ILOC_ROWS static const size_t APPROX_HEADER_SIZE = 2 * 1024; - const size_t numBytesPerRow = 456 * sizeof(types::complex); + const size_t numBytesPerRow = 456 * sizeof(CxDataTypeT); const size_t maxProductSize = numRowsPerSeg * numBytesPerRow + APPROX_HEADER_SIZE; - Tester tester(schemaPaths, setMaxProductSize, maxProductSize); + Tester tester(schemaPaths, setMaxProductSize, maxProductSize); tester.testSingleWrite(); tester.testMultipleWritesOfFullRows(); tester.testMultipleWritesOfPartialRows(); @@ -474,12 +478,12 @@ bool doTestsBothDataTypes(const std::vector& schemaPaths, size_t numRowsPerSeg = 0) { bool success = true; - if (!doTests(schemaPaths, setMaxProductSize, numRowsPerSeg)) + if (!doTests(schemaPaths, setMaxProductSize, numRowsPerSeg)) { success = false; } - if (!doTests(schemaPaths, setMaxProductSize, numRowsPerSeg)) + if (!doTests(schemaPaths, setMaxProductSize, numRowsPerSeg)) { success = false; } diff --git a/six/modules/c++/six.sicd/unittests/test_CollectionInfo.cpp b/six/modules/c++/six.sicd/unittests/test_CollectionInfo.cpp index 9c33121b5a..b05e580d1e 100644 --- a/six/modules/c++/six.sicd/unittests/test_CollectionInfo.cpp +++ b/six/modules/c++/six.sicd/unittests/test_CollectionInfo.cpp @@ -49,7 +49,7 @@ TEST_CASE(DummyData) { - const auto data = createData(types::RowCol(10, 10)); + const auto data = createData(types::RowCol(10, 10)); const std::vector schemaPaths; const auto result = six::sicd::Utilities::toXMLString(*data, schemaPaths); @@ -69,7 +69,7 @@ TEST_CASE(Classification) { const std::string classificationText("UNCLASSIFIED"); - auto data = createData(types::RowCol(10, 10)); + auto data = createData(types::RowCol(10, 10)); data->collectionInformation->setClassificationLevel(classificationText); TEST_ASSERT_TRUE(data->getClassification().isUnclassified()); @@ -98,7 +98,7 @@ TEST_CASE(ClassificationCanada) const std::string classificationText("NON CLASSIFI\xc3\x89 / UNCLASSIFIED"); // UTF-8 "NON CLASSIFIÉ / UNCLASSIFIED" #endif - auto data = createData(types::RowCol(10, 10)); + auto data = createData(types::RowCol(10, 10)); data->collectionInformation->setClassificationLevel(classificationText); TEST_ASSERT_TRUE(data->getClassification().isUnclassified()); diff --git a/six/modules/c++/six/include/six/Adapters.h b/six/modules/c++/six/include/six/Adapters.h index 2d359c1216..84fe1b6a32 100644 --- a/six/modules/c++/six/include/six/Adapters.h +++ b/six/modules/c++/six/include/six/Adapters.h @@ -170,7 +170,7 @@ class NewMemoryWriteHandler final : public nitf::WriteHandler // all of our code std::span buffer, size_t firstRow, const Data& data, bool doByteSwap); NewMemoryWriteHandler(const NITFSegmentInfo& info, - std::span buffer, + std::span buffer, size_t firstRow, const Data& data, bool doByteSwap); NewMemoryWriteHandler(const NITFSegmentInfo& info, std::span> buffer, diff --git a/six/modules/c++/six/include/six/AmplitudeTable.h b/six/modules/c++/six/include/six/AmplitudeTable.h index 5ea0e750fa..649c39fab1 100644 --- a/six/modules/c++/six/include/six/AmplitudeTable.h +++ b/six/modules/c++/six/include/six/AmplitudeTable.h @@ -197,8 +197,8 @@ class ComplexToAMP8IPHS8I final ~ComplexToAMP8IPHS8I() = default; ComplexToAMP8IPHS8I(const ComplexToAMP8IPHS8I&) = delete; ComplexToAMP8IPHS8I& operator=(const ComplexToAMP8IPHS8I&) = delete; - ComplexToAMP8IPHS8I(ComplexToAMP8IPHS8I&&) = default; - ComplexToAMP8IPHS8I& operator=(ComplexToAMP8IPHS8I&&) = default; + ComplexToAMP8IPHS8I(ComplexToAMP8IPHS8I&&) = delete; // implicitly deleted because of =delete for copy + ComplexToAMP8IPHS8I& operator=(ComplexToAMP8IPHS8I&&) = delete; // implicitly deleted because of =delete for copy /*! * Get the nearest amplitude and phase value given a complex value diff --git a/six/modules/c++/six/include/six/NITFWriteControl.h b/six/modules/c++/six/include/six/NITFWriteControl.h index a4a0e6f146..499e49da6a 100644 --- a/six/modules/c++/six/include/six/NITFWriteControl.h +++ b/six/modules/c++/six/include/six/NITFWriteControl.h @@ -300,7 +300,7 @@ class NITFWriteControl : public WriteControl // Be explicit about the types of images that can be saved; templates are provided below. void save_image(std::span, nitf::IOInterface&, const std::vector&); - void save_image(std::span, nitf::IOInterface&, const std::vector&); + void save_image(std::span, nitf::IOInterface&, const std::vector&); void save_image(std::span>, nitf::IOInterface&, const std::vector&); void save_image(std::span, nitf::IOInterface&, const std::vector&); void save_image(std::span, nitf::IOInterface&, const std::vector&); diff --git a/six/modules/c++/six/include/six/Parameter.h b/six/modules/c++/six/include/six/Parameter.h index 1f001529aa..5db4b9e8e4 100644 --- a/six/modules/c++/six/include/six/Parameter.h +++ b/six/modules/c++/six/include/six/Parameter.h @@ -19,8 +19,9 @@ * see . * */ -#ifndef __SIX_PARAMETER_H__ -#define __SIX_PARAMETER_H__ +#pragma once +#ifndef SIX_six_Parameter_h_INCLUDED_ +#define SIX_six_Parameter_h_INCLUDED_ #include #include @@ -38,33 +39,38 @@ namespace six * and get parameters directly from native types without string * conversion. */ -class Parameter +struct Parameter final { -public: Parameter() = default; - //! Destructor - ~Parameter() - { - } + ~Parameter() = default; - Parameter(const Parameter & other) - : mValue(other.mValue), - mName(other.mName) - { - } + Parameter(const Parameter&) = default; + Parameter& operator=(const Parameter&) = default; + Parameter(Parameter&&) = default; + Parameter& operator=(Parameter&&) = default; //! Templated constructor, constructs from given value template - Parameter(T value) + Parameter(const T& value) { mValue = str::toString(value); } + Parameter(const char* value) : Parameter(std::string(value)) + { + } template - Parameter(types::complex value) + Parameter(const std::complex& value) { - mValue = str::toString >(mValue); + mValue = str::toString >(mValue); } + //#if CODA_OSS_types_unique_zinteger + //template + //Parameter(const types::zinteger& value) + //{ + // mValue = str::toString >(mValue); + //} + //#endif /*! * \tparam T Desired (presumably numeric) type to convert to @@ -72,28 +78,40 @@ class Parameter * \return Value as a T type */ template - inline operator T() const + operator T() const { return str::toType(mValue); } //! Get a string as a string - inline std::string str() const + std::string str() const { return mValue; } //! Get the parameter's name - inline std::string getName() const + std::string getName() const { return mName; } //! Get complex parameter template - inline types::complex getComplex() const + std::complex getComplex() const { - return str::toType >(mValue); + return str::toType >(mValue); } + template + void getComplex(std::complex& result) const + { + result = str::toType >(mValue); + } + //#if CODA_OSS_types_unique_zinteger + //template + //void getComplex(types::zinteger& result) const + //{ + // result = str::toType >(mValue); + //} + //#endif //! Set the parameters' name void setName(std::string name) @@ -103,17 +121,28 @@ class Parameter //! Set the parameters' value template - void setValue(T value) + void setValue(const T& value) { mValue = str::toString(value); } + void setValue(const char* value) + { + setValue(std::string(value)); + } //! Overload templated setValue function template - void setValue(const types::complex& value) + void setValue(const std::complex& value) { - mValue = str::toString >(value); + mValue = str::toString >(value); } + //#if CODA_OSS_types_unique_zinteger + //template + //void setValue(const types::zinteger& value) + //{ + // mValue = str::toString >(value); + //} + //#endif //! Get back const char* operator const char*() const @@ -121,23 +150,20 @@ class Parameter return mValue.c_str(); } - bool operator==(const Parameter& o) const - { - return mName == o.mName && mValue == o.mValue; - } - - bool operator!=(const Parameter& o) const - { - return !((*this) == o); - } - -protected: +private: std::string mValue; std::string mName; - }; +inline bool operator==(const Parameter& lhs, const Parameter& rhs) +{ + return (lhs.getName() == rhs.getName()) && (lhs.str() == rhs.str()); +} +inline bool operator!=(const Parameter& lhs, const Parameter& rhs) +{ + return !(lhs == rhs); } -#endif +} +#endif // SIX_six_Parameter_h_INCLUDED_ \ No newline at end of file diff --git a/six/modules/c++/six/include/six/Types.h b/six/modules/c++/six/include/six/Types.h index c2c6736021..961ec58950 100644 --- a/six/modules/c++/six/include/six/Types.h +++ b/six/modules/c++/six/include/six/Types.h @@ -52,6 +52,7 @@ namespace six { using zfloat = scene::zfloat; using zdouble = scene::zdouble; + using zint16_t = std::complex; // TODO: types::zint16_t; } #include "six/AmplitudeTable.h" @@ -198,7 +199,7 @@ struct Constants // Each pixel is stored as a pair of numbers that represent the real and imaginary // components. Each component is stored in a 16-bit signed integer in 2's // complement format (2 bytes per component, 4 bytes per pixel). - static_assert(sizeof(types::zint16_t) == 4, "RE16I_IM16I should be two 16-bit integers"); + static_assert(sizeof(six::zint16_t) == 4, "RE16I_IM16I should be two 16-bit integers"); return 4; } diff --git a/six/modules/c++/six/source/Adapters.cpp b/six/modules/c++/six/source/Adapters.cpp index 790809dee0..f1693a4947 100644 --- a/six/modules/c++/six/source/Adapters.cpp +++ b/six/modules/c++/six/source/Adapters.cpp @@ -294,7 +294,7 @@ NewMemoryWriteHandler::NewMemoryWriteHandler(const NITFSegmentInfo& info, } NewMemoryWriteHandler::NewMemoryWriteHandler(const NITFSegmentInfo& info, - std::span buffer, size_t firstRow, const Data& data, bool doByteSwap) + std::span buffer, size_t firstRow, const Data& data, bool doByteSwap) : NewMemoryWriteHandler(info, cast(buffer), firstRow, data, doByteSwap) { // Each pixel is stored as a pair of numbers that represent the real and imaginary diff --git a/six/modules/c++/six/source/NITFWriteControl.cpp b/six/modules/c++/six/source/NITFWriteControl.cpp index d96406281d..06dd4e73f1 100644 --- a/six/modules/c++/six/source/NITFWriteControl.cpp +++ b/six/modules/c++/six/source/NITFWriteControl.cpp @@ -524,7 +524,7 @@ void NITFWriteControl::save_image(std::span imageData, { do_save(imageData, outputFile, convert_paths(schemaPaths)); } -void NITFWriteControl::save_image(std::span imageData, +void NITFWriteControl::save_image(std::span imageData, nitf::IOInterface& outputFile, const std::vector& schemaPaths) { diff --git a/six/modules/c++/six/source/SICommonXMLParser.cpp b/six/modules/c++/six/source/SICommonXMLParser.cpp index 93ef38b68f..6b9da165b7 100644 --- a/six/modules/c++/six/source/SICommonXMLParser.cpp +++ b/six/modules/c++/six/source/SICommonXMLParser.cpp @@ -542,7 +542,7 @@ XMLElem SICommonXMLParser::createLatLonAlt(const std::string& name, void SICommonXMLParser::parseParameter(const xml::lite::Element* element, Parameter& p) const { p.setName(element->getAttributes().getValue("name")); - p.setValue(element->getCharacterData()); + p.setValue(element->getCharacterData()); } void SICommonXMLParser::parseParameters(const xml::lite::Element* paramXML,