Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
move some content from AsNone into As (AsNone should die)
[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 shareResources(double now) override;
34   void updateActionsState(double now, double delta) override;
35   bool shareResourcesIsIdempotent() override {return true;}
36
37   Link*
38   createLink(const char *name,
39       double bw_initial,
40       tmgr_trace_t bw_trace,
41       double lat_initial,
42       tmgr_trace_t lat_trace,
43       int initiallyOn,
44       tmgr_trace_t state_trace,
45       e_surf_link_sharing_policy_t policy,
46       xbt_dict_t properties)          override { DIE_IMPOSSIBLE; }
47   void addTraces()                    override { DIE_IMPOSSIBLE; }
48 };
49
50 /**********
51  * Action *
52  **********/
53 class NetworkConstantAction : public NetworkAction {
54 public:
55   NetworkConstantAction(NetworkConstantModel *model_, double size, double latency)
56   : NetworkAction(model_, size, false)
57   , m_latInit(latency)
58   {
59         m_latency = latency;
60         if (m_latency <= 0.0) {
61           p_stateSet = getModel()->getDoneActionSet();
62           p_stateSet->push_back(*this);
63         }
64         p_variable = NULL;
65   };
66   int unref() override;
67   void cancel() override;
68   double m_latInit;
69 };
70
71 }
72 }
73
74 #endif /* NETWORK_CONSTANT_HPP_ */