* This is a singleton containing all the main functions of the simulation.
*/
class XBT_PUBLIC Engine {
+ friend simgrid::kernel::EngineImpl;
+
public:
/** Constructor, taking the command line parameters of your main function */
explicit Engine(int* argc, char** argv);
void load_platform(const std::string& platf);
- void register_function(const std::string& name, int (*code)(int, char**));
+ XBT_ATTRIB_DEPRECATED_v330("Please change the return code of your actors to void") void register_function(
+ const std::string& name, int (*code)(int, char**));
+
+ void register_function(const std::string& name, void (*code)(int, char**));
void register_function(const std::string& name, void (*code)(std::vector<std::string>));
- void register_default(int (*code)(int, char**));
+ XBT_ATTRIB_DEPRECATED_v330("Please change the return code of your actors to void") void register_default(
+ int (*code)(int, char**));
+ void register_default(void (*code)(int, char**));
+ void register_default(kernel::actor::ActorCodeFactory factory);
+
+ void register_function(const std::string& name, kernel::actor::ActorCodeFactory factory);
template <class F> void register_actor(const std::string& name)
{
- simix::register_function(name, [](std::vector<std::string> args) {
- return simix::ActorCode([args] {
+ register_function(name, [](std::vector<std::string> args) {
+ return kernel::actor::ActorCode([args] {
F code(std::move(args));
code();
});
});
}
-
template <class F> void register_actor(const std::string& name, F code)
{
- simix::register_function(name, [code](std::vector<std::string> args) {
- return simix::ActorCode([code, args] { code(std::move(args)); });
+ register_function(name, [code](std::vector<std::string> args) {
+ return kernel::actor::ActorCode([code, args] { code(std::move(args)); });
});
}
#endif /*DOXYGEN*/
public:
+ /** Returns the amount of hosts existing in the platform. */
size_t get_host_count();
- /** @brief Returns the list of all hosts found in the platform */
+ /** Returns a vector of all hosts found in the platform.
+ *
+ * The order is generally different from the creation/declaration order in the XML platform because we use a hash
+ * table internally.
+ */
std::vector<Host*> get_all_hosts();
std::vector<Host*> get_filtered_hosts(const std::function<bool(Host*)>& filter);
Host* host_by_name(const std::string& name);