7684972a | /* Copyright (C) CJ Affiliate * * You may use, distribute and modify this code under the * terms of the GNU General Public License version 2 or * later. * * You should have received a copy of the license with this * file. If not, you will find a copy in the "LICENSE" file * at https://github.com/cjdev/dual-control. */ |
55259c47 | #ifndef _USER_H #define _USER_H #include <vector> #include <string> |
9a0bfcb2 | #include <memory> |
bef74c28 | #include <iostream> |
d8adc881 | #include "sys_unistd.h" #include "sys_pwd.h" |
55259c47 | |
28855478 | class user_ifc |
cdf7fd74 | { public: |
28855478 | virtual ~user_ifc() {} |
af3a4cd4 | virtual std::string home_directory() const |
0e218820 | { |
af3a4cd4 | return ""; |
bef74c28 | } |
55259c47 | }; |
3ae0e083 | class user |
cdf7fd74 | { |
0e218820 | public: typedef std::shared_ptr<user_ifc> delegate; private: delegate delegate_; public: user (delegate delegate) : delegate_ (delegate) { } user() : user (delegate (new user_ifc)) {} |
af3a4cd4 | std::string home_directory() const |
0e218820 | { return delegate_-> home_directory(); } |
bef74c28 | static user create (const passwd &passwd); |
28855478 | }; class directory_ifc { public: virtual ~directory_ifc() {} |
bf756dea | virtual std::vector<user> find_user (const std::string &user_name) const |
28855478 | { return std::vector<user>(); } |
8c62e61c | virtual std::vector<user> get_current_user () const { |
b8155a93 | return {}; }; |
28855478 | }; class directory : public directory_ifc { |
189f062b | public: typedef std::shared_ptr<directory_ifc> delegate; private: delegate delegate_; public: |
b8155a93 | directory (delegate delegate) : delegate_ (delegate) {} /* directory() : directory (delegate (new directory_ifc)) {} */ |
bf756dea | std::vector<user> find_user (const std::string &user_name) const |
28855478 | { return delegate_->find_user (user_name); } |
b8155a93 | std::vector<user> get_current_user () const { return delegate_->get_current_user(); } |
189f062b | static directory create (unistd &unistd, pwd &pwd); |
3c673060 | }; |
55259c47 | #endif |
8c62e61c |