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

📄 scheduler-group.cc

📁 obs网络试验平台
💻 CC
字号:
/* Copyright (c) University of Maryland, Baltimore County, 2003. * Original Authors: Ramakrishna Shenai, Sunil Gowda and Krishna Sivalingam. * * This software is developed at the University of Maryland, Baltimore County under * grants from Cisco Systems Inc and the University of Maryland, Baltimore County. * * Permission to use, copy, modify, and distribute this software and its * documentation in source and binary forms for non-commercial purposes * and without fee is hereby granted, provided that the above copyright * notice appear in all copies and that both the copyright notice and * this permission notice appear in supporting documentation. and that * any documentation, advertising materials, and other materials related * to such distribution and use acknowledge that the software was * developed by the University of Maryland, Baltimore County.  The name of * the University may not be used to endorse or promote products derived from * this software without specific prior written permission. * * Copyright (C) 2000-2003 Washington State University. All rights reserved. * This software was originally developed at Alcatel USA and subsequently modified * at Washington State University, Pullman, WA  through research work which was * supported by Alcatel USA, Inc and Cisco Systems Inc. * The  following notice is in adherence to the Washington State University * copyright policy follows. * * License is granted to copy, to use, and to make and to use derivative * works for research and evaluation purposes, provided that Washington * State University is acknowledged in all documentation pertaining to any such * copy or derivative work. Washington State University grants no other * licenses expressed or implied. The Washington State University name * should not be used in any advertising without its written permission. * * WASHINGTON STATE UNIVERSITY MAKES NO REPRESENTATIONS CONCERNING EITHER * THE MERCHANTABILITY OF THIS SOFTWARE OR THE SUITABILITY OF THIS SOFTWARE * FOR ANY PARTICULAR PURPOSE.  The software is provided "as is" *  without express or implied warranty of any kind. These notices must * be retained in any copies of any part of this software. *///#include "scheduler-group.h"//GMG -- changed include to classifier-base.h, which itself includes//       scheduler-group.h.  Must do it this way because//       BaseClassifier class contains a Scheduler_group object;//       must have BaseClassifier defined first.  If include//       scheduler group first, that will include lauc-scheduler,//       which inlcudes classifier base.#include "../classifier/classifier-base.h"Scheduler_group::Scheduler_group()  {    currsize_ = 0;    slot_ = NULL;    add_slots( default_size );}Scheduler_group::~Scheduler_group() {    delete[] slot_;}// install the NsObject at the specified slotvoid Scheduler_group::install( LaucScheduler *obj, u_int slot ) {    if( slot >= currsize_ )        add_slots( slot + 1 );    slot_[slot] = obj;}// install NsObject ptr at the next available slotvoid Scheduler_group::install( LaucScheduler *obj ) {    install( obj, getNext() );}// return the object specified by the slot number or NULLLaucScheduler* Scheduler_group::getObject( u_int slot ) {    if( slot >= currsize_ )        return NULL;    if( slot_[slot] == 0  )        return NULL;    return ( slot_[slot] );}// search for a base scheduler based upon its dest-node-idLaucScheduler* Scheduler_group::search( u_int dest_id ) {    LaucScheduler *result = NULL;    for( u_int i = 0; i < currsize_; i++ ) {        if( slot_[i] != NULL )        if( slot_[i] != 0 ) {            result = slot_[i];            if( result->destNodeId() == dest_id )                return result;            result = NULL;        }    }    return result;}// protected methodsvoid Scheduler_group::add_slots( u_int nslots ) {    assert( nslots > 0 );    int n = currsize_;    currsize_ += nslots;    LaucScheduler** old = slot_;    slot_ = new LaucScheduler*[currsize_];    memset( slot_, 0, currsize_ * sizeof( LaucScheduler* ) );    if( old != NULL )  {        for( int i = 0; i < n ; i++ )            slot_[i] = old[i];        delete[] old;    }}u_int Scheduler_group::getNext() {    for( u_int i = 0; i < currsize_; i++ )        if( slot_[i] == 0 )            return (i);    // oops ... no more slots available add default_size    // more slots to the slot group and make the function    // call again    add_slots( default_size );    return ( getNext() );}// diagnostic methodvoid Scheduler_group::printInfo(){    for( u_int i = 0; i < currsize_; i++ ) {        LaucScheduler *sc = getObject( i );        if( sc == NULL ) {            cout << "LaucScheduler at slot " << i << " is NULL " << endl;        }        else {            cout << "Destination node id is: "<< sc->destNodeId() << endl;            for( u_int j = 0; j < sc->maxChannels(); j++ )                sc->printChInfo( j );        }        cout << "printed information for laucscheduler at slot" << i << endl;    }}/*void main() {    Scheduler_group sg;    NsObject *p = new NsObject;    p->setId( 9000 );    sg.install( p, 3 );    for( int i = 0; i < 13; i++ )   {        NsObject *n = new NsObject;        n->setId( i );        sg.install( n );    }    for( int i = 0; i < 13; i++ )   {        NsObject *n = sg.getObject( i );        cout << "id" << n->getId() << endl;    }} */

⌨️ 快捷键说明

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