Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 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 | |
| 17 | #ifndef ART_SRC_MIRROR_OBJECT_ARRAY_H_ |
| 18 | #define ART_SRC_MIRROR_OBJECT_ARRAY_H_ |
| 19 | |
| 20 | #include "array.h" |
| 21 | |
| 22 | namespace art { |
| 23 | namespace mirror { |
| 24 | |
| 25 | template<class T> |
| 26 | class MANAGED ObjectArray : public Array { |
| 27 | public: |
| 28 | static ObjectArray<T>* Alloc(Thread* self, Class* object_array_class, int32_t length) |
| 29 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 30 | |
| 31 | T* Get(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 32 | |
| 33 | void Set(int32_t i, T* object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 34 | |
| 35 | // Set element without bound and element type checks, to be used in limited |
| 36 | // circumstances, such as during boot image writing |
| 37 | void SetWithoutChecks(int32_t i, T* object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 38 | |
| 39 | // Set element without bound and element type checks, to be used in limited circumstances, such |
| 40 | // as during boot image writing. Does not do write barrier. |
| 41 | void SetPtrWithoutChecks(int32_t i, T* object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 42 | |
| 43 | T* GetWithoutChecks(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 44 | |
| 45 | static void Copy(const ObjectArray<T>* src, int src_pos, |
| 46 | ObjectArray<T>* dst, int dst_pos, |
| 47 | size_t length) |
| 48 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 49 | |
| 50 | ObjectArray<T>* CopyOf(Thread* self, int32_t new_length) |
| 51 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 52 | |
| 53 | private: |
| 54 | DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectArray); |
| 55 | }; |
| 56 | |
| 57 | } // namespace mirror |
| 58 | } // namespace art |
| 59 | |
| 60 | #endif // ART_SRC_MIRROR_OBJECT_ARRAY_H_ |