~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/error_message.cc

Merged in latest plugin-slot-reorg.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
#include "drizzled/server_includes.h"
21
 
#include "drizzled/service/error_message.h"
22
21
#include "drizzled/plugin/error_message.h"
23
22
#include "drizzled/plugin/registry.h"
24
23
 
26
25
 
27
26
#include <vector>
28
27
 
29
 
using namespace drizzled;
30
28
using namespace std;
31
29
 
32
 
void service::ErrorMessage::add(plugin::ErrorMessage *handler)
 
30
namespace drizzled
 
31
{
 
32
 
 
33
vector<plugin::ErrorMessage *> all_errmsg_handler;
 
34
bool errmsg_has= false;
 
35
 
 
36
 
 
37
void plugin::ErrorMessage::add(plugin::ErrorMessage *handler)
33
38
{
34
39
  all_errmsg_handler.push_back(handler);
35
40
  errmsg_has= true;
36
41
}
37
42
 
38
 
void service::ErrorMessage::remove(plugin::ErrorMessage *handler)
 
43
void plugin::ErrorMessage::remove(plugin::ErrorMessage *handler)
39
44
{
40
45
  all_errmsg_handler.erase(find(all_errmsg_handler.begin(),
41
46
                                all_errmsg_handler.end(), handler));
42
47
}
43
48
 
44
49
 
45
 
namespace drizzled
46
 
{
47
 
namespace service
48
 
{
49
 
namespace errmsg_priv
50
 
{
51
 
 
52
50
class Print : public unary_function<plugin::ErrorMessage *, bool>
53
51
{
54
52
  Session *session;
84
82
  }
85
83
}; 
86
84
 
87
 
} /* namespace errmsg_priv */
88
 
} /* namespace service */
89
 
} /* namespace drizzled */
90
85
 
91
 
bool service::ErrorMessage::vprintf(Session *session, int priority,
 
86
bool plugin::ErrorMessage::vprintf(Session *session, int priority,
92
87
                                 char const *format, va_list ap)
93
88
{
94
89
 
107
102
  /* Use find_if instead of foreach so that we can collect return codes */
108
103
  vector<plugin::ErrorMessage *>::iterator iter=
109
104
    find_if(all_errmsg_handler.begin(), all_errmsg_handler.end(),
110
 
            service::errmsg_priv::Print(session, priority, format, ap)); 
 
105
            Print(session, priority, format, ap)); 
111
106
  /* If iter is == end() here, that means that all of the plugins returned
112
107
   * false, which in this case means they all succeeded. Since we want to 
113
108
   * return false on success, we return the value of the two being != 
115
110
  return iter != all_errmsg_handler.end();
116
111
}
117
112
 
118
 
 
 
113
} /* namespace drizzled */