PageRenderTime 35ms CodeModel.GetById 15ms app.highlight 15ms RepoModel.GetById 3ms app.codeStats 0ms

/indra/llmessage/lliopipe.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 120 lines | 72 code | 12 blank | 36 comment | 3 complexity | f328070b50d3a629f579cbf84c458120 MD5 | raw file
  1/** 
  2 * @file lliopipe.cpp
  3 * @author Phoenix
  4 * @date 2004-11-19
  5 * @brief Implementation of the LLIOPipe class
  6 *
  7 * $LicenseInfo:firstyear=2004&license=viewerlgpl$
  8 * Second Life Viewer Source Code
  9 * Copyright (C) 2010, Linden Research, Inc.
 10 * 
 11 * This library is free software; you can redistribute it and/or
 12 * modify it under the terms of the GNU Lesser General Public
 13 * License as published by the Free Software Foundation;
 14 * version 2.1 of the License only.
 15 * 
 16 * This library is distributed in the hope that it will be useful,
 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 19 * Lesser General Public License for more details.
 20 * 
 21 * You should have received a copy of the GNU Lesser General Public
 22 * License along with this library; if not, write to the Free Software
 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 24 * 
 25 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 26 * $/LicenseInfo$
 27 */
 28
 29#include "linden_common.h"
 30#include "lliopipe.h"
 31
 32#include "llpumpio.h"
 33
 34static const std::string STATUS_SUCCESS_NAMES[LLIOPipe::STATUS_SUCCESS_COUNT] =
 35{
 36	std::string("STATUS_OK"),
 37	std::string("STATUS_STOP"),
 38	std::string("STATUS_DONE"),
 39	std::string("STATUS_BREAK"),
 40	std::string("STATUS_NEED_PROCESS"),
 41};
 42
 43static const std::string STATUS_ERROR_NAMES[LLIOPipe::STATUS_ERROR_COUNT] =
 44{
 45	std::string("STATUS_ERROR"),
 46	std::string("STATUS_NOT_IMPLEMENTED"),
 47	std::string("STATUS_PRECONDITION_NOT_MET"),
 48	std::string("STATUS_NO_CONNECTION"),
 49	std::string("STATUS_LOST_CONNECTION"),
 50	std::string("STATUS_EXPIRED"),
 51};
 52
 53#ifdef LL_DEBUG_PUMPS
 54// Debugging schmutz for deadlock
 55const char	*gPumpFile = "";
 56S32			gPumpLine = 0;
 57
 58void pump_debug(const char *file, S32 line)
 59{
 60	gPumpFile = file;
 61	gPumpLine = line;
 62}
 63#endif /* LL_DEBUG_PUMPS */
 64
 65/**
 66 * LLIOPipe
 67 */
 68LLIOPipe::LLIOPipe() :
 69	mReferenceCount(0)
 70{
 71}
 72
 73LLIOPipe::~LLIOPipe()
 74{
 75	//lldebugs << "destroying LLIOPipe" << llendl;
 76}
 77
 78//virtual 
 79bool LLIOPipe::isValid() 
 80{
 81	return true ;
 82}
 83
 84// static
 85std::string LLIOPipe::lookupStatusString(EStatus status)
 86{
 87	if((status >= 0) && (status < STATUS_SUCCESS_COUNT))
 88	{
 89		return STATUS_SUCCESS_NAMES[status];
 90	}
 91	else
 92	{
 93		S32 error_code = ((S32)status * -1) - 1;
 94		if(error_code < STATUS_ERROR_COUNT)
 95		{
 96			return STATUS_ERROR_NAMES[error_code];
 97		}
 98	}
 99	std::string rv;
100	return rv;
101}
102
103LLIOPipe::EStatus LLIOPipe::process(
104	const LLChannelDescriptors& channels,
105	buffer_ptr_t& buffer,
106	bool& eos,
107	LLSD& context,
108	LLPumpIO* pump)
109{
110	return process_impl(channels, buffer, eos, context, pump);
111}
112
113// virtual
114LLIOPipe::EStatus LLIOPipe::handleError(
115	LLIOPipe::EStatus status,
116	LLPumpIO* pump)
117{
118	// by default, the error is not handled.
119	return status;
120}