1 /* Copyright (c) 2007-2010, 2012-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef SIMGRID_SIMIX_HPP
8 #define SIMGRID_SIMIX_HPP
13 #include <xbt/function_types.h>
14 #include <simgrid/simix.h>
22 class ContextFactory {
27 ContextFactory(std::string name) : name_(std::move(name)) {}
28 virtual ~ContextFactory();
29 virtual Context* create_context(
30 xbt_main_func_t, int, char **, void_pfn_smxprocess_t,
33 virtual void run_all() = 0;
34 virtual Context* self();
35 std::string const& name() const
40 void declare_context(void* T, std::size_t size);
42 template<class T, class... Args>
43 T* new_context(Args&&... args)
45 T* context = new T(std::forward<Args>(args)...);
46 this->declare_context(context, sizeof(T));
53 xbt_main_func_t code_ = nullptr;
55 char **argv_ = nullptr;
56 void_pfn_smxprocess_t cleanup_func_ = nullptr;
57 smx_process_t process_ = nullptr;
61 Context(xbt_main_func_t code,
62 int argc, char **argv,
63 void_pfn_smxprocess_t cleanup_func,
64 smx_process_t process);
67 return code_(argc_, argv_);
69 smx_process_t process()
71 return this->process_;
77 virtual void suspend() = 0;