Changeset eaee7f for src


Ignore:
Timestamp:
Oct 5, 2009, 9:14:28 PM (15 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
e65246
Parents:
33f9f7
Message:

even the class of the member function can be templated, see ActOnAllUnitTest.

Note however that specializations of templated member functions are not allowed.

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/ActOnAllUnitTest.cpp

    r33f9f7 reaee7f  
    4040};
    4141
    42 /** UnitTest for VectorList::ActOnAllVectors() and Vector::AddVector(), Vector::SubtractVector(),
     42/** UnitTest for VectorList::ActOnAll() and Vector::AddVector(), Vector::SubtractVector(),
    4343 */
    4444void ActOnAllTest::AddSubtractTest()
     
    4747
    4848  // adding, subtracting
    49   VL.ActOnAllVectors( &Vector::AddVector, &test );
     49  VL.ActOnAll( &Vector::AddVector, &test );
    5050  CPPUNIT_ASSERT_EQUAL( VL == Ref , false );
    51   VL.ActOnAllVectors( &Vector::SubtractVector, &test );
     51  VL.ActOnAll( &Vector::SubtractVector, &test );
    5252  CPPUNIT_ASSERT_EQUAL( VL == Ref , true );
    5353};
    5454
    55 /** UnitTest for VectorList::ActOnAllVectors()
     55/** UnitTest for VectorList::ActOnAll()
    5656 */
    5757void ActOnAllTest::ScaleTest()
     
    6161
    6262  // scaling by value
    63   VL.ActOnAllVectors( (void (Vector::*)(double)) &Vector::Scale, 2. );
     63  VL.ActOnAll( (void (Vector::*)(double)) &Vector::Scale, 2. );
    6464  CPPUNIT_ASSERT_EQUAL( VL == Ref , false );
    6565
    66   VL.ActOnAllVectors( (void (Vector::*)(double)) &Vector::Scale, 0.5 );
     66  VL.ActOnAll( (void (Vector::*)(double)) &Vector::Scale, 0.5 );
    6767  CPPUNIT_ASSERT_EQUAL( VL == Ref , true );
    6868
    6969  // scaling by ref
    70   VL.ActOnAllVectors( (void (Vector::*)(double *)) &Vector::Scale, &factor );
     70  VL.ActOnAll( (void (Vector::*)(double *)) &Vector::Scale, &factor );
    7171  CPPUNIT_ASSERT_EQUAL( VL == Ref , false );
    7272
    73   VL.ActOnAllVectors( (void (Vector::*)(double *)) &Vector::Scale, &inverse );
     73  VL.ActOnAll( (void (Vector::*)(double *)) &Vector::Scale, &inverse );
    7474  CPPUNIT_ASSERT_EQUAL( VL == Ref , true );
    7575
     
    8181    inverses[i] = 1./factors[i];
    8282  }
    83   VL.ActOnAllVectors( (void (Vector::*)(double **)) &Vector::Scale, &factors );
     83  VL.ActOnAll( (void (Vector::*)(double **)) &Vector::Scale, &factors );
    8484  CPPUNIT_ASSERT_EQUAL( VL == Ref , false );
    8585
    86   VL.ActOnAllVectors( (void (Vector::*)(double **)) &Vector::Scale, &inverses );
     86  VL.ActOnAll( (void (Vector::*)(double **)) &Vector::Scale, &inverses );
    8787  CPPUNIT_ASSERT_EQUAL( VL == Ref , true );
    8888};
    8989
    90 /** UnitTest for VectorList::ActOnAllVectors() and Vector::MakeNormalVector()
     90/** UnitTest for VectorList::ActOnAll() and Vector::MakeNormalVector()
    9191 */
    9292void ActOnAllTest::NormalizeTest()
     
    9797  // normalize with respect to x and y axis
    9898  bool (Vector::*f)(const Vector *, const Vector *) = &Vector::MakeNormalVector;
    99   VL.ActOnAllVectors( f, &xaxis, &yaxis );
     99  VL.ActOnAll( f, &xaxis, &yaxis );
    100100  CPPUNIT_ASSERT_EQUAL( VL == Ref , false );
    101101
  • src/ActOnAlltest.hpp

    r33f9f7 reaee7f  
    2626  void EmptyList();
    2727
    28   template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T), T t );
    29   template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U), T t, U u );
    30   template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v);
     28  template <typename klasse, typename res, typename T> void ActOnAll( res (klasse::*f)(T), T t );
     29  template <typename klasse, typename res, typename T, typename U> void ActOnAll( res (klasse::*f)(T, U), T t, U u );
     30  template <typename klasse, typename res, typename T, typename U, typename V> void ActOnAll( res (klasse::*f)(T, U, V), T t, U u, V v);
    3131
    3232  bool operator == (VectorList &rhs);
     
    7070VectorList::~VectorList() { };
    7171
    72 template <typename res, typename T> void VectorList::ActOnAllVectors( res (Vector::*f)(T), T t )
     72template <typename klasse, typename res, typename T> void VectorList::ActOnAll( res (klasse::*f)(T), T t )
    7373{
    74   Vector *test = NULL;
    75   for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++) {
    76     test = *Runner;
    77     (test->*f)(t);
    78   }
     74  for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++)
     75    ((*Runner)->*f)(t);
    7976};
    8077
    81 template <typename res, typename T, typename U> void VectorList::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u )
     78template <typename klasse, typename res, typename T, typename U> void VectorList::ActOnAll( res (klasse::*f)(T, U), T t, U u )
    8279{
    83   Vector *test = NULL;
    84   for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++) {
    85     test = *Runner;
    86     (test->*f)(t, u);
    87   }
     80  for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++)
     81    ((*Runner)->*f)(t, u);
    8882};
    8983
    90 template <typename res, typename T, typename U, typename V> void VectorList::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v)
     84template <typename klasse, typename res, typename T, typename U, typename V> void VectorList::ActOnAll( res (klasse::*f)(T, U, V), T t, U u, V v)
    9185{
    92   Vector *test = NULL;
    93   for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++) {
    94     test = *Runner;
    95     (test->*f)(t, u, v);
    96   }
     86  for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++)
     87    ((*Runner)->*f)(t, u, v);
    9788};
    9889
Note: See TracChangeset for help on using the changeset viewer.