CIRCT 22.0.0git
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Types | Private Attributes | List of all members
esi::Context Class Reference

AcceleratorConnections, Accelerators, and Manifests must all share a context. More...

#include <Context.h>

Collaboration diagram for esi::Context:
Collaboration graph
[legend]

Public Member Functions

 Context ()
 
 Context (std::unique_ptr< Logger > logger)
 
 ~Context ()
 
void disconnectAll ()
 Disconnect from all accelerators associated with this context.
 
std::optional< const Type * > getType (Type::ID id) const
 Resolve a type id to the type.
 
void registerType (Type *type)
 Register a type with the context. Takes ownership of the pointer type.
 
AcceleratorConnectionconnect (std::string backend, std::string connection)
 Connect to an accelerator backend.
 
void setLogger (std::unique_ptr< Logger > logger)
 Register a logger with the accelerator. Assumes ownership of the logger.
 
LoggergetLogger ()
 

Static Public Member Functions

template<typename T , typename... Args>
static std::unique_ptr< ContextwithLogger (Args &&...args)
 Create a context with a specific logger type.
 

Private Types

using TypeCache = std::map< Type::ID, std::unique_ptr< Type > >
 

Private Attributes

std::unique_ptr< Loggerlogger
 
std::vector< std::unique_ptr< AcceleratorConnection > > connections
 
TypeCache types
 

Detailed Description

AcceleratorConnections, Accelerators, and Manifests must all share a context.

It owns all the types, uniquifying them. It also owns the connections (which own the Accelerators). When it is destroyed, all connections are disconnected and the objects are destroyed.

Definition at line 34 of file Context.h.

Member Typedef Documentation

◆ TypeCache

using esi::Context::TypeCache = std::map<Type::ID, std::unique_ptr<Type> >
private

Definition at line 76 of file Context.h.

Constructor & Destructor Documentation

◆ Context() [1/2]

Context::Context ( )

Definition at line 22 of file Context.cpp.

◆ Context() [2/2]

Context::Context ( std::unique_ptr< Logger logger)

Definition at line 24 of file Context.cpp.

◆ ~Context()

Context::~Context ( )

Definition at line 25 of file Context.cpp.

References disconnectAll().

Member Function Documentation

◆ connect()

AcceleratorConnection * Context::connect ( std::string  backend,
std::string  connection 
)

Connect to an accelerator backend.

Retains ownership internally and returns a non-owning pointer.

Definition at line 314 of file Accelerator.cpp.

References connections, esi::Logger::error(), esi::registry::internal::BackendRegistry::get(), getLogger(), esi::Logger::info(), and esi::loadBackend().

◆ disconnectAll()

void Context::disconnectAll ( )

Disconnect from all accelerators associated with this context.

Definition at line 27 of file Context.cpp.

References connections.

Referenced by ~Context().

◆ getLogger()

Logger & esi::Context::getLogger ( )
inline

Definition at line 69 of file Context.h.

References logger.

Referenced by connect(), esi::AcceleratorConnection::getLogger(), esi::loadBackend(), and main().

◆ getType()

std::optional< const Type * > esi::Context::getType ( Type::ID  id) const
inline

Resolve a type id to the type.

Definition at line 50 of file Context.h.

References types.

◆ registerType()

void Context::registerType ( Type type)

Register a type with the context. Takes ownership of the pointer type.

Definition at line 33 of file Context.cpp.

References esi::Type::getID(), esi::Type::toString(), and types.

◆ setLogger()

void esi::Context::setLogger ( std::unique_ptr< Logger logger)
inline

Register a logger with the accelerator. Assumes ownership of the logger.

Definition at line 64 of file Context.h.

References logger.

Referenced by PYBIND11_MODULE().

◆ withLogger()

template<typename T , typename... Args>
static std::unique_ptr< Context > esi::Context::withLogger ( Args &&...  args)
inlinestatic

Create a context with a specific logger type.

Definition at line 45 of file Context.h.

Member Data Documentation

◆ connections

std::vector<std::unique_ptr<AcceleratorConnection> > esi::Context::connections
private

Definition at line 73 of file Context.h.

Referenced by connect(), and disconnectAll().

◆ logger

std::unique_ptr<Logger> esi::Context::logger
private

Definition at line 72 of file Context.h.

Referenced by getLogger(), and setLogger().

◆ types

TypeCache esi::Context::types
private

Definition at line 77 of file Context.h.

Referenced by getType(), and registerType().


The documentation for this class was generated from the following files: