Logo AND Algorithmique Numérique Distribuée

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