Logo AND Algorithmique Numérique Distribuée

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