~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/generator/session.h

  • Committer: Mark Atwood
  • Date: 2011-08-11 03:05:03 UTC
  • mfrom: (2385.1.12 refactor4)
  • Revision ID: me@mark.atwood.name-20110811030503-rp9xjihc5x3y0x4q
mergeĀ lp:~olafvdspek/drizzle/refactor4

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#ifndef DRIZZLED_GENERATOR_SESSION_H
22
 
#define DRIZZLED_GENERATOR_SESSION_H
 
21
#pragma once
23
22
 
24
23
#include <boost/thread/mutex.hpp>
25
 
#include "drizzled/session/cache.h"
26
 
#include "drizzled/identifier/user.h"
 
24
 
 
25
#include <drizzled/identifier/user.h>
 
26
#include <drizzled/session/cache.h>
27
27
 
28
28
namespace drizzled {
29
29
namespace generator {
32
32
{
33
33
  session::Cache::list local_list;
34
34
  session::Cache::list::const_iterator iter;
35
 
  identifier::User::const_reference user;
 
35
  const identifier::User& user;
36
36
 
37
37
public:
38
38
 
39
 
  Session(identifier::User::const_reference arg) :
 
39
  Session(const identifier::User& arg) :
40
40
    user(arg)
41
41
  {
42
 
    boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
43
 
    local_list= session::Cache::singleton().getCache();
 
42
    boost::mutex::scoped_lock scopedLock(session::Cache::mutex());
 
43
    local_list= session::Cache::getCache();
44
44
    iter= local_list.begin();
45
45
  }
46
46
 
47
 
  ~Session()
48
 
  {
49
 
  }
50
 
 
51
 
  operator drizzled::Session::pointer()
 
47
  operator drizzled::Session*()
52
48
  {
53
49
    while (iter != local_list.end())
54
50
    {
55
 
      drizzled::Session::pointer ret= (*iter).get();
 
51
      drizzled::Session* ret= iter->get();
56
52
      iter++;
57
53
 
58
 
      if (not ret->isViewable(user))
59
 
      {
60
 
        continue;
61
 
      }
62
 
 
63
 
      return ret;
 
54
      if (ret->isViewable(user))
 
55
              return ret;
64
56
    }
65
 
 
66
 
    return drizzled::Session::pointer();
 
57
    return NULL;
67
58
  }
68
59
};
69
60
 
70
61
} /* namespace generator */
71
62
} /* namespace drizzled */
72
63
 
73
 
#endif /* DRIZZLED_GENERATOR_SESSION_H */