('cpp:identifier', 'simgrid::s4u::Activity_T<Io>'),
('cpp:identifier', 'simgrid::s4u::this_actor'),
('cpp:identifier', 'simgrid::xbt'),
- ('cpp:identifier', 'simgrid::xbt::string'),
('cpp:identifier', 'size_t'),
('cpp:identifier', 'ssize_t'),
('cpp:identifier', 'this_actor'),
('cpp:identifier', 'xbt::signal<void(kernel::resource::NetworkAction&)>'),
('cpp:identifier', 'xbt::signal<void(kernel::resource::NetworkAction&, kernel::resource::Action::State)>'),
('cpp:identifier', 'xbt::signal<void(void)>'),
- ('cpp:identifier', 'xbt::string'),
]
# For cross-ref generation
static bool is_maestro();
/** Retrieves the name of that actor as a C++ string */
- const simgrid::xbt::string& get_name() const;
+ const std::string& get_name() const;
/** Retrieves the name of that actor as a C string */
const char* get_cname() const;
/** Retrieves the host on which that actor is running */
static Host* current();
/** Retrieves the name of that host as a C++ string */
- xbt::string const& get_name() const;
+ std::string const& get_name() const;
/** Retrieves the name of that host as a C string */
const char* get_cname() const;
#include <simgrid/s4u/Actor.hpp>
#include <simgrid/s4u/Comm.hpp>
#include <smpi/forward.hpp>
-#include <xbt/string.hpp>
#include <memory>
#include <string>
public:
/** @brief Retrieves the name of that mailbox as a C++ string */
- const xbt::string& get_name() const;
+ const std::string& get_name() const;
/** @brief Retrieves the name of that mailbox as a C string */
const char* get_cname() const;
#ifndef SIMGRID_XBT_STRING_HPP
#define SIMGRID_XBT_STRING_HPP
-#include <simgrid/config.h>
+#include "xbt/base.h"
#include <cstdarg>
#include <cstdlib>
#include <string>
-#if SIMGRID_HAVE_MC
-
-#include <algorithm>
-#include <cstddef>
-#include <cstring>
-#include <iterator>
-#include <stdexcept>
-
-#include <xbt/sysdep.h>
-
-#endif
-
namespace simgrid {
namespace xbt {
*/
XBT_PUBLIC std::string string_vprintf(const char* fmt, va_list ap) XBT_ATTRIB_PRINTF(1, 0);
-#if SIMGRID_HAVE_MC
-
-/** POD structure representation of a string
- */
-struct string_data {
- char* data;
- std::size_t len;
-};
-
-/** A std::string-like with well-known representation
- *
- * HACK, this is a (incomplete) replacement for `std::string`.
- * It has a fixed POD representation (`simgrid::xbt::string_data`)
- * which can be used to easily read the string content from another
- * process.
- *
- * The internal representation of a `std::string` is private.
- * We could add some code to read this for a given implementation.
- * However, even if we focus on GNU libstdc++ with Itanium ABI
- * GNU libstdc++ currently has two different ABIs
- *
- * * the pre-C++11 is a pointer to a ref-counted
- * string-representation (with support for COW);
- *
- * * the [C++11-conforming implementation](https://gcc.gnu.org/gcc-5/changes.html)
- * does not use refcouting/COW but has a small string optimization.
- */
-class XBT_PUBLIC string {
- static char NUL;
- string_data str;
-
-public:
- // Types
- using size_type = std::size_t;
- using reference = char&;
- using const_reference = const char&;
- using iterator = char*;
- using const_iterator = const char*;
-
- // Dtor
- ~string()
- {
- if (str.data != &NUL)
- delete[] str.data;
- }
-
- // Ctors
- string(const char* s, size_t size)
- {
- if (size == 0) {
- str.len = 0;
- str.data = &NUL;
- } else {
- str.len = size;
- str.data = new char[str.len + 1];
- std::copy_n(s, str.len, str.data);
- str.data[str.len] = '\0';
- }
- }
- string() : string(&NUL, 0) {}
- explicit string(const char* s) : string(s, strlen(s)) {}
- string(string const& s) : string(s.c_str(), s.size()) {}
- string(string&& s) noexcept : str(s.str)
- {
- s.str.len = 0;
- s.str.data = &NUL;
- }
- explicit string(std::string const& s) : string(s.c_str(), s.size()) {}
-
- // Assign
- void assign(const char* s, size_t size)
- {
- if (str.data != &NUL) {
- delete[] str.data;
- str.data = nullptr;
- str.len = 0;
- }
- if (size != 0) {
- str.len = size;
- str.data = new char[str.len + 1];
- std::copy_n(s, str.len, str.data);
- str.data[str.len] = '\0';
- }
- }
-
- // Copy
- string& operator=(const char* s)
- {
- assign(s, std::strlen(s));
- return *this;
- }
- string& operator=(string const& s)
- {
- if (this != &s)
- assign(s.c_str(), s.size());
- return *this;
- }
- string& operator=(std::string const& s)
- {
- assign(s.c_str(), s.size());
- return *this;
- }
-
- // Capacity
- size_t size() const { return str.len; }
- size_t length() const { return str.len; }
- bool empty() const { return str.len == 0; }
- void shrink_to_fit() { /* Being there, but doing nothing */}
-
- // Element access
- char* data() { return str.data; }
- const char* data() const { return str.data; }
- char* c_str() { return str.data; }
- const char* c_str() const { return str.data; };
- reference at(size_type i)
- {
- if (i >= size())
- throw std::out_of_range("Out of range");
- return data()[i];
- }
- const_reference at(size_type i) const
- {
- if (i >= size())
- throw std::out_of_range("Out of range");
- return data()[i];
- }
- reference operator[](size_type i)
- {
- return data()[i];
- }
- const_reference operator[](size_type i) const
- {
- return data()[i];
- }
- // Conversion
- static const string_data& to_string_data(const string& s) { return s.str; }
- operator std::string() const { return std::string(this->c_str(), this->size()); }
-
- // Iterators
- iterator begin() { return data(); }
- iterator end() { return data() + size(); }
- const_iterator begin() const { return data(); }
- const_iterator end() const { return data() + size(); }
- const_iterator cbegin() const { return data(); }
- const_iterator cend() const { return data() + size(); }
- // (Missing, reverse iterators)
-
- // Operations
- void clear()
- {
- str.len = 0;
- str.data = &NUL;
- }
-
- size_t copy(char* s, size_t len, size_t pos = 0) const
- {
- if (pos > str.len)
- throw std::out_of_range(string_printf("xbt::string::copy with pos > size() (%zu > %zu)", pos, str.len));
- size_t count = std::min(len, str.len - pos);
- std::copy_n(str.data + pos, count, s);
- return count;
- }
-
- bool equals(const char* data, std::size_t len) const
- {
- return this->size() == len
- && std::memcmp(this->c_str(), data, len) == 0;
- }
-
- bool operator==(string const& that) const
- {
- return this->equals(that.c_str(), that.size());
- }
- bool operator==(std::string const& that) const
- {
- return this->equals(that.c_str(), that.size());
- }
- bool operator==(const char* that) const
- {
- return this->equals(that, std::strlen(that));
- }
-
- template<class X>
- bool operator!=(X const& that) const
- {
- return not (*this == that);
- }
-
- // Compare:
- int compare(const char* data, std::size_t len) const
- {
- size_t n = std::min(this->size(), len);
- int res = memcmp(this->c_str(), data, n);
- if (res != 0)
- return res;
- else if (this->size() == len)
- return 0;
- else if (this->size() < len)
- return -1;
- else
- return 1;
- }
- int compare(string const& that) const
- {
- return this->compare(that.c_str(), that.size());
- }
- int compare(std::string const& that) const
- {
- return this->compare(that.c_str(), that.size());
- }
- int compare(const char* that) const
- {
- return this->compare(that, std::strlen(that));
- }
-
- // Define < <= >= > in term of compare():
- template<class X>
- bool operator<(X const& that) const
- {
- return this->compare(that) < 0;
- }
- template<class X>
- bool operator<=(X const& that) const
- {
- return this->compare(that) <= 0;
- }
- template<class X>
- bool operator>(X const& that) const
- {
- return this->compare(that) > 0;
- }
- template<class X>
- bool operator>=(X const& that) const
- {
- return this->compare(that) >= 0;
- }
-};
-
-inline
-bool operator==(std::string const& a, string const& b)
-{
- return b == a;
-}
-inline
-bool operator!=(std::string const& a, string const& b)
-{
- return b != a;
-}
-inline
-bool operator<(std::string const& a, string const& b)
-{
- return b > a;
+} // namespace xbt
}
-inline
-bool operator<=(std::string const& a, string const& b)
-{
- return b >= a;
-}
-inline
-bool operator>(std::string const& a, string const& b)
-{
- return b < a;
-}
-inline
-bool operator>=(std::string const& a, string const& b)
-{
- return b <= a;
-}
-
-#else
-
-typedef std::string string;
-
-#endif
-}
-}
-
-#endif
+#endif
\ No newline at end of file
},
"The current pstate (read/write property).")
.def_static("current", &Host::current, py::call_guard<py::gil_scoped_release>(),
- "Retrieves the host on which the running actor is located.")
+ "Retrieves the host on which the running actor is located.")
.def_property_readonly(
- "name",
- [](const Host* self) {
- return std::string(self->get_name().c_str()); // Convert from xbt::string because of MC
- },
- "The name of this host (read-only property).")
+ "name", [](const Host* self) { return self->get_name(); }, "The name of this host (read-only property).")
.def_property_readonly("load", &Host::get_load,
"Returns the current computation load (in flops per second), NOT taking the external load "
"into account. This is the currently achieved speed (read-only property).")
.def_static("by_name", &Link::by_name, "Retrieves a Link from its name, or dies")
.def("seal", &Link::seal, py::call_guard<py::gil_scoped_release>(), "Seal this link")
.def_property_readonly(
- "name",
- [](const Link* self) {
- return std::string(self->get_name().c_str()); // Convert from xbt::string because of MC
- },
- "The name of this link")
+ "name", [](const Link* self) { return self->get_name(); }, "The name of this link")
.def_property_readonly("bandwidth", &Link::get_bandwidth,
"The bandwidth (in bytes per second) (read-only property).")
.def_property_readonly("latency", &Link::get_latency, "The latency (in seconds) (read-only property).");
.def(
"__str__", [](const Mailbox* self) { return std::string("Mailbox(") + self->get_cname() + ")"; },
"Textual representation of the Mailbox`")
- .def_static("by_name", &Mailbox::by_name,
- py::call_guard<py::gil_scoped_release>(),
- py::arg("name"),
+ .def_static("by_name", &Mailbox::by_name, py::call_guard<py::gil_scoped_release>(), py::arg("name"),
"Retrieve a Mailbox from its name")
.def_property_readonly(
- "name",
- [](const Mailbox* self) {
- return std::string(self->get_name().c_str()); // Convert from xbt::string because of MC
- },
+ "name", [](const Mailbox* self) { return self->get_name(); },
"The name of that mailbox (read-only property).")
.def_property_readonly("ready", &Mailbox::ready, py::call_guard<py::gil_scoped_release>(),
"Check if there is a communication ready to be consumed from a mailbox.")
data.inc_ref();
return self->put_init(data.ptr(), size);
},
- py::call_guard<py::gil_scoped_release>(),
- "Creates (but don’t start) a data transmission to that mailbox.")
+ py::call_guard<py::gil_scoped_release>(), "Creates (but don’t start) a data transmission to that mailbox.")
.def(
"get",
[](Mailbox* self) {
#define SIMGRID_KERNEL_ACTIVITY_MAILBOX_HPP
#include <boost/circular_buffer.hpp>
-#include <xbt/string.hpp>
#include "simgrid/s4u/Engine.hpp"
#include "simgrid/s4u/Mailbox.hpp"
static constexpr size_t MAX_MAILBOX_SIZE = 10000000;
s4u::Mailbox piface_;
- xbt::string name_;
+ std::string name_;
actor::ActorImplPtr permanent_receiver_; // actor to which the mailbox is attached
boost::circular_buffer_space_optimized<CommImplPtr> comm_queue_{MAX_MAILBOX_SIZE};
// messages already received in the permanent receive mode
const s4u::Mailbox* get_iface() const { return &piface_; }
s4u::Mailbox* get_iface() { return &piface_; }
- const xbt::string& get_name() const { return name_; }
+ const std::string& get_name() const { return name_; }
const char* get_cname() const { return name_.c_str(); }
void set_receiver(s4u::ActorPtr actor);
void push(CommImplPtr comm);
return (self_context != nullptr) ? self_context->get_actor() : nullptr;
}
-ActorImpl::ActorImpl(xbt::string name, s4u::Host* host, aid_t ppid)
+ActorImpl::ActorImpl(std::string name, s4u::Host* host, aid_t ppid)
: ActorIDTrait(std::move(name), ppid), host_(host), piface_(this)
{
simcall_.issuer_ = this;
throw HostFailureException(XBT_THROW_POINT, "Cannot attach actor on failed host.");
}
- auto* actor = new ActorImpl(xbt::string(name), host, /*ppid*/ -1);
+ auto* actor = new ActorImpl(std::string(name), host, /*ppid*/ -1);
/* Actor data */
actor->piface_.set_data(data);
actor->code_ = nullptr;
ActorImplPtr ActorImpl::init(const std::string& name, s4u::Host* host) const
{
- auto* actor = new ActorImpl(xbt::string(name), host, get_pid());
+ auto* actor = new ActorImpl(name, host, get_pid());
intrusive_ptr_add_ref(actor);
/* The on_creation() signal must be delayed until there, where the pid and everything is set */
ActorImplPtr actor;
if (parent_actor != nullptr)
- actor = parent_actor->init(xbt::string(name), host);
+ actor = parent_actor->init(name, host);
else
- actor = self()->init(xbt::string(name), host);
+ actor = self()->init(name, host);
actor->piface_.set_data(data); /* actor data */
{
auto* engine = EngineImpl::get_instance();
/* Create maestro actor and initialize it */
- auto* maestro = new ActorImpl(xbt::string(""), /*host*/ nullptr, /*ppid*/ -1);
+ auto* maestro = new ActorImpl(/*name*/ "", /*host*/ nullptr, /*ppid*/ -1);
if (not code) {
maestro->context_.reset(engine->get_context_factory()->create_context(ActorCode(), maestro));
/*------------------------- [ ActorIDTrait ] -------------------------*/
class XBT_PUBLIC ActorIDTrait {
- xbt::string name_;
- aid_t pid_ = 0;
- aid_t ppid_ = -1;
+ std::string name_;
+ aid_t pid_ = 0;
+ aid_t ppid_ = -1;
static unsigned long maxpid_;
public:
explicit ActorIDTrait(const std::string& name, aid_t ppid);
- const xbt::string& get_name() const { return name_; }
+ const std::string& get_name() const { return name_; }
const char* get_cname() const { return name_.c_str(); }
aid_t get_pid() const { return pid_; }
aid_t get_ppid() const { return ppid_; }
friend activity::MailboxImpl;
public:
- ActorImpl(xbt::string name, s4u::Host* host, aid_t ppid);
+ ActorImpl(std::string name, s4u::Host* host, aid_t ppid);
ActorImpl(const ActorImpl&) = delete;
ActorImpl& operator=(const ActorImpl&) = delete;
~ActorImpl();
return std::string("CommWait(comm_id:") + ptr_to_id<activity::CommImpl const>(comm) +
" src:" + std::to_string(comm->src_actor_ != nullptr ? comm->src_actor_->get_pid() : -1) +
" dst:" + std::to_string(comm->dst_actor_ != nullptr ? comm->dst_actor_->get_pid() : -1) +
- " mbox:" + std::string(comm->get_mailbox() == nullptr ? xbt::string("-") : comm->get_mailbox()->get_name()) +
+ " mbox:" + std::string(comm->get_mailbox() == nullptr ? std::string("-") : comm->get_mailbox()->get_name()) +
"(id:" + std::to_string(comm->get_mailbox_id()) + ") srcbuf:" + src_buff_id + " dstbuf:" + dst_buff_id +
" bufsize:" + std::to_string(comm->src_buff_size_) + ")";
} else {
class WifiLinkImpl : public StandardLinkImpl {
/** @brief Hold every rates association between host and links (host name, rates id) */
- std::map<xbt::string, int> host_rates_;
+ std::map<std::string, int> host_rates_;
/** @brief A link can have several bandwidths attached to it (mostly use by wifi model) */
std::vector<Metric> bandwidths_;
#include "src/mc/remote/RemotePtr.hpp"
#include "src/mc/sosp/PageStore.hpp"
#include "xbt/base.h"
-#include "xbt/string.hpp"
#include <memory>
#include <set>
class ModelChecker {
CheckerSide checker_side_;
/** String pool for host names */
- std::set<xbt::string, std::less<>> hostnames_;
+ std::set<std::string, std::less<>> hostnames_;
// This is the parent snapshot of the current state:
PageStore page_store_{500};
std::unique_ptr<RemoteProcess> remote_process_;
Channel& channel() { return checker_side_.get_channel(); }
PageStore& page_store() { return page_store_; }
- xbt::string const& get_host_name(const char* hostname)
+ std::string const& get_host_name(const char* hostname)
{
- return *this->hostnames_.insert(xbt::string(hostname)).first;
+ return *this->hostnames_.insert(std::string(hostname)).first;
}
void start();
Remote<kernel::actor::ActorImpl> copy;
/** Hostname (owned by `mc_model_checker->hostnames_`) */
- const xbt::string* hostname = nullptr;
- xbt::string name;
+ const std::string* hostname = nullptr;
+ std::string name;
void clear()
{
return self == nullptr || kernel::EngineImpl::get_instance()->is_maestro(self);
}
-const simgrid::xbt::string& Actor::get_name() const
+const std::string& Actor::get_name() const
{
return this->pimpl_->get_name();
}
return self->get_host();
}
-xbt::string const& Host::get_name() const
+std::string const& Host::get_name() const
{
return this->pimpl_->get_name();
}
namespace simgrid::s4u {
-const xbt::string& Mailbox::get_name() const
+const std::string& Mailbox::get_name() const
{
return pimpl_->get_name();
}
s4u::Host piface_;
std::map<std::string, DiskImpl*, std::less<>> disks_;
std::map<std::string, VirtualMachineImpl*, std::less<>> vms_;
- xbt::string name_{"noname"};
+ std::string name_{"noname"};
routing::NetZoneImpl* englobing_zone_ = nullptr;
bool sealed_ = false;
virtual s4u::Host* get_iface() { return &piface_; }
/** Retrieves the name of that host as a C++ string */
- xbt::string const& get_name() const { return name_; }
+ std::string const& get_name() const { return name_; }
/** Retrieves the name of that host as a C string */
const char* get_cname() const { return name_.c_str(); }
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include <simgrid/config.h>
#include <xbt/string.hpp>
#include <xbt/sysdep.h>
-#include <cstdarg>
-#include <cstdio>
-
namespace simgrid::xbt {
-#if SIMGRID_HAVE_MC
-
-char string::NUL = '\0';
-
-#endif
-
std::string string_vprintf(const char *fmt, va_list ap)
{
// Get the size: