OSDN Git Service

fix cmake/Macros.cmake
[moflib/moflib.git] / moflib-1.0 / moflib / moflib / mof / stream / ReferenceWrapper.hpp
1 #pragma once
2 #include <mof/stream/Reference.hpp>
3 #include <mof/stream/Offset.hpp>
4 #include <mof/stream/TypeStream.hpp>
5 #include <vector>
6
7 namespace mof
8 {
9 //{{{ ReferenceWrapper
10     template<typename T>
11     class ReferenceWrapper
12     {
13     public:
14     
15         typename Reference<T>::Handler makeRef(const typename Manipulator<T>::Handler& body)
16         {
17             m_list.push_back(makeReferenceHandler(body));
18             return m_list.back();
19         }
20         
21         typename Reference<T>::Handler makeRef(const T& body)
22         {
23             m_list.push_back(makeReferenceHandler<T>(makeConstantHandler(body)));
24             return m_list.back();
25         }
26
27
28         void replace(int index , const typename Manipulator<T>::Handler& body)
29         {
30             m_list[index]->replace(body);
31             //m_list[index]->replace(makeOffsetHandler(body , -1 * (int)m_stream.getCurrentFrameNumber()));
32         }
33         
34         void replace(int index , const T& body)
35         {
36             m_list[index]->replace(makeConstantHandler(body));
37             //m_list[index]->replace(makeOffsetHandler(makeConstantHandler(body) , -1 * (int)m_stream.getCurrentFrameNumber()));
38         }
39
40         template<typename T, typename K>
41         void replace(int index , const TypeStream<T, K>& stream , const typename Manipulator<T>::Handler& body)
42         {
43             m_list[index]->replace(makeOffsetHandler<T>(body , -1 * stream.getCurrentFrameNumber()));
44         }
45         
46
47         typename Reference<T>::Handler getRef(int index) const
48         {
49             return m_list[index];
50         }
51
52     private:
53         std::vector<typename Reference<T>::Handler> m_list;
54     };
55 //}}}
56 } // namespace mof
57