separator.cc

来自「clustering for ns-2 simulation」· CC 代码 · 共 106 行

CC
106
字号
/** * Copyright (c) 2006 Michele Mastrogiovanni. * *   Licensed under the Apache License, Version 2.0 (the "License"); *   you may not use this file except in compliance with the License. *   You may obtain a copy of the License at * *       http://www.apache.org/licenses/LICENSE-2.0 * *   Unless required by applicable law or agreed to in writing, software *   distributed under the License is distributed on an "AS IS" BASIS, *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *   See the License for the specific language governing permissions and *   limitations under the License. * */ #include "Separator.h"Separator* Separator::instance_;static class SeparatorClass : public TclClass {public:    SeparatorClass() : TclClass("Utility/SEPARATOR") {}    TclObject* create(int , const char*const* ) {        return(new Separator());    }} class_separator_utility;void Separator::recv(Packet *p, Handler *h){}Separator::Separator() : TclObject(){	indexCurrentModule = -1;	instance_ = this;}//// Lancia il modulo successivo://void Separator::startModule(){	indexCurrentModule++;	for (map<NodeAddress, vector<ClusteringModule *> >::iterator m = modules.begin(); m != modules.end(); m++) {		vector<ClusteringModule *> & v = (m->second);		if (indexCurrentModule < v.size())			v[indexCurrentModule]->startModule();	}}intSeparator::command(int argc, const char * const * argv){	if (argc == 2) {        if (strcmp (argv[1], "start") == 0) {			startModule();            return TCL_OK;        }	}    else if (argc == 4) {        if (strcmp (argv[1], "register") == 0) {			NodeAddress node = atoi(argv[2]);			ClusteringModule * module = (ClusteringModule*)TclObject::lookup(argv[3]);			registerNode(node, module);            return TCL_OK;        }    }	    return TclObject::command(argc, argv);}//// Termina il modulo corrente.// Se tutti i nodi hanno terminato, lancia il modulo// superiore.//voidSeparator::endCurrentModule(NodeAddress node){	endedNodes.insert(node);	if (endedNodes.size() == modules.size()) {		endedNodes.clear();		startModule();	}}//// Registra un modulo per un nodo.//voidSeparator::registerNode(NodeAddress node, ClusteringModule * module){	modules[node].push_back(module);}int Separator::getIndexCurrentModule(){	return indexCurrentModule;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?