DiscoverTenerife
Public Member Functions | Private Member Functions | Private Attributes | List of all members
requestHandler Class Reference

class that controls the request of places information. More...

Public Member Functions

 requestHandler (Dictionary< string, Dictionary< string, Dictionary< string, string > > > allPlaces)
 constructor of the requestHandler class, it initialize all the properties of the object and instanciate a new Place and store it on the listOfPlaces_ property for each place of the given dictionary. More...
 
Place askForAPlace ()
 this method access to the sortByLessDistance method of optionsController class and it shorts the places acording to the chosen sort method calling the sortPlaces method if the chosen sort method has changed since last call to this method. It returns the next place that should be showed to the user acording to the sorting method and the prefferences of the current user of what the current user wants to see. More...
 
void sortPlaces ()
 Sorts the places acording to the current user preferences. More...
 
void oneMoreVisitToPlaceByTypeAndId (string type, string id)
 Calls the method oneMoreVisit of the given instance of the class Place that matches the given type and id. More...
 
Place getPlaceByTypeAndId (string type, string id)
 It returns the place that match the given type and id, if there inst any place with that index or type it will raise an exception. More...
 
void useStartIndex ()
 This method sets the currentIndex_ at the startIndex_ to start from the begining of the sorted list of places. More...
 
void updateStartIndex ()
 This method updates the startIndex_ to take new places. More...
 
int visitsOfMostVisitedPlace ()
 This method calculates the maximum number of visits between each type of place and then, it calculates the maximum number of all types. Basically, it returns the maximum number of visits between all places. More...
 

Private Member Functions

void updateIndex ()
 updates the currentIndex_ property to point the next place type that should be chosen. More...
 
int compareTwoPlacesTakingAwareOfOptions (Dictionary< string, int > placeIndexA, Dictionary< string, int > placeIndexB)
 This method compares two given places (dictionaries contains id and type of each one) the possible results are: More...
 
bool thereIsAnyChangeInOptions ()
 This method checks if the user has changed his type of places preferences or not. More...
 

Private Attributes

int currentIndex_
 stores the index of the next place that will be returned. More...
 
List< string > typesOfSites_
 List of strings that contains the valid types of the places. More...
 
List< List< Place > > listOfPlaces_
 Stores all the places splited by types. More...
 
List< Dictionary< string, int > > sortedPlaceIndex_
 Stores the sorted index of the places when the type is defined. More...
 
bool sortedByDistance_
 true if the places should be sorted by distance, false in other case. More...
 
Dictionary< string, bool > whatToSeeOptions_
 It stores the extracted options of which types of places the user wants to see. It is stored for comparing and noticing where they change and for accesing it for sorting the places. More...
 
int startIndex_ = 0
 the index on which we start to count to extract new places. This index is releated to the sortedPlace list. More...
 

Detailed Description

class that controls the request of places information.

Constructor & Destructor Documentation

◆ requestHandler()

requestHandler.requestHandler ( Dictionary< string, Dictionary< string, Dictionary< string, string > > >  allPlaces)

constructor of the requestHandler class, it initialize all the properties of the object and instanciate a new Place and store it on the listOfPlaces_ property for each place of the given dictionary.

Parameters
Dictionary<string,Dictionary<string,Dictionary<string,string>>>dictionary string conversion the data of all places.

Member Function Documentation

◆ askForAPlace()

Place requestHandler.askForAPlace ( )

this method access to the sortByLessDistance method of optionsController class and it shorts the places acording to the chosen sort method calling the sortPlaces method if the chosen sort method has changed since last call to this method. It returns the next place that should be showed to the user acording to the sorting method and the prefferences of the current user of what the current user wants to see.

Returns
Place the next place that should be showed to the user.

◆ compareTwoPlacesTakingAwareOfOptions()

int requestHandler.compareTwoPlacesTakingAwareOfOptions ( Dictionary< string, int >  placeIndexA,
Dictionary< string, int >  placeIndexB 
)
private

This method compares two given places (dictionaries contains id and type of each one) the possible results are:

Parameters
Dictionary<string,int>type and id of the place A
Dictionary<string,int>type and id of the place B
Returns
int the comparation result, it could be -1, 0 or 1.
  • -1 if placeA should be first than placeB
  • 1 if placeB should be first than placeA
  • 0 if placeA and placeB they are equivalent if we just look the user preferences of place's type and visited or not visited.

◆ getPlaceByTypeAndId()

Place requestHandler.getPlaceByTypeAndId ( string  type,
string  id 
)

It returns the place that match the given type and id, if there inst any place with that index or type it will raise an exception.

Returns
Place with the given type and id.

◆ oneMoreVisitToPlaceByTypeAndId()

void requestHandler.oneMoreVisitToPlaceByTypeAndId ( string  type,
string  id 
)

Calls the method oneMoreVisit of the given instance of the class Place that matches the given type and id.

◆ sortPlaces()

void requestHandler.sortPlaces ( )

Sorts the places acording to the current user preferences.

◆ thereIsAnyChangeInOptions()

bool requestHandler.thereIsAnyChangeInOptions ( )
private

This method checks if the user has changed his type of places preferences or not.

Returns
true if there is some changes on the whatToSeeOptions, false if they isnt any change.

◆ updateIndex()

void requestHandler.updateIndex ( )
private

updates the currentIndex_ property to point the next place type that should be chosen.

◆ updateStartIndex()

void requestHandler.updateStartIndex ( )

This method updates the startIndex_ to take new places.

◆ useStartIndex()

void requestHandler.useStartIndex ( )

This method sets the currentIndex_ at the startIndex_ to start from the begining of the sorted list of places.

◆ visitsOfMostVisitedPlace()

int requestHandler.visitsOfMostVisitedPlace ( )

This method calculates the maximum number of visits between each type of place and then, it calculates the maximum number of all types. Basically, it returns the maximum number of visits between all places.

Returns
int the maximum number of visits between all places.

Member Data Documentation

◆ currentIndex_

int requestHandler.currentIndex_
private

stores the index of the next place that will be returned.

◆ listOfPlaces_

List<List<Place> > requestHandler.listOfPlaces_
private

Stores all the places splited by types.

  • First index: Type.
  • Second index: Place ID.

◆ sortedByDistance_

bool requestHandler.sortedByDistance_
private

true if the places should be sorted by distance, false in other case.

◆ sortedPlaceIndex_

List<Dictionary<string,int> > requestHandler.sortedPlaceIndex_
private

Stores the sorted index of the places when the type is defined.

◆ startIndex_

int requestHandler.startIndex_ = 0
private

the index on which we start to count to extract new places. This index is releated to the sortedPlace list.

◆ typesOfSites_

List<string> requestHandler.typesOfSites_
private

List of strings that contains the valid types of the places.

◆ whatToSeeOptions_

Dictionary<string,bool> requestHandler.whatToSeeOptions_
private

It stores the extracted options of which types of places the user wants to see. It is stored for comparing and noticing where they change and for accesing it for sorting the places.


The documentation for this class was generated from the following file: