Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rework how host-to-host comms are managed
[simgrid.git] / include / simgrid / forward.h
1 /* Copyright (c) 2004-2022. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef SIMGRID_TYPES_H
7 #define SIMGRID_TYPES_H
8
9 #include <xbt/base.h>
10
11 #ifdef __cplusplus
12
13 #include <boost/intrusive_ptr.hpp>
14 #include <vector>
15
16 namespace simgrid {
17
18 namespace s4u {
19 class Activity;
20 /** Smart pointer to a simgrid::s4u::Activity */
21 using ActivityPtr = boost::intrusive_ptr<Activity>;
22 XBT_PUBLIC void intrusive_ptr_release(const Activity* actor);
23 XBT_PUBLIC void intrusive_ptr_add_ref(const Activity* actor);
24
25 class Actor;
26 /** Smart pointer to a simgrid::s4u::Actor */
27 using ActorPtr = boost::intrusive_ptr<Actor>;
28 XBT_PUBLIC void intrusive_ptr_release(const Actor* actor);
29 XBT_PUBLIC void intrusive_ptr_add_ref(const Actor* actor);
30
31 class Barrier;
32 /** Smart pointer to a simgrid::s4u::Barrier */
33 using BarrierPtr = boost::intrusive_ptr<Barrier>;
34 XBT_PUBLIC void intrusive_ptr_release(Barrier* m);
35 XBT_PUBLIC void intrusive_ptr_add_ref(Barrier* m);
36
37 class Comm;
38 /** Smart pointer to a simgrid::s4u::Comm */
39 using CommPtr = boost::intrusive_ptr<Comm>;
40 XBT_PUBLIC void intrusive_ptr_release(Comm* c);
41 XBT_PUBLIC void intrusive_ptr_add_ref(Comm* c);
42
43 class ConditionVariable;
44 /** @beginrst
45  * Smart pointer to a :cpp:type:`simgrid::s4u::ConditionVariable`
46  * @endrst
47  */
48 using ConditionVariablePtr = boost::intrusive_ptr<ConditionVariable>;
49 XBT_PUBLIC void intrusive_ptr_release(const ConditionVariable* c);
50 XBT_PUBLIC void intrusive_ptr_add_ref(const ConditionVariable* c);
51
52 class Engine;
53
54 class Exec;
55 /** Smart pointer to a simgrid::s4u::Exec */
56 using ExecPtr = boost::intrusive_ptr<Exec>;
57 XBT_PUBLIC void intrusive_ptr_release(Exec* e);
58 XBT_PUBLIC void intrusive_ptr_add_ref(Exec* e);
59
60 class Host;
61
62 class Io;
63 /** Smart pointer to a simgrid::s4u::Io */
64 using IoPtr = boost::intrusive_ptr<Io>;
65 XBT_PUBLIC void intrusive_ptr_release(Io* i);
66 XBT_PUBLIC void intrusive_ptr_add_ref(Io* i);
67
68 class Link;
69 class SplitDuplexLink;
70
71 class Mailbox;
72
73 class Mutex;
74 XBT_PUBLIC void intrusive_ptr_release(const Mutex* m);
75 XBT_PUBLIC void intrusive_ptr_add_ref(const Mutex* m);
76 /**
77  * @beginrst
78  * Smart pointer to a :cpp:type:`simgrid::s4u::Mutex`
79  * @endrst
80  */
81 using MutexPtr = boost::intrusive_ptr<Mutex>;
82
83 class NetZone;
84 class VirtualMachine;
85 class File;
86
87 class Semaphore;
88 /** Smart pointer to a simgrid::s4u::Semaphore */
89 using SemaphorePtr = boost::intrusive_ptr<Semaphore>;
90 XBT_PUBLIC void intrusive_ptr_release(const Semaphore* m);
91 XBT_PUBLIC void intrusive_ptr_add_ref(const Semaphore* m);
92
93 class Disk;
94 /**
95  * @brief Callback to dynamically change the resource's capacity
96  *
97  * Allows user to change resource's capacity depending on the number of concurrent activities
98  * running on the resource at a given instant
99  */
100 using NonLinearResourceCb = std::function<double(double capacity, int n_activities)>;
101 } // namespace s4u
102
103 namespace config {
104 template <class T> class Flag;
105 }
106
107 namespace kernel {
108 class EngineImpl;
109 namespace actor {
110 class ActorImpl;
111 using ActorImplPtr = boost::intrusive_ptr<ActorImpl>;
112
113 // What's executed as an actor code:
114 using ActorCode = std::function<void()>;
115 // Create an ActorCode from the parameters parsed in the XML file (or elsewhere)
116 using ActorCodeFactory = std::function<ActorCode(std::vector<std::string> args)>;
117
118 class SimcallObserver;
119 } // namespace actor
120
121 namespace activity {
122   class ActivityImpl;
123   enum class State;
124   using ActivityImplPtr = boost::intrusive_ptr<ActivityImpl>;
125   XBT_PUBLIC void intrusive_ptr_add_ref(ActivityImpl* activity);
126   XBT_PUBLIC void intrusive_ptr_release(ActivityImpl* activity);
127
128   class ConditionVariableImpl;
129   using ConditionVariableImplPtr = boost::intrusive_ptr<ConditionVariableImpl>;
130   XBT_PUBLIC void intrusive_ptr_add_ref(ConditionVariableImpl* cond);
131   XBT_PUBLIC void intrusive_ptr_release(ConditionVariableImpl* cond);
132
133   class CommImpl;
134   using CommImplPtr = boost::intrusive_ptr<CommImpl>;
135   class ExecImpl;
136   using ExecImplPtr = boost::intrusive_ptr<ExecImpl>;
137   class IoImpl;
138   using IoImplPtr = boost::intrusive_ptr<IoImpl>;
139   class MutexImpl;
140   using MutexImplPtr = boost::intrusive_ptr<MutexImpl>;
141   class MutexAcquisitionImpl;
142   using MutexAcquisitionImplPtr = boost::intrusive_ptr<MutexAcquisitionImpl>;
143   XBT_PUBLIC void intrusive_ptr_add_ref(MutexImpl* mutex);
144   XBT_PUBLIC void intrusive_ptr_release(MutexImpl* mutex);
145   class SynchroImpl;
146   using SynchroImplPtr = boost::intrusive_ptr<SynchroImpl>;
147   class SemaphoreImpl;
148   using SemaphoreImplPtr = boost::intrusive_ptr<SemaphoreImpl>;
149   class SemAcquisitionImpl;
150   using SemAcquisitionImplPtr = boost::intrusive_ptr<SemAcquisitionImpl>;
151   XBT_PUBLIC void intrusive_ptr_add_ref(SemaphoreImpl* sem);
152   XBT_PUBLIC void intrusive_ptr_release(SemaphoreImpl* sem);
153   class SleepImpl;
154   using SleepImplPtr = boost::intrusive_ptr<SleepImpl>;
155
156   class MailboxImpl;
157 }
158 namespace context {
159 class Context;
160 class ContextFactory;
161 } // namespace context
162 namespace lmm {
163 class Element;
164 class Variable;
165 class Constraint;
166 class ConstraintLight;
167 class System;
168 }
169 namespace resource {
170 class Action;
171 class CpuImpl;
172 class Model;
173 class Resource;
174 class CpuModel;
175 class HostImpl;
176 class HostModel;
177 class NetworkModel;
178 class NetworkModelIntf;
179 class LinkImpl;
180 class StandardLinkImpl;
181 class SplitDuplexLinkImpl;
182 class NetworkAction;
183 class DiskImpl;
184 class DiskModel;
185 class VirtualMachineImpl;
186 class VMModel;
187 }
188 namespace timer {
189 class Timer;
190 }
191 namespace routing {
192 class NetPoint;
193 class NetZoneImpl;
194 }
195 namespace profile {
196 class Event;
197 class FutureEvtSet;
198 class Profile;
199 } // namespace profile
200 } // namespace kernel
201 namespace mc {
202 class State;
203 }
204 } // namespace simgrid
205
206 using s4u_Actor             = simgrid::s4u::Actor;
207 using s4u_Barrier           = simgrid::s4u::Barrier;
208 using s4u_Comm              = simgrid::s4u::Comm;
209 using s4u_Exec              = simgrid::s4u::Exec;
210 using s4u_Host              = simgrid::s4u::Host;
211 using s4u_Link              = simgrid::s4u::Link;
212 using s4u_File              = simgrid::s4u::File;
213 using s4u_ConditionVariable = simgrid::s4u::ConditionVariable;
214 using s4u_Mailbox           = simgrid::s4u::Mailbox;
215 using s4u_Mutex             = simgrid::s4u::Mutex;
216 using s4u_Semaphore         = simgrid::s4u::Semaphore;
217 using s4u_Disk              = simgrid::s4u::Disk;
218 using s4u_NetZone           = simgrid::s4u::NetZone;
219 using s4u_VM                = simgrid::s4u::VirtualMachine;
220
221 using smx_timer_t    = simgrid::kernel::timer::Timer*;
222 using smx_actor_t    = simgrid::kernel::actor::ActorImpl*;
223 using smx_activity_t = simgrid::kernel::activity::ActivityImpl*;
224 using smx_cond_t     = simgrid::kernel::activity::ConditionVariableImpl*;
225 using smx_mailbox_t  = simgrid::kernel::activity::MailboxImpl*;
226 using smx_mutex_t    = simgrid::kernel::activity::MutexImpl*;
227 using smx_sem_t      = simgrid::kernel::activity::SemaphoreImpl*;
228 #else
229
230 typedef struct s4u_Actor s4u_Actor;
231 typedef struct s4u_Barrier s4u_Barrier;
232 typedef struct s4u_Comm s4u_Comm;
233 typedef struct s4u_Exec s4u_Exec;
234 typedef struct s4u_Host s4u_Host;
235 typedef struct s4u_Link s4u_Link;
236 typedef struct s4u_File s4u_File;
237 typedef struct s4u_ConditionVariable s4u_ConditionVariable;
238 typedef struct s4u_Mailbox s4u_Mailbox;
239 typedef struct s4u_Mutex s4u_Mutex;
240 typedef struct s4u_Semaphore s4u_Semaphore;
241 typedef struct s4u_Disk s4u_Disk;
242 typedef struct s4u_NetZone s4u_NetZone;
243 typedef struct s4u_VM s4u_VM;
244
245 typedef struct s_smx_timer* smx_timer_t;
246 typedef struct s_smx_actor* smx_actor_t;
247 typedef struct s_smx_activity* smx_activity_t;
248 typedef struct s_smx_cond_t* smx_cond_t;
249 typedef struct s_smx_mailbox* smx_mailbox_t;
250 typedef struct s_smx_mutex* smx_mutex_t;
251 typedef struct s_smx_sem* smx_sem_t;
252
253 #endif
254
255 /** Pointer to a SimGrid barrier object */
256 typedef s4u_Barrier* sg_bar_t;
257 /** Constant pointer to a SimGrid barrier object */
258 typedef const s4u_Barrier* const_sg_bar_t;
259 typedef s4u_Comm* sg_comm_t;
260 typedef const s4u_Comm* const_sg_comm_t;
261 typedef s4u_Exec* sg_exec_t;
262 typedef const s4u_Exec* const_sg_exec_t;
263 typedef s4u_ConditionVariable* sg_cond_t;
264 typedef const s4u_ConditionVariable* const_sg_cond_t;
265 typedef s4u_Mailbox* sg_mailbox_t;
266 typedef const s4u_Mailbox* const_sg_mailbox_t;
267 typedef s4u_Mutex* sg_mutex_t;
268 typedef const s4u_Mutex* const_sg_mutex_t;
269 typedef s4u_Semaphore* sg_sem_t;
270 typedef const s4u_Semaphore* const_sg_sem_t;
271 typedef s4u_NetZone* sg_netzone_t;
272 typedef const s4u_NetZone* const_sg_netzone_t;
273 typedef s4u_Host* sg_host_t;
274 typedef const s4u_Host* const_sg_host_t;
275 typedef s4u_Link* sg_link_t;
276 typedef const s4u_Link* const_sg_link_t;
277 typedef s4u_Disk* sg_disk_t;
278 typedef const s4u_Disk* const_sg_disk_t;
279 /** Pointer to a SimGrid file object @ingroup plugin_filesystem */
280 typedef s4u_File* sg_file_t;
281 /** Constant pointer to a SimGrid file object @ingroup plugin_filesystem */
282 typedef const s4u_File* const_sg_file_t;
283 typedef s4u_VM* sg_vm_t;
284 typedef const s4u_VM* const_sg_vm_t;
285 /** Pointer to an actor object */
286 typedef s4u_Actor* sg_actor_t;
287 /** Pointer to a constant actor object */
288 typedef const s4u_Actor* const_sg_actor_t;
289
290 typedef struct s_smx_simcall* smx_simcall_t;
291
292 /** @ingroup m_datatypes_management_details
293  * @brief Type for any simgrid size
294  */
295 typedef unsigned long long sg_size_t;
296
297 /** @ingroup m_datatypes_management_details
298  * @brief Type for any simgrid offset
299  */
300 typedef long long sg_offset_t;
301
302 /** Actor's ID, just like the classical processes' have PID in UNIX */
303 typedef long aid_t;
304
305 typedef enum {
306   SG_OK,
307   SG_ERROR_CANCELED,
308   SG_ERROR_TIMEOUT,
309   SG_ERROR_HOST,
310   SG_ERROR_NETWORK,
311   SG_ERROR_STORAGE,
312   SG_ERROR_VM
313 } sg_error_t;
314
315 #endif /* SIMGRID_TYPES_H */