Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* header files are included here */
- PCI_card card;
- int main(void)
- {
- card.init_card(0);
- return 0;
- }
- #ifndef __PCI_CARD_H
- #define __PCI_CARD_H
- /* header files are included here */
- typedef struct {
- int32_t card_index;
- int32_t user_counter;
- } card_dev_t;
- class PCI_card {
- public:
- PCI_card() : dev_descriptor(-1) { enlarge_vector(); }
- int32_t init_card(int32_t card_num);
- private:
- int32_t dev_descriptor;
- public:
- static int32_t enlarge_vector();
- private:
- static int32_t card_amount;
- static std::vector<card_dev_t> cards;
- };
- #endif
- /* header files are included here */
- int32_t PCI_card::card_amount = -1;
- std::vector<card_dev_t> PCI_card::cards;
- int32_t PCI_card::init_card(int32_t card_num)
- {
- if (card_num >= card_amount || card_num < 0)
- return -1;
- card_dev_t new_card = {
- .card_index = card_num,
- .user_counter = 1
- };
- cards[card_num] = new_card;
- dev_descriptor = card_num;
- return 0;
- }
- int32_t PCI_card::enlarge_vector()
- {
- card_amount = 10;
- card_dev_t null_card = {
- .card_index = -1,
- .user_counter = -1
- };
- cards.resize(card_amount, null_card);
- return card_amount;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement