X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FSocketPolicy.hh;h=39d358e9b45c170ae5bbf5aa9a79243dcfa992ec;hb=1374f1e71bb61c93f6ec354fc10a932d10ee1c3c;hp=3509acc71311c7279bc17a02b5189f5d37367ebb;hpb=f73fa16ed5abdce272ac77f8b8b9ef2b9922c266;p=senf.git diff --git a/Socket/SocketPolicy.hh b/Socket/SocketPolicy.hh index 3509acc..39d358e 100644 --- a/Socket/SocketPolicy.hh +++ b/Socket/SocketPolicy.hh @@ -1,8 +1,8 @@ // $Id:SocketPolicy.hh 218 2007-03-20 14:39:32Z tho $ // // Copyright (C) 2006 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -23,33 +23,25 @@ /** \file \brief Policy Framework public header - \todo We should probably remove BufferingPolicy from the interface, it does not make much sense - (how did I come to include it ??) - - \todo Do we want to support separate read and write policies. This allows to treat pipes within - this framework however, is this worth the effort? - - \idea Creating a new Socket will create 4 (!) new instances (The handle, the body, the policy - and the protocol) of which 3 (argh) (body, policy and protocol) live on the heap. This is - expensive. We should convert all the policy classes to singletons and assign the same - instance to all socket bodies with the same policy. This would reduce the number of heap - allocations per socket handle to two. + \idea Creating a new Socket will create 3 new instances (The handle, the body, the policy) of + which 2 (argh) (body, policy) live on the heap. This is expensive. We should convert all the + policy classes to singletons and assign the same instance to all socket bodies with the same + policy. This would reduce the number of heap allocations per socket handle to one (which is + already optimized using the pool_alloc_mixin) */ /** \defgroup policy_group The Policy Framework - \htmlonly - - SocketPolicy - BufferingPolicyBase - WritePolicyBase - ReadPolicyBase - CommunicationPolicyBase - FramingPolicyBase - AddressingPolicyBase - - Socket Policy - \endhtmlonly +
+ \ref WritePolicyBase + \ref AddressingPolicyBase + \ref FramingPolicyBase + \ref PolicyBase + \ref SocketPolicy + \ref CommunicationPolicyBase + \ref ReadPolicyBase +
+ \htmlonly SocketPolicy \endhtmlonly \section policy_group_introduction Introduction to the Policy Framework @@ -69,10 +61,7 @@
readPolicy
configures the readability of the socket
-
writePolicy
configures the writability of the socket
- -
bufferingPolicy
configures, if and how buffering is configured for a - socket
+
writePolicy
configures the writability of the socket
The template senf::SocketPolicy combines these policy axis to form a concrete socket policy. In a concrete policy, each of these policy axis is assigned a value, the policy value. This value @@ -112,7 +101,7 @@ separately but at the same time for each policy axis: \code - // This defines an incomplete policy where addressingPolicy, writePolicy and bufferingPolicy + // This defines an incomplete policy where addressingPolicy and writePolicy // are unspecified typedef senf::MakeSocketPolicy< senf::StreamFramingPolicy, @@ -128,8 +117,7 @@ // StreamFramingPolicy, // ConnectedCommunicationPolicy, // ReadablePolicy, - // WritablePolicy, - // SocketBufferingPolicy>::policy + // WritablePolicy>::policy senf::TCPv4ClientSocketHandle tcpHandle (...); MyReadableHandle myHandle (tcpHandle); // Conversion to more basic socket handle @@ -144,7 +132,7 @@ In the following discussion we will use the following conventions: \li \e Axis is one or \c AddressingPolicy, \c FramingPolicy, \c CommunicationPolicy, \c - ReadPolicy, \c WritePolicy or \c BufferingPolicy + ReadPolicy or \c WritePolicy \li \e socketPolicy is any socket policy (that is, an instantiation of the SocketPolicy template) \li \e trait is an any policy class (that is, any class derived from one of the axis base @@ -176,7 +164,7 @@ derives from SocketPolicyBase. This is simpler than checking the template directly).
\c template \c SocketPolicy < \e addressingPolicy, \e framingPolicy, \e communicationPolicy, - \e readPolicy, \e writePolicy, \e bufferingPolicy >
This is the central SocketPolicy + \e readPolicy, \e writePolicy >
This is the central SocketPolicy template. It combines a complete set of policy classes, one for each axis.
\c template \c MakeSocketPolicy < \e args >
\c MakeSocketPolicy is a template @@ -197,10 +185,10 @@ \section policy_implement Implementing Policy Classes - To define a new policy class, derive from the corresponding base class for your policy - axes. The only policy axis which might possibly need to be extended are the addressing policy - (AddressingPolicyBase) and the buffering policy (BufferingPolicyBase). See the Documentation of - these classes for more information on which members can be implemented. + To define a new policy class, derive from the corresponding base class for your policy axes. The + only policy axis which might possibly need to be extended is the addressing policy + (AddressingPolicyBase). See the Documentation of these classes for more information on which + members can be implemented. All members you define must be static. For any of the policy classes, you must only define those members which are supported by your implementation. If you leave out a member you automatically @@ -218,10 +206,10 @@ \code struct ExampleAddressingPolicy { - template - void connect(senf::SocketHandle handle, Address & addr, + template + void connect(senf::SocketHandle handle, Address & addr, typename senf::IfCommmunicationPolicyIs< - Policy, senf::ConnectedCommunicationPolicy>::type * = 0); + SPolicy, senf::ConnectedCommunicationPolicy>::type * = 0); }; \endcode @@ -280,8 +268,7 @@ namespace senf { (FramingPolicy) \ (CommunicationPolicy) \ (ReadPolicy) \ - (WritePolicy) \ - (BufferingPolicy) + (WritePolicy) // Wer define these classes explicitly (and not with some macro // magic) because @@ -305,7 +292,7 @@ namespace senf { */ struct AddressingPolicyBase { - virtual ~AddressingPolicyBase() {} + virtual ~AddressingPolicyBase(); class Address { Address(); }; }; @@ -322,7 +309,7 @@ namespace senf { */ struct FramingPolicyBase { - virtual ~FramingPolicyBase() {} + virtual ~FramingPolicyBase(); }; /** \brief Policy defining, how peers are selected @@ -347,7 +334,7 @@ namespace senf { */ struct CommunicationPolicyBase { - virtual ~CommunicationPolicyBase() {} + virtual ~CommunicationPolicyBase(); }; /** \brief Policy defining the readability @@ -370,7 +357,7 @@ namespace senf { */ struct ReadPolicyBase { - virtual ~ReadPolicyBase() {} + virtual ~ReadPolicyBase(); }; /** \brief Policy defining the writability @@ -393,19 +380,7 @@ namespace senf { */ struct WritePolicyBase { - virtual ~WritePolicyBase() {} - }; - - /** \brief Policy defining the buffering interface - - The BufferingPolicy defines the buffer handling of the socket. It may provide the following - members: - - \see policy_group - */ - struct BufferingPolicyBase - { - virtual ~BufferingPolicyBase() {} + virtual ~WritePolicyBase(); }; // The implementation file will for each Policy declared above