m2etis  0.4
TreeFactory.h
Go to the documentation of this file.
1 /*
2  Copyright (2016) Michael Baer, Daniel Bonrath, All rights reserved.
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15  */
16 
22 #ifndef __M2ETIS_PUBSUB_TREEFACTORY_H__
23 #define __M2ETIS_PUBSUB_TREEFACTORY_H__
24 
25 #include "m2etis/pubsub/Tree.h"
27 
28 namespace m2etis {
29 namespace pubsub {
30 
38  class TreeFactory {
39  // This variable holds the next tree id, for usage as message type
40  uint16_t next_treename = CHANNEL_COUNT;
41 
42  public:
43  template<class ChannelType, class NetworkType, class EventType>
44  Tree<ChannelType, NetworkType, EventType> * createTree(const typename NetworkType::Key & self, const typename NetworkType::Key & rendezvous, const typename NetworkType::Key & root, PubSubSystemEnvironment * pssi, int cI) {
45  auto * ret = new Tree<ChannelType, NetworkType, EventType>(next_treename, self, rendezvous, root, pssi, cI);
46 
47  if (ret != nullptr) {
48  ++next_treename;
49  }
50 
51  return ret;
52  }
53  };
54 
55 } /* namespace pubsub */
56 } /* namespace m2etis */
57 
58 #endif /* __M2ETIS_PUBSUB_TREEFACTORY_H__ */
59 
Tree< ChannelType, NetworkType, EventType > * createTree(const typename NetworkType::Key &self, const typename NetworkType::Key &rendezvous, const typename NetworkType::Key &root, PubSubSystemEnvironment *pssi, int cI)
Definition: TreeFactory.h:44
TreeFactory builds trees with a unique MessageType.
Definition: TreeFactory.h:38