⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stackutility.cc

📁 clustering for ns-2 simulation
💻 CC
字号:

/**
 * 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 "StackUtility.h"

static class StackUtilityClass : public TclClass {
public:
    StackUtilityClass() : TclClass("Utility/STACK") {}
    TclObject* create(int , const char*const* ) {
        return(new StackUtility());
    }
} class_stack_utility;

int 
StackUtility::command(int argc, const char * const * argv)
{
    if (argc == 4) {
		//
		// $stack-utility set-module 0 $utility0
		// $stack-utility set-module 1 $utility1
		//
        if (strcmp (argv[1], "set-module") == 0) {
			int num = atoi(argv[2]);
			dumpData[num] = (CommonUtility *) TclObject::lookup(argv[3]);
			if (num > top_module)
				top_module = num;
			if (base_module == -1)
				base_module = num;
			else if (num < base_module)
				base_module = num;
            return (TCL_OK);
        }
	}
	else if (argc == 3) {
		if (strcmp (argv[1], "set-separator") == 0) {
			separator = (Separator *) TclObject::lookup(argv[2]);
			return (TCL_OK);
		}
		else if (strcmp (argv[1], "set-topology-name") == 0) {
			topology = string(argv[2]);
			return TCL_OK;
		}
    }
    
    return CommonUtility::command(argc, argv);
}

void
StackUtility::dump() 
{
	cerr << topology << " - ";
	for (map<int, CommonUtility*>::iterator i = dumpData.begin(); i != dumpData.end();) {
		cout << (i->second)->algorithm;
		cerr << (i->second)->algorithm;
		i++;
		if (i != dumpData.end()) {
			cout << "-";
			cerr << "-";
		}
		else
			cout << " ";
	}
	cerr << endl;
	cout << endl;

	for (map<int, CommonUtility *>::iterator i = dumpData.begin(); i != dumpData.end(); i++)
		(i->second)->dump();
}

void 
StackUtility::addTransmitPacket(double packets, double bytes) { 
	packetsTransmit += packets;
	bytesTransmit += bytes;

	dumpData[separator->getIndexCurrentModule()]->packetsTransmit += packets;
	dumpData[separator->getIndexCurrentModule()]->bytesTransmit += bytes;
}

⌨️ 快捷键说明

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