SMIL  0.9.1
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'' AND ANY
18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
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 
67  // Public interface
68 
69  bool keepAlive;
70  bool autoResizeImages;
71 
72  UINT getNumberOfThreads();
73  UINT getNumberOfCores();
74  UINT getMaxNumberOfThreads();
75  RES_T setNumberOfThreads(UINT nbr);
76  void resetNumberOfThreads();
77  size_t getAllocatedMemory();
78  void registerObject(BaseObject *obj);
79  void unregisterObject(BaseObject *obj);
80  void showAllImages();
81  void hideAllImages();
82  void deleteAllImages();
83  vector<BaseObject*> getRegisteredObjects();
84  vector<BaseImage*> getImages();
85  int getImageIndex(BaseImage *img);
86  void getCompilationInfos(ostream &outStream = std::cout);
87  const CpuID &getCpuID() { return cpuID; }
88 
89  Signal onBaseImageCreated;
90  Signal onBaseImageDestroyed;
91 
92 
93  protected:
94  UINT coreNumber;
95  UINT threadNumber;
96  UINT maxThreadNumber;
97 
98  const char *systemName;
99  const char *targetArchitecture;
100  const bool supportOpenMP;
101 
102  vector<BaseObject*> registeredObjects;
103  vector<BaseImage*> registeredImages;
104  void deleteRegisteredObjects();
105 
106  const CpuID cpuID;
107 
108 
109  };
110 
113 } // namespace smil
114 
115 
116 #endif // _DCORE_INSTANCE_H
117 
Definition: DColorConvert.h:38
Definition: DSignal.h:55
Definition: DInstance.hpp:39
Definition: DCpuID.h:66
Base Smil Object.
Definition: DBaseObject.h:53
Base Image class.
Definition: DBaseImage.h:50
Core module instance.
Definition: DCoreInstance.h:57