Hello
I'm working on a simple web application and I need some design consideration with you guys..
I have 2 'cache' vectors where I store all dns records..
Both record types derive from base class base_record which is abstract class (has some virtual functions and stuff)..
They are:
Code:
class a_record : public base_record {
}
class aa_record : public base_record {
}
There is a vector of strings in each of those classes which stores all ip addreses for the specific domain.. I want to be able to get first ip address in the list and then try connecting to it.. If connection cannot be established I move to the next ip address string in the vector inside the record class object..
The next time I access the same object (of record class) and I want to get ip address it should return the last ip address that was used (the one we were able to connect to).
So I've been thinking of some options that would be suitable:
1. make a simple size_type member in each record class that would store the current position
2. use boost iterator libraries (which I dont fully understand how they work and if they would really be suitable for this - I would need some kind of endless iterators)
3. overload * operator so that it would return current ip address (string), overload ++ so that it would move to the next element in the list (this seems as the most sensible solution to me)
I want this to be professional and as simple as possible.. What do you guys think which design should I go for? Maybe some other suggestion? I know it sounds really easy but this kind of problems always make me (probably) think too much..
Thanks a lot for help!