Changeset f66195 for src/helpers.hpp


Ignore:
Timestamp:
Oct 9, 2009, 10:54:52 AM (16 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:
49f802c
Parents:
e41951
Message:

forward declarations used to untangle interdependet classes.

  • basically, everywhere in header files we removed '#include' lines were only pointer to the respective classes were used and the include line was moved to the implementation file.
  • as a sidenote, lots of funny errors happened because headers were included via a nesting over three other includes. Now, all should be declared directly as needed, as only very little include lines remain in header files.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/helpers.hpp

    re41951 rf66195  
    99using namespace std;
    1010
     11/*********************************************** includes ***********************************/
     12
    1113// include config.h
    1214#ifdef HAVE_CONFIG_H
     
    1416#endif
    1517
    16 #include <iostream>
    17 #include <iomanip>
    1818#include <fstream>
    19 #include <sstream>
    20 #include <math.h>
    21 #include <string>
    2219
    23 #include "defs.hpp"
    24 #include "verbose.hpp"
    2520#include "memoryallocator.hpp"
    2621
     
    5146void flip(double *x, double *y);
    5247int pot(int base, int n);
    53 //void * Malloc(size_t size, const char* output);
    54 //void * Calloc(size_t size, const char* output);
    55 //void * ReAlloc(void * OldPointer, size_t size, const char* output);
    56 //char* MallocString(size_t size, const char* output);
    57 //void Free(void ** buffer, const char* output);
    5848char *FixedDigitNumber(const int FragmentNumber, const int digits);
    5949bool IsValidNumber( const char *string);
     50int CompareDoubles (const void * a, const void * b);
     51double * ReturnFullMatrixforSymmetric(double *cell_size);
    6052
    6153/********************************************** helpful template functions *********************************/
     
    119111};
    120112
    121 /******************************** Some templates for list management ***********************************/
    122 
    123 /** Adds linking of an item to a list.
    124  * \param *walker
    125  * \return true - adding succeeded, false - error in list
    126  */
    127 template <typename X> void link(X *walker, X *end)
    128 {
    129   X *vorher = end->previous;
    130   if (vorher != NULL)
    131     vorher->next = walker;
    132   end->previous = walker;
    133   walker->previous = vorher;
    134   walker->next = end;
    135 };
    136 
    137 /** Removes linking of an item in a list.
    138  * \param *walker
    139  * \return true - removing succeeded, false - given item not found in list
    140  */
    141 template <typename X> void unlink(X *walker)
    142 {
    143   if (walker->next != NULL)
    144     walker->next->previous = walker->previous;
    145   if (walker->previous != NULL)
    146     walker->previous->next = walker->next;
    147 };
    148 
    149 /** Adds new item before an item \a *end in a list.
    150  * \param *pointer   item to be added
    151  * \param *end  end of list
    152  * \return true - addition succeeded, false - unable to add item to list
    153  */
    154 template <typename X>  bool add(X *pointer, X *end)
    155 {
    156   if (end != NULL) {
    157     link(pointer, end);
    158   } else {
    159     pointer->previous = NULL;
    160     pointer->next = NULL;
    161   }
    162   return true;
    163 };
    164 
    165 /** Finds item in list
    166  * \param *suche  search criteria
    167  * \param *start  begin of list
    168  * \param *end  end of list
    169  * \return X - if found, NULL - if not found
    170  */
    171 template <typename X, typename Y> X * find(Y *suche, X *start, X *end)
    172 {
    173   X *walker = start;
    174   while (walker->next != end) { // go through list
    175     walker = walker->next; // step onward beforehand
    176     if (*walker->sort == *suche) return (walker);
    177   }
    178   return NULL;
    179 };
    180 
    181 /** Removes an item from the list without check.
    182  * \param *walker item to be removed
    183  * \return true - removing succeeded, false - given item not found in list
    184  */
    185 template <typename X> void removewithoutcheck(X *walker)
    186 {
    187   if (walker != NULL) {
    188     unlink(walker);
    189     delete(walker);
    190     walker = NULL;
    191   }
    192 };
    193 
    194 /** Removes an item from the list, checks if exists.
    195  * Checks beforehand if atom is really within molecule list.
    196  * \param *pointer   item to be removed
    197  * \param *start  begin of list
    198  * \param *end  end of list
    199  * \return true - removing succeeded, false - given item not found in list
    200  */
    201 template <typename X> bool remove(X *pointer, X *start, X *end)
    202 {
    203   X *walker = find (pointer->sort, start, end);
    204 /*  while (walker->next != pointer) { // search through list
    205     walker = walker->next;
    206     if (walker == end) return false;  // item not found in list
    207   }*/
    208   // atom found, now unlink
    209   if (walker != NULL)
    210     removewithoutcheck(walker);
    211   else
    212     return false;
    213   return true;
    214 };
    215 
    216 /** Cleans the whole list.
    217  * \param *start begin of list
    218  * \param *end end of list
    219  * \return true - list was cleaned successfully, false - error in list structure
    220  */
    221 template <typename X> bool cleanup(X *start, X *end)
    222 {
    223   X *pointer = start->next;
    224   X *walker;
    225   while (pointer != end) { // go through list
    226     walker = pointer; // mark current
    227     pointer = pointer->next; // step onward beforehand
    228     // remove walker
    229     unlink(walker);
    230     delete(walker);
    231     walker = NULL;
    232   }
    233   return true;
    234 };
    235 
    236 /** Returns the first marker in a chain list.
    237  * \param *me one arbitrary item in chain list
    238  * \return poiner to first marker
    239  */
    240 template <typename X> X *GetFirst(X *me)
    241 {
    242   X *Binder = me;
    243   while(Binder->previous != NULL)
    244     Binder = Binder->previous;
    245   return Binder;
    246 };
    247 
    248 /** Returns the last marker in a chain list.
    249  * \param *me one arbitrary item in chain list
    250  * \return poiner to last marker
    251  */
    252 template <typename X> X *GetLast(X *me)
    253 {
    254   X *Binder = me;
    255   while(Binder->next != NULL)
    256     Binder = Binder->next;
    257   return Binder;
    258 };
    259 
    260113/** Frees a two-dimensional array.
    261114 * \param *ptr pointer to array
     
    285138
    286139
     140
    287141#endif /*HELPERS_HPP_*/
Note: See TracChangeset for help on using the changeset viewer.