git.fiddlerwoaroof.com
sys_stdlib.h
7d075ab4
 /* Copyright (C) CJ Affiliate
  *
  * You may use, distribute and modify this code under  the
  * terms of the  GNU General Public License  version 2  or
  * later.
  *
  * You should have received a copy of the license with this
  * file. If not, you will find a copy in the "LICENSE" file
  * at https://github.com/cjdev/dual-control.
  */
 
552f2a03
 #ifndef SYS_CSTDLIB_H_
 #define SYS_CSTDLIB_H_
 
 #include <memory>
 
7d075ab4
 class stdlib_ifc
 {
 public:
23c0bd4d
     virtual void srand (unsigned int seed) const
     {
56917f64
     }
7d075ab4
     virtual int rand() const
     {
         return 0;
     }
552f2a03
 };
 
7d075ab4
 class stdlib
 {
 public:
     using delegate = std::shared_ptr<stdlib_ifc>;
 private:
     delegate delegate_;
 public:
     stdlib (delegate delegate = std::make_shared<stdlib_ifc>()) : delegate_
         (delegate) {}
23c0bd4d
     void srand (unsigned int seed) const
     {
         return delegate_->srand (seed);
56917f64
     }
7d075ab4
     int rand() const
     {
         return delegate_->rand();
     }
     static const stdlib &get();
552f2a03
 };
 
 #endif
7d075ab4