blob: 898631bdcccaf9f1112f87fda2ffa2af061996cb [file] [log] [blame]
/* $Id$
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to you under the Apache License, Version
* 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "serialization/EtchValidatorNone.h"
#include "support/EtchRuntime.h"
capu::SmartPointer<EtchValidator>* EtchValidatorNone::Validators(EtchRuntime* runtime) {
static EtchValidatorCaches validators;
return validators.get(runtime);
}
const EtchObjectType* EtchValidatorNone::TYPE() {
static const EtchObjectType TYPE(EOTID_VALIDATOR_NONE, NULL);
return &TYPE;
}
EtchValidatorNone::EtchValidatorNone()
: EtchValidator(EtchValidatorNone::TYPE()) {
//TODO rafactor this
mRuntime = EtchRuntime::getRuntime();
}
EtchValidatorNone::EtchValidatorNone(const EtchValidatorNone& other)
: EtchValidator(other), mRuntime(other.mRuntime) {
}
EtchValidatorNone::~EtchValidatorNone() {
}
capu::bool_t EtchValidatorNone::validate(capu::SmartPointer<EtchObject> value) {
return value->equals(EtchBinaryTaggedData::NONE().get());
}
status_t EtchValidatorNone::validateValue(capu::SmartPointer<EtchObject> value, capu::SmartPointer<EtchObject>& result) {
if (validate(value)) {
result = value;
CAPU_LOG_TRACE(mRuntime->getLogger(), "EtchValidatorNone", "NONE has been validated");
return ETCH_OK;
} else {
CAPU_LOG_WARN(mRuntime->getLogger(), "EtchValidatorNone", "NONE has not been validated");
return ETCH_ERROR;
}
}
status_t EtchValidatorNone::Get(capu::SmartPointer<EtchValidator> &val) {
//TODO rafactor this
EtchRuntime* runtime = EtchRuntime::getRuntime();
if (Validators(runtime)[0].get() == NULL) {
Validators(runtime)[0] = new EtchValidatorNone();
CAPU_LOG_TRACE(runtime->getLogger(), "EtchValidatorNone", "EtchValidatorNone has been created");
}
val = Validators(runtime)[0];
return ETCH_OK;
}
status_t EtchValidatorNone::getElementValidator(capu::SmartPointer<EtchValidator> &val) {
return ETCH_EUNIMPL;
}