2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/public-api/actors/custom-actor.h>
22 #include <dali/internal/event/actors/custom-actor-internal.h>
23 #include <dali/public-api/object/type-registry.h>
35 // not directly creatable
39 TypeRegistration mType( typeid(Dali::CustomActor), typeid(Dali::Actor), Create );
43 CustomActor::CustomActor()
47 CustomActor CustomActor::DownCast( BaseHandle handle )
49 return CustomActor( dynamic_cast<Dali::Internal::CustomActor*>(handle.GetObjectPtr()) );
52 CustomActor::~CustomActor()
56 CustomActor::CustomActor(const CustomActor& copy)
61 CustomActor& CustomActor::operator=(const CustomActor& rhs)
63 BaseHandle::operator=(rhs);
67 CustomActorImpl& CustomActor::GetImplementation()
69 Internal::CustomActor& internal = GetImpl(*this);
71 return internal.GetImplementation();
74 const CustomActorImpl& CustomActor::GetImplementation() const
76 const Internal::CustomActor& internal = GetImpl(*this);
78 return internal.GetImplementation();
81 CustomActor::CustomActor(CustomActorImpl& implementation)
82 : Actor(Internal::CustomActor::New(implementation).Get())
86 CustomActor::CustomActor(Internal::CustomActor* internal)
89 // Check we haven't just constructed a new handle, while in the internal custom actors destructor.
90 // This can happen if the user defined CustomActorImpl destructor calls Self(), to create a new handle
91 // to the CustomActor.
93 // If it's in the destructor then the ref count is zero, so once we've created a new handle it will be 1
94 // Without this check, the actor will be deleted a second time, when the handle is disposed of
99 DALI_ASSERT_ALWAYS(internal->ReferenceCount() != 1 && "Are you trying to use CustomActorImpl::Self() inside a CustomActorImpl destructor?");