Leosac  0.8.0
Open Source Access Control
RFIDCard.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-2016 Leosac
3 
4  This file is part of Leosac.
5 
6  Leosac is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Affero General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Leosac is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Affero General Public License for more details.
15 
16  You should have received a copy of the GNU Affero General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
24 
25 namespace Leosac
26 {
27 namespace Cred
28 {
32 #pragma db object polymorphic optimistic
33 class RFIDCard : public virtual IRFIDCard, public Credential
34 {
35  public:
37  RFIDCard() = default;
38 
46  RFIDCard(const std::string &card_id, int nb_bits);
47 
48  virtual const std::string &card_id() const override;
49 
50  virtual int nb_bits() const override;
51 
52  virtual uint64_t to_int() const override;
53 
54  virtual uint64_t to_raw_int() const override;
55 
56  void nb_bits(int i) override;
57 
58  void card_id(const std::string &string) override;
59 
60  protected:
61  int nb_bits_;
62  std::string card_id_;
63 
64  private:
68  uint64_t to_wiegand_26() const;
69 
73  uint64_t to_wiegand_34() const;
74 
75  friend class odb::access;
76 };
77 
79 {
80  public:
81  static void validate(const IRFIDCard &card);
82  static void validate_card_id(const std::string &card_id);
83  static void validate_nb_bits(int nb_bits);
84 };
85 }
86 }
Leosac::Cred::RFIDCard::MAKE_VISITABLE_FALLBACK
MAKE_VISITABLE_FALLBACK(IRFIDCard)
Leosac::Cred::RFIDCardValidator::validate
static void validate(const IRFIDCard &card)
Definition: RFIDCard.cpp:111
Leosac::Cred::RFIDCard::to_wiegand_34
uint64_t to_wiegand_34() const
Extract the card ID, assuming the format to be Wiegand34.
Definition: RFIDCard.cpp:86
Leosac::Cred::RFIDCard::nb_bits
virtual int nb_bits() const override
Definition: RFIDCard.cpp:39
Leosac::Cred::RFIDCard::nb_bits_
int nb_bits_
Definition: RFIDCard.hpp:61
Leosac::Cred::RFIDCard
An RFID card credential.
Definition: RFIDCard.hpp:33
Leosac::Cred::RFIDCardValidator::validate_nb_bits
static void validate_nb_bits(int nb_bits)
Definition: RFIDCard.cpp:144
Leosac::Cred::RFIDCard::card_id_
std::string card_id_
Definition: RFIDCard.hpp:62
Credential.hpp
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Cred::RFIDCard::access
friend class odb::access
Definition: RFIDCard.hpp:75
Leosac::Cred::RFIDCard::RFIDCard
RFIDCard()=default
Leosac::Cred::RFIDCardValidator::validate_card_id
static void validate_card_id(const std::string &card_id)
Definition: RFIDCard.cpp:117
Leosac::Cred::Credential
An ODB enabled credential object.
Definition: Credential.hpp:37
Leosac::Cred::RFIDCard::card_id
virtual const std::string & card_id() const override
Definition: RFIDCard.cpp:34
Leosac::Cred::RFIDCard::to_wiegand_26
uint64_t to_wiegand_26() const
Extract the card ID, assuming the format to be Wiegand26.
Definition: RFIDCard.cpp:73
Leosac::Cred::RFIDCard::to_int
virtual uint64_t to_int() const override
Returns the integer representation of the card ID.
Definition: RFIDCard.cpp:58
Leosac::Cred::RFIDCard::to_raw_int
virtual uint64_t to_raw_int() const override
Convert the bits of the card to an integer.
Definition: RFIDCard.cpp:44
IRFIDCard.hpp
Leosac::Cred::RFIDCardValidator
Definition: RFIDCard.hpp:78
Leosac::Cred::IRFIDCard
Interface for RFIDCard credential.
Definition: IRFIDCard.hpp:32