OSDN Git Service

* public snapshot of sid simulator
[pf3gnuchains/pf3gnuchains3x.git] / sid / component / rtc / components.cxx
1 // components.cxx - definitions for this component library.  -*- C++ -*-
2
3 // Copyright (C) 1999, 2000 Red Hat.
4 // This file is part of SID and is licensed under the GPL.
5 // See the file COPYING.SID for conditions for redistribution.
6
7 #include "config.h"
8 #include "components.h"
9
10 static
11 vector<string>
12 rtcListTypes()
13 {
14   vector<string> types;
15   types.push_back("hw-rtc-ds1642");
16   types.push_back("hw-rtc-ds1742");
17   types.push_back("hw-rtc-sid");
18   return types;
19 }
20
21 static
22 component*
23 rtcCreate(const string& typeName)
24 {
25   if (typeName == "hw-rtc-ds1642")
26     return new ds1642();
27   else if (typeName == "hw-rtc-ds1742")
28     return new ds1742();
29   else if (typeName == "hw-rtc-sid")
30     return new sidrtc();
31   else
32     return 0;
33 }
34
35 static
36 void
37 rtcDelete(component* c)
38 {
39   // ds1742 is derived from ds1642
40   ds1642* r1 = dynamic_cast<ds1642*>(c);
41   if (r1) { delete r1; return; }
42   sidrtc* r2 = dynamic_cast<sidrtc*>(c);
43   if (r2) { delete r2; return; }
44 }
45
46
47 // static object
48 extern const component_library rtc_component_library;
49
50 const component_library rtc_component_library DLLEXPORT =
51 {
52   COMPONENT_LIBRARY_MAGIC,
53   & rtcListTypes,
54   & rtcCreate,
55   & rtcDelete
56 };