Skip to content
Snippets Groups Projects
Commit b574efa9 authored by sbund's avatar sbund
Browse files

Basisframework abgeschlossen

parent 91b52a9f
No related branches found
No related tags found
No related merge requests found
...@@ -96,62 +96,73 @@ prefix_ bool satcom::lib::FileBody::ok() ...@@ -96,62 +96,73 @@ prefix_ bool satcom::lib::FileBody::ok()
prefix_ void satcom::lib::FileHandle::close() prefix_ void satcom::lib::FileHandle::close()
{ {
body_->close(); body().close();
} }
prefix_ void satcom::lib::FileHandle::terminate() prefix_ void satcom::lib::FileHandle::terminate()
{ {
body_->terminate(); body().terminate();
} }
prefix_ void satcom::lib::FileHandle::flush() prefix_ void satcom::lib::FileHandle::flush()
{ {
body_->flush(); body().flush();
} }
prefix_ bool satcom::lib::FileHandle::readable() prefix_ bool satcom::lib::FileHandle::readable()
const const
{ {
return body_->readable(); return body().readable();
} }
prefix_ bool satcom::lib::FileHandle::writeable() prefix_ bool satcom::lib::FileHandle::writeable()
const const
{ {
return body_->writeable(); return body().writeable();
} }
prefix_ bool satcom::lib::FileHandle::valid() prefix_ bool satcom::lib::FileHandle::valid()
const const
{ {
return body_->valid(); return body().valid();
} }
prefix_ satcom::lib::FileHandle::operator bool () prefix_ satcom::lib::FileHandle::operator bool ()
const const
{ {
return body_->ok(); return body().ok();
} }
prefix_ bool satcom::lib::FileHandle::operator!() prefix_ bool satcom::lib::FileHandle::operator!()
const const
{ {
return ! body_->ok(); return ! body().ok();
} }
prefix_ int satcom::lib::FileHandle::fd() prefix_ int satcom::lib::FileHandle::fd()
const const
{ {
return body_->fd(); return body().fd();
} }
prefix_ satcom::lib::FileHandle::FileHandle(std::auto_ptr<FileBody> body) prefix_ satcom::lib::FileHandle::FileHandle(std::auto_ptr<FileBody> body)
: body_(body.release()) : body_(body.release())
{} {}
prefix_ satcom::lib::FileBody & satcom::lib::FileHandle::body()
{
return *body_;
}
prefix_ satcom::lib::FileBody const & satcom::lib::FileHandle::body()
const
{
return *body_;
}
prefix_ int satcom::lib::FileHandle::fd(int fd) prefix_ int satcom::lib::FileHandle::fd(int fd)
{ {
return body_->fd(fd); return body().fd(fd);
} }
///////////////////////////////cci.e/////////////////////////////////////// ///////////////////////////////cci.e///////////////////////////////////////
......
...@@ -74,6 +74,9 @@ namespace lib { ...@@ -74,6 +74,9 @@ namespace lib {
protected: protected:
explicit FileHandle(std::auto_ptr<FileBody> body); explicit FileHandle(std::auto_ptr<FileBody> body);
FileBody & body();
FileBody const & body() const;
int fd(int fd); int fd(int fd);
private: private:
......
// $Id$
//
// Copyright (C) 2006
// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
// Stefan Bund <stefan.bund@fokus.fraunhofer.de>
//
// This program 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 of the License, or
// (at your option) any later version.
//
// This program 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.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Definition of inline template functions
//#include "ProtocolClientSocketHandle.ih"
// Custom includes
#define prefix_ inline
///////////////////////////////cti.p///////////////////////////////////////
template <class SocketProtocol>
prefix_ satcom::lib::ProtocolClientSocketHandle<SocketProtocol>::ProtocolClientSocketHandle()
: ClientSocketHandle<typename SocketProtocol::Policy>(
std::auto_ptr<satcom::lib::SocketProtocol>(new SocketProtocol()))
{}
template <class SocketProtocol>
prefix_ SocketProtocol const &
satcom::lib::ProtocolClientSocketHandle<SocketProtocol>::protocol()
{
BOOST_ASSERT( dynamic_cast<SocketProtocol const *>(&this->body().protocol()) );
return static_cast<SocketProtocol const &>(this->body().protocol());
}
///////////////////////////////cti.e///////////////////////////////////////
#undef prefix_
// Local Variables:
// mode: c++
// c-file-style: "satcom"
// End:
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#define HH_ProtocolClientSocketHandle_ 1 #define HH_ProtocolClientSocketHandle_ 1
// Custom includes // Custom includes
#include "ClientSocketHandle.hh"
//#include "ProtocolClientSocketHandle.mpp" //#include "ProtocolClientSocketHandle.mpp"
///////////////////////////////hh.p//////////////////////////////////////// ///////////////////////////////hh.p////////////////////////////////////////
...@@ -47,24 +48,14 @@ namespace lib { ...@@ -47,24 +48,14 @@ namespace lib {
///\name Structors and default members ///\name Structors and default members
///@{ ///@{
// default default constructor // TODO: Non-default constructors (via argument forwarding
// default copy constructor // to the SocketProtocol::init(...) methods
// default copy assignment ProtocolClientSocketHandle();
// default destructor
// no conversion constructors
///@} ///@}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
///\name Accessors
///@{
///@} Protocol const & protocol();
///////////////////////////////////////////////////////////////////////////
///\name Mutators
///@{
///@}
protected: protected:
...@@ -77,7 +68,7 @@ namespace lib { ...@@ -77,7 +68,7 @@ namespace lib {
///////////////////////////////hh.e//////////////////////////////////////// ///////////////////////////////hh.e////////////////////////////////////////
//#include "ProtocolClientSocketHandle.cci" //#include "ProtocolClientSocketHandle.cci"
//#include "ProtocolClientSocketHandle.ct" //#include "ProtocolClientSocketHandle.ct"
//#include "ProtocolClientSocketHandle.cti" #include "ProtocolClientSocketHandle.cti"
#endif #endif
......
// $Id$
//
// Copyright (C) 2006
// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
// Stefan Bund <stefan.bund@fokus.fraunhofer.de>
//
// This program 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 of the License, or
// (at your option) any later version.
//
// This program 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.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Unit tests
//#include "ProtocolClientSocketHandle.test.hh"
//#include "ProtocolClientSocketHandle.test.ih"
// Custom includes
#include "ProtocolClientSocketHandle.hh"
#include <boost/test/auto_unit_test.hpp>
#include <boost/test/test_tools.hpp>
#define prefix_
///////////////////////////////cc.p////////////////////////////////////////
namespace {
namespace sl = satcom::lib;
struct INetAddressingPolicy : public sl::AddressingPolicyBase {};
struct UnixAddressingPolicy : public sl::AddressingPolicyBase {};
struct StreamFramingPolicy : public sl::FramingPolicyBase {};
struct DgramFramingPolicy : public sl::FramingPolicyBase {};
struct ConnectedCommunicationPolicy : public sl::CommunicationPolicyBase {};
struct UnconnectedCommunicationPolicy : public sl::CommunicationPolicyBase {};
struct ReadablePolicy : public sl::ReadPolicyBase {};
struct UnreadablePolicy : public sl::ReadPolicyBase {};
struct WritablePolicy : public sl::WritePolicyBase {};
struct UnwritablePolicy : public sl::WritePolicyBase {};
struct SocketBufferingPolicy : public sl::BufferingPolicyBase {};
typedef sl::MakeSocketPolicy<
INetAddressingPolicy,
StreamFramingPolicy,
ConnectedCommunicationPolicy,
ReadablePolicy,
WritablePolicy,
SocketBufferingPolicy
>::policy MyProtocol_Policy;
class MyProtocol
: public sl::ConcreteSocketProtocol<MyProtocol_Policy>
{
public:
~MyProtocol() {}
};
}
BOOST_AUTO_UNIT_TEST(protocolClientSocketHandle)
{
typedef sl::ProtocolClientSocketHandle<MyProtocol> MySocketHandle;
MySocketHandle h;
h.protocol();
}
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
// Local Variables:
// mode: c++
// c-file-style: "satcom"
// End:
// $Id$
//
// Copyright (C) 2006
// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
// Stefan Bund <stefan.bund@fokus.fraunhofer.de>
//
// This program 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 of the License, or
// (at your option) any later version.
//
// This program 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.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Definition of inline template functions
//#include "ProtocolServerSocketHandle.ih"
// Custom includes
#define prefix_ inline
///////////////////////////////cti.p///////////////////////////////////////
template <class SocketProtocol>
prefix_ satcom::lib::ProtocolServerSocketHandle<SocketProtocol>::ProtocolServerSocketHandle()
: ServerSocketHandle<typename SocketProtocol::Policy>(
std::auto_ptr<satcom::lib::SocketProtocol>(new SocketProtocol()))
{}
template <class SocketProtocol>
prefix_ SocketProtocol const &
satcom::lib::ProtocolServerSocketHandle<SocketProtocol>::protocol()
{
BOOST_ASSERT( dynamic_cast<SocketProtocol const *>(&this->body().protocol()) );
return static_cast<SocketProtocol const &>(this->body().protocol());
}
///////////////////////////////cti.e///////////////////////////////////////
#undef prefix_
// Local Variables:
// mode: c++
// c-file-style: "satcom"
// End:
// $Id$
//
// Copyright (C) 2006
// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
// Stefan Bund <stefan.bund@fokus.fraunhofer.de>
//
// This program 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 of the License, or
// (at your option) any later version.
//
// This program 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.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HH_ProtocolServerSocketHandle_
#define HH_ProtocolServerSocketHandle_ 1
// Custom includes
#include "ServerSocketHandle.hh"
//#include "ProtocolServerSocketHandle.mpp"
///////////////////////////////hh.p////////////////////////////////////////
namespace satcom {
namespace lib {
/** \brief
*/
template <class SocketProtocol>
class ProtocolServerSocketHandle
: public ServerSocketHandle<typename SocketProtocol::Policy>
{
public:
///////////////////////////////////////////////////////////////////////////
// Types
typedef SocketProtocol Protocol;
///////////////////////////////////////////////////////////////////////////
///\name Structors and default members
///@{
// TODO: Non-default constructors (via argument forwarding
// to the SocketProtocol::init(...) methods
ProtocolServerSocketHandle();
///@}
///////////////////////////////////////////////////////////////////////////
Protocol const & protocol();
protected:
private:
};
}}
///////////////////////////////hh.e////////////////////////////////////////
//#include "ProtocolServerSocketHandle.cci"
//#include "ProtocolServerSocketHandle.ct"
#include "ProtocolServerSocketHandle.cti"
#endif
// Local Variables:
// mode: c++
// c-file-style: "satcom"
// End:
// $Id$
//
// Copyright (C) 2006
// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
// Stefan Bund <stefan.bund@fokus.fraunhofer.de>
//
// This program 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 of the License, or
// (at your option) any later version.
//
// This program 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.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Unit tests
//#include "ProtocolServerSocketHandle.test.hh"
//#include "ProtocolServerSocketHandle.test.ih"
// Custom includes
#include "ProtocolServerSocketHandle.hh"
#include <boost/test/auto_unit_test.hpp>
#include <boost/test/test_tools.hpp>
#define prefix_
///////////////////////////////cc.p////////////////////////////////////////
namespace {
namespace sl = satcom::lib;
struct INetAddressingPolicy : public sl::AddressingPolicyBase {};
struct UnixAddressingPolicy : public sl::AddressingPolicyBase {};
struct StreamFramingPolicy : public sl::FramingPolicyBase {};
struct DgramFramingPolicy : public sl::FramingPolicyBase {};
struct ConnectedCommunicationPolicy : public sl::CommunicationPolicyBase {};
struct UnconnectedCommunicationPolicy : public sl::CommunicationPolicyBase {};
struct ReadablePolicy : public sl::ReadPolicyBase {};
struct UnreadablePolicy : public sl::ReadPolicyBase {};
struct WritablePolicy : public sl::WritePolicyBase {};
struct UnwritablePolicy : public sl::WritePolicyBase {};
struct SocketBufferingPolicy : public sl::BufferingPolicyBase {};
typedef sl::MakeSocketPolicy<
INetAddressingPolicy,
StreamFramingPolicy,
ConnectedCommunicationPolicy,
ReadablePolicy,
WritablePolicy,
SocketBufferingPolicy
>::policy MyProtocol_Policy;
class MyProtocol
: public sl::ConcreteSocketProtocol<MyProtocol_Policy>
{
public:
~MyProtocol() {}
};
}
BOOST_AUTO_UNIT_TEST(protocolServerSocketHandle)
{
typedef sl::ProtocolServerSocketHandle<MyProtocol> MySocketHandle;
MySocketHandle h;
h.protocol();
}
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
// Local Variables:
// mode: c++
// c-file-style: "satcom"
// End:
...@@ -33,6 +33,12 @@ prefix_ satcom::lib::SocketBody::SocketBody(std::auto_ptr<SocketProtocol> protoc ...@@ -33,6 +33,12 @@ prefix_ satcom::lib::SocketBody::SocketBody(std::auto_ptr<SocketProtocol> protoc
: protocol_(protocol) : protocol_(protocol)
{} {}
prefix_ satcom::lib::SocketProtocol const & satcom::lib::SocketBody::protocol()
const
{
return *protocol_;
}
///////////////////////////////cci.e/////////////////////////////////////// ///////////////////////////////cci.e///////////////////////////////////////
#undef prefix_ #undef prefix_
......
...@@ -56,6 +56,21 @@ prefix_ satcom::lib::SocketHandle<SocketPolicy>::SocketHandle(FileHandle other, ...@@ -56,6 +56,21 @@ prefix_ satcom::lib::SocketHandle<SocketPolicy>::SocketHandle(FileHandle other,
: FileHandle(other) : FileHandle(other)
{} {}
template <class SocketPolicy>
prefix_ satcom::lib::SocketBody & satcom::lib::SocketHandle<SocketPolicy>::body()
{
BOOST_ASSERT( dynamic_cast<SocketBody *>(&FileHandle::body()) );
return static_cast<SocketBody &>(FileHandle::body());
}
template <class SocketPolicy>
prefix_ satcom::lib::SocketBody const & satcom::lib::SocketHandle<SocketPolicy>::body()
const
{
BOOST_ASSERT( dynamic_cast<SocketBody const *>(&FileHandle::body()) );
return static_cast<SocketBody const &>(FileHandle::body());
}
template <class SocketPolicy> template <class SocketPolicy>
prefix_ void satcom::lib::SocketHandle<SocketPolicy>::assign(FileHandle other) prefix_ void satcom::lib::SocketHandle<SocketPolicy>::assign(FileHandle other)
{ {
......
...@@ -75,6 +75,10 @@ namespace lib { ...@@ -75,6 +75,10 @@ namespace lib {
protected: protected:
explicit SocketHandle(std::auto_ptr<SocketProtocol> protocol); explicit SocketHandle(std::auto_ptr<SocketProtocol> protocol);
SocketHandle(FileHandle other, bool isChecked); SocketHandle(FileHandle other, bool isChecked);
SocketBody & body();
SocketBody const & body() const;
void assign(FileHandle other); void assign(FileHandle other);
private: private:
......
...@@ -55,6 +55,8 @@ namespace lib { ...@@ -55,6 +55,8 @@ namespace lib {
///@} ///@}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
SocketProtocol const & protocol() const;
protected: protected:
private: private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment