DUDS
Distributed Update of Data from Something
Part.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DUDS project. It is subject to the BSD-style
3  * license terms in the LICENSE file found in the top-level directory of this
4  * distribution and at https://github.com/jjackowski/duds/blob/master/LICENSE.
5  * No part of DUDS, including this file, may be copied, modified, propagated,
6  * or distributed except according to the terms contained in the LICENSE file.
7  *
8  * Copyright (C) 2017 Jeff Jackowski
9  */
10 #include <boost/uuid/uuid.hpp>
11 
12 namespace duds { namespace hardware {
13 
25 class PartModel {
26  boost::uuids::uuid pid;
27  std::string partname;
28 protected:
29  PartModel() = default; // serialization
30  PartModel(const boost::uuids::uuid &id, const std::string &name) :
31  pid(id), partname(name) { }
32 public:
33  const boost::uuids::uuid id() const {
34  return pid;
35  }
36  const std::string &name() const {
37  return partname;
38  }
39 };
40 
41 } }
42 
43 // the rest of this file suggests the direction of future development
44 
45 #if 0
46 
54 class PartInstance {
55  boost::uuids::uuid partid;
56 public:
57  const boost::uuids::uuid &partId() const {
58  return partid;
59  }
60 };
61 
62 #include <boost/multi_index_container.hpp>
63 #include <boost/multi_index/hashed_index.hpp>
64 #include <boost/multi_index/mem_fun.hpp>
65 #include <boost/multi_index/tag.hpp>
66 
67 struct PartIndex_UUID { };
68 struct PartIndex_Name { };
69 
70 typedef boost::multi_index::multi_index_container<
71  PartModel,
72  boost::multi_index::indexed_by<
73  boost::multi_index::hashed_unique<
74  boost::multi_index::tag<PartIndex_UUID>,
75  boost::multi_index::const_mem_fun<
76  PartModel, boost::uuids::uuid, &PartModel::id
77  >
78  >,
79  boost::multi_index::hashed_non_unique<
80  boost::multi_index::tag<PartIndex_Name>,
81  boost::multi_index::const_mem_fun<
82  PartModel, std::string, &PartModel::name
83  >
84  >
85  >
86 > PartModelContainer;
87 
93 class PartLibrary {
94  PartModelContainer parts; // clonus horror
95 public:
96  const PartModel& part(const boost::uuids::uuid &id) const;
97 };
98 
99 #endif
100 
boost::uuids::uuid pid
Definition: Part.hpp:26
std::string partname
Definition: Part.hpp:27
const boost::uuids::uuid id() const
Definition: Part.hpp:33
const std::string & name() const
Definition: Part.hpp:36
Represents a hardware part; typically an item that can be purchased and added to a circut...
Definition: Part.hpp:25
PartModel(const boost::uuids::uuid &id, const std::string &name)
Definition: Part.hpp:30