Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Move code in simgrid::mc
[simgrid.git] / src / surf / network_constant.hpp
1 /* Copyright (c) 2013-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef NETWORK_CONSTANT_HPP_
8 #define NETWORK_CONSTANT_HPP_
9
10 #include <xbt/base.h>
11
12 #include "network_interface.hpp"
13
14 namespace simgrid {
15   namespace surf {
16
17     /***********
18      * Classes *
19      ***********/
20
21     class XBT_PRIVATE NetworkConstantModel;
22     class XBT_PRIVATE NetworkConstantAction;
23
24     /*********
25      * Model *
26      *********/
27     class NetworkConstantModel : public NetworkModel {
28     public:
29       NetworkConstantModel()  : NetworkModel() { };
30       ~NetworkConstantModel() { }
31
32       Action *communicate(NetCard *src, NetCard *dst, double size, double rate) override;
33       double next_occuring_event(double now) override;
34       bool next_occuring_event_isIdempotent() override {return true;}
35       void updateActionsState(double now, double delta) override;
36
37       Link* createLink(const char *name, double bw, double lat, e_surf_link_sharing_policy_t policy, xbt_dict_t properties) override
38         { DIE_IMPOSSIBLE; }
39     };
40
41     /**********
42      * Action *
43      **********/
44     class NetworkConstantAction : public NetworkAction {
45     public:
46       NetworkConstantAction(NetworkConstantModel *model_, double size, double latency)
47     : NetworkAction(model_, size, false)
48     , m_latInit(latency)
49     {
50         m_latency = latency;
51         if (m_latency <= 0.0) {
52           p_stateSet = getModel()->getDoneActionSet();
53           p_stateSet->push_back(*this);
54         }
55         p_variable = NULL;
56     };
57       int unref() override;
58       void cancel() override;
59       double m_latInit;
60     };
61
62   }
63 }
64
65 #endif /* NETWORK_CONSTANT_HPP_ */