~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/generator/session.h

  • Committer: Mark Atwood
  • Date: 2011-10-27 05:08:12 UTC
  • mfrom: (2445.1.11 rf)
  • Revision ID: me@mark.atwood.name-20111027050812-1icvs72lb0u4xdc4
mergeĀ lp:~olafvdspek/drizzle/refactor8

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"
 
24
 
 
25
#include <drizzled/identifier/user.h>
 
26
#include <drizzled/session/cache.h>
26
27
 
27
28
namespace drizzled {
28
29
namespace generator {
31
32
{
32
33
  session::Cache::list local_list;
33
34
  session::Cache::list::const_iterator iter;
 
35
  const identifier::User& user;
34
36
 
35
37
public:
36
38
 
37
 
  Session()
 
39
  Session(const identifier::User& arg) :
 
40
    user(arg)
38
41
  {
39
 
    boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
40
 
    local_list= session::Cache::singleton().getCache();
 
42
    boost::mutex::scoped_lock scopedLock(session::Cache::mutex());
 
43
    local_list= session::Cache::getCache();
41
44
    iter= local_list.begin();
42
45
  }
43
46
 
44
 
  ~Session()
45
 
  {
46
 
  }
47
 
 
48
 
  operator drizzled::Session::shared_ptr()
 
47
  operator drizzled::Session*()
49
48
  {
50
49
    while (iter != local_list.end())
51
50
    {
52
 
      if (not (*iter)->isViewable())
53
 
      {
54
 
        iter++;
55
 
        continue;
56
 
      }
57
 
 
58
 
      drizzled::Session::shared_ptr ret(*iter);
 
51
      drizzled::Session* ret= iter->get();
59
52
      iter++;
60
 
      return ret;
 
53
 
 
54
      if (ret->isViewable(user))
 
55
              return ret;
61
56
    }
62
 
 
63
 
    return drizzled::Session::shared_ptr();
 
57
    return NULL;
64
58
  }
65
59
};
66
60
 
67
61
} /* namespace generator */
68
62
} /* namespace drizzled */
69
63
 
70
 
#endif /* DRIZZLED_GENERATOR_SESSION_H */