Skip to content

Commit 1de52c4

Browse files
committed
fix: Python binding error
Signed-off-by: Yash Pandey (YP) <[email protected]>
1 parent 6646a44 commit 1de52c4

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

include/casbin/casbin_enforcer.h

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ namespace casbin {
3030
/* Enforcer API */
3131
virtual void InitWithFile(const std::string& model_path, const std::string& policy_path) = 0;
3232
virtual void InitWithAdapter(const std::string& model_path, std::shared_ptr<Adapter> adapter) = 0;
33-
virtual void InitWithModelAndAdapter(std::shared_ptr<Model> m, std::shared_ptr<Adapter> adapter) = 0;
33+
virtual void InitWithModelAndAdapter(const std::shared_ptr<Model>& m, std::shared_ptr<Adapter> adapter) = 0;
3434
virtual void Initialize() = 0;
3535
virtual void LoadModel() = 0;
3636
virtual std::shared_ptr<Model> GetModel() = 0;
37-
virtual void SetModel(std::shared_ptr<Model> m) = 0;
37+
virtual void SetModel(const std::shared_ptr<Model>& m) = 0;
3838
virtual std::shared_ptr<Adapter> GetAdapter() = 0;
3939
virtual void SetAdapter(std::shared_ptr<Adapter> adapter) = 0;
4040
virtual void SetWatcher(std::shared_ptr<Watcher> watcher) = 0;
4141
virtual std::shared_ptr<RoleManager> GetRoleManager() = 0;
42-
virtual void SetRoleManager(std::shared_ptr<RoleManager> rm) = 0;
42+
virtual void SetRoleManager(std::shared_ptr<RoleManager>& rm) = 0;
4343
virtual void SetEffector(std::shared_ptr<Effector> eft) = 0;
4444
virtual void ClearPolicy() = 0;
4545
virtual void LoadPolicy() = 0;
@@ -166,8 +166,8 @@ namespace casbin {
166166
bool m_auto_build_role_links;
167167
bool m_auto_notify_watcher;
168168

169-
// enforce use a custom matcher to decides whether a "subject" can access a "object"
170-
// with the operation "action", input parameters are usually: (matcher, sub, obj, act),
169+
// enforce use a custom matcher to decides whether a "subject" can access a "object"
170+
// with the operation "action", input parameters are usually: (matcher, sub, obj, act),
171171
// use model matcher by default when matcher is "".
172172
bool m_enforce(const std::string& matcher, Scope scope);
173173

@@ -199,13 +199,13 @@ namespace casbin {
199199
* @param m the model.
200200
* @param adapter the adapter.
201201
*/
202-
Enforcer(std::shared_ptr<Model> m, std::shared_ptr<Adapter> adapter);
202+
Enforcer(const std::shared_ptr<Model>& m, std::shared_ptr<Adapter> adapter);
203203
/**
204204
* Enforcer initializes an enforcer with a model.
205205
*
206206
* @param m the model.
207207
*/
208-
Enforcer(std::shared_ptr<Model> m);
208+
Enforcer(const std::shared_ptr<Model>& m);
209209
/**
210210
* Enforcer initializes an enforcer with a model file.
211211
*
@@ -225,16 +225,16 @@ namespace casbin {
225225
// InitWithAdapter initializes an enforcer with a database adapter.
226226
void InitWithAdapter(const std::string& model_path, std::shared_ptr<Adapter> adapter);
227227
// InitWithModelAndAdapter initializes an enforcer with a model and a database adapter.
228-
void InitWithModelAndAdapter(std::shared_ptr<Model> m, std::shared_ptr<Adapter> adapter);
228+
void InitWithModelAndAdapter(const std::shared_ptr<Model>& m, std::shared_ptr<Adapter> adapter);
229229
void Initialize();
230230
// LoadModel reloads the model from the model CONF file.
231-
// Because the policy is attached to a model, so the policy is invalidated and
231+
// Because the policy is attached to a model, so the policy is invalidated and
232232
// needs to be reloaded by calling LoadPolicy().
233233
void LoadModel();
234234
// GetModel gets the current model.
235235
std::shared_ptr<Model> GetModel();
236236
// SetModel sets the current model.
237-
void SetModel(std::shared_ptr<Model> m);
237+
void SetModel(const std::shared_ptr<Model>& m);
238238
// GetAdapter gets the current adapter.
239239
std::shared_ptr<Adapter> GetAdapter();
240240
// SetAdapter sets the current adapter.
@@ -244,7 +244,7 @@ namespace casbin {
244244
// GetRoleManager gets the current role manager.
245245
std::shared_ptr<RoleManager> GetRoleManager();
246246
// SetRoleManager sets the current role manager.
247-
void SetRoleManager(std::shared_ptr <RoleManager> rm);
247+
void SetRoleManager(std::shared_ptr<RoleManager>& rm);
248248
// SetEffector sets the current effector.
249249
void SetEffector(std::shared_ptr<Effector> eft);
250250
// ClearPolicy clears all policy.
@@ -378,27 +378,26 @@ namespace casbin {
378378
std::vector<std::vector<std::string>> GetPermissionsForUserInDomain(const std::string& user, const std::string& domain = {});
379379
bool AddRoleForUserInDomain(const std::string& user, const std::string& role, const std::string& domain = {});
380380
bool DeleteRoleForUserInDomain(const std::string& user, const std::string& role, const std::string& domain = {});
381-
382381
};
383382

384383
class CachedEnforcer : public Enforcer {
385384
public:
386385
std::unordered_map<std::string, bool> m;
387386
bool enableCache;
388387
std::mutex locker;
389-
388+
390389
CachedEnforcer(const CachedEnforcer& ce);
391390
CachedEnforcer(CachedEnforcer&& ce);
392-
391+
393392
void EnableCache(const bool& enableCache);
394393
std::pair<bool, bool> getCachedResult(const std::string& key);
395394
void setCachedResult(const std::string& key, const bool& res);
396395
void InvalidateCache();
397-
396+
398397
public:
399-
/**
400-
* Enforcer is the default constructor.
401-
*/
398+
/**
399+
* Enforcer is the default constructor.
400+
*/
402401
CachedEnforcer();
403402
/**
404403
* Enforcer initializes an enforcer with a model file and a policy file.
@@ -420,13 +419,13 @@ namespace casbin {
420419
* @param m the model.
421420
* @param adapter the adapter.
422421
*/
423-
CachedEnforcer(std::shared_ptr<Model> m, std::shared_ptr<Adapter> adapter);
422+
CachedEnforcer(const std::shared_ptr<Model>& m, std::shared_ptr<Adapter> adapter);
424423
/**
425424
* Enforcer initializes an enforcer with a model.
426425
*
427426
* @param m the model.
428427
*/
429-
CachedEnforcer(std::shared_ptr<Model> m);
428+
CachedEnforcer(const std::shared_ptr<Model>& m);
430429
/**
431430
* Enforcer initializes an enforcer with a model file.
432431
*
@@ -441,7 +440,7 @@ namespace casbin {
441440
* @param enable_log whether to enable Casbin's log.
442441
*/
443442
CachedEnforcer(const std::string& model_path, const std::string& policy_file, bool enable_log);
444-
443+
445444
bool Enforce(Scope scope);
446445
// Enforce with a vector param,decides whether a "subject" can access a
447446
// "object" with the operation "action", input parameters are usually: (sub,
@@ -502,14 +501,14 @@ namespace casbin {
502501
* @param m the model.
503502
* @param adapter the adapter.
504503
*/
505-
SyncedEnforcer(std::shared_ptr<Model> m, std::shared_ptr<Adapter> adapter);
504+
SyncedEnforcer(const std::shared_ptr<Model>& m, std::shared_ptr<Adapter> adapter);
506505

507506
/**
508507
* Enforcer initializes an enforcer with a model.
509508
*
510509
* @param m the model.
511510
*/
512-
SyncedEnforcer(std::shared_ptr<Model> m);
511+
SyncedEnforcer(const std::shared_ptr<Model>& m);
513512

514513
/**
515514
* Enforcer initializes an enforcer with a model file.

0 commit comments

Comments
 (0)