Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
convert S4U to my current coding convention
[simgrid.git] / include / simgrid / s4u / mailbox.hpp
1 /* Copyright (c) 2006-2015. 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_S4U_MAILBOX_HPP
7 #define SIMGRID_S4U_MAILBOX_HPP
8
9 #include <boost/unordered_map.hpp>
10
11 #include <xbt/base.h>
12 #include <simgrid/s4u/forward.hpp>
13 #include <simgrid/s4u/actor.hpp>
14
15 namespace simgrid {
16 namespace s4u {
17
18 /** @brief Mailboxes
19  *
20  * Rendez-vous point for network communications, similar to URLs on which you could post and retrieve data.
21  * They are not network locations: you can post and retrieve on a given mailbox from anywhere on the network.
22  * You can access any mailbox without any latency. The network delay are only related to the location of the
23  * sender and receiver.
24  */
25 XBT_PUBLIC_CLASS Mailbox {
26   friend Comm;
27
28 private:
29   Mailbox(const char*name, smx_rdv_t inferior);
30 public:
31   ~Mailbox();
32   
33 protected:
34   smx_rdv_t getInferior() { return inferior_; }
35
36 public:
37   /** Get the name of that mailbox */
38   const char *getName();
39   /** Retrieve the mailbox associated to the given string */
40   static Mailbox *byName(const char *name);
41
42 private:
43   std::string name_;
44   smx_rdv_t inferior_;
45   static boost::unordered_map<std::string, Mailbox *> *mailboxes;
46 };
47 }} // namespace simgrid::s4u
48
49 #endif /* SIMGRID_S4U_MAILBOX_HPP */