fetchable.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright (C) 2010 CZ NIC
  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. // $id$
  15. #ifndef __FETCHABLE_H
  16. #define __FETCHABLE_H
  17. /**
  18. * \file fetchable.h
  19. * \short Interface of information that can be fetched.
  20. */
  21. namespace isc {
  22. namespace nsas {
  23. /**
  24. * \short Interface of information that can be fetched.
  25. *
  26. * This just holds a state of information that can be fetched from somewhere.
  27. * No locking is performed, if it is desirable, it should be locked manually.
  28. */
  29. class Fetchable {
  30. public:
  31. /// \short States the Fetchable object can be in.
  32. enum State {
  33. /// \short No one yet asked for the information.
  34. NOT_ASKED,
  35. /// \short The information is too old and should not be used.
  36. EXPIRED,
  37. /// \short The information is asked for but it did not arrive.
  38. IN_PROGRESS,
  39. /// \short It is not possible to get the information.
  40. UNREACHABLE,
  41. /// \short The information is already present.
  42. READY
  43. };
  44. /// \short Constructors
  45. //@{
  46. /// This creates the Fetchable object in the given state.
  47. Fetchable(State state = NOT_ASKED) :
  48. state_(state)
  49. { }
  50. //@}
  51. /// \short Getter and setter of current state.
  52. //@{
  53. State getState() const { return state_; }
  54. void setState(State state) { state_ = state; }
  55. //@}
  56. private:
  57. State state_;
  58. };
  59. } // namespace nsas
  60. } // namespace isc
  61. #endif // __FETCHABLE_H