SMIL  1.0.4
DCoreInstance.h
1 /*
2  * Copyright (c) 2011-2016, Matthieu FAESSEL and ARMINES
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of Matthieu FAESSEL, or ARMINES nor the
14  * names of its contributors may be used to endorse or promote products
15  * derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef _DCORE_INSTANCE_H
31 #define _DCORE_INSTANCE_H
32 
33 #include <iostream>
34 #include <algorithm>
35 
36 #include "DCommon.h"
37 #include "DTimer.h"
38 #include "DSignal.h"
39 #include "DErrors.h"
40 #include "DCpuID.h"
41 
42 #include "private/DInstance.hpp"
43 
44 namespace smil
45 {
46  class BaseObject;
47  class BaseImage;
48 
57  class Core : public UniqueInstance<Core>
58  {
59  friend class UniqueInstance<Core>;
60 
61  protected:
62  Core();
63  ~Core();
64 
65  public:
66  // Public interface
67 
68  bool keepAlive;
69  bool autoResizeImages;
70 
71  UINT getNumberOfThreads();
72  UINT getNumberOfCores();
73  UINT getMaxNumberOfThreads();
74  RES_T setNumberOfThreads(UINT nbr);
75  void resetNumberOfThreads();
76  size_t getAllocatedMemory();
77  const CpuID &getCpuID()
78  {
79  return cpuID;
80  }
81 
82  void registerObject(BaseObject *obj);
83  void unregisterObject(BaseObject *obj);
84  vector<BaseObject *> getRegisteredObjects();
85  vector<BaseImage *> getImages();
86 
87  void showAllImages();
88  void hideAllImages();
89  void deleteAllImages();
90  int getImageIndex(BaseImage *img);
91 
92  void getCompilationInfos(ostream &outStream = std::cout);
93 
94  Signal onBaseImageCreated;
95  Signal onBaseImageDestroyed;
96 
97  protected:
98  UINT coreNumber;
99  UINT threadNumber;
100  UINT maxThreadNumber;
101 
102  const char *systemName;
103  const char *targetArchitecture;
104  const bool supportOpenMP;
105 
106  vector<BaseObject *> registeredObjects;
107  vector<BaseImage *> registeredImages;
108  void deleteRegisteredObjects();
109 
110  const CpuID cpuID;
111  };
112 
115 } // namespace smil
116 
117 #endif // _DCORE_INSTANCE_H
Base Image class.
Definition: DBaseImage.h:50
Base Smil Object.
Definition: DBaseObject.h:52
Core module instance.
Definition: DCoreInstance.h:58
Definition: DCpuID.h:72
Definition: DSignal.h:56
Definition: DInstance.hpp:40