Changeset 16:c92e61e5d244 in rrlib_util


Ignore:
Timestamp:
31.01.2011 10:32:48 (9 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
default
Phase:
public
Convert:
svn:dcce5f72-5200-4218-9373-75d9081937af/trunk@23
Message:

Reformatting to meet code templates

Files:
22 edited

Legend:

Unmodified
Added
Removed
  • fstream/fileno.h

    r4 r16  
    5858 */ 
    5959//---------------------------------------------------------------------- 
    60 #ifndef _rrlib_util_fstream_fileno_h_ 
    61 #define _rrlib_util_fstream_fileno_h_ 
     60#ifndef ___rrlib__util__fstream__fileno_h___ 
     61#define ___rrlib__util__fstream__fileno_h___ 
    6262 
    6363//---------------------------------------------------------------------- 
  • make.xml

    r9 r16  
    2020      patterns/* 
    2121      patterns/command/* 
    22 <!--  patterns/singleton/* --> 
     22      patterns/singleton/* 
     23<!--  patterns/factory/* --> 
    2324    </sources> 
    2425  </rrlib> 
     
    3637  </testprogram> 
    3738 
    38 <!--  
    3939  <testprogram name="singleton_pattern"> 
    4040    <sources> 
     
    4242    </sources> 
    4343  </testprogram> 
    44 --> 
    4544 
    4645  <testprogram name="final_class_pattern"> 
     
    5049  </testprogram> 
    5150 
     51<!--  
     52  <testprogram name="factory_pattern"> 
     53    <sources> 
     54      test/test_factory_pattern.cpp 
     55    </sources> 
     56  </testprogram> 
     57--> 
     58 
    5259</targets> 
  • patterns/command.h

    r6 r16  
    3232 */ 
    3333//---------------------------------------------------------------------- 
    34 #ifndef _rrlib_util_patterns_command_h_ 
    35 #define _rrlib_util_patterns_command_h_ 
     34#ifndef __rrlib__util__patterns__command_h__ 
     35#define __rrlib__util__patterns__command_h__ 
    3636 
    3737//---------------------------------------------------------------------- 
  • patterns/command/tFirstParameterBinder.h

    r6 r16  
    3232 */ 
    3333//---------------------------------------------------------------------- 
    34 #ifndef _rrlib_util_patterns_command_tFirstParameterBinder_h_ 
    35 #define _rrlib_util_patterns_command_tFirstParameterBinder_h_ 
     34#ifndef __rrlib__util__patterns__command__tFirstParameterBinder_h__ 
     35#define __rrlib__util__patterns__command__tFirstParameterBinder_h__ 
    3636 
    3737#include "rrlib/util/patterns/command/tFunctorHandlerBase.h" 
     
    7070class tFirstParameterBinder : public tFunctorHandlerBase<TReturn, TParameterRest...> 
    7171{ 
    72   tFunctor<TReturn, TFirstParameter, TParameterRest...> functor; 
    73   TFirstParameter bound_parameter; 
    7472 
     73//---------------------------------------------------------------------- 
     74// Public methods and typedefs 
     75//---------------------------------------------------------------------- 
    7576public: 
    7677 
     
    8586  } 
    8687 
     88//---------------------------------------------------------------------- 
     89// Private fields and methods 
     90//---------------------------------------------------------------------- 
     91private: 
     92 
     93  tFunctor<TReturn, TFirstParameter, TParameterRest...> functor; 
     94  TFirstParameter bound_parameter; 
    8795}; 
    8896 
  • patterns/command/tFunctor.h

    r6 r16  
    3232 */ 
    3333//---------------------------------------------------------------------- 
    34 #ifndef _rrlib_util_patterns_command_tFunctor_h_ 
    35 #define _rrlib_util_patterns_command_tFunctor_h_ 
     34#ifndef __rrlib__util__patterns__command__tFunctor_h__ 
     35#define __rrlib__util__patterns__command__tFunctor_h__ 
    3636 
    3737//---------------------------------------------------------------------- 
     
    7474{ 
    7575 
    76   std::shared_ptr<tFunctorHandlerBase<TReturn, TParameters...>> handler; 
    77  
    78   tFunctor(); 
    79  
     76//---------------------------------------------------------------------- 
     77// Public methods and typedefs 
     78//---------------------------------------------------------------------- 
    8079public: 
    8180 
     
    103102  } 
    104103 
     104//---------------------------------------------------------------------- 
     105// Private fields and methods 
     106//---------------------------------------------------------------------- 
     107private: 
     108 
     109  std::shared_ptr<tFunctorHandlerBase<TReturn, TParameters...>> handler; 
     110 
     111//  tFunctor(); 
     112 
    105113}; 
    106114 
  • patterns/command/tFunctorChainer.h

    r6 r16  
    3232 */ 
    3333//---------------------------------------------------------------------- 
    34 #ifndef _rrlib_util_patterns_command_tFunctorChainer_h_ 
    35 #define _rrlib_util_patterns_command_tFunctorChainer_h_ 
     34#ifndef __rrlib__util__patterns__command__tFunctorChainer_h__ 
     35#define __rrlib__util__patterns__command__tFunctorChainer_h__ 
    3636 
    3737#include "rrlib/util/patterns/command/tFunctorHandlerBase.h" 
     
    7070class tFunctorChainer : public tFunctorHandlerBase<void> 
    7171{ 
    72   TFirstFunctor first_functor; 
    73   TSecondFunctor second_functor; 
    7472 
     73//---------------------------------------------------------------------- 
     74// Public methods and typedefs 
     75//---------------------------------------------------------------------- 
    7576public: 
    7677 
     
    8687  } 
    8788 
     89//---------------------------------------------------------------------- 
     90// Private fields and methods 
     91//---------------------------------------------------------------------- 
     92private: 
     93 
     94  TFirstFunctor first_functor; 
     95  TSecondFunctor second_functor; 
     96 
    8897}; 
    8998 
  • patterns/command/tFunctorHandler.h

    r6 r16  
    3232 */ 
    3333//---------------------------------------------------------------------- 
    34 #ifndef _rrlib_util_patterns_command_tFunctorHandler_h_ 
    35 #define _rrlib_util_patterns_command_tFunctorHandler_h_ 
     34#ifndef __rrlib__util__patterns__command__tFunctorHandler_h__ 
     35#define __rrlib__util__patterns__command__tFunctorHandler_h__ 
    3636 
    3737#include "rrlib/util/patterns/command/tFunctorHandlerBase.h" 
     
    7171{ 
    7272 
    73   TFunctor functor; 
    74  
     73//---------------------------------------------------------------------- 
     74// Public methods and typedefs 
     75//---------------------------------------------------------------------- 
    7576public: 
    7677 
     
    8485  } 
    8586 
     87//---------------------------------------------------------------------- 
     88// Private fields and methods 
     89//---------------------------------------------------------------------- 
     90private: 
     91 
     92  TFunctor functor; 
     93 
    8694}; 
    8795 
  • patterns/command/tFunctorHandlerBase.h

    r6 r16  
    3232 */ 
    3333//---------------------------------------------------------------------- 
    34 #ifndef _rrlib_util_patterns_command_tFunctorHandlerBase_h_ 
    35 #define _rrlib_util_patterns_command_tFunctorHandlerBase_h_ 
     34#ifndef __rrlib__util__patterns__command__tFunctorHandlerBase_h__ 
     35#define __rrlib__util__patterns__command__tFunctorHandlerBase_h__ 
    3636 
    3737//---------------------------------------------------------------------- 
  • patterns/command/tMemberFunctionHandler.h

    r6 r16  
    3232 */ 
    3333//---------------------------------------------------------------------- 
    34 #ifndef _rrlib_util_patterns_command_tMemberFunctionHandler_h_ 
    35 #define _rrlib_util_patterns_command_tMemberFunctionHandler_h_ 
     34#ifndef __rrlib__util__patterns__command__tMemberFunctionHandler_h__ 
     35#define __rrlib__util__patterns__command__tMemberFunctionHandler_h__ 
    3636 
    3737#include "rrlib/util/patterns/command/tFunctorHandlerBase.h" 
     
    7171{ 
    7272 
    73   TObject &object; 
    74   TFunction function; 
    75  
     73//---------------------------------------------------------------------- 
     74// Public methods and typedefs 
     75//---------------------------------------------------------------------- 
    7676public: 
    7777 
     
    8686  } 
    8787 
     88//---------------------------------------------------------------------- 
     89// Private fields and methods 
     90//---------------------------------------------------------------------- 
     91private: 
     92 
     93  TObject &object; 
     94  TFunction function; 
     95 
    8896}; 
    8997 
  • patterns/final_class.h

    r6 r16  
    3232 */ 
    3333//---------------------------------------------------------------------- 
    34 #ifndef _rrlib_util_patterns_final_class_h_ 
    35 #define _rrlib_util_patterns_final_class_h_ 
     34#ifndef __rrlib__util__patterns__final_class_h__ 
     35#define __rrlib__util__patterns__final_class_h__ 
    3636 
    3737//---------------------------------------------------------------------- 
  • patterns/singleton.h

    r7 r16  
    3232 */ 
    3333//---------------------------------------------------------------------- 
    34 #ifndef _rrlib_util_patterns_singleton_h_ 
    35 #define _rrlib_util_patterns_singleton_h_ 
     34#ifndef __rrlib__util__patterns__singleton_h__ 
     35#define __rrlib__util__patterns__singleton_h__ 
    3636 
    3737//---------------------------------------------------------------------- 
  • patterns/singleton/policies/creation/CreateStatic.h

    r7 r16  
    3232 */ 
    3333//---------------------------------------------------------------------- 
    34 #ifndef _rrlib_util_patterns_singleton_CreateStatic_h_ 
    35 #define _rrlib_util_patterns_singleton_CreateStatic_h_ 
     34#ifndef __rrlib__util__patterns__singleton__policies__creation__CreateStatic_h__ 
     35#define __rrlib__util__patterns__singleton__policies__creation__CreateStatic_h__ 
    3636 
    3737//---------------------------------------------------------------------- 
     
    5555namespace util 
    5656{ 
     57namespace singleton 
     58{ 
     59 
    5760//---------------------------------------------------------------------- 
    5861// Forward declarations / typedefs / enums 
     
    8588} 
    8689} 
     90} 
    8791 
    8892#endif 
  • patterns/singleton/policies/creation/CreateUsingMalloc.h

    r7 r16  
    3232 */ 
    3333//---------------------------------------------------------------------- 
    34 #ifndef _rrlib_util_patterns_singleton_CreateUsingMalloc_h_ 
    35 #define _rrlib_util_patterns_singleton_CreateUsingMalloc_h_ 
     34#ifndef __rrlib__util__patterns__singleton__policies__creation__CreateUsingMalloc_h__ 
     35#define __rrlib__util__patterns__singleton__policies__creation__CreateUsingMalloc_h__ 
    3636 
    3737//---------------------------------------------------------------------- 
     
    5454{ 
    5555namespace util 
     56{ 
     57namespace singleton 
    5658{ 
    5759 
     
    8890} 
    8991} 
     92} 
    9093 
    9194#endif 
  • patterns/singleton/policies/creation/CreateUsingNew.h

    r7 r16  
    3232 */ 
    3333//---------------------------------------------------------------------- 
    34 #ifndef _rrlib_util_patterns_singleton_CreateUsingNew_h_ 
    35 #define _rrlib_util_patterns_singleton_CreateUsingNew_h_ 
     34#ifndef __rrlib__util__patterns__singleton__policies__creation__CreateUsingNew_h__ 
     35#define __rrlib__util__patterns__singleton__policies__creation__CreateUsingNew_h__ 
    3636 
    3737//---------------------------------------------------------------------- 
     
    5454{ 
    5555namespace util 
     56{ 
     57namespace singleton 
    5658{ 
    5759 
     
    8587} 
    8688} 
     89} 
    8790 
    8891#endif 
  • patterns/singleton/policies/lifetime/DefaultLifetime.h

    r7 r16  
    3232 */ 
    3333//---------------------------------------------------------------------- 
    34 #ifndef _rrlib_util_patterns_singleton_DefaultLifetime_h_ 
    35 #define _rrlib_util_patterns_singleton_DefaultLifetime_h_ 
     34#ifndef __rrlib__util__patterns__singleton__policies__lifetime__DefaultLifetime_h__ 
     35#define __rrlib__util__patterns__singleton__policies__lifetime__DefaultLifetime_h__ 
    3636 
    3737//---------------------------------------------------------------------- 
    3838// External includes (system with <>, local with "") 
    3939//---------------------------------------------------------------------- 
     40#include <stdexcept> 
    4041 
    4142//---------------------------------------------------------------------- 
     
    5455{ 
    5556namespace util 
     57{ 
     58namespace singleton 
    5659{ 
    5760 
     
    8588} 
    8689} 
     90} 
    8791 
    8892#endif 
  • patterns/singleton/policies/lifetime/NoDestruction.h

    r7 r16  
    3232 */ 
    3333//---------------------------------------------------------------------- 
    34 #ifndef _rrlib_util_patterns_singleton_NoDestruction_h_ 
    35 #define _rrlib_util_patterns_singleton_NoDestruction_h_ 
     34#ifndef __rrlib__util__patterns__singleton__policies__lifetime__NoDestruction_h__ 
     35#define __rrlib__util__patterns__singleton__policies__lifetime__NoDestruction_h__ 
    3636 
    3737//---------------------------------------------------------------------- 
    3838// External includes (system with <>, local with "") 
    3939//---------------------------------------------------------------------- 
     40#include <stdexcept> 
    4041 
    4142//---------------------------------------------------------------------- 
     
    5455{ 
    5556namespace util 
     57{ 
     58namespace singleton 
    5659{ 
    5760 
     
    8386} 
    8487} 
     88} 
    8589 
    8690#endif 
  • patterns/singleton/policies/lifetime/PhoenixSingleton.h

    r7 r16  
    3232 */ 
    3333//---------------------------------------------------------------------- 
    34 #ifndef _rrlib_util_patterns_singleton_PhoenixSingleton_h_ 
    35 #define _rrlib_util_patterns_singleton_PhoenixSingleton_h_ 
     34#ifndef __rrlib__util__patterns__singleton__policies__lifetime__PhoenixSingleton_h__ 
     35#define __rrlib__util__patterns__singleton__policies__lifetime__PhoenixSingleton_h__ 
    3636 
    3737//---------------------------------------------------------------------- 
     
    5454{ 
    5555namespace util 
     56{ 
     57namespace singleton 
    5658{ 
    5759 
     
    8385} 
    8486} 
     87} 
    8588 
    8689#endif 
  • patterns/singleton/tSingletonHolder.h

    r7 r16  
    3232 */ 
    3333//---------------------------------------------------------------------- 
    34 #ifndef _rrlib_util_patterns_singleton_tSingletonHolder_h_ 
    35 #define _rrlib_util_patterns_singleton_tSingletonHolder_h_ 
     34#ifndef __rrlib__util__patterns__singleton__tSingletonHolder_h__ 
     35#define __rrlib__util__patterns__singleton__tSingletonHolder_h__ 
    3636 
    3737//---------------------------------------------------------------------- 
     
    6868 * 
    6969 */ 
    70 template < typename T, 
    71 template <typename> class TCreationPolicy = CreateUsingNew, 
    72 template <typename> class TLifetimePolicy = DefaultLifetime > 
     70template < 
     71typename T, 
     72template <typename> class TCreationPolicy = singleton::CreateUsingNew, 
     73template <typename> class TLifetimePolicy = singleton::DefaultLifetime 
     74> 
    7375class tSingletonHolder : public boost::noncopyable 
    7476{ 
     77 
     78//---------------------------------------------------------------------- 
     79// Public methods and typedefs 
     80//---------------------------------------------------------------------- 
     81public: 
     82 
     83  static T &GetInstance() 
     84  { 
     85    if (!tSingletonHolder::Instance()) 
     86    { 
     87      if (tSingletonHolder::Destroyed()) 
     88      { 
     89        TLifetimePolicy<T>::OnDeadReference(); 
     90        tSingletonHolder::Destroyed() = false; 
     91      } 
     92      tSingletonHolder::Instance() = TCreationPolicy<T>::Create(); 
     93      TLifetimePolicy<T>::ScheduleDestruction(&tSingletonHolder::DestroyInstance); 
     94    } 
     95    return *tSingletonHolder::Instance(); 
     96  } 
     97 
     98//---------------------------------------------------------------------- 
     99// Private fields and methods 
     100//---------------------------------------------------------------------- 
     101private: 
     102 
    75103  tSingletonHolder(); 
    76104 
    77105  static void DestroyInstance() 
    78106  { 
    79     assert(!Destroyed()); 
    80     TCreationPolicy<T>::Destroy(Instance()); 
    81     Instance() = 0; 
    82     Destroyed() = true; 
     107    assert(!tSingletonHolder::Destroyed()); 
     108    TCreationPolicy<T>::Destroy(tSingletonHolder::Instance()); 
     109    tSingletonHolder::Instance() = 0; 
     110    tSingletonHolder::Destroyed() = true; 
    83111  } 
    84112 
     
    94122  } 
    95123 
    96 public: 
    97  
    98   static T &GetInstance() 
    99   { 
    100     if (!Instance()) 
    101     { 
    102       if (Destroyed()) 
    103       { 
    104         TLifetimePolicy<T>::OnDeadReference(); 
    105         Destroyed() = false; 
    106       } 
    107       Instance() = TCreationPolicy<T>::Create(); 
    108       TLifetimePolicy<T>::ScheduleDestruction(&DestroyInstance); 
    109     } 
    110     return *Instance(); 
    111   } 
    112  
    113124}; 
    114125 
  • stl_container/join.h

    r4 r16  
    3232 */ 
    3333//---------------------------------------------------------------------- 
    34 #ifndef _rrlib_util_stl_container_join_h_ 
    35 #define _rrlib_util_stl_container_join_h_ 
     34#ifndef __rrlib__util__stl_container__join_h__ 
     35#define __rrlib__util__stl_container__join_h__ 
    3636 
    3737//---------------------------------------------------------------------- 
  • stl_container/join.hpp

    r1 r16  
    6868{ 
    6969template <typename TBidirectionalIterator> 
    70 inline void __Join(TBidirectionalIterator first, TBidirectionalIterator last, std::ostream &destination, const char *delimiter, std::bidirectional_iterator_tag) 
     70inline void JoinImplementation(TBidirectionalIterator first, TBidirectionalIterator last, std::ostream &destination, const char *delimiter, std::bidirectional_iterator_tag) 
    7171{ 
    7272  assert(first != last); 
     
    7676 
    7777template <class TInputIterator> 
    78 inline void __Join(TInputIterator first, TInputIterator last, std::ostream &destination, const char *delimiter, std::input_iterator_tag) 
     78inline void JoinImplementation(TInputIterator first, TInputIterator last, std::ostream &destination, const char *delimiter, std::input_iterator_tag) 
    7979{ 
    8080  assert(first != last); 
     
    8787 
    8888template <class TInputIterator> 
    89 inline std::string __Join(TInputIterator first, TInputIterator last, const char *delimiter) 
     89inline std::string JoinImplementation(TInputIterator first, TInputIterator last, const char *delimiter) 
    9090{ 
    9191  assert(first != last); 
     
    101101  if (first != last) 
    102102  { 
    103     __Join(first, last, destination, delimiter, typename std::iterator_traits<TIterator>::iterator_category()); 
     103    JoinImplementation(first, last, destination, delimiter, typename std::iterator_traits<TIterator>::iterator_category()); 
    104104  } 
    105105} 
     
    116116  if (first != last) 
    117117  { 
    118     return __Join(first, last, delimiter); 
     118    return JoinImplementation(first, last, delimiter); 
    119119  } 
    120120  return ""; 
  • test/test_command_pattern.cpp

    r10 r16  
    4949// Namespace usage 
    5050//---------------------------------------------------------------------- 
     51using namespace rrlib::util; 
    5152 
    5253//---------------------------------------------------------------------- 
     
    101102} 
    102103 
    103 void CreateCommand(const rrlib::util::tFunctor<const char *, double, double> &command) 
     104void CreateCommand(const tFunctor<const char *, double, double> &command) 
    104105{ 
    105106  std::cout << command(4, 4.5) << std::endl; 
     
    125126  // Test basic functor objects 
    126127  TestFunctor1 f1; 
    127   rrlib::util::tFunctor<void, int, double> cmd1(f1); 
     128  tFunctor<void, int, double> cmd1(f1); 
    128129  TestFunctor2 f2; 
    129   rrlib::util::tFunctor<bool, int> cmd2(f2); 
     130  tFunctor<bool, int> cmd2(f2); 
    130131  TestFunctor3 f3; 
    131   rrlib::util::tFunctor<void> cmd3(f3); 
     132  tFunctor<void> cmd3(f3); 
    132133 
    133134  cmd1(4, 4.5); 
     
    136137 
    137138  // pointer to function 
    138   rrlib::util::tFunctor<void, int, double> cmd4(&TestFunction); 
     139  tFunctor<void, int, double> cmd4(&TestFunction); 
    139140  cmd4(4, 4.5); 
    140141 
    141142  // pointer to function with implicit conversions 
    142   rrlib::util::tFunctor<std::string, int, int> cmd5(&TestConversions); 
     143  tFunctor<std::string, int, int> cmd5(&TestConversions); 
    143144  std::cout << cmd5(4, 4.5).substr(7) << std::endl; 
    144145 
     
    147148  // pointer to member functions for objects 
    148149  Parrot geronimo; 
    149   rrlib::util::tFunctor<void> cmd6(geronimo, &Parrot::Eat); 
    150   rrlib::util::tFunctor<void> cmd7(geronimo, &Parrot::Speak); 
     150  tFunctor<void> cmd6(geronimo, &Parrot::Eat); 
     151  tFunctor<void> cmd7(geronimo, &Parrot::Speak); 
    151152 
    152153  cmd6(); 
     
    154155 
    155156  // copy of functors 
    156   rrlib::util::tFunctor<void, int, double> cmd8(cmd1); 
     157  tFunctor<void, int, double> cmd8(cmd1); 
    157158  cmd8(4, 4.5); 
    158159 
    159160  // binding of first parameter 
    160   rrlib::util::tFunctor<void, double> cmd9 = rrlib::util::BindFirstParameter(cmd1, 4); 
     161  tFunctor<void, double> cmd9 = BindFirstParameter(cmd1, 4); 
    161162  cmd9(4.5); 
    162163 
    163164  // binding of second parameter (in terms of the first parameter, applied recursively) 
    164   rrlib::util::BindFirstParameter(cmd9, 4.5)(); 
     165  BindFirstParameter(cmd9, 4.5)(); 
    165166 
    166167  // chaining of two functors 
    167   rrlib::util::tFunctor<void> cmd10 = rrlib::util::ChainFunctors(cmd6, cmd7); 
     168  tFunctor<void> cmd10 = ChainFunctors(cmd6, cmd7); 
    168169  cmd10(); 
    169170 
    170171  // recursive chaining 
    171   rrlib::util::ChainFunctors(cmd6, cmd10)(); 
     172  ChainFunctors(cmd6, cmd10)(); 
    172173 
    173174  // STL compliance 
    174   std::vector<rrlib::util::tFunctor<void, int, double>> commands; 
     175  std::vector<tFunctor<void, int, double>> commands; 
    175176  commands.push_back(cmd1); 
    176177  commands.push_back(cmd4); 
    177178  commands.push_back(cmd8); 
    178179 
    179   for (std::vector<rrlib::util::tFunctor<void, int, double>>::iterator it = commands.begin(); it != commands.end(); ++it) 
     180  for (std::vector<tFunctor<void, int, double>>::iterator it = commands.begin(); it != commands.end(); ++it) 
    180181  { 
    181182    (*it)(4, 4.5); 
  • test/test_singleton_pattern.cpp

    r10 r16  
    4848// Namespace usage 
    4949//---------------------------------------------------------------------- 
     50using namespace rrlib::util; 
    5051 
    5152//---------------------------------------------------------------------- 
     
    7879  } 
    7980}; 
    80 typedef rrlib::util::tSingletonHolder<tLogImplementation, rrlib::util::CreateStatic, rrlib::util::NoDestruction> tLog; 
     81typedef tSingletonHolder<tLogImplementation, singleton::CreateStatic, singleton::PhoenixSingleton> tLog; 
     82//typedef tSingletonHolder<tLogImplementation, singleton::CreateStatic, singleton::NoDestruction> tLog; 
    8183 
    8284struct tKeyboardImplementation 
Note: See TracChangeset for help on using the changeset viewer.