Logo AND Algorithmique Numérique Distribuée

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