SocketPolicy.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
222 #ifndef HH_SENF_Socket_SocketPolicy_
223 #define HH_SENF_Socket_SocketPolicy_ 1
224 
225 // Custom includes
226 
227 //#include "SocketPolicy.mpp"
228 //-/////////////////////////////////////////////////////////////////////////////////////////////////
229 
230 namespace senf {
231 
233  //\{
234 
235  // This may be adapted to change the supported policies (however, ClientSocketHandle and
236  // ServerSocketHandle will probably have to be adjusted accordingly)
237 
248 # define SENF_SOCKET_POLICIES \
249  (AddressingPolicy) \
250  (FramingPolicy) \
251  (CommunicationPolicy) \
252  (ReadPolicy) \
253  (WritePolicy)
254 
255  // Wer define these classes explicitly (and not with some macro
256  // magic) because
257  // a) AddressingPolicyBase is different from all the others
258  // b) We want to document each one explicitly
259 
275  struct AddressingPolicyBase
276  {
277  virtual ~AddressingPolicyBase();
279  class Address { Address(); };
280  };
281 
292  struct FramingPolicyBase
293  {
294  virtual ~FramingPolicyBase();
295  };
296 
318  {
319  virtual ~CommunicationPolicyBase();
320  };
321 
344  struct ReadPolicyBase
345  {
346  virtual ~ReadPolicyBase();
348  class Buffer { Buffer(); };
349  };
350 
374  struct WritePolicyBase
375  {
376  virtual ~WritePolicyBase();
378  class Buffer { Buffer(); };
379  };
380 
381  // The implementation file will for each Policy declared above
382  // define the following (SomePolicy is one of the above):
383  //
384  // struct SomePolicyBase;
385  // typedef UndefinedSomePolicy;
386  // template SomePolicyIs< SocketPolicy, Axis >
387  // template IfSomePolicyIs< SocketPolicy, Axis >
388  // template IfSomePolicyIsNot< SocketPolicy, Axis >
389  //
390  // Additionally the following are defined:
391  //
392  // class SocketPolicyBase
393  // template SocketPolicy< ..policies.. >
394  // template MakeSocketPolicy< ..args.. >
395  // template SocketPolicyIsBaseOf< Base, Derived >
396 
397 # ifdef DOXYGEN
398 
399  // The following stub definitions are only visible to doxygen
400 
405 
414  template <class SocketPolicy, class Trait>
415  struct AddressingPolicyIs
416  {};
417 
427  template <class SocketPolicy, class Trait>
428  struct IfAddressingPolicyIs
429  {};
430 
434  template <class SocketPolicy, class Trait>
436  {};
437 
448  struct SocketPolicyBase
449  {
456  AddressingPolicyBase const & theAddressingPolicy() const = 0;
457 
458  virtual ~SocketPolicyBase();
459  };
460 
475  template < class AddressingPolicy >
476  struct SocketPolicy
477  {
493  static void checkBaseOf(SocketPolicyBase const & other);
494  };
495 
505  template <class Arg1, class Arg2, class ArgN>
506  struct MakeSocketPolicy
507  {};
508 
522  template <class Base, class Derived>
523  struct SocketPolicyIsBaseOf
524  {};
525 
526 # endif
527 
528  //\}
529 }
530 
531 //-/////////////////////////////////////////////////////////////////////////////////////////////////
532 #include "SocketPolicy.ih"
533 //#include "SocketPolicy.cci"
534 #include "SocketPolicy.ct"
535 //#include "SocketPolicy.cti"
536 #endif
537 
538 
539 // Local Variables:
540 // mode: c++
541 // fill-column: 100
542 // c-file-style: "senf"
543 // indent-tabs-mode: nil
544 // ispell-local-dictionary: "american"
545 // compile-command: "scons -u test"
546 // comment-column: 40
547 // End:
Enable template overload depending on policy value.
Inversion of IfAddressingPolicyIs.
AddressingPolicyBase UnspecifiedAddressingPolicy
Alias of AddressingPolicyBase for better readability.
Policy defining, how peers are selected.
Policy defining socket addressing.
Check policy compatibility.
Policy defining the readability.
Policy defining the framing format.
Baseclass of all SocketPolicies.
Collection of policy classes.
Policy defining the writability.
Check single policy axis.
Metafunction to create SocketPolicy.