📄 gav_aux.cc
字号:
// ----------------------------------------------------------------------------// 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.11 2004/03/04 20:19:05 breholee Exp $// ----------------------------------------------------------------------------#include <config.h>#include "GAV.hh"#include "PrettyDebug.hh"#include "converter.hh"#include <algorithm>#include <assert.h>using std::list ;// ----------------------------------------------------------------------------// 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(){ delete _value ;}// ----------------------------------------------------------------------------// AttributeHandleValuePairSetImp// ----------------------------------------------------------------------------AttributeHandleValuePairSetImp::~AttributeHandleValuePairSetImp(){ empty();}// ----------------------------------------------------------------------------ULongAttributeHandleValuePairSetImp::size() 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(){ while (!list<AttributeHandleValuePair *>::empty()) { delete front(); pop_front(); }}// ----------------------------------------------------------------------------ULongAttributeHandleValuePairSetImp::start() 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(){ empty();}// ----------------------------------------------------------------------------inline ULongAttributeHandleSetImp::size() 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(){ list<AttributeHandle>::clear();}// ----------------------------------------------------------------------------inline BooleanAttributeHandleSetImp::isEmpty() 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())
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -