Savarese Software Research Corporation
SessionData.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2006-2009 Savarese Software Research Corporation
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     https://www.savarese.com/software/ApacheLicense-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00022 #ifndef __SSRC_WSPR_SESSION_DATA_H
00023 #define __SSRC_WSPR_SESSION_DATA_H
00024 
00025 #include <ssrc/wispers/types.h>
00026 #include <ssrc/wispers/utility/Properties.h>
00027 
00028 __BEGIN_NS_SSRC_WSPR_SESSION
00029 
00030 using std::string;
00031 using NS_SSRC_WSPR_UTILITY::Properties;
00032 
00033 typedef unsigned int idle_count_type;
00034 
00035 struct SessionData {
00036   sid_type sid;
00037   sid_type xsrf_token;
00038   uid_type uid;
00039   idle_count_type idle_count;
00040   boost::shared_ptr<Properties> attributes;
00041 
00042   SessionData() :
00043     sid(), xsrf_token(), uid(), idle_count(), attributes()
00044   { }
00045 
00046 #if !defined(SWIG)
00047   explicit
00048   SessionData(const sid_type & sid,
00049               const sid_type & xsrf_token,
00050               const idle_count_type idle_count = 0,
00051               const uid_type uid = 0,
00052               Properties && attributes = Properties()) :
00053     sid(sid), xsrf_token(xsrf_token), uid(uid), idle_count(idle_count),
00054     attributes(new Properties(std::move(attributes)))
00055   { }
00056 #endif
00057 
00058   string login() { return attributes->get<string>("", "login"); }
00059 
00060   template<class Archive>
00061   void serialize(Archive & ar, const unsigned int) {
00062     ar & sid & xsrf_token & uid & idle_count & attributes;
00063   }
00064 
00065 };
00066 
00067 typedef boost::shared_ptr<SessionData> session_ptr;
00068 
00069 __END_NS_SSRC_WSPR_SESSION
00070 
00071 #if !defined(SWIG)
00072 BOOST_CLASS_TRACKING(NS_SSRC_WSPR_SESSION::SessionData, boost::serialization::track_never)
00073 #endif
00074 
00075 #endif

Savarese Software Research Corporation
Copyright © 2006-2011 Savarese Software Research Corporation. All rights reserved.