gav_aux.cc
来自「certi-SHM-3.0.tar 不错的开源的分布式方针软件 大家多多支持 他」· CC 代码 · 共 635 行 · 第 1/2 页
CC
635 行
// -*- mode:C++ ; tab-width:4 ; c-basic-offset:4 ; indent-tabs-mode:nil -*-// ----------------------------------------------------------------------------// CERTI - HLA RunTime Infrastructure// Copyright (C) 2002, 2003 ONERA//// This file is part of CERTI-libCERTI//// CERTI-libCERTI is free software ; you can redistribute it and/or// modify it under the terms of the GNU Lesser General Public License// as published by the Free Software Foundation ; either version 2 of// the License, or (at your option) any later version.//// CERTI-libCERTI is distributed in the hope that it will be useful, but// WITHOUT ANY WARRANTY ; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU// Lesser General Public License for more details.//// You should have received a copy of the GNU Lesser General Public// License along with this program ; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307// USA//// $Id: GAV_aux.cc,v 3.8 2003/02/19 18:07:29 breholee Exp $// ----------------------------------------------------------------------------#include "GAV.hh"// ----------------------------------------------------------------------------// AttributeHandleValuePair// ----------------------------------------------------------------------------namespace certi {// ----------------------------------------------------------------------------AttributeHandleValuePair::AttributeHandleValuePair(Handle handle, const char *value, ULong value_length){ _handle = handle ; _valueLength = value_length ; _value = (char *)malloc(value_length); memcpy(_value, value, value_length);}// ----------------------------------------------------------------------------AttributeHandleValuePair::~AttributeHandleValuePair(void){ delete _value ;}// ----------------------------------------------------------------------------// AttributeHandleValuePairSetImp// ----------------------------------------------------------------------------AttributeHandleValuePairSetImp::~AttributeHandleValuePairSetImp(void){ empty();}// ----------------------------------------------------------------------------inline ULongAttributeHandleValuePairSetImp::size(void) const{ return list<AttributeHandleValuePair *>::size();}// ----------------------------------------------------------------------------HandleAttributeHandleValuePairSetImp::getHandle(ULong i) const throw (ArrayIndexOutOfBounds){ list<AttributeHandleValuePair *>::const_iterator j = begin(); for (ULong k = 0 ; j != end(); j++, k++) { if (i == k) return (*j)->_handle ; } throw ArrayIndexOutOfBounds();}// ----------------------------------------------------------------------------ULongAttributeHandleValuePairSetImp::getValueLength(ULong i) const throw (ArrayIndexOutOfBounds){ list<AttributeHandleValuePair *>::const_iterator j = begin(); for (ULong k = 0 ; j != end(); j++, k++) { if (i == k) return (*j)->_valueLength ; } throw ArrayIndexOutOfBounds();}// ----------------------------------------------------------------------------voidAttributeHandleValuePairSetImp::getValue(ULong i, char *buff, ULong& value_length) const throw (ArrayIndexOutOfBounds){ list<AttributeHandleValuePair *>::const_iterator j = begin(); for (ULong k = 0 ; j != end(); j++, k++) { if (i == k) { value_length = (*j)->_valueLength ; memcpy(buff, (*j)->_value, (*j)->_valueLength); return ; } } throw ArrayIndexOutOfBounds();}// ----------------------------------------------------------------------------char *AttributeHandleValuePairSetImp::getValuePointer(ULong i, ULong& value_length) const throw (ArrayIndexOutOfBounds){ list<AttributeHandleValuePair *>::const_iterator j = begin(); for (ULong k = 0 ; j != end(); j++, k++) { if (i == k) { value_length = (*j)->_valueLength ; return (*j)->_value ; } } throw ArrayIndexOutOfBounds();}// ----------------------------------------------------------------------------inline TransportTypeAttributeHandleValuePairSetImp::getTransportType(ULong) const throw (ArrayIndexOutOfBounds, InvalidHandleValuePairSetContext){ return _transport ;}// ----------------------------------------------------------------------------inline OrderTypeAttributeHandleValuePairSetImp::getOrderType(ULong) const throw (ArrayIndexOutOfBounds, InvalidHandleValuePairSetContext){ return _order ;}// ----------------------------------------------------------------------------Region*AttributeHandleValuePairSetImp::getRegion(ULong) const throw (ArrayIndexOutOfBounds, InvalidHandleValuePairSetContext, UnimplementedService)//CERTI{ throw UnimplementedService();}// ----------------------------------------------------------------------------voidAttributeHandleValuePairSetImp::add(Handle h, const char *buff, ULong value_length) throw (ValueLengthExceeded, ValueCountExceeded){ AttributeHandleValuePair *ahvp ; ahvp = new AttributeHandleValuePair(h, buff, value_length); push_front(ahvp);}// ----------------------------------------------------------------------------voidAttributeHandleValuePairSetImp::remove(Handle h) throw (ArrayIndexOutOfBounds){ list<AttributeHandleValuePair *>::iterator j ; for (j = begin(); j != end(); j++) { if ((*j)->_handle == h) { delete (*j); erase(j); return ; } } throw ArrayIndexOutOfBounds();}// ----------------------------------------------------------------------------voidAttributeHandleValuePairSetImp::moveFrom(const AttributeHandleValuePairSet&, ULong&) throw (ValueCountExceeded, ArrayIndexOutOfBounds, UnimplementedService) //CERTI{ throw UnimplementedService();}// ----------------------------------------------------------------------------voidAttributeHandleValuePairSetImp::empty(void){ while (!list<AttributeHandleValuePair *>::empty()) { delete front(); pop_front(); }}// ----------------------------------------------------------------------------ULongAttributeHandleValuePairSetImp::start(void) const{ //not implemented return 0 ;}// ----------------------------------------------------------------------------ULongAttributeHandleValuePairSetImp::valid(ULong) const{ //not implemented return 0 ;}// ----------------------------------------------------------------------------ULongAttributeHandleValuePairSetImp::next(ULong) const{ //not implemented return 0 ;}// ----------------------------------------------------------------------------// AttributeSetFactory// ----------------------------------------------------------------------------AttributeHandleValuePairSet*AttributeSetFactory::create(ULong) throw (MemoryExhausted, ValueCountExceeded, HandleValuePairMaximumExceeded){ AttributeHandleValuePairSetImp *ahvps ; ahvps = new AttributeHandleValuePairSetImp ; ahvps->_order = RECEIVE ; ahvps->_transport = RELIABLE ; return (AttributeHandleValuePairSet *) ahvps ;}// ----------------------------------------------------------------------------// AttributeHandleSetImp// ----------------------------------------------------------------------------AttributeHandleSetImp::~AttributeHandleSetImp(void){ empty();}// ----------------------------------------------------------------------------inline ULongAttributeHandleSetImp::size(void) const{ return list<AttributeHandle>::size();}// ----------------------------------------------------------------------------AttributeHandleAttributeHandleSetImp::getHandle(ULong i) const throw (ArrayIndexOutOfBounds){ list<AttributeHandle>::const_iterator h ; ULong j ; for (j = 0, h = begin(); h != end(); h++, j++) { if (i == j) return (*h); } throw ArrayIndexOutOfBounds();}// ----------------------------------------------------------------------------voidAttributeHandleSetImp::add(AttributeHandle h) throw (ArrayIndexOutOfBounds, AttributeNotDefined){ push_front(h);}// ----------------------------------------------------------------------------voidAttributeHandleSetImp::remove(AttributeHandle h) throw (AttributeNotDefined)// not guaranteed safe while iterating{ if (isMember(h) == RTI_TRUE) list<AttributeHandle>::remove(h); else throw AttributeNotDefined();}// ----------------------------------------------------------------------------voidAttributeHandleSetImp::empty(void){ list<AttributeHandle>::clear();}// ----------------------------------------------------------------------------inline BooleanAttributeHandleSetImp::isEmpty(void) const{ return ((list<AttributeHandle>::empty()) ? RTI_TRUE : RTI_FALSE);}// ----------------------------------------------------------------------------BooleanAttributeHandleSetImp::isMember(AttributeHandle h) const{ list<AttributeHandle>::const_iterator result = find(begin(), end(), h); if (result == end()) return RTI_FALSE ; else return RTI_TRUE ;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?