explicit NetZone(NetZone * father, const char* name);
virtual ~NetZone();
+ std::vector<Host*>* hosts_ = nullptr;
public:
/** @brief Seal your netzone once you're done adding content, and before routing stuff through it */
NetZone* father();
xbt_dict_t children(); // Sub netzones
- std::vector<Host*> hosts(); // my content as a vector of hosts
+ std::vector<Host*>* hosts(); // my content as a vector of hosts
/** Get the properties assigned to a host */
std::unordered_map<std::string, std::string>* properties();
simgrid::s4u::NetZone* as = jnetzone_get_native(env, jas);
jclass cls = jxbt_get_class(env, "org/simgrid/msg/Host");
- std::vector<sg_host_t> table = as->hosts();
+ std::vector<sg_host_t>* table = as->hosts();
if (!cls)
return nullptr;
- jtable = env->NewObjectArray(static_cast<jsize>(table.size()), cls, nullptr);
+ jtable = env->NewObjectArray(static_cast<jsize>(table->size()), cls, nullptr);
if (!jtable) {
jxbt_throw_jni(env, "Hosts table allocation failed");
}
int index = 0;
- for (auto host : table) {
+ for (auto host : *table) {
jhost = static_cast<jobject>(host->extension(JAVA_HOST_LEVEL));
if (!jhost) {
jname = env->NewStringUTF(host->cname());
{
xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t), nullptr);
- for (auto host : netzone->hosts()) {
+ for (auto host : *netzone->hosts()) {
xbt_dynar_push(res, &host);
}
NetZone::NetZone(NetZone* father, const char* name) : father_(father), name_(xbt_strdup(name))
{
+ for (auto card : vertices_) {
+ s4u::Host* host = simgrid::s4u::Host::by_name_or_null(card->name());
+ if (host != nullptr)
+ hosts_->push_back(host);
+ }
}
+
void NetZone::seal()
{
sealed_ = true;
return father_;
}
-std::vector<s4u::Host*> NetZone::hosts()
+std::vector<s4u::Host*>* NetZone::hosts()
{
- std::vector<s4u::Host*> res;
-
- for (auto card : vertices_) {
- s4u::Host* host = simgrid::s4u::Host::by_name_or_null(card->name());
- if (host != nullptr)
- res.push_back(host);
- }
- return res;
+ return hosts_;
}
int NetZone::addComponent(kernel::routing::NetPoint* elm)