Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move SimcallObserver from simgrid::mc to simgrid::kernel::actor
[simgrid.git] / include / simgrid / forward.h
1 /* Copyright (c) 2004-2021. 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
70 class Mailbox;
71
72 class Mutex;
73 XBT_PUBLIC void intrusive_ptr_release(const Mutex* m);
74 XBT_PUBLIC void intrusive_ptr_add_ref(const Mutex* m);
75 /**
76  * @beginrst
77  * Smart pointer to a :cpp:type:`simgrid::s4u::Mutex`
78  * @endrst
79  */
80 using MutexPtr = boost::intrusive_ptr<Mutex>;
81
82 class NetZone;
83 class VirtualMachine;
84 class File;
85
86 class Semaphore;
87 /** Smart pointer to a simgrid::s4u::Semaphore */
88 using SemaphorePtr = boost::intrusive_ptr<Semaphore>;
89 XBT_PUBLIC void intrusive_ptr_release(const Semaphore* m);
90 XBT_PUBLIC void intrusive_ptr_add_ref(const Semaphore* m);
91
92 class Disk;
93 } // namespace s4u
94
95 namespace config {
96 template <class T> class Flag;
97 }
98
99 namespace kernel {
100 class EngineImpl;
101 namespace actor {
102 class ActorImpl;
103 using ActorImplPtr = boost::intrusive_ptr<ActorImpl>;
104
105 // What's executed as an actor code:
106 using ActorCode = std::function<void()>;
107 // Create an ActorCode from the parameters parsed in the XML file (or elsewhere)
108 using ActorCodeFactory = std::function<ActorCode(std::vector<std::string> args)>;
109
110 class SimcallObserver;
111 } // namespace actor
112
113 namespace activity {
114   class ActivityImpl;
115   enum class State;
116   using ActivityImplPtr = boost::intrusive_ptr<ActivityImpl>;
117   XBT_PUBLIC void intrusive_ptr_add_ref(ActivityImpl* activity);
118   XBT_PUBLIC void intrusive_ptr_release(ActivityImpl* activity);
119
120   class ConditionVariableImpl;
121   using ConditionVariableImplPtr = boost::intrusive_ptr<ConditionVariableImpl>;
122   XBT_PUBLIC void intrusive_ptr_add_ref(ConditionVariableImpl* cond);
123   XBT_PUBLIC void intrusive_ptr_release(ConditionVariableImpl* cond);
124
125   class CommImpl;
126   using CommImplPtr = boost::intrusive_ptr<CommImpl>;
127   class ExecImpl;
128   using ExecImplPtr = boost::intrusive_ptr<ExecImpl>;
129   class IoImpl;
130   using IoImplPtr = boost::intrusive_ptr<IoImpl>;
131   class MutexImpl;
132   using MutexImplPtr = boost::intrusive_ptr<MutexImpl>;
133   XBT_PUBLIC void intrusive_ptr_add_ref(MutexImpl* mutex);
134   XBT_PUBLIC void intrusive_ptr_release(MutexImpl* mutex);
135   class RawImpl;
136   using RawImplPtr = boost::intrusive_ptr<RawImpl>;
137   class SemaphoreImpl;
138   using SemaphoreImplPtr = boost::intrusive_ptr<SemaphoreImpl>;
139   XBT_PUBLIC void intrusive_ptr_add_ref(SemaphoreImpl* sem);
140   XBT_PUBLIC void intrusive_ptr_release(SemaphoreImpl* sem);
141   class SleepImpl;
142   using SleepImplPtr = boost::intrusive_ptr<SleepImpl>;
143
144   class MailboxImpl;
145 }
146 namespace context {
147 class Context;
148 class ContextFactory;
149 } // namespace context
150 namespace lmm {
151 class Element;
152 class Variable;
153 class Constraint;
154 class ConstraintLight;
155 class System;
156 }
157 namespace resource {
158 class Action;
159 class Cpu;
160 class Model;
161 class Resource;
162 class CpuModel;
163 class NetworkModel;
164 class LinkImpl;
165 class NetworkAction;
166 class DiskImpl;
167 class DiskModel;
168 }
169 namespace routing {
170 class ClusterCreationArgs;
171 class LinkCreationArgs;
172 class NetPoint;
173 class NetZoneImpl;
174 class RouteCreationArgs;
175 }
176 namespace profile {
177 class Event;
178 class FutureEvtSet;
179 class Profile;
180 } // namespace profile
181 } // namespace kernel
182 namespace simix {
183   class Host;
184   class Timer;
185 }
186 namespace surf {
187   class HostImpl;
188   class HostModel;
189 }
190 namespace mc {
191 class CommunicationDeterminismChecker;
192 }
193 namespace vm {
194 class VMModel;
195 class VirtualMachineImpl;
196 } // namespace vm
197 } // namespace simgrid
198
199 using s4u_Actor             = simgrid::s4u::Actor;
200 using s4u_Barrier           = simgrid::s4u::Barrier;
201 using s4u_Comm              = simgrid::s4u::Comm;
202 using s4u_Exec              = simgrid::s4u::Exec;
203 using s4u_Host              = simgrid::s4u::Host;
204 using s4u_Link              = simgrid::s4u::Link;
205 using s4u_File              = simgrid::s4u::File;
206 using s4u_ConditionVariable = simgrid::s4u::ConditionVariable;
207 using s4u_Mailbox           = simgrid::s4u::Mailbox;
208 using s4u_Mutex             = simgrid::s4u::Mutex;
209 using s4u_Semaphore         = simgrid::s4u::Semaphore;
210 using s4u_Disk              = simgrid::s4u::Disk;
211 using s4u_NetZone           = simgrid::s4u::NetZone;
212 using s4u_VM                = simgrid::s4u::VirtualMachine;
213
214 using smx_timer_t    = simgrid::simix::Timer*;
215 using smx_actor_t    = simgrid::kernel::actor::ActorImpl*;
216 using smx_activity_t = simgrid::kernel::activity::ActivityImpl*;
217 using smx_cond_t     = simgrid::kernel::activity::ConditionVariableImpl*;
218 using smx_mailbox_t  = simgrid::kernel::activity::MailboxImpl*;
219 using smx_mutex_t    = simgrid::kernel::activity::MutexImpl*;
220 using smx_sem_t      = simgrid::kernel::activity::SemaphoreImpl*;
221 using e_smx_state_t XBT_ATTRIB_DEPRECATED_v330("Please use kernel::activity::State") = simgrid::kernel::activity::State;
222 #else
223
224 typedef struct s4u_Actor s4u_Actor;
225 typedef struct s4u_Barrier s4u_Barrier;
226 typedef struct s4u_Comm s4u_Comm;
227 typedef struct s4u_Exec s4u_Exec;
228 typedef struct s4u_Host s4u_Host;
229 typedef struct s4u_Link s4u_Link;
230 typedef struct s4u_File s4u_File;
231 typedef struct s4u_ConditionVariable s4u_ConditionVariable;
232 typedef struct s4u_Mailbox s4u_Mailbox;
233 typedef struct s4u_Mutex s4u_Mutex;
234 typedef struct s4u_Semaphore s4u_Semaphore;
235 typedef struct s4u_Disk s4u_Disk;
236 typedef struct s4u_NetZone s4u_NetZone;
237 typedef struct s4u_VM s4u_VM;
238 XBT_ATTRIB_DEPRECATED_v330("Please stop using this type alias") typedef enum kernel_activity_state e_smx_state_t;
239
240 typedef struct s_smx_timer* smx_timer_t;
241 typedef struct s_smx_actor* smx_actor_t;
242 typedef struct s_smx_activity* smx_activity_t;
243 typedef struct s_smx_cond_t* smx_cond_t;
244 typedef struct s_smx_mailbox* smx_mailbox_t;
245 typedef struct s_smx_mutex* smx_mutex_t;
246 typedef struct s_smx_sem* smx_sem_t;
247
248 #endif
249
250 /** Pointer to a SimGrid barrier object */
251 typedef s4u_Barrier* sg_bar_t;
252 /** Constant pointer to a SimGrid barrier object */
253 typedef const s4u_Barrier* const_sg_bar_t;
254 typedef s4u_Comm* sg_comm_t;
255 typedef const s4u_Comm* const_sg_comm_t;
256 typedef s4u_Exec* sg_exec_t;
257 typedef const s4u_Exec* const_sg_exec_t;
258 typedef s4u_ConditionVariable* sg_cond_t;
259 typedef const s4u_ConditionVariable* const_sg_cond_t;
260 typedef s4u_Mailbox* sg_mailbox_t;
261 typedef const s4u_Mailbox* const_sg_mailbox_t;
262 typedef s4u_Mutex* sg_mutex_t;
263 typedef const s4u_Mutex* const_sg_mutex_t;
264 typedef s4u_Semaphore* sg_sem_t;
265 typedef const s4u_Semaphore* const_sg_sem_t;
266 typedef s4u_NetZone* sg_netzone_t;
267 typedef const s4u_NetZone* const_sg_netzone_t;
268 typedef s4u_Host* sg_host_t;
269 typedef const s4u_Host* const_sg_host_t;
270 typedef s4u_Link* sg_link_t;
271 typedef const s4u_Link* const_sg_link_t;
272 typedef s4u_Disk* sg_disk_t;
273 typedef const s4u_Disk* const_sg_disk_t;
274 /** Pointer to a SimGrid file object */
275 typedef s4u_File* sg_file_t;
276 /** Constant pointer to a SimGrid file object */
277 typedef const s4u_File* const_sg_file_t;
278 typedef s4u_VM* sg_vm_t;
279 typedef const s4u_VM* const_sg_vm_t;
280 typedef s4u_Actor* sg_actor_t;
281 typedef const s4u_Actor* const_sg_actor_t;
282
283 typedef struct s_smx_simcall* smx_simcall_t;
284
285 /** @ingroup m_datatypes_management_details
286  * @brief Type for any simgrid size
287  */
288 typedef unsigned long long sg_size_t;
289
290 /** @ingroup m_datatypes_management_details
291  * @brief Type for any simgrid offset
292  */
293 typedef long long sg_offset_t;
294
295 /** Actor's ID, just like the classical processes' have PID in UNIX */
296 typedef long aid_t;
297
298 typedef enum {
299   SG_OK,
300   SG_ERROR_CANCELED,
301   SG_ERROR_TIMEOUT,
302   SG_ERROR_HOST,
303   SG_ERROR_NETWORK,
304   SG_ERROR_STORAGE,
305   SG_ERROR_VM
306 } sg_error_t;
307
308 #endif /* SIMGRID_TYPES_H */