2026-04-20 12:45:31 -04:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" lang = "en-US" >
< head >
< meta http-equiv = "Content-Type" content = "text/xhtml;charset=UTF-8" / >
< meta http-equiv = "X-UA-Compatible" content = "IE=11" / >
< meta name = "generator" content = "Doxygen 1.13.2" / >
< meta name = "viewport" content = "width=device-width, initial-scale=1" / >
< title > GridFire: src/include/gridfire/engine/scratchpads/utils.h File Reference< / title >
< link href = "tabs.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "jquery.js" > < / script >
< script type = "text/javascript" src = "dynsections.js" > < / script >
< script type = "text/javascript" src = "clipboard.js" > < / script >
< link href = "navtree.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "navtreedata.js" > < / script >
< script type = "text/javascript" src = "navtree.js" > < / script >
< script type = "text/javascript" src = "resize.js" > < / script >
< script type = "text/javascript" src = "cookie.js" > < / script >
< link href = "search/search.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "search/searchdata.js" > < / script >
< script type = "text/javascript" src = "search/search.js" > < / script >
< link href = "doxygen.css" rel = "stylesheet" type = "text/css" / >
< link href = "doxygen-awesome.css" rel = "stylesheet" type = "text/css" / >
< link href = "doxygen-awesome-sidebar-only.css" rel = "stylesheet" type = "text/css" / >
< / head >
< body >
< div id = "top" > <!-- do not remove this div, it is closed by doxygen! -->
< div id = "titlearea" >
< table cellspacing = "0" cellpadding = "0" >
< tbody >
< tr id = "projectrow" >
< td id = "projectalign" >
2026-06-14 08:36:52 -04:00
< div id = "projectname" > GridFire< span id = "projectnumber" >   v1.0.2< / span >
2026-04-20 12:45:31 -04:00
< / div >
< div id = "projectbrief" > General Purpose Nuclear Network< / div >
< / td >
< / tr >
< / tbody >
< / table >
< / div >
<!-- end header part -->
<!-- Generated by Doxygen 1.13.2 -->
< script type = "text/javascript" >
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699& dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
< / script >
< script type = "text/javascript" >
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699& dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
< / script >
< script type = "text/javascript" src = "menudata.js" > < / script >
< script type = "text/javascript" src = "menu.js" > < / script >
< script type = "text/javascript" >
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699& dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search',true);
$(function() { init_search(); });
});
/* @license-end */
< / script >
< div id = "main-nav" > < / div >
< / div > <!-- top -->
< div id = "side-nav" class = "ui-resizable side-nav-resizable" >
< div id = "nav-tree" >
< div id = "nav-tree-contents" >
< div id = "nav-sync" class = "sync" > < / div >
< / div >
< / div >
< div id = "splitbar" style = "-moz-user-select:none;"
class="ui-resizable-handle">
< / div >
< / div >
< script type = "text/javascript" >
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699& dn=expat.txt MIT */
$(function(){initNavTree('engine_2scratchpads_2utils_8h.html',''); initResizable(true); });
/* @license-end */
< / script >
< div id = "doc-content" >
<!-- window showing the filter options -->
< div id = "MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
< / div >
<!-- iframe showing the search results (closed by default) -->
< div id = "MSearchResultsWindow" >
< div id = "MSearchResults" >
< div class = "SRPage" >
< div id = "SRIndex" >
< div id = "SRResults" > < / div >
< div class = "SRStatus" id = "Loading" > Loading...< / div >
< div class = "SRStatus" id = "Searching" > Searching...< / div >
< div class = "SRStatus" id = "NoMatches" > No Matches< / div >
< / div >
< / div >
< / div >
< / div >
< div class = "header" >
< div class = "summary" >
< a href = "#namespaces" > Namespaces< / a > |
< a href = "#func-members" > Functions< / a > < / div >
< div class = "headertitle" > < div class = "title" > utils.h File Reference< / div > < / div >
< / div > <!-- header -->
< div class = "contents" >
< p > Utility functions for convenient scratchpad retrieval with exception handling.
< a href = "#details" > More...< / a > < / p >
2026-06-14 08:36:52 -04:00
< div class = "textblock" > < code > #include < expected> < / code > < br / >
< code > #include " < a class = "el" href = "blob_8h.html" > gridfire/engine/scratchpads/blob.h< / a > " < / code > < br / >
2026-04-20 12:45:31 -04:00
< code > #include " < a class = "el" href = "error__scratchpad_8h.html" > gridfire/exceptions/error_scratchpad.h< / a > " < / code > < br / >
< / div > < div class = "textblock" > < div class = "dynheader" >
Include dependency graph for utils.h:< / div >
< div class = "dyncontent" >
< div class = "center" > < div class = "zoom" > < iframe scrolling = "no" frameborder = "0" src = "engine_2scratchpads_2utils_8h__incl.svg" width = "100%" height = "593" > < p > < b > This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.< / b > < / p > < / iframe > < / div > < / div >
< / div >
< / div > < div class = "textblock" > < div class = "dynheader" >
This graph shows which files directly or indirectly include this file:< / div >
< div class = "dyncontent" >
< div class = "center" > < div class = "zoom" > < iframe scrolling = "no" frameborder = "0" src = "engine_2scratchpads_2utils_8h__dep__incl.svg" width = "100%" height = "600" > < p > < b > This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.< / b > < / p > < / iframe > < / div > < / div >
< / div >
< / div > < table class = "memberdecls" >
< tr class = "heading" > < td colspan = "2" > < h2 class = "groupheader" > < a id = "namespaces" name = "namespaces" > < / a >
Namespaces< / h2 > < / td > < / tr >
< tr class = "memitem:" > < td class = "memItemLeft" align = "right" valign = "top" > namespace   < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "namespacegridfire.html" > gridfire< / a > < / td > < / tr >
< tr class = "separator:" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< tr class = "memitem:" > < td class = "memItemLeft" align = "right" valign = "top" > namespace   < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "namespacegridfire_1_1engine.html" > gridfire::engine< / a > < / td > < / tr >
< tr class = "separator:" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< tr class = "memitem:" > < td class = "memItemLeft" align = "right" valign = "top" > namespace   < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "namespacegridfire_1_1engine_1_1scratch.html" > gridfire::engine::scratch< / a > < / td > < / tr >
< tr class = "memdesc:namespacegridfire_1_1engine_1_1scratch" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Scratchpad memory management for computational engines. < br / > < / td > < / tr >
< tr class = "separator:" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< / table > < table class = "memberdecls" >
< tr class = "heading" > < td colspan = "2" > < h2 class = "groupheader" > < a id = "func-members" name = "func-members" > < / a >
Functions< / h2 > < / td > < / tr >
< tr class = "memitem:ab8f89f710094bfc93b84e26c818249b9" id = "r_ab8f89f710094bfc93b84e26c818249b9" > < td class = "memTemplParams" colspan = "2" > template< IsScratchPad CTX> < / td > < / tr >
< tr class = "memitem:ab8f89f710094bfc93b84e26c818249b9" > < td class = "memTemplItemLeft" align = "right" valign = "top" > CTX *  < / td > < td class = "memTemplItemRight" valign = "bottom" > < a class = "el" href = "namespacegridfire_1_1engine_1_1scratch.html#ab8f89f710094bfc93b84e26c818249b9" > gridfire::engine::scratch::get_state< / a > (< a class = "el" href = "classgridfire_1_1engine_1_1scratch_1_1_state_blob.html" > StateBlob< / a > & ctx)< / td > < / tr >
< tr class = "memdesc:ab8f89f710094bfc93b84e26c818249b9" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Retrieve a scratchpad from a < a class = "el" href = "classgridfire_1_1engine_1_1scratch_1_1_state_blob.html" title = "Container for managing a collection of typed scratchpad instances." > StateBlob< / a > , throwing on error. < br / > < / td > < / tr >
< tr class = "separator:ab8f89f710094bfc93b84e26c818249b9" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< tr class = "memitem:a322cc33cefc958d2507229aa283e8d4e" id = "r_a322cc33cefc958d2507229aa283e8d4e" > < td class = "memTemplParams" colspan = "2" > template< IsScratchPad CTX> < / td > < / tr >
< tr class = "memitem:a322cc33cefc958d2507229aa283e8d4e" > < td class = "memTemplItemLeft" align = "right" valign = "top" > const CTX *  < / td > < td class = "memTemplItemRight" valign = "bottom" > < a class = "el" href = "namespacegridfire_1_1engine_1_1scratch.html#a322cc33cefc958d2507229aa283e8d4e" > gridfire::engine::scratch::get_state< / a > (const < a class = "el" href = "classgridfire_1_1engine_1_1scratch_1_1_state_blob.html" > StateBlob< / a > & ctx)< / td > < / tr >
< tr class = "memdesc:a322cc33cefc958d2507229aa283e8d4e" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Retrieve a const scratchpad from a const < a class = "el" href = "classgridfire_1_1engine_1_1scratch_1_1_state_blob.html" title = "Container for managing a collection of typed scratchpad instances." > StateBlob< / a > , throwing on error. < br / > < / td > < / tr >
< tr class = "separator:a322cc33cefc958d2507229aa283e8d4e" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< tr class = "memitem:aeae70212ece1d604b41e434641bd4291" id = "r_aeae70212ece1d604b41e434641bd4291" > < td class = "memTemplParams" colspan = "2" > template< IsScratchPad CTX, bool MUST_BE_INITIALIZED> < / td > < / tr >
< tr class = "memitem:aeae70212ece1d604b41e434641bd4291" > < td class = "memTemplItemLeft" align = "right" valign = "top" > CTX *  < / td > < td class = "memTemplItemRight" valign = "bottom" > < a class = "el" href = "namespacegridfire_1_1engine_1_1scratch.html#aeae70212ece1d604b41e434641bd4291" > gridfire::engine::scratch::get_state< / a > (< a class = "el" href = "classgridfire_1_1engine_1_1scratch_1_1_state_blob.html" > StateBlob< / a > & ctx)< / td > < / tr >
< tr class = "memdesc:aeae70212ece1d604b41e434641bd4291" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Retrieve a scratchpad with optional initialization check, throwing on error. < br / > < / td > < / tr >
< tr class = "separator:aeae70212ece1d604b41e434641bd4291" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< tr class = "memitem:afd8f2cf5ed25a1c719ba1886836ff892" id = "r_afd8f2cf5ed25a1c719ba1886836ff892" > < td class = "memTemplParams" colspan = "2" > template< IsScratchPad CTX, bool MUST_BE_INITIALIZED> < / td > < / tr >
< tr class = "memitem:afd8f2cf5ed25a1c719ba1886836ff892" > < td class = "memTemplItemLeft" align = "right" valign = "top" > const CTX *  < / td > < td class = "memTemplItemRight" valign = "bottom" > < a class = "el" href = "namespacegridfire_1_1engine_1_1scratch.html#afd8f2cf5ed25a1c719ba1886836ff892" > gridfire::engine::scratch::get_state< / a > (const < a class = "el" href = "classgridfire_1_1engine_1_1scratch_1_1_state_blob.html" > StateBlob< / a > & ctx)< / td > < / tr >
< tr class = "memdesc:afd8f2cf5ed25a1c719ba1886836ff892" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Retrieve a const scratchpad with optional initialization check, throwing on error. < br / > < / td > < / tr >
< tr class = "separator:afd8f2cf5ed25a1c719ba1886836ff892" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< / table >
< a name = "details" id = "details" > < / a > < h2 class = "groupheader" > Detailed Description< / h2 >
< div class = "textblock" > < p > Utility functions for convenient scratchpad retrieval with exception handling. < / p >
< p > This header provides helper functions that wrap StateBlob's get() methods, converting error codes into exceptions for simpler error handling. These utilities eliminate the need to manually check std::expected results and switch on error codes at every call site.< / p >
< dl class = "section user" > < dt > Purpose< / dt > < dd > The utility functions provide:< ul >
< li > Exception-based error handling instead of std::expected< / li >
< li > Consistent error messages across the codebase< / li >
< li > Both mutable and const-correct overloads< / li >
< li > Optional initialization checking via template parameter< / li >
< / ul >
< / dd > < / dl >
< dl class = "section user" > < dt > Examples< / dt > < dd > < div class = "fragment" > < div class = "line" > < span class = "preprocessor" > #include " < a class = "code" href = "engine_2scratchpads_2utils_8h.html" > gridfire/engine/scratchpads/utils.h< / a > " < / span > < / div >
< div class = "line" > < span class = "preprocessor" > #include " < a class = "code" href = "engine__graph__scratchpad_8h.html" > gridfire/engine/scratchpads/engine_graph_scratchpad.h< / a > " < / span > < / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "keyword" > using namespace < / span > < a class = "code hl_namespace" href = "namespacegridfire_1_1engine_1_1scratch.html" > gridfire::engine::scratch< / a > ;< / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "keywordtype" > void< / span > compute(< a class = "code hl_class" href = "classgridfire_1_1engine_1_1scratch_1_1_state_blob.html" > StateBlob< / a > & blob) {< / div >
< div class = "line" > < span class = "comment" > // Simple retrieval - throws if not found< / span > < / div >
< div class = "line" > < a class = "code hl_struct" href = "structgridfire_1_1engine_1_1scratch_1_1_graph_engine_scratch_pad.html" > GraphEngineScratchPad< / a > * < a class = "code hl_namespace" href = "namespacegridfire_1_1engine_1_1scratch.html" > scratch< / a > = < a class = "code hl_function" href = "namespacegridfire_1_1engine_1_1scratch.html#ab8f89f710094bfc93b84e26c818249b9" > get_state< GraphEngineScratchPad> < / a > (blob);< / div >
< div class = "line" > < a class = "code hl_namespace" href = "namespacegridfire_1_1engine_1_1scratch.html" > scratch< / a > -> initialize(< a class = "code hl_namespace" href = "namespacegridfire_1_1engine.html" > engine< / a > );< / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "comment" > // Retrieval with initialization check - throws if not initialized< / span > < / div >
< div class = "line" > < span class = "keyword" > auto< / span > * initialized_scratch = < a class = "code hl_function" href = "namespacegridfire_1_1engine_1_1scratch.html#ab8f89f710094bfc93b84e26c818249b9" > get_state< GraphEngineScratchPad, true> < / a > (blob);< / div >
< div class = "line" > < span class = "comment" > // Safe to use - guaranteed to be initialized< / span > < / div >
< div class = "line" > }< / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "keywordtype" > void< / span > read_only_access(< span class = "keyword" > const< / span > < a class = "code hl_class" href = "classgridfire_1_1engine_1_1scratch_1_1_state_blob.html" > StateBlob< / a > & blob) {< / div >
< div class = "line" > < span class = "comment" > // Const overload for read-only access< / span > < / div >
< div class = "line" > < span class = "keyword" > const< / span > < a class = "code hl_struct" href = "structgridfire_1_1engine_1_1scratch_1_1_graph_engine_scratch_pad.html" > GraphEngineScratchPad< / a > * < a class = "code hl_namespace" href = "namespacegridfire_1_1engine_1_1scratch.html" > scratch< / a > = < a class = "code hl_function" href = "namespacegridfire_1_1engine_1_1scratch.html#ab8f89f710094bfc93b84e26c818249b9" > get_state< GraphEngineScratchPad> < / a > (blob);< / div >
< div class = "line" > < span class = "keywordtype" > bool< / span > ready = < a class = "code hl_namespace" href = "namespacegridfire_1_1engine_1_1scratch.html" > scratch< / a > -> is_initialized();< / div >
< div class = "line" > }< / div >
< div class = "ttc" id = "aclassgridfire_1_1engine_1_1scratch_1_1_state_blob_html" > < div class = "ttname" > < a href = "classgridfire_1_1engine_1_1scratch_1_1_state_blob.html" > gridfire::engine::scratch::StateBlob< / a > < / div > < div class = "ttdoc" > Container for managing a collection of typed scratchpad instances.< / div > < div class = "ttdef" > < b > Definition< / b > blob.h:114< / div > < / div >
< div class = "ttc" id = "aengine_2scratchpads_2utils_8h_html" > < div class = "ttname" > < a href = "engine_2scratchpads_2utils_8h.html" > utils.h< / a > < / div > < div class = "ttdoc" > Utility functions for convenient scratchpad retrieval with exception handling.< / div > < / div >
< div class = "ttc" id = "aengine__graph__scratchpad_8h_html" > < div class = "ttname" > < a href = "engine__graph__scratchpad_8h.html" > engine_graph_scratchpad.h< / a > < / div > < div class = "ttdoc" > Scratchpad implementation for the GraphEngine using CppAD automatic differentiation.< / div > < / div >
< div class = "ttc" id = "anamespacegridfire_1_1engine_1_1scratch_html" > < div class = "ttname" > < a href = "namespacegridfire_1_1engine_1_1scratch.html" > gridfire::engine::scratch< / a > < / div > < div class = "ttdoc" > Scratchpad memory management for computational engines.< / div > < div class = "ttdef" > < b > Definition< / b > blob.h:69< / div > < / div >
2026-06-14 08:36:52 -04:00
< div class = "ttc" id = "anamespacegridfire_1_1engine_1_1scratch_html_ab8f89f710094bfc93b84e26c818249b9" > < div class = "ttname" > < a href = "namespacegridfire_1_1engine_1_1scratch.html#ab8f89f710094bfc93b84e26c818249b9" > gridfire::engine::scratch::get_state< / a > < / div > < div class = "ttdeci" > CTX * get_state(StateBlob & ctx)< / div > < div class = "ttdoc" > Retrieve a scratchpad from a StateBlob, throwing on error.< / div > < div class = "ttdef" > < b > Definition< / b > utils.h:87< / div > < / div >
< div class = "ttc" id = "anamespacegridfire_1_1engine_html" > < div class = "ttname" > < a href = "namespacegridfire_1_1engine.html" > gridfire::engine< / a > < / div > < div class = "ttdef" > < b > Definition< / b > dynamic_engine_diagnostics.h:40< / div > < / div >
2026-04-20 12:45:31 -04:00
< div class = "ttc" id = "astructgridfire_1_1engine_1_1scratch_1_1_graph_engine_scratch_pad_html" > < div class = "ttname" > < a href = "structgridfire_1_1engine_1_1scratch_1_1_graph_engine_scratch_pad.html" > gridfire::engine::scratch::GraphEngineScratchPad< / a > < / div > < div class = "ttdoc" > Scratchpad for storing CppAD automatic differentiation state for GraphEngine.< / div > < div class = "ttdef" > < b > Definition< / b > engine_graph_scratchpad.h:83< / div > < / div >
< / div > <!-- fragment --> < / dd > < / dl >
< dl class = "section user" > < dt > Thread Safety< / dt > < dd > These functions inherit the thread safety characteristics of StateBlob. They are < b > not thread-safe< / b > - each thread should operate on its own StateBlob instance.< / dd > < / dl >
< dl class = "section see" > < dt > See also< / dt > < dd > StateBlob < / dd >
< dd >
IsScratchPad < / dd >
< dd >
exceptions::ScratchPadError < / dd > < / dl >
< / div > < / div > <!-- contents -->
< / div > <!-- doc - content -->
<!-- start footer part -->
< div id = "nav-path" class = "navpath" > <!-- id is needed for treeview function! -->
< ul >
< li class = "navelem" > < a class = "el" href = "dir_68267d1309a1af8e8297ef4c3efbcdba.html" > src< / a > < / li > < li class = "navelem" > < a class = "el" href = "dir_b0856f6b0d80ccb263b2f415c91f9e17.html" > include< / a > < / li > < li class = "navelem" > < a class = "el" href = "dir_3626e0c0e3c5d7812d6b277dfa4ec364.html" > gridfire< / a > < / li > < li class = "navelem" > < a class = "el" href = "dir_aff155d61c3b73b9ab7dcdc908c4d49e.html" > engine< / a > < / li > < li class = "navelem" > < a class = "el" href = "dir_65a5f8f804465673712f6f1daa9f9ade.html" > scratchpads< / a > < / li > < li class = "navelem" > < a class = "el" href = "engine_2scratchpads_2utils_8h.html" > utils.h< / a > < / li >
< li class = "footer" > Generated by < a href = "https://www.doxygen.org/index.html" > < img class = "footer" src = "doxygen.svg" width = "104" height = "31" alt = "doxygen" / > < / a > 1.13.2 < / li >
< / ul >
< / div >
< / body >
< / html >