aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/skin/feeds/textfeed.h
blob: 1c2d9bc1aef3a4ce90251a8052ecf0fd4b0ff588 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef _TEXTFEED_H
#define _TEXTFEED_H

#include <bfc/common.h>
#include <map>
#include <string>
#include <utility>
#include <bfc/depend.h>
#include <api/service/svcs/svc_textfeed.h>
#include <api/syscb/callbacks/corecbi.h>

/**
  This is the standard helper class for implementing a textfeed.
  Be sure to check out class EzFeed in ezfeed.h, which combines this
  class with a service factory.
*/
class TextFeed : public svc_textFeedI, public DependentI 
{
public:
/**
  Call this to register your feeds by id. Make the ids unique!
  @see sendFeed()
  @ret TRUE if succeeded, FALSE on error (i.e. nonunique id)
*/
  int registerFeed(const wchar_t *feedid, const wchar_t *initial_text=L"", const wchar_t *description=L"");

/**
  Call this to send text into a feed.
  @see registerFeed()
  @ret TRUE if succeeded, FALSE on error (i.e. feedid not registered)
*/
  int sendFeed(const wchar_t *feedid, const wchar_t *text);

//  Gives the most recently sent text on a feed.
  virtual const wchar_t *getFeedText(const wchar_t *feedid);

//  Gives a description for the feed (used by accessibility).
  virtual const wchar_t *getFeedDescription(const wchar_t *feedid);

protected:
  virtual api_dependent *getDependencyPtr() { return this; }
  virtual void dependent_onRegViewer(api_dependentviewer *viewer, int add);
  virtual void *dependent_getInterface(const GUID *classguid);

/**
  Called when someone subscribes to this feed.
*/
  virtual void onRegClient() { }
  virtual void onDeregClient() { }

  virtual int hasFeed(const wchar_t *name);

private:
  std::map<std::wstring, std::pair<std::wstring, std::wstring> > feeds;
};

#endif