Changeset 94605f for src/RandomNumbers


Ignore:
Timestamp:
May 5, 2016, 5:14:19 PM (10 years ago)
Author:
Frederik Heber <heber@…>
Parents:
4a319a
git-author:
Frederik Heber <heber@…> (05/05/16 14:54:56)
git-committer:
Frederik Heber <heber@…> (05/05/16 17:14:19)
Message:

Replaced .. by getConstInstance() wherever possible.

Location:
src/RandomNumbers
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/RandomNumbers/RandomNumberDistributionFactory.hpp

    r4a319a r94605f  
    5959  virtual ~RandomNumberDistributionFactory();
    6060
     61  //!> expose namemap
     62  using ManipulablePrototypeFactory<RandomNumberDistribution, RandomNumberDistribution_Parameters>::NameMap;
    6163};
    6264
  • src/RandomNumbers/RandomNumberEngineFactory.hpp

    r4a319a r94605f  
    5959  virtual ~RandomNumberEngineFactory();
    6060
     61  //!> expose namemap
     62  using ManipulablePrototypeFactory<RandomNumberEngine, RandomNumberEngine_Parameters>::NameMap;
    6163};
    6264
  • src/RandomNumbers/unittests/RandomNumberDistributionFactoryUnitTest.cpp

    r4a319a r94605f  
    104104{
    105105  // check the injectiveness of enum and string map
    106   for (RandomNumberDistributionFactory::NameMap::const_iterator
    107       iter = RandomNumberDistributionFactory::getInstance().names.begin();
    108       iter != RandomNumberDistributionFactory::getInstance().names.end();
     106  const RandomNumberDistributionFactory& factory = RandomNumberDistributionFactory::getConstInstance();
     107  for (RandomNumberDistributionFactory::NameMap::const_iterator iter =
     108      RandomNumberDistributionFactory::names.begin();
     109      iter != RandomNumberDistributionFactory::names.end();
    109110      ++iter) {
    110111    CPPUNIT_ASSERT_EQUAL(
    111112        iter->second,
    112         RandomNumberDistributionFactory::getInstance().getName(
    113             RandomNumberDistributionFactory::getInstance().getEnum(
    114                 iter->second
    115             )
    116         )
     113        factory.getName( factory.getEnum(iter->second) )
    117114    );
    118115  }
    119116
    120117  // check one of the distributions in the table
    121   rndA = RandomNumberDistributionFactory::getInstance().
    122       ManipulablePrototypeTable[RandomNumberDistributionFactory::uniform_smallint]->clone();
     118  rndA = RandomNumberDistributionFactory::ManipulablePrototypeTable[RandomNumberDistributionFactory::uniform_smallint]->clone();
    123119  CPPUNIT_ASSERT_EQUAL(
    124120      std::string(typeid(boost::uniform_smallint<> ).name()),
     
    129125  CPPUNIT_ASSERT_EQUAL( 0., rndA->min() );
    130126  CPPUNIT_ASSERT_EQUAL( 9., rndA->max() );
     127  rndA = NULL;
    131128}
    132129
    133130void RandomNumberDistributionFactoryTest::PrototypeManipulationTest()
    134131{
     132  const RandomNumberDistributionFactory& factory = RandomNumberDistributionFactory::getConstInstance();
    135133  // make unmodified clone
    136   rndA_1 = RandomNumberDistributionFactory::getInstance().
    137       getProduct(RandomNumberDistributionFactory::uniform_smallint);
     134  rndA_1 = factory.getProduct(RandomNumberDistributionFactory::uniform_smallint);
    138135
    139136  // do something with the prototype
     
    157154      manipulatePrototype(std::string("uniform_smallint"), *params);
    158155  // ... and check
    159   rndA_3 = RandomNumberDistributionFactory::getInstance().
    160       getProduct(RandomNumberDistributionFactory::uniform_smallint);
     156  rndA_3 = factory.getProduct(RandomNumberDistributionFactory::uniform_smallint);
    161157  CPPUNIT_ASSERT_EQUAL( 25., rndA_3->max());
    162158  CPPUNIT_ASSERT( rndA_1->max() != rndA_3->max());
  • src/RandomNumbers/unittests/RandomNumberEngineFactoryUnitTest.cpp

    r4a319a r94605f  
    108108{
    109109  // check the injectiveness of enum and string map
     110  const RandomNumberEngineFactory &factory = RandomNumberEngineFactory::getConstInstance();
    110111  for (RandomNumberEngineFactory::NameMap::const_iterator
    111       iter = RandomNumberEngineFactory::getInstance().names.begin();
    112       iter != RandomNumberEngineFactory::getInstance().names.end();
     112      iter = RandomNumberEngineFactory::names.begin();
     113      iter != RandomNumberEngineFactory::names.end();
    113114      ++iter) {
    114115    CPPUNIT_ASSERT_EQUAL(
    115116        iter->second,
    116         RandomNumberEngineFactory::getInstance().getName(
    117             RandomNumberEngineFactory::getInstance().getEnum(
    118                 iter->second
    119             )
    120         )
     117        factory.getName( factory.getEnum(iter->second) )
    121118    );
    122119  }
  • src/RandomNumbers/unittests/RandomNumberGeneratorFactoryUnitTest.cpp

    r4a319a r94605f  
    104104{
    105105  // check one of the engines and distributions
    106   RandomNumberGenerator& rng = *(RandomNumberGeneratorFactory::getInstance().
    107       GeneratorPrototypeTable[RandomNumberEngineFactory::minstd_rand0]
    108                               [RandomNumberDistributionFactory::uniform_smallint]);
     106  const RandomNumberGenerator& rng =
     107      *RandomNumberGeneratorFactory::GeneratorPrototypeTable[RandomNumberEngineFactory::minstd_rand0]
     108                              [RandomNumberDistributionFactory::uniform_smallint];
    109109  CPPUNIT_ASSERT_EQUAL(
    110110      std::string(typeid(boost::minstd_rand0).name()),
Note: See TracChangeset for help on using the changeset viewer.