1717#ifndef ABAC_H
1818#define ABAC_H
1919
20- #include < unordered_map>
21- #include < string>
22- #include < vector>
23- #include < variant>
24- #include < memory>
20+ #include " attribute_types.h"
2521
2622namespace casbin {
2723
@@ -31,16 +27,10 @@ namespace casbin {
3127 */
3228class ABACData {
3329
34- public:
35-
36- // Intrinsic definitions
37- typedef std::variant<std::string, int32_t , float > VariantType;
38- typedef std::unordered_map<std::string, VariantType> VariantMap;
39-
4030private:
4131
4232 // HashMap containing attributes as key-value pairs
43- VariantMap m_attributes;
33+ AttributeMap m_attributes;
4434
4535public:
4636 /* *
@@ -54,15 +44,15 @@ class ABACData {
5444 *
5545 * Key's type is std::string and value's type can be one of std::string, int32_t, and float only
5646 */
57- ABACData (const VariantMap & attribs);
47+ ABACData (const AttributeMap & attribs);
5848 /* *
5949 * @brief Add attribute to the corresponding ABAC entity
6050 *
6151 * @param key Name of the attribute
6252 * @param value Value of the attribute
6353 * @return true when attribute is added successfully, false otherwise
6454 */
65- bool AddAttribute (const std::string& key, const VariantType & value);
55+ bool AddAttribute (const std::string& key, const AttributeValue & value);
6656 /* *
6757 * @brief Add attributes to the corresponding ABAC entity
6858 *
@@ -75,7 +65,7 @@ class ABACData {
7565 * Key's type is std::string and value's type can be one of std::string, int32_t, and float only
7666 * @return true if attributes are added successfully, false otherwise
7767 */
78- bool AddAttributes (const VariantMap & attribs);
68+ bool AddAttributes (const AttributeList & attribs);
7969 /* *
8070 * @brief Delete attribute of the corresponding ABAC entity
8171 *
@@ -92,19 +82,31 @@ class ABACData {
9282 * @return true
9383 * @return false
9484 */
95- bool UpdateAttribute (const std::string& key, const VariantType & value);
85+ bool UpdateAttribute (const std::string& key, const AttributeValue & value);
9686 /* *
9787 * @brief Get the Attributes of the corresponding ABAC entity
9888 *
9989 * @return const reference to the hashmap containing attributes in key-value pairs
10090 */
101- const VariantMap & GetAttributes ();
91+ const AttributeMap & GetAttributes ();
10292};
10393
10494// Casbin ABAC entity type
10595typedef ABACData ABACData;
10696
107- const std::shared_ptr<ABACData> GetData (const ABACData::VariantMap& attribs);
97+ /* *
98+ * @brief Get casbin::ABACData object
99+ *
100+ * @param attribs Should be of the format: {
101+ * { "attrib_name1", value1 },
102+ * { "attrib_name2", value2 },
103+ * ...
104+ * }
105+ *
106+ * Key's type is std::string and value's type can be one of std::string, int32_t, double, and float only
107+ * @return Pointer to casbin::ABACData entity
108+ */
109+ const std::shared_ptr<ABACData> GetDataObject (const AttributeMap& attribs);
108110}
109111
110112#endif
0 commit comments