-/* $Id: package.cpp,v 1.6 2006-01-11 11:51:50 adam Exp $
- Copyright (c) 2005, Index Data.
+/* This file is part of Metaproxy.
+ Copyright (C) 2005-2011 Index Data
-%LICENSE%
- */
+Metaproxy is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Metaproxy 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 General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
#include "config.hpp"
+#include <metaproxy/package.hpp>
+#include <yaz/snprintf.h>
+#include <yaz/log.h>
+
+#include <sstream>
-#include "package.hpp"
+namespace mp = metaproxy_1;
-yp2::Package::Package()
- : m_route_pos(0), m_data(0)
+mp::Package::Package()
+ : m_route_pos(0)
{
}
-yp2::Package::~Package()
+mp::Package::~Package()
{
delete m_route_pos;
}
-yp2::Package::Package(yp2::Session &session, yp2::Origin &origin)
+mp::Package::Package(mp::Session &session, const mp::Origin &origin)
: m_session(session), m_origin(origin),
- m_route_pos(0), m_data(0)
+ m_route_pos(0)
{
}
-yp2::Package & yp2::Package::copy_filter(const Package &p)
+
+mp::Package & mp::Package::copy_filter(const Package &p)
{
+ delete m_route_pos;
m_route_pos = p.m_route_pos->clone();
return *this;
}
-void yp2::Package::move()
+void mp::Package::move()
{
if (m_route_pos)
{
}
}
-void yp2::Package::move(std::string route)
+void mp::Package::move(std::string route)
{
if (m_route_pos)
{
}
-yp2::Session & yp2::Package::session()
+mp::Session & mp::Package::session()
{
return m_session;
}
-
-int yp2::Package::data() const
-{
- return m_data;
-}
-
-int & yp2::Package::data()
-{
- return m_data;
-}
-
-yp2::Package & yp2::Package::data(const int & data)
-{
- m_data = data;
- return *this;
-}
-
-yp2::Origin yp2::Package::origin() const
+mp::Origin mp::Package::origin() const
{
return m_origin;
}
-
-yp2::Origin & yp2::Package::origin()
+
+mp::Origin & mp::Package::origin()
{
return m_origin;
}
-yp2::Package & yp2::Package::origin(const Origin & origin)
-{
- m_origin = origin;
- return *this;
-}
-
-yp2::Package & yp2::Package::router(const yp2::Router &router)
+mp::Package & mp::Package::router(const mp::Router &router)
{
m_route_pos = router.createpos();
return *this;
}
-yazpp_1::GDU &yp2::Package::request()
+yazpp_1::GDU &mp::Package::request()
{
return m_request_gdu;
}
-yazpp_1::GDU &yp2::Package::response()
+yazpp_1::GDU &mp::Package::response()
{
return m_response_gdu;
}
-yp2::Session yp2::Package::session() const
+mp::Session mp::Package::session() const
{
return m_session;
}
+
+std::ostream& std::operator<<(std::ostream& os, const mp::Package& p)
+{
+ os << p.origin() << " ";
+ os << p.session().id();
+ return os;
+}
+
+void mp::Package::log(const char *module, int level, const char *fmt, ...) const
+{
+ char buf[4096];
+ va_list ap;
+ va_start(ap, fmt);
+
+ yaz_vsnprintf(buf, sizeof(buf)-30, fmt, ap);
+
+ std::ostringstream os;
+
+ os << module << " " << *this << " " << buf;
+
+ va_end(ap);
+ yaz_log(level, "%s", os.str().c_str());
+}
/*
* Local variables:
* c-basic-offset: 4
+ * c-file-style: "Stroustrup"
* indent-tabs-mode: nil
- * c-file-style: "stroustrup"
* End:
* vim: shiftwidth=4 tabstop=8 expandtab
*/
+