This repository attempts to modernize JJK's code.
In order to improve on JJK's code, the following breaking changes have been made (just a rough summary as it is a major rewrite so a lot of things have changed):
- All mutators and accessors have been renamed to use snake_case instead of camelCase.
GETandSEThas been modified to take one parameter only. The type of the property, the name of the accessor/mutator and the name of their parameters will be generated automatically.GET_WITH_NAMEandSET_WITH_NAMEwere also added for customizing the generated accessor/mutator names.- All generators have been deleted. Templates are used in place of them for a more type-safe approach.
- Almost all special members have become public because of the removal of generators.
*::generator::printfunctions have been moved to their enclosing classes of the inner classes they belong. For example, callheader::printinstead ofheader::generator:print. Except forevent::generator::print, which have been moved toevent::print_registered_event_typesbecause there was already anevent::printthat did something different.packet::discardhas been removed since none of its members are dynamically allocated anymore.node::add_phy_neighborhas been modified to take one parameter only sincelink's generator has been removed and the fact thatsimple_linkis the only link type. If you would like to add more link types in the future, you can usestd::variantandstd::visitjust like how we removedpacket's generator.
This is a major revamp of JJK's code, so there are some features that you need to access in a different way. The following list tries to list all of them.
-
Since all accessors now return const references, so you can't directly call a non-const function on the return value of a accessors. Instead, there are usually alternative functions that you can call to achieve the same effect:
- Call
IoT_ctrl_packet::increase_payload_counterinstead ofIoT_ctrl_payload::increase. - Call
set_src_ID/set_dst_ID/set_pre_ID/set_nex_ID/set_msgon the packet directly instead of calling the getter for the header or payload on the packet and then setting them.
- Call
-
Since all generators have been removed, you should use the following constructors instead of generators:
- Call the default constructor of the packet type you want to generate instead of
packet::packet_generator::generate. - Call the copy/move constructor of the packet type you want to replicate instead of
packet::packet_generator::replicate.
- Call the default constructor of the packet type you want to generate instead of
-
Use the variant type
node::PacketTypesandstd::visitinstead ofpacket *and downcasting. -
Instead of calling
node::generator::generate, callIoT_device::generate. -
Instead of calling
link::generator::generate, callsimple_link::generate. -
Instead of calling
event::generator::generate, call<event-type>::generate. -
Instead of accessing
event::trigger_timedirectly, callget_trigger_time/set_trigger_time.