Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fc380850511ba299875203331104e4fc42bfcbd7
[simgrid.git] / include / simgrid / forward.h
1 /* Copyright (c) 2004-2023. 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* act);
23 XBT_PUBLIC void intrusive_ptr_add_ref(const Activity* act);
24
25 class ActivitySet;
26 /** Smart pointer to a simgrid::s4u::Activity */
27 using ActivitySetPtr = boost::intrusive_ptr<ActivitySet>;
28 XBT_PUBLIC void intrusive_ptr_release(const ActivitySet* as);
29 XBT_PUBLIC void intrusive_ptr_add_ref(const ActivitySet* as);
30
31 class Actor;
32 /** Smart pointer to a simgrid::s4u::Actor */
33 using ActorPtr = boost::intrusive_ptr<Actor>;
34 XBT_PUBLIC void intrusive_ptr_release(const Actor* actor);
35 XBT_PUBLIC void intrusive_ptr_add_ref(const Actor* actor);
36
37 class Barrier;
38 /** Smart pointer to a simgrid::s4u::Barrier */
39 using BarrierPtr = boost::intrusive_ptr<Barrier>;
40 XBT_PUBLIC void intrusive_ptr_release(Barrier* b);
41 XBT_PUBLIC void intrusive_ptr_add_ref(Barrier* b);
42
43 class Comm;
44 /** Smart pointer to a simgrid::s4u::Comm */
45 using CommPtr = boost::intrusive_ptr<Comm>;
46 XBT_PUBLIC void intrusive_ptr_release(Comm* c);
47 XBT_PUBLIC void intrusive_ptr_add_ref(Comm* c);
48
49 class ConditionVariable;
50 /** @beginrst
51  * Smart pointer to a :cpp:type:`simgrid::s4u::ConditionVariable`
52  * @endrst
53  */
54 using ConditionVariablePtr = boost::intrusive_ptr<ConditionVariable>;
55 XBT_PUBLIC void intrusive_ptr_release(const ConditionVariable* c);
56 XBT_PUBLIC void intrusive_ptr_add_ref(const ConditionVariable* c);
57
58 class Engine;
59
60 class Exec;
61 /** Smart pointer to a simgrid::s4u::Exec */
62 using ExecPtr = boost::intrusive_ptr<Exec>;
63 XBT_PUBLIC void intrusive_ptr_release(Exec* e);
64 XBT_PUBLIC void intrusive_ptr_add_ref(Exec* e);
65
66 class Host;
67
68 class Io;
69 /** Smart pointer to a simgrid::s4u::Io */
70 using IoPtr = boost::intrusive_ptr<Io>;
71 XBT_PUBLIC void intrusive_ptr_release(Io* i);
72 XBT_PUBLIC void intrusive_ptr_add_ref(Io* i);
73
74 class Link;
75 class SplitDuplexLink;
76
77 class Mailbox;
78
79 class Mess;
80 /** Smart pointer to a simgrid::s4u::Mess */
81 using MessPtr = boost::intrusive_ptr<Mess>;
82 XBT_PUBLIC void intrusive_ptr_release(Mess* c);
83 XBT_PUBLIC void intrusive_ptr_add_ref(Mess* c);
84
85 class MessageQueue;
86
87 class Mutex;
88 XBT_PUBLIC void intrusive_ptr_release(const Mutex* m);
89 XBT_PUBLIC void intrusive_ptr_add_ref(const Mutex* m);
90 /**
91  * @beginrst
92  * Smart pointer to a :cpp:type:`simgrid::s4u::Mutex`
93  * @endrst
94  */
95 using MutexPtr = boost::intrusive_ptr<Mutex>;
96
97 class NetZone;
98 class VirtualMachine;
99 class File;
100
101 class Semaphore;
102 /** Smart pointer to a simgrid::s4u::Semaphore */
103 using SemaphorePtr = boost::intrusive_ptr<Semaphore>;
104 XBT_PUBLIC void intrusive_ptr_release(const Semaphore* m);
105 XBT_PUBLIC void intrusive_ptr_add_ref(const Semaphore* m);
106
107 class Disk;
108 /**
109  * @brief Callback to dynamically change the resource's capacity
110  *
111  * Allows user to change resource's capacity depending on the number of concurrent activities
112  * running on the resource at a given instant
113  */
114 using NonLinearResourceCb = std::function<double(double capacity, int n_activities)>;
115 } // namespace s4u
116
117 namespace config {
118 template <class T> class Flag;
119 }
120
121 namespace kernel {
122 class EngineImpl;
123 namespace actor {
124 class ActorImpl;
125 using ActorImplPtr = boost::intrusive_ptr<ActorImpl>;
126
127 // What's executed as an actor code:
128 using ActorCode = std::function<void()>;
129 // Create an ActorCode from the parameters parsed in the XML file (or elsewhere)
130 using ActorCodeFactory = std::function<ActorCode(std::vector<std::string> args)>;
131
132 class Simcall;
133 class SimcallObserver;
134 class MutexObserver;
135 class ConditionVariableObserver;
136 class ObjectAccessSimcallObserver;
137 class ObjectAccessSimcallItem;
138 } // namespace actor
139
140 namespace activity {
141   class ActivityImpl;
142   enum class State;
143   using ActivityImplPtr = boost::intrusive_ptr<ActivityImpl>;
144   XBT_PUBLIC void intrusive_ptr_add_ref(ActivityImpl* activity);
145   XBT_PUBLIC void intrusive_ptr_release(ActivityImpl* activity);
146
147   class BarrierImpl;
148   using BarrierImplPtr = boost::intrusive_ptr<BarrierImpl>;
149   XBT_PUBLIC void intrusive_ptr_add_ref(BarrierImpl* cond);
150   XBT_PUBLIC void intrusive_ptr_release(BarrierImpl* cond);
151   class BarrierAcquisitionImpl;
152   using BarrierAcquisitionImplPtr = boost::intrusive_ptr<BarrierAcquisitionImpl>;
153
154   class ConditionVariableImpl;
155   using ConditionVariableImplPtr = boost::intrusive_ptr<ConditionVariableImpl>;
156   XBT_PUBLIC void intrusive_ptr_add_ref(ConditionVariableImpl* cond);
157   XBT_PUBLIC void intrusive_ptr_release(ConditionVariableImpl* cond);
158   class ConditionVariableAcquisitionImpl;
159   using ConditionVariableAcquisitionImplPtr = boost::intrusive_ptr<ConditionVariableAcquisitionImpl>;
160
161   class CommImpl;
162   using CommImplPtr = boost::intrusive_ptr<CommImpl>;
163   class ExecImpl;
164   using ExecImplPtr = boost::intrusive_ptr<ExecImpl>;
165   class IoImpl;
166   using IoImplPtr = boost::intrusive_ptr<IoImpl>;
167   class MessImpl;
168   using MessImplPtr = boost::intrusive_ptr<MessImpl>;
169   class MutexImpl;
170   using MutexImplPtr = boost::intrusive_ptr<MutexImpl>;
171   class MutexAcquisitionImpl;
172   using MutexAcquisitionImplPtr = boost::intrusive_ptr<MutexAcquisitionImpl>;
173   XBT_PUBLIC void intrusive_ptr_add_ref(MutexImpl* mutex);
174   XBT_PUBLIC void intrusive_ptr_release(MutexImpl* mutex);
175   class SynchroImpl;
176   using SynchroImplPtr = boost::intrusive_ptr<SynchroImpl>;
177   class SemaphoreImpl;
178   using SemaphoreImplPtr = boost::intrusive_ptr<SemaphoreImpl>;
179   class SemAcquisitionImpl;
180   using SemAcquisitionImplPtr = boost::intrusive_ptr<SemAcquisitionImpl>;
181   XBT_PUBLIC void intrusive_ptr_add_ref(SemaphoreImpl* sem);
182   XBT_PUBLIC void intrusive_ptr_release(SemaphoreImpl* sem);
183   class SleepImpl;
184   using SleepImplPtr = boost::intrusive_ptr<SleepImpl>;
185
186   class MailboxImpl;
187   class MessageQueueImpl;
188 }
189 namespace context {
190 class Context;
191 class ContextFactory;
192 } // namespace context
193 namespace lmm {
194 class Element;
195 class Variable;
196 class Constraint;
197 class ConstraintLight;
198 class System;
199 }
200 namespace resource {
201 class Action;
202 class CpuAction;
203 class CpuImpl;
204 class Model;
205 class Resource;
206 class CpuModel;
207 class HostImpl;
208 class HostModel;
209 class NetworkModel;
210 class LinkImpl;
211 class StandardLinkImpl;
212 class SplitDuplexLinkImpl;
213 class NetworkAction;
214 class DiskImpl;
215 using DiskImplPtr = boost::intrusive_ptr<DiskImpl>;
216 class DiskModel;
217 class VirtualMachineImpl;
218 class VMModel;
219 }
220 namespace timer {
221 class Timer;
222 }
223 namespace routing {
224 class NetPoint;
225 class NetZoneImpl;
226 }
227 namespace profile {
228 class Event;
229 class FutureEvtSet;
230 class Profile;
231 } // namespace profile
232 } // namespace kernel
233 namespace mc {
234 class State;
235 class RemoteApp;
236 }
237 } // namespace simgrid
238
239 using s4u_Actor             = simgrid::s4u::Actor;
240 using s4u_Activity          = simgrid::s4u::Activity;
241 using s4u_ActivitySet       = simgrid::s4u::ActivitySet;
242 using s4u_Barrier           = simgrid::s4u::Barrier;
243 using s4u_Comm              = simgrid::s4u::Comm;
244 using s4u_Exec              = simgrid::s4u::Exec;
245 using s4u_Host              = simgrid::s4u::Host;
246 using s4u_Link              = simgrid::s4u::Link;
247 using s4u_File              = simgrid::s4u::File;
248 using s4u_ConditionVariable = simgrid::s4u::ConditionVariable;
249 using s4u_Mailbox           = simgrid::s4u::Mailbox;
250 using s4u_MessageQueue      = simgrid::s4u::MessageQueue;
251 using s4u_Mutex             = simgrid::s4u::Mutex;
252 using s4u_Semaphore         = simgrid::s4u::Semaphore;
253 using s4u_Disk              = simgrid::s4u::Disk;
254 using s4u_NetZone           = simgrid::s4u::NetZone;
255 using s4u_VM                = simgrid::s4u::VirtualMachine;
256
257 using smx_activity_t = simgrid::kernel::activity::ActivityImpl*;
258 #else
259
260 typedef struct s4u_Actor s4u_Actor;
261 typedef struct s4u_Activity s4u_Activity;
262 typedef struct s4u_ActivitySet s4u_ActivitySet;
263 typedef struct s4u_Barrier s4u_Barrier;
264 typedef struct s4u_Comm s4u_Comm;
265 typedef struct s4u_Exec s4u_Exec;
266 typedef struct s4u_Host s4u_Host;
267 typedef struct s4u_Link s4u_Link;
268 typedef struct s4u_File s4u_File;
269 typedef struct s4u_ConditionVariable s4u_ConditionVariable;
270 typedef struct s4u_Mailbox s4u_Mailbox;
271 typedef struct s4u_MessageQueue s4u_MessageQueue;
272 typedef struct s4u_Mutex s4u_Mutex;
273 typedef struct s4u_Semaphore s4u_Semaphore;
274 typedef struct s4u_Disk s4u_Disk;
275 typedef struct s4u_NetZone s4u_NetZone;
276 typedef struct s4u_VM s4u_VM;
277
278 typedef struct s_smx_activity* smx_activity_t;
279
280 #endif
281
282 /** Pointer to a SimGrid barrier object */
283 typedef s4u_Barrier* sg_bar_t;
284 typedef s4u_Comm* sg_comm_t;
285 typedef s4u_Exec* sg_exec_t;
286 typedef const s4u_Exec* const_sg_exec_t;
287 typedef s4u_ConditionVariable* sg_cond_t;
288 typedef const s4u_ConditionVariable* const_sg_cond_t;
289 typedef s4u_Mailbox* sg_mailbox_t;
290 typedef const s4u_Mailbox* const_sg_mailbox_t;
291 typedef s4u_MessageQueue* sg_messagequeue_t;
292 typedef const s4u_MessageQueue* const_sg_messagequeue_t;
293 typedef s4u_Mutex* sg_mutex_t;
294 typedef const s4u_Mutex* const_sg_mutex_t;
295 typedef s4u_Semaphore* sg_sem_t;
296 typedef const s4u_Semaphore* const_sg_sem_t;
297 typedef s4u_NetZone* sg_netzone_t;
298 typedef const s4u_NetZone* const_sg_netzone_t;
299 typedef s4u_Host* sg_host_t;
300 typedef const s4u_Host* const_sg_host_t;
301 typedef s4u_Link* sg_link_t;
302 typedef const s4u_Link* const_sg_link_t;
303 typedef s4u_Disk* sg_disk_t;
304 typedef const s4u_Disk* const_sg_disk_t;
305 /** Pointer to a SimGrid file object @ingroup plugin_filesystem */
306 typedef s4u_File* sg_file_t;
307 /** Constant pointer to a SimGrid file object @ingroup plugin_filesystem */
308 typedef const s4u_File* const_sg_file_t;
309 typedef s4u_VM* sg_vm_t;
310 typedef const s4u_VM* const_sg_vm_t;
311 /** Pointer to an actor object */
312 typedef s4u_Actor* sg_actor_t;
313 /** Pointer to a constant actor object */
314 typedef const s4u_Actor* const_sg_actor_t;
315
316 /** Pointer to an activity object */
317 typedef s4u_Activity* sg_activity_t;
318 /** Pointer to a constant activity object */
319 typedef const s4u_Activity* const_sg_activity_t;
320
321 /** Pointer to an activity set object */
322 typedef s4u_ActivitySet* sg_activity_set_t;
323 /** Pointer to a constant activity set object */
324 typedef const s4u_ActivitySet* const_sg_activity_set_t;
325
326 /** @ingroup m_datatypes_management_details
327  * @brief Type for any SimGrid size
328  */
329 typedef unsigned long long sg_size_t;
330
331 /** @ingroup m_datatypes_management_details
332  * @brief Type for any SimGrid offset
333  */
334 typedef long long sg_offset_t;
335
336 /** Actor's ID, just like the classical processes' have PID in UNIX */
337 typedef long aid_t;
338
339 typedef enum {
340   SG_OK /** Code returned when no problem occured */,
341   SG_ERROR_CANCELED /** Code returned when something got canceled before completion */,
342   SG_ERROR_TIMEOUT /** Code returned when timeout elapsed */,
343   SG_ERROR_HOST /** Code returned when a host fails */,
344   SG_ERROR_NETWORK /** Code returned when a communication fails because of the network or because of the remote host */,
345   SG_ERROR_STORAGE /** Code returned when a storage fails */,
346   SG_ERROR_VM /** Code returned when a VM fails */
347 } sg_error_t;
348
349 XBT_PUBLIC int SMPI_is_inited();
350
351 #endif /* SIMGRID_TYPES_H */