Mark Slee | e9ce01c | 2007-05-16 02:29:53 +0000 | [diff] [blame] | 1 | // Copyright (c) 2006- Facebook |
| 2 | // Distributed under the Thrift Software License |
| 3 | // |
| 4 | // See accompanying file LICENSE or visit the Thrift site at: |
| 5 | // http://developers.facebook.com/thrift/ |
| 6 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 7 | #ifndef T_MAP_H |
| 8 | #define T_MAP_H |
| 9 | |
Mark Slee | 4f8da1d | 2006-10-12 02:47:27 +0000 | [diff] [blame] | 10 | #include "t_container.h" |
| 11 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 12 | /** |
| 13 | * A map is a lightweight container type that just wraps another two data |
| 14 | * types. |
| 15 | * |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 16 | */ |
Mark Slee | 4f8da1d | 2006-10-12 02:47:27 +0000 | [diff] [blame] | 17 | class t_map : public t_container { |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 18 | public: |
| 19 | t_map(t_type* key_type, t_type* val_type) : |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 20 | key_type_(key_type), |
| 21 | val_type_(val_type) {} |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 22 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 23 | t_type* get_key_type() const { |
| 24 | return key_type_; |
| 25 | } |
| 26 | |
| 27 | t_type* get_val_type() const { |
| 28 | return val_type_; |
| 29 | } |
| 30 | |
| 31 | bool is_map() const { |
| 32 | return true; |
| 33 | } |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 34 | |
David Reiss | 18bf22d | 2007-08-28 20:49:17 +0000 | [diff] [blame] | 35 | virtual std::string get_fingerprint_material() const { |
| 36 | return "map<" + key_type_->get_fingerprint_material() + |
| 37 | "," + val_type_->get_fingerprint_material() + ">"; |
| 38 | } |
| 39 | |
David Reiss | 9885c68 | 2007-08-30 23:12:37 +0000 | [diff] [blame] | 40 | virtual void generate_fingerprint() { |
| 41 | t_type::generate_fingerprint(); |
| 42 | key_type_->generate_fingerprint(); |
| 43 | val_type_->generate_fingerprint(); |
| 44 | } |
| 45 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 46 | private: |
| 47 | t_type* key_type_; |
| 48 | t_type* val_type_; |
| 49 | }; |
| 50 | |
| 51 | #endif |