Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Move Server in simgrid::mc
[simgrid.git] / src / mc / ModelChecker.cpp
1 /* Copyright (c) 2008-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 #include <cassert>
8
9 #include "simgrid/sg_config.h" // sg_cfg_get_boolean
10
11 #include "ModelChecker.hpp"
12 #include "PageStore.hpp"
13
14 ::simgrid::mc::ModelChecker* mc_model_checker = NULL;
15
16 namespace simgrid {
17 namespace mc {
18
19 ModelChecker::ModelChecker(pid_t pid, int socket) :
20   hostnames_(xbt_dict_new()),
21   page_store_(500),
22   process_(pid, socket),
23   parent_snapshot_(nullptr)
24 {
25   // TODO, avoid direct dependency on sg_cfg
26   process_.privatized(sg_cfg_get_boolean("smpi/privatize_global_variables"));
27 }
28
29 ModelChecker::~ModelChecker()
30 {
31   xbt_dict_free(&this->hostnames_);
32 }
33
34 const char* ModelChecker::get_host_name(const char* hostname)
35 {
36   // Lookup the host name in the dictionary (or create it):
37   xbt_dictelm_t elt = xbt_dict_get_elm_or_null(this->hostnames_, hostname);
38   if (!elt) {
39     xbt_dict_set(this->hostnames_, hostname, NULL, NULL);
40     elt = xbt_dict_get_elm_or_null(this->hostnames_, hostname);
41     assert(elt);
42   }
43   return elt->key;
44 }
45
46 }
47 }