1
0

textfeed.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef _TEXTFEED_H
  2. #define _TEXTFEED_H
  3. #include <bfc/common.h>
  4. #include <map>
  5. #include <string>
  6. #include <utility>
  7. #include <bfc/depend.h>
  8. #include <api/service/svcs/svc_textfeed.h>
  9. #include <api/syscb/callbacks/corecbi.h>
  10. /**
  11. This is the standard helper class for implementing a textfeed.
  12. Be sure to check out class EzFeed in ezfeed.h, which combines this
  13. class with a service factory.
  14. */
  15. class TextFeed : public svc_textFeedI, public DependentI
  16. {
  17. public:
  18. /**
  19. Call this to register your feeds by id. Make the ids unique!
  20. @see sendFeed()
  21. @ret TRUE if succeeded, FALSE on error (i.e. nonunique id)
  22. */
  23. int registerFeed(const wchar_t *feedid, const wchar_t *initial_text=L"", const wchar_t *description=L"");
  24. /**
  25. Call this to send text into a feed.
  26. @see registerFeed()
  27. @ret TRUE if succeeded, FALSE on error (i.e. feedid not registered)
  28. */
  29. int sendFeed(const wchar_t *feedid, const wchar_t *text);
  30. // Gives the most recently sent text on a feed.
  31. virtual const wchar_t *getFeedText(const wchar_t *feedid);
  32. // Gives a description for the feed (used by accessibility).
  33. virtual const wchar_t *getFeedDescription(const wchar_t *feedid);
  34. protected:
  35. virtual api_dependent *getDependencyPtr() { return this; }
  36. virtual void dependent_onRegViewer(api_dependentviewer *viewer, int add);
  37. virtual void *dependent_getInterface(const GUID *classguid);
  38. /**
  39. Called when someone subscribes to this feed.
  40. */
  41. virtual void onRegClient() { }
  42. virtual void onDeregClient() { }
  43. virtual int hasFeed(const wchar_t *name);
  44. private:
  45. std::map<std::wstring, std::pair<std::wstring, std::wstring> > feeds;
  46. };
  47. #endif