HostModule is an interface for classes which is registered to a certain Host. HostModules can communicate with each other by their names.
More...
#include <E_Host.hpp>
|
| HostModule (std::string name, Host &host) |
| Create a HostModule. It is automatically registered to the Host. Module is registered to a System when it is created. More...
|
|
virtual std::string | getHostModuleName () final |
|
virtual void | initialize (void) |
| This function is automatically called by Host just before the simulation begins. You can override this function if needed.
|
|
virtual void | finalize (void) |
| This function is automatically called by Host just after the simulation ends. You can override this function if needed.
|
|
virtual std::any | diagnose (std::any param) |
| Host module control function.
|
|
|
virtual void | packetArrived (std::string fromModule, Packet &&packet)=0 |
| This function is automatically called by Host when this module receives a Packet. You must override this function to handle Packet events. When a Packet is received, you must FREE IT OR PASS IT TO OTHER HOSTMODULE. More...
|
|
virtual void | sendPacket (std::string toModule, Packet &&packet) final |
| This function transfers Packets among HostModules in the Host. Unlike Module::Message, we use fire-and-forget policy with Packets. Once you send a Packet using sendPacket, you DO NOT HAVE TO FREE THAT PACKET. More...
|
|
void | sendPacket (std::string toModule, const Packet &packet) |
|
Time | getCurrentTime () |
|
Size | getWireSpeed (int port_num) |
| Get cost for local port (link) More...
|
|
size_t | getPortCount () |
| Get the number of ports. More...
|
|
void | print_log (uint64_t level, const char *format,...) |
| Prints log with specified log level and format. NetworkLog::print_log prints logs specified in log level parameter. For example, if log level is set to TCP_LOG, it only prints TCP_LOG logs. If you want to print multiple log levels in NetworkLog, you can set log level with OR operation (i.e. SYSCALL_ERROR | MODULE_ERROR). More...
|
|
HostModule is an interface for classes which is registered to a certain Host. HostModules can communicate with each other by their names.
- Note
- HostModule has no relationship with Module.
◆ HostModule()
E::HostModule::HostModule |
( |
std::string |
name, |
|
|
Host & |
host |
|
) |
| |
Create a HostModule. It is automatically registered to the Host. Module is registered to a System when it is created.
- Parameters
-
name | Name of this module. This name is used for identifying each module. |
host | Host to be registered. |
◆ getCurrentTime()
Time E::HostModule::getCurrentTime |
( |
| ) |
|
|
protected |
- Returns
- Returns current virtual clock of the System.
◆ getHostModuleName()
std::string E::HostModule::getHostModuleName |
( |
| ) |
|
|
finalvirtual |
- Returns
- My name used in the registered Host.
◆ getPortCount()
size_t E::HostModule::getPortCount |
( |
| ) |
|
|
protected |
Get the number of ports.
- Returns
- the number of ports
◆ getWireSpeed()
Size E::HostModule::getWireSpeed |
( |
int |
port_num | ) |
|
|
protected |
Get cost for local port (link)
- Parameters
-
port_num | querying port's number |
- Returns
- local link cost
◆ packetArrived()
virtual void E::HostModule::packetArrived |
( |
std::string |
fromModule, |
|
|
Packet && |
packet |
|
) |
| |
|
protectedpure virtual |
◆ print_log()
void E::HostModule::print_log |
( |
uint64_t |
level, |
|
|
const char * |
format, |
|
|
|
... |
|
) |
| |
|
protected |
Prints log with specified log level and format. NetworkLog::print_log prints logs specified in log level parameter. For example, if log level is set to TCP_LOG, it only prints TCP_LOG logs. If you want to print multiple log levels in NetworkLog, you can set log level with OR operation (i.e. SYSCALL_ERROR | MODULE_ERROR).
- Note
- Log::print_log
- Parameters
-
level | log level |
format | Format string |
... | Print arguments for format string |
◆ sendPacket()
void E::HostModule::sendPacket |
( |
std::string |
toModule, |
|
|
Packet && |
packet |
|
) |
| |
|
finalprotectedvirtual |
This function transfers Packets among HostModules in the Host. Unlike Module::Message, we use fire-and-forget policy with Packets. Once you send a Packet using sendPacket, you DO NOT HAVE TO FREE THAT PACKET.
- Parameters
-
The documentation for this class was generated from the following files:
- include/E/Networking/E_Host.hpp
- src/Networking/E_Host.cpp