The Sparta Modeling Framework
Loading...
Searching...
No Matches
Resource.hpp File Reference

File that defines the Resource class. Consider using sparta::Unit instead. More...

#include <string>
#include <ostream>
#include <type_traits>
#include "sparta/simulation/ResourceContainer.hpp"
#include "sparta/simulation/Clock.hpp"
#include "sparta/utils/SpartaException.hpp"
#include "sparta/kernel/Scheduler.hpp"
#include "sparta/utils/SpartaAssert.hpp"
#include "sparta/simulation/TreeNode.hpp"
#include "sparta/utils/Utils.hpp"
#include "simdb/Errors.hpp"

Go to the source code of this file.

Classes

class  sparta::PostRunValidationInfo
 Information describing the type of validation being done. More...
 
class  sparta::Resource
 The is the base class for all types of resources used by the SPARTA framework. More...
 
class  sparta::AssertContext
 Creates a helper traits class for determining whehther a type has a member named getClock. More...
 

Namespaces

namespace  sparta
 Macros for handling exponential backoff.
 

Macros

#define ADD_CONTEXT_INFORMATION(ex, thisptr)
 Helper for adding context information to the end of a SpartaException.
 
#define sparta_assert_context(e, insertions)
 Check condition and throw a sparta exception if condition evaluates to false or 0. Exception will contain as much information about context as this method can figure out. This includes Resources, TreeNodes, and anyt type of this pointer having a getClock method.
 

Detailed Description

File that defines the Resource class. Consider using sparta::Unit instead.

Definition in file Resource.hpp.

Macro Definition Documentation

◆ ADD_CONTEXT_INFORMATION

#define ADD_CONTEXT_INFORMATION (   ex,
  thisptr 
)
Value:
ex << " " << ac.getContextDescription<typename std::remove_pointer<decltype(thisptr)>::type>(thisptr);
Creates a helper traits class for determining whehther a type has a member named getClock.
Definition Resource.hpp:253
std::string getContextDescription(CTXT *ctxt, typename std::enable_if<!std::is_base_of< Resource, CTXT >::value &&!std::is_base_of< TreeNode, CTXT >::value &&!has_attr_getClock< CTXT >::value >::type *dummy=nullptr)
Handle default case where pointer is not a sparta::Resource.
Definition Resource.hpp:289

Helper for adding context information to the end of a SpartaException.

Parameters
exsparta::Exception
thisptrthis pointer from context of the call

Definition at line 379 of file Resource.hpp.

◆ sparta_assert_context

#define sparta_assert_context (   e,
  insertions 
)
Value:
if(__builtin_expect(!(e), 0)) { sparta::SpartaException ex(std::string(#e) + ": " ); \
ex << insertions; \
ADD_FILE_INFORMATION(ex, __FILE__, __LINE__); \
ADD_CONTEXT_INFORMATION(ex, this); \
throw ex; }
Used to construct and throw a standard C++ exception. Inherits from std::exception.

Check condition and throw a sparta exception if condition evaluates to false or 0. Exception will contain as much information about context as this method can figure out. This includes Resources, TreeNodes, and anyt type of this pointer having a getClock method.

Parameters
eCondition
insertionscode to insert additional strings to the end of a sparta::Exception omitting the first '<<' operator. (e.g. "1 << 2")
Precondition
Must be used within a class where a this pointer is available
If calling context is a subclass of sparta::TreeNode or sparta::Resource, then it must publicly inherit from that class so that it may access its getContainer, getLocation or getLocation methods as appropriate

Example

sparta_assert_context(f==true, "Error at " << x << ", oh no!");
#define sparta_assert_context(e, insertions)
Check condition and throw a sparta exception if condition evaluates to false or 0....
Definition Resource.hpp:402

Definition at line 402 of file Resource.hpp.