fetchable.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #ifndef __FETCHABLE_H
  15. #define __FETCHABLE_H
  16. /**
  17. * \file fetchable.h
  18. * \short Interface of information that can be fetched.
  19. */
  20. namespace isc {
  21. namespace nsas {
  22. /**
  23. * \short Interface of information that can be fetched.
  24. *
  25. * This just holds a state of information that can be fetched from somewhere.
  26. * No locking is performed, if it is desirable, it should be locked manually.
  27. */
  28. class Fetchable {
  29. public:
  30. /// \short States the Fetchable object can be in.
  31. enum State {
  32. /// \short No one yet asked for the information.
  33. NOT_ASKED,
  34. /// \short The information is too old and should not be used.
  35. EXPIRED,
  36. /// \short The information is asked for but it did not arrive.
  37. IN_PROGRESS,
  38. /// \short It is not possible to get the information.
  39. UNREACHABLE,
  40. /// \short The information is already present.
  41. READY
  42. };
  43. /// \short Constructors
  44. //@{
  45. /// This creates the Fetchable object in the given state.
  46. Fetchable(State state = NOT_ASKED) :
  47. state_(state)
  48. { }
  49. //@}
  50. /// \short Getter and setter of current state.
  51. //@{
  52. State getState() const { return state_; }
  53. void setState(State state) { state_ = state; }
  54. //@}
  55. private:
  56. State state_;
  57. };
  58. } // namespace nsas
  59. } // namespace isc
  60. #endif // __FETCHABLE_H