1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// MCpp_BoardImpl.h - MULTICAM C++ API - BoardListImpl
#if !defined(__MCPP_BOARDLISTIMPL_H__)
#define __MCPP_BOARDLISTIMPL_H__
 
#include <cstring>
#include "MCpp_BoardList.h"
 
namespace
{
 
int mc_stricmp(const char *s1, const char *s2)
{
#if defined(__GNUC__)
   return strcasecmp(s1, s2);
#elif defined(_MSC_VER) && _MSC_VER >= 1400
   // Visual Studio 8 or higher deprecate stricmp.
   return _stricmp(s1, s2);
#else
   return stricmp(s1, s2);
#endif
}
}
 
namespace Euresys
{
  namespace MultiCam
  {
//    BoardListImpl* GetBoardListImpl()
 
    inline BoardListImpl::BoardListImpl()
    {
      List = NULL;
      Count = 0;
    }
 
    inline BoardListImpl::~BoardListImpl()
    {
      Clear();
    }
 
    inline void BoardListImpl::Clear()
    {
      int i;
 
      if (List != NULL)
      {
        for (i = 0 ; i < Count ; i++)
        {
          if (List[i] != NULL)
            delete List[i];
        }
        delete[] List;
      }
      List = NULL;
      Count = 0;
    }
 
    // Initialization
    inline void BoardListImpl::Init()
    {
      int i;
 
      if (List != NULL) // Already initialized
        return;
 
      Config.GetParam(MC_BoardCount, Count);
      if (Count > 0)
      {
        List = new Board *[Count];
        for (i = 0 ; i < Count ; i++)
          List[i] = NULL;
        for (i = 0 ; i < Count ; i++)
          List[i] = new Board(i);
      }
    }
 
    // Accessors
 
    inline Board *BoardListImpl::GetBoardByDriverIndex(int DriverIndex)
    {
      if (DriverIndex >= 0 && DriverIndex < Count)
        return List[DriverIndex];
      else
      {
        ThrowMultiCamException(MC_NO_BOARD_FOUND);
        return NULL;
      }
    }
 
    inline Board *BoardListImpl::GetBoardByPciPosition(int PciPosition)
    {
      int i;
      int pos;
 
      for (i = 0 ; i < Count ; i++)
      {
        List[i]->GetParam(MC_PciPosition, pos);
        if (pos == PciPosition)
          return List[i];
      }
 
      ThrowMultiCamException(MC_NO_BOARD_FOUND);
      return NULL;
    }
 
    inline Board *BoardListImpl::GetBoardByBoardName(const char *BoardName)
    {
      int i;
      char name[64];
 
      for (i = 0 ; i < Count ; i++)
      {
        List[i]->GetParam(MC_BoardName, name, sizeof(name));
        if (mc_stricmp(name, BoardName) == 0)
          return List[i];
      }
 
      ThrowMultiCamException(MC_NO_BOARD_FOUND);
      return NULL;
    }
 
    inline Board *BoardListImpl::GetBoardByBoardIdentifier(const char *BoardIdentifier)
    {
      int i;
      char id[64];
 
      for (i = 0 ; i < Count ; i++)
      {
        List[i]->GetParam(MC_BoardIdentifier, id, sizeof(id));
        if (mc_stricmp(id, BoardIdentifier) == 0)
          return List[i];
      }
 
      ThrowMultiCamException(MC_NO_BOARD_FOUND);
      return NULL;
    }
 
    inline int BoardListImpl::GetCount()
    {
      return Count;
    }
  }
}
 
#endif